aoe.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "64+"
  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_KICKME = (1<<4), /* slow polling network card catch */
  66. DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */
  67. };
  68. enum {
  69. DEFAULTBCNT = 2 * 512, /* 2 sectors */
  70. MIN_BUFS = 16,
  71. NTARGETS = 8,
  72. NAOEIFS = 8,
  73. NSKBPOOLMAX = 256,
  74. NFACTIVE = 61,
  75. TIMERTICK = HZ / 10,
  76. RTTSCALE = 8,
  77. RTTDSCALE = 3,
  78. RTTAVG_INIT = USEC_PER_SEC / 4 << RTTSCALE,
  79. RTTDEV_INIT = RTTAVG_INIT / 4,
  80. HARD_SCORN_SECS = 10, /* try another remote port after this */
  81. MAX_TAINT = 1000, /* cap on aoetgt taint */
  82. };
  83. struct buf {
  84. ulong nframesout;
  85. ulong resid;
  86. ulong bv_resid;
  87. sector_t sector;
  88. struct bio *bio;
  89. struct bio_vec *bv;
  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. sector_t lba;
  104. struct sk_buff *skb; /* command skb freed on module exit */
  105. struct sk_buff *r_skb; /* response skb for async processing */
  106. struct buf *buf;
  107. struct bio_vec *bv;
  108. ulong bcnt;
  109. ulong bv_off;
  110. char flags;
  111. };
  112. struct aoeif {
  113. struct net_device *nd;
  114. ulong lost;
  115. int bcnt;
  116. };
  117. struct aoetgt {
  118. unsigned char addr[6];
  119. ushort nframes; /* cap on frames to use */
  120. struct aoedev *d; /* parent device I belong to */
  121. struct list_head ffree; /* list of free frames */
  122. struct aoeif ifs[NAOEIFS];
  123. struct aoeif *ifp; /* current aoeif in use */
  124. ushort nout; /* number of AoE commands outstanding */
  125. ushort maxout; /* current value for max outstanding */
  126. ushort next_cwnd; /* incr maxout after decrementing to zero */
  127. ushort ssthresh; /* slow start threshold */
  128. ulong falloc; /* number of allocated frames */
  129. int taint; /* how much we want to avoid this aoetgt */
  130. int minbcnt;
  131. int wpkts, rpkts;
  132. char nout_probes;
  133. };
  134. struct aoedev {
  135. struct aoedev *next;
  136. ulong sysminor;
  137. ulong aoemajor;
  138. u32 rttavg; /* scaled AoE round trip time average */
  139. u32 rttdev; /* scaled round trip time mean deviation */
  140. u16 aoeminor;
  141. u16 flags;
  142. u16 nopen; /* (bd_openers isn't available without sleeping) */
  143. u16 fw_ver; /* version of blade's firmware */
  144. u16 lasttag; /* last tag sent */
  145. u16 useme;
  146. ulong ref;
  147. struct work_struct work;/* disk create work struct */
  148. struct gendisk *gd;
  149. struct request_queue *blkq;
  150. struct hd_geometry geo;
  151. sector_t ssize;
  152. struct timer_list timer;
  153. spinlock_t lock;
  154. struct sk_buff_head skbpool;
  155. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  156. struct { /* pointers to work in progress */
  157. struct buf *buf;
  158. struct bio *nxbio;
  159. struct request *rq;
  160. } ip;
  161. ulong maxbcnt;
  162. struct list_head factive[NFACTIVE]; /* hash of active frames */
  163. struct list_head rexmitq; /* deferred retransmissions */
  164. struct aoetgt *targets[NTARGETS];
  165. struct aoetgt **tgt; /* target in use when working */
  166. ulong ntargets;
  167. ulong kicked;
  168. char ident[512];
  169. };
  170. /* kthread tracking */
  171. struct ktstate {
  172. struct completion rendez;
  173. struct task_struct *task;
  174. wait_queue_head_t *waitq;
  175. int (*fn) (void);
  176. char *name;
  177. spinlock_t *lock;
  178. };
  179. int aoeblk_init(void);
  180. void aoeblk_exit(void);
  181. void aoeblk_gdalloc(void *);
  182. void aoedisk_rm_sysfs(struct aoedev *d);
  183. int aoechr_init(void);
  184. void aoechr_exit(void);
  185. void aoechr_error(char *);
  186. void aoecmd_work(struct aoedev *d);
  187. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  188. struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
  189. void aoecmd_cfg_rsp(struct sk_buff *);
  190. void aoecmd_sleepwork(struct work_struct *);
  191. void aoecmd_wreset(struct aoetgt *t);
  192. void aoecmd_cleanslate(struct aoedev *);
  193. void aoecmd_exit(void);
  194. int aoecmd_init(void);
  195. struct sk_buff *aoecmd_ata_id(struct aoedev *);
  196. void aoe_freetframe(struct frame *);
  197. void aoe_flush_iocq(void);
  198. void aoe_end_request(struct aoedev *, struct request *, int);
  199. int aoe_ktstart(struct ktstate *k);
  200. void aoe_ktstop(struct ktstate *k);
  201. int aoedev_init(void);
  202. void aoedev_exit(void);
  203. struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
  204. void aoedev_downdev(struct aoedev *d);
  205. int aoedev_flush(const char __user *str, size_t size);
  206. void aoe_failbuf(struct aoedev *, struct buf *);
  207. void aoedev_put(struct aoedev *);
  208. int aoenet_init(void);
  209. void aoenet_exit(void);
  210. void aoenet_xmit(struct sk_buff_head *);
  211. int is_aoe_netif(struct net_device *ifp);
  212. int set_aoe_iflist(const char __user *str, size_t size);