aoe.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "47q"
  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. struct aoe_atahdr {
  44. unsigned char aflags;
  45. unsigned char errfeat;
  46. unsigned char scnt;
  47. unsigned char cmdstat;
  48. unsigned char lba0;
  49. unsigned char lba1;
  50. unsigned char lba2;
  51. unsigned char lba3;
  52. unsigned char lba4;
  53. unsigned char lba5;
  54. unsigned char res[2];
  55. };
  56. struct aoe_cfghdr {
  57. __be16 bufcnt;
  58. __be16 fwver;
  59. unsigned char scnt;
  60. unsigned char aoeccmd;
  61. unsigned char cslen[2];
  62. };
  63. enum {
  64. DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
  65. DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
  66. DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
  67. DEVFL_CLOSEWAIT = (1<<3), /* device is waiting for all closes to revalidate */
  68. DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */
  69. DEVFL_KICKME = (1<<5), /* slow polling network card catch */
  70. DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
  71. BUFFL_FAIL = 1,
  72. };
  73. enum {
  74. DEFAULTBCNT = 2 * 512, /* 2 sectors */
  75. NPERSHELF = 16, /* number of slots per shelf address */
  76. FREETAG = -1,
  77. MIN_BUFS = 16,
  78. NTARGETS = 8,
  79. NAOEIFS = 8,
  80. NSKBPOOLMAX = 128,
  81. TIMERTICK = HZ / 10,
  82. MINTIMER = HZ >> 2,
  83. MAXTIMER = HZ << 1,
  84. HELPWAIT = 20,
  85. };
  86. struct buf {
  87. struct list_head bufs;
  88. ulong stime; /* for disk stats */
  89. ulong flags;
  90. ulong nframesout;
  91. ulong resid;
  92. ulong bv_resid;
  93. ulong bv_off;
  94. sector_t sector;
  95. struct bio *bio;
  96. struct bio_vec *bv;
  97. };
  98. struct frame {
  99. int tag;
  100. ulong waited;
  101. struct buf *buf;
  102. char *bufaddr;
  103. ulong bcnt;
  104. sector_t lba;
  105. struct sk_buff *skb;
  106. };
  107. struct aoeif {
  108. struct net_device *nd;
  109. unsigned char lost;
  110. unsigned char lostjumbo;
  111. ushort maxbcnt;
  112. };
  113. struct aoetgt {
  114. unsigned char addr[6];
  115. ushort nframes;
  116. struct frame *frames;
  117. struct aoeif ifs[NAOEIFS];
  118. struct aoeif *ifp; /* current aoeif in use */
  119. ushort nout;
  120. ushort maxout;
  121. u16 lasttag; /* last tag sent */
  122. u16 useme;
  123. ulong lastwadj; /* last window adjustment */
  124. int wpkts, rpkts;
  125. int dataref;
  126. };
  127. struct aoedev {
  128. struct aoedev *next;
  129. ulong sysminor;
  130. ulong aoemajor;
  131. u16 aoeminor;
  132. u16 flags;
  133. u16 nopen; /* (bd_openers isn't available without sleeping) */
  134. u16 rttavg; /* round trip average of requests/responses */
  135. u16 mintimer;
  136. u16 fw_ver; /* version of blade's firmware */
  137. struct work_struct work;/* disk create work struct */
  138. struct gendisk *gd;
  139. struct request_queue *blkq;
  140. struct hd_geometry geo;
  141. sector_t ssize;
  142. struct timer_list timer;
  143. spinlock_t lock;
  144. struct sk_buff_head sendq;
  145. struct sk_buff_head skbpool;
  146. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  147. struct list_head bufq; /* queue of bios to work on */
  148. struct buf *inprocess; /* the one we're currently working on */
  149. struct aoetgt *targets[NTARGETS];
  150. struct aoetgt **tgt; /* target in use when working */
  151. struct aoetgt **htgt; /* target needing rexmit assistance */
  152. };
  153. int aoeblk_init(void);
  154. void aoeblk_exit(void);
  155. void aoeblk_gdalloc(void *);
  156. void aoedisk_rm_sysfs(struct aoedev *d);
  157. int aoechr_init(void);
  158. void aoechr_exit(void);
  159. void aoechr_error(char *);
  160. void aoecmd_work(struct aoedev *d);
  161. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  162. void aoecmd_ata_rsp(struct sk_buff *);
  163. void aoecmd_cfg_rsp(struct sk_buff *);
  164. void aoecmd_sleepwork(struct work_struct *);
  165. void aoecmd_cleanslate(struct aoedev *);
  166. struct sk_buff *aoecmd_ata_id(struct aoedev *);
  167. int aoedev_init(void);
  168. void aoedev_exit(void);
  169. struct aoedev *aoedev_by_aoeaddr(int maj, int min);
  170. struct aoedev *aoedev_by_sysminor_m(ulong sysminor);
  171. void aoedev_downdev(struct aoedev *d);
  172. int aoedev_flush(const char __user *str, size_t size);
  173. int aoenet_init(void);
  174. void aoenet_exit(void);
  175. void aoenet_xmit(struct sk_buff_head *);
  176. int is_aoe_netif(struct net_device *ifp);
  177. int set_aoe_iflist(const char __user *str, size_t size);