aoe.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 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. MINTIMER = HZ >> 2,
  77. MAXTIMER = HZ << 1,
  78. };
  79. struct buf {
  80. ulong nframesout;
  81. ulong resid;
  82. ulong bv_resid;
  83. sector_t sector;
  84. struct bio *bio;
  85. struct bio_vec *bv;
  86. struct request *rq;
  87. };
  88. struct frame {
  89. struct list_head head;
  90. u32 tag;
  91. ulong waited;
  92. struct aoetgt *t; /* parent target I belong to */
  93. sector_t lba;
  94. struct sk_buff *skb; /* command skb freed on module exit */
  95. struct sk_buff *r_skb; /* response skb for async processing */
  96. struct buf *buf;
  97. struct bio_vec *bv;
  98. ulong bcnt;
  99. ulong bv_off;
  100. };
  101. struct aoeif {
  102. struct net_device *nd;
  103. ulong lost;
  104. int bcnt;
  105. };
  106. struct aoetgt {
  107. unsigned char addr[6];
  108. ushort nframes;
  109. struct aoedev *d; /* parent device I belong to */
  110. struct list_head ffree; /* list of free frames */
  111. struct aoeif ifs[NAOEIFS];
  112. struct aoeif *ifp; /* current aoeif in use */
  113. ushort nout;
  114. ushort maxout;
  115. ulong falloc;
  116. ulong lastwadj; /* last window adjustment */
  117. int minbcnt;
  118. int wpkts, rpkts;
  119. };
  120. struct aoedev {
  121. struct aoedev *next;
  122. ulong sysminor;
  123. ulong aoemajor;
  124. u16 aoeminor;
  125. u16 flags;
  126. u16 nopen; /* (bd_openers isn't available without sleeping) */
  127. u16 rttavg; /* round trip average of requests/responses */
  128. u16 mintimer;
  129. u16 fw_ver; /* version of blade's firmware */
  130. u16 lasttag; /* last tag sent */
  131. u16 useme;
  132. ulong ref;
  133. struct work_struct work;/* disk create work struct */
  134. struct gendisk *gd;
  135. struct request_queue *blkq;
  136. struct hd_geometry geo;
  137. sector_t ssize;
  138. struct timer_list timer;
  139. spinlock_t lock;
  140. struct sk_buff_head skbpool;
  141. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  142. struct { /* pointers to work in progress */
  143. struct buf *buf;
  144. struct bio *nxbio;
  145. struct request *rq;
  146. } ip;
  147. ulong maxbcnt;
  148. struct list_head factive[NFACTIVE]; /* hash of active frames */
  149. struct aoetgt *targets[NTARGETS];
  150. struct aoetgt **tgt; /* target in use when working */
  151. struct aoetgt *htgt; /* target needing rexmit assistance */
  152. ulong ntargets;
  153. ulong kicked;
  154. };
  155. /* kthread tracking */
  156. struct ktstate {
  157. struct completion rendez;
  158. struct task_struct *task;
  159. wait_queue_head_t *waitq;
  160. int (*fn) (void);
  161. char *name;
  162. spinlock_t *lock;
  163. };
  164. int aoeblk_init(void);
  165. void aoeblk_exit(void);
  166. void aoeblk_gdalloc(void *);
  167. void aoedisk_rm_sysfs(struct aoedev *d);
  168. int aoechr_init(void);
  169. void aoechr_exit(void);
  170. void aoechr_error(char *);
  171. void aoecmd_work(struct aoedev *d);
  172. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  173. struct sk_buff *aoecmd_ata_rsp(struct sk_buff *);
  174. void aoecmd_cfg_rsp(struct sk_buff *);
  175. void aoecmd_sleepwork(struct work_struct *);
  176. void aoecmd_cleanslate(struct aoedev *);
  177. void aoecmd_exit(void);
  178. int aoecmd_init(void);
  179. struct sk_buff *aoecmd_ata_id(struct aoedev *);
  180. void aoe_freetframe(struct frame *);
  181. void aoe_flush_iocq(void);
  182. void aoe_end_request(struct aoedev *, struct request *, int);
  183. int aoe_ktstart(struct ktstate *k);
  184. void aoe_ktstop(struct ktstate *k);
  185. int aoedev_init(void);
  186. void aoedev_exit(void);
  187. struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc);
  188. void aoedev_downdev(struct aoedev *d);
  189. int aoedev_flush(const char __user *str, size_t size);
  190. void aoe_failbuf(struct aoedev *, struct buf *);
  191. void aoedev_put(struct aoedev *);
  192. int aoenet_init(void);
  193. void aoenet_exit(void);
  194. void aoenet_xmit(struct sk_buff_head *);
  195. int is_aoe_netif(struct net_device *ifp);
  196. int set_aoe_iflist(const char __user *str, size_t size);