aoe.h 4.2 KB

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