aoe.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "22"
  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 xprintk(L, fmt, arg...) printk(L "aoe: " "%s: " fmt, __func__, ## arg)
  12. #define iprintk(fmt, arg...) xprintk(KERN_INFO, fmt, ## arg)
  13. #define eprintk(fmt, arg...) xprintk(KERN_ERR, fmt, ## arg)
  14. #define dprintk(fmt, arg...) xprintk(KERN_DEBUG, fmt, ## arg)
  15. #define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor))
  16. #define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF)
  17. #define AOEMINOR(sysminor) ((sysminor) % NPERSHELF)
  18. #define WHITESPACE " \t\v\f\n"
  19. enum {
  20. AOECMD_ATA,
  21. AOECMD_CFG,
  22. AOEFL_RSP = (1<<3),
  23. AOEFL_ERR = (1<<2),
  24. AOEAFL_EXT = (1<<6),
  25. AOEAFL_DEV = (1<<4),
  26. AOEAFL_ASYNC = (1<<1),
  27. AOEAFL_WRITE = (1<<0),
  28. AOECCMD_READ = 0,
  29. AOECCMD_TEST,
  30. AOECCMD_PTEST,
  31. AOECCMD_SET,
  32. AOECCMD_FSET,
  33. AOE_HVER = 0x10,
  34. };
  35. struct aoe_hdr {
  36. unsigned char dst[6];
  37. unsigned char src[6];
  38. __be16 type;
  39. unsigned char verfl;
  40. unsigned char err;
  41. __be16 major;
  42. unsigned char minor;
  43. unsigned char cmd;
  44. __be32 tag;
  45. };
  46. struct aoe_atahdr {
  47. unsigned char aflags;
  48. unsigned char errfeat;
  49. unsigned char scnt;
  50. unsigned char cmdstat;
  51. unsigned char lba0;
  52. unsigned char lba1;
  53. unsigned char lba2;
  54. unsigned char lba3;
  55. unsigned char lba4;
  56. unsigned char lba5;
  57. unsigned char res[2];
  58. };
  59. struct aoe_cfghdr {
  60. __be16 bufcnt;
  61. __be16 fwver;
  62. unsigned char scnt;
  63. unsigned char aoeccmd;
  64. unsigned char cslen[2];
  65. };
  66. enum {
  67. DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */
  68. DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */
  69. DEVFL_EXT = (1<<2), /* device accepts lba48 commands */
  70. DEVFL_CLOSEWAIT = (1<<3), /* device is waiting for all closes to revalidate */
  71. DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */
  72. DEVFL_PAUSE = (1<<5),
  73. DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
  74. DEVFL_MAXBCNT = (1<<7), /* d->maxbcnt is not changeable */
  75. DEVFL_KICKME = (1<<8),
  76. BUFFL_FAIL = 1,
  77. };
  78. enum {
  79. DEFAULTBCNT = 2 * 512, /* 2 sectors */
  80. NPERSHELF = 16, /* number of slots per shelf address */
  81. FREETAG = -1,
  82. MIN_BUFS = 8,
  83. };
  84. struct buf {
  85. struct list_head bufs;
  86. ulong start_time; /* for disk stats */
  87. ulong flags;
  88. ulong nframesout;
  89. char *bufaddr;
  90. ulong resid;
  91. ulong bv_resid;
  92. sector_t sector;
  93. struct bio *bio;
  94. struct bio_vec *bv;
  95. };
  96. struct frame {
  97. int tag;
  98. ulong waited;
  99. struct buf *buf;
  100. char *bufaddr;
  101. ulong bcnt;
  102. sector_t lba;
  103. struct sk_buff *skb;
  104. };
  105. struct aoedev {
  106. struct aoedev *next;
  107. unsigned char addr[6]; /* remote mac addr */
  108. ushort flags;
  109. ulong sysminor;
  110. ulong aoemajor;
  111. ulong aoeminor;
  112. u16 nopen; /* (bd_openers isn't available without sleeping) */
  113. u16 lasttag; /* last tag sent */
  114. u16 rttavg; /* round trip average of requests/responses */
  115. u16 mintimer;
  116. u16 fw_ver; /* version of blade's firmware */
  117. u16 maxbcnt;
  118. struct work_struct work;/* disk create work struct */
  119. struct gendisk *gd;
  120. request_queue_t blkq;
  121. struct hd_geometry geo;
  122. sector_t ssize;
  123. struct timer_list timer;
  124. spinlock_t lock;
  125. struct net_device *ifp; /* interface ed is attached to */
  126. struct sk_buff *sendq_hd; /* packets needing to be sent, list head */
  127. struct sk_buff *sendq_tl;
  128. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  129. struct list_head bufq; /* queue of bios to work on */
  130. struct buf *inprocess; /* the one we're currently working on */
  131. ushort lostjumbo;
  132. ushort nframes; /* number of frames below */
  133. struct frame *frames;
  134. };
  135. int aoeblk_init(void);
  136. void aoeblk_exit(void);
  137. void aoeblk_gdalloc(void *);
  138. void aoedisk_rm_sysfs(struct aoedev *d);
  139. int aoechr_init(void);
  140. void aoechr_exit(void);
  141. void aoechr_error(char *);
  142. void aoecmd_work(struct aoedev *d);
  143. void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
  144. void aoecmd_ata_rsp(struct sk_buff *);
  145. void aoecmd_cfg_rsp(struct sk_buff *);
  146. void aoecmd_sleepwork(void *vp);
  147. struct sk_buff *new_skb(ulong);
  148. int aoedev_init(void);
  149. void aoedev_exit(void);
  150. struct aoedev *aoedev_by_aoeaddr(int maj, int min);
  151. struct aoedev *aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt);
  152. void aoedev_downdev(struct aoedev *d);
  153. int aoedev_isbusy(struct aoedev *d);
  154. int aoenet_init(void);
  155. void aoenet_exit(void);
  156. void aoenet_xmit(struct sk_buff *);
  157. int is_aoe_netif(struct net_device *ifp);
  158. int set_aoe_iflist(const char __user *str, size_t size);
  159. u64 mac_addr(char addr[6]);