aoe.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "49"
  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 SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor))
  12. #define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF)
  13. #define AOEMINOR(sysminor) ((sysminor) % NPERSHELF)
  14. #define WHITESPACE " \t\v\f\n"
  15. enum {
  16. AOECMD_ATA,
  17. AOECMD_CFG,
  18. AOECMD_VEND_MIN = 0xf0,
  19. AOEFL_RSP = (1<<3),
  20. AOEFL_ERR = (1<<2),
  21. AOEAFL_EXT = (1<<6),
  22. AOEAFL_DEV = (1<<4),
  23. AOEAFL_ASYNC = (1<<1),
  24. AOEAFL_WRITE = (1<<0),
  25. AOECCMD_READ = 0,
  26. AOECCMD_TEST,
  27. AOECCMD_PTEST,
  28. AOECCMD_SET,
  29. AOECCMD_FSET,
  30. AOE_HVER = 0x10,
  31. };
  32. struct aoe_hdr {
  33. unsigned char dst[6];
  34. unsigned char src[6];
  35. __be16 type;
  36. unsigned char verfl;
  37. unsigned char err;
  38. __be16 major;
  39. unsigned char minor;
  40. unsigned char cmd;
  41. __be32 tag;
  42. };
  43. #define AOE_MAXSHELF (0xffff-1) /* one less than the broadcast shelf address */
  44. struct aoe_atahdr {
  45. unsigned char aflags;
  46. unsigned char errfeat;
  47. unsigned char scnt;
  48. unsigned char cmdstat;
  49. unsigned char lba0;
  50. unsigned char lba1;
  51. unsigned char lba2;
  52. unsigned char lba3;
  53. unsigned char lba4;
  54. unsigned char lba5;
  55. unsigned char res[2];
  56. };
  57. struct aoe_cfghdr {
  58. __be16 bufcnt;
  59. __be16 fwver;
  60. unsigned char scnt;
  61. unsigned char aoeccmd;
  62. unsigned char cslen[2];
  63. };
  64. enum {
  65. DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
  66. DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
  67. DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
  68. DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */
  69. DEVFL_KICKME = (1<<4), /* slow polling network card catch */
  70. DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */
  71. };
  72. enum {
  73. DEFAULTBCNT = 2 * 512, /* 2 sectors */
  74. NPERSHELF = 16, /* number of slots per shelf address */
  75. MIN_BUFS = 16,
  76. NTARGETS = 8,
  77. NAOEIFS = 8,
  78. NSKBPOOLMAX = 256,
  79. NFACTIVE = 61,
  80. TIMERTICK = HZ / 10,
  81. MINTIMER = HZ >> 2,
  82. MAXTIMER = HZ << 1,
  83. };
  84. struct buf {
  85. ulong nframesout;
  86. ulong resid;
  87. ulong bv_resid;
  88. sector_t sector;
  89. struct bio *bio;
  90. struct bio_vec *bv;
  91. struct request *rq;
  92. };
  93. struct frame {
  94. struct list_head head;
  95. u32 tag;
  96. ulong waited;
  97. struct aoetgt *t; /* parent target I belong to */
  98. sector_t lba;
  99. struct sk_buff *skb; /* command skb freed on module exit */
  100. struct sk_buff *r_skb; /* response skb for async processing */
  101. struct buf *buf;
  102. struct bio_vec *bv;
  103. ulong bcnt;
  104. ulong bv_off;
  105. };
  106. struct aoeif {
  107. struct net_device *nd;
  108. ulong lost;
  109. int bcnt;
  110. };
  111. struct aoetgt {
  112. unsigned char addr[6];
  113. ushort nframes;
  114. struct aoedev *d; /* parent device I belong to */
  115. struct list_head ffree; /* list of free frames */
  116. struct aoeif ifs[NAOEIFS];
  117. struct aoeif *ifp; /* current aoeif in use */
  118. ushort nout;
  119. ushort maxout;
  120. ulong falloc;
  121. ulong lastwadj; /* last window adjustment */
  122. int minbcnt;
  123. int wpkts, rpkts;
  124. };
  125. struct aoedev {
  126. struct aoedev *next;
  127. ulong sysminor;
  128. ulong aoemajor;
  129. u16 aoeminor;
  130. u16 flags;
  131. u16 nopen; /* (bd_openers isn't available without sleeping) */
  132. u16 rttavg; /* round trip average of requests/responses */
  133. u16 mintimer;
  134. u16 fw_ver; /* version of blade's firmware */
  135. u16 lasttag; /* last tag sent */
  136. u16 useme;
  137. ulong ref;
  138. struct work_struct work;/* disk create work struct */
  139. struct gendisk *gd;
  140. struct request_queue *blkq;
  141. struct hd_geometry geo;
  142. sector_t ssize;
  143. struct timer_list timer;
  144. spinlock_t lock;
  145. struct sk_buff_head skbpool;
  146. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  147. struct { /* pointers to work in progress */
  148. struct buf *buf;
  149. struct bio *nxbio;
  150. struct request *rq;
  151. } ip;
  152. ulong maxbcnt;
  153. struct list_head factive[NFACTIVE]; /* hash of active frames */
  154. struct aoetgt *targets[NTARGETS];
  155. struct aoetgt **tgt; /* target in use when working */
  156. struct aoetgt *htgt; /* target needing rexmit assistance */
  157. ulong ntargets;
  158. ulong kicked;
  159. };
  160. /* kthread tracking */
  161. struct ktstate {
  162. struct completion rendez;
  163. struct task_struct *task;
  164. wait_queue_head_t *waitq;
  165. int (*fn) (void);
  166. char *name;
  167. spinlock_t *lock;
  168. };
  169. int aoeblk_init(void);
  170. void aoeblk_exit(void);
  171. void aoeblk_gdalloc(void *);
  172. void aoedisk_rm_sysfs(struct aoedev *d);
  173. int aoechr_init(void);
  174. void aoechr_exit(void);
  175. void aoechr_error(char *);
  176. void aoecmd_work(struct aoedev *d);
  177. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  178. struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
  179. void aoecmd_cfg_rsp(struct sk_buff *);
  180. void aoecmd_sleepwork(struct work_struct *);
  181. void aoecmd_cleanslate(struct aoedev *);
  182. void aoecmd_exit(void);
  183. int aoecmd_init(void);
  184. struct sk_buff *aoecmd_ata_id(struct aoedev *);
  185. void aoe_freetframe(struct frame *);
  186. void aoe_flush_iocq(void);
  187. void aoe_end_request(struct aoedev *, struct request *, int);
  188. int aoe_ktstart(struct ktstate *k);
  189. void aoe_ktstop(struct ktstate *k);
  190. int aoedev_init(void);
  191. void aoedev_exit(void);
  192. struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
  193. void aoedev_downdev(struct aoedev *d);
  194. int aoedev_flush(const char __user *str, size_t size);
  195. void aoe_failbuf(struct aoedev *, struct buf *);
  196. void aoedev_put(struct aoedev *);
  197. int aoenet_init(void);
  198. void aoenet_exit(void);
  199. void aoenet_xmit(struct sk_buff_head *);
  200. int is_aoe_netif(struct net_device *ifp);
  201. int set_aoe_iflist(const char __user *str, size_t size);