aoe.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* Copyright (c) 2013 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "85"
  3. #define AOE_MAJOR 152
  4. #define DEVICE_NAME "aoe"
  5. /* set AOE_PARTITIONS to 1 to use whole-disks only
  6. * default is 16, which is 15 partitions plus the whole disk
  7. */
  8. #ifndef AOE_PARTITIONS
  9. #define AOE_PARTITIONS (16)
  10. #endif
  11. #define WHITESPACE " \t\v\f\n,"
  12. enum {
  13. AOECMD_ATA,
  14. AOECMD_CFG,
  15. AOECMD_VEND_MIN = 0xf0,
  16. AOEFL_RSP = (1<<3),
  17. AOEFL_ERR = (1<<2),
  18. AOEAFL_EXT = (1<<6),
  19. AOEAFL_DEV = (1<<4),
  20. AOEAFL_ASYNC = (1<<1),
  21. AOEAFL_WRITE = (1<<0),
  22. AOECCMD_READ = 0,
  23. AOECCMD_TEST,
  24. AOECCMD_PTEST,
  25. AOECCMD_SET,
  26. AOECCMD_FSET,
  27. AOE_HVER = 0x10,
  28. };
  29. struct aoe_hdr {
  30. unsigned char dst[6];
  31. unsigned char src[6];
  32. __be16 type;
  33. unsigned char verfl;
  34. unsigned char err;
  35. __be16 major;
  36. unsigned char minor;
  37. unsigned char cmd;
  38. __be32 tag;
  39. };
  40. struct aoe_atahdr {
  41. unsigned char aflags;
  42. unsigned char errfeat;
  43. unsigned char scnt;
  44. unsigned char cmdstat;
  45. unsigned char lba0;
  46. unsigned char lba1;
  47. unsigned char lba2;
  48. unsigned char lba3;
  49. unsigned char lba4;
  50. unsigned char lba5;
  51. unsigned char res[2];
  52. };
  53. struct aoe_cfghdr {
  54. __be16 bufcnt;
  55. __be16 fwver;
  56. unsigned char scnt;
  57. unsigned char aoeccmd;
  58. unsigned char cslen[2];
  59. };
  60. enum {
  61. DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
  62. DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
  63. DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
  64. DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
  65. DEVFL_GD_NOW = (1<<4), /* allocating gendisk */
  66. DEVFL_KICKME = (1<<5), /* slow polling network card catch */
  67. DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
  68. DEVFL_FREEING = (1<<7), /* set when device is being cleaned up */
  69. DEVFL_FREED = (1<<8), /* device has been cleaned up */
  70. };
  71. enum {
  72. DEFAULTBCNT = 2 * 512, /* 2 sectors */
  73. MIN_BUFS = 16,
  74. NTARGETS = 4,
  75. NAOEIFS = 8,
  76. NSKBPOOLMAX = 256,
  77. NFACTIVE = 61,
  78. TIMERTICK = HZ / 10,
  79. RTTSCALE = 8,
  80. RTTDSCALE = 3,
  81. RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
  82. RTTDEV_INIT = RTTAVG_INIT / 4,
  83. HARD_SCORN_SECS = 10, /* try another remote port after this */
  84. MAX_TAINT = 1000, /* cap on aoetgt taint */
  85. };
  86. struct buf {
  87. ulong nframesout;
  88. struct bio *bio;
  89. struct bvec_iter iter;
  90. struct request *rq;
  91. };
  92. enum frame_flags {
  93. FFL_PROBE = 1,
  94. };
  95. struct frame {
  96. struct list_head head;
  97. u32 tag;
  98. struct timeval sent; /* high-res time packet was sent */
  99. u32 sent_jiffs; /* low-res jiffies-based sent time */
  100. ulong waited;
  101. ulong waited_total;
  102. struct aoetgt *t; /* parent target I belong to */
  103. struct sk_buff *skb; /* command skb freed on module exit */
  104. struct sk_buff *r_skb; /* response skb for async processing */
  105. struct buf *buf;
  106. struct bvec_iter iter;
  107. char flags;
  108. };
  109. struct aoeif {
  110. struct net_device *nd;
  111. ulong lost;
  112. int bcnt;
  113. };
  114. struct aoetgt {
  115. unsigned char addr[6];
  116. ushort nframes; /* cap on frames to use */
  117. struct aoedev *d; /* parent device I belong to */
  118. struct list_head ffree; /* list of free frames */
  119. struct aoeif ifs[NAOEIFS];
  120. struct aoeif *ifp; /* current aoeif in use */
  121. ushort nout; /* number of AoE commands outstanding */
  122. ushort maxout; /* current value for max outstanding */
  123. ushort next_cwnd; /* incr maxout after decrementing to zero */
  124. ushort ssthresh; /* slow start threshold */
  125. ulong falloc; /* number of allocated frames */
  126. int taint; /* how much we want to avoid this aoetgt */
  127. int minbcnt;
  128. int wpkts, rpkts;
  129. char nout_probes;
  130. };
  131. struct aoedev {
  132. struct aoedev *next;
  133. ulong sysminor;
  134. ulong aoemajor;
  135. u32 rttavg; /* scaled AoE round trip time average */
  136. u32 rttdev; /* scaled round trip time mean deviation */
  137. u16 aoeminor;
  138. u16 flags;
  139. u16 nopen; /* (bd_openers isn't available without sleeping) */
  140. u16 fw_ver; /* version of blade's firmware */
  141. u16 lasttag; /* last tag sent */
  142. u16 useme;
  143. ulong ref;
  144. struct work_struct work;/* disk create work struct */
  145. struct gendisk *gd;
  146. struct dentry *debugfs;
  147. struct request_queue *blkq;
  148. struct hd_geometry geo;
  149. sector_t ssize;
  150. struct timer_list timer;
  151. spinlock_t lock;
  152. struct sk_buff_head skbpool;
  153. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  154. struct { /* pointers to work in progress */
  155. struct buf *buf;
  156. struct bio *nxbio;
  157. struct request *rq;
  158. } ip;
  159. ulong maxbcnt;
  160. struct list_head factive[NFACTIVE]; /* hash of active frames */
  161. struct list_head rexmitq; /* deferred retransmissions */
  162. struct aoetgt **targets;
  163. ulong ntargets; /* number of allocated aoetgt pointers */
  164. struct aoetgt **tgt; /* target in use when working */
  165. ulong kicked;
  166. char ident[512];
  167. };
  168. /* kthread tracking */
  169. struct ktstate {
  170. struct completion rendez;
  171. struct task_struct *task;
  172. wait_queue_head_t *waitq;
  173. int (*fn) (int);
  174. char name[12];
  175. spinlock_t *lock;
  176. int id;
  177. int active;
  178. };
  179. int aoeblk_init(void);
  180. void aoeblk_exit(void);
  181. void aoeblk_gdalloc(void *);
  182. void aoedisk_rm_debugfs(struct aoedev *d);
  183. void aoedisk_rm_sysfs(struct aoedev *d);
  184. int aoechr_init(void);
  185. void aoechr_exit(void);
  186. void aoechr_error(char *);
  187. void aoecmd_work(struct aoedev *d);
  188. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  189. struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
  190. void aoecmd_cfg_rsp(struct sk_buff *);
  191. void aoecmd_sleepwork(struct work_struct *);
  192. void aoecmd_wreset(struct aoetgt *t);
  193. void aoecmd_cleanslate(struct aoedev *);
  194. void aoecmd_exit(void);
  195. int aoecmd_init(void);
  196. struct sk_buff *aoecmd_ata_id(struct aoedev *);
  197. void aoe_freetframe(struct frame *);
  198. void aoe_flush_iocq(void);
  199. void aoe_flush_iocq_by_index(int);
  200. void aoe_end_request(struct aoedev *, struct request *, int);
  201. int aoe_ktstart(struct ktstate *k);
  202. void aoe_ktstop(struct ktstate *k);
  203. int aoedev_init(void);
  204. void aoedev_exit(void);
  205. struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
  206. void aoedev_downdev(struct aoedev *d);
  207. int aoedev_flush(const char __user *str, size_t size);
  208. void aoe_failbuf(struct aoedev *, struct buf *);
  209. void aoedev_put(struct aoedev *);
  210. int aoenet_init(void);
  211. void aoenet_exit(void);
  212. void aoenet_xmit(struct sk_buff_head *);
  213. int is_aoe_netif(struct net_device *ifp);
  214. int set_aoe_iflist(const char __user *str, size_t size);