aoe.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */
  2. #define VERSION "5"
  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) * 10 + (aoeminor))
  12. #define AOEMAJOR(sysminor) ((sysminor) / 10)
  13. #define AOEMINOR(sysminor) ((sysminor) % 10)
  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. unsigned char type[2];
  35. unsigned char verfl;
  36. unsigned char err;
  37. unsigned char major[2];
  38. unsigned char minor;
  39. unsigned char cmd;
  40. unsigned char tag[4];
  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. unsigned char bufcnt[2];
  57. unsigned char fwver[2];
  58. unsigned char res;
  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_WC_UPDATE = (1<<4), /* this device needs to update write cache status */
  68. DEVFL_WORKON = (1<<4),
  69. BUFFL_FAIL = 1,
  70. };
  71. enum {
  72. MAXATADATA = 1024,
  73. NPERSHELF = 10,
  74. FREETAG = -1,
  75. MIN_BUFS = 8,
  76. };
  77. struct buf {
  78. struct list_head bufs;
  79. ulong flags;
  80. ulong nframesout;
  81. char *bufaddr;
  82. ulong resid;
  83. ulong bv_resid;
  84. sector_t sector;
  85. struct bio *bio;
  86. struct bio_vec *bv;
  87. };
  88. struct frame {
  89. int tag;
  90. ulong waited;
  91. struct buf *buf;
  92. char *bufaddr;
  93. int writedatalen;
  94. int ndata;
  95. /* largest possible */
  96. unsigned char data[sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr)];
  97. };
  98. struct aoedev {
  99. struct aoedev *next;
  100. unsigned char addr[6]; /* remote mac addr */
  101. ushort flags;
  102. ulong sysminor;
  103. ulong aoemajor;
  104. ulong aoeminor;
  105. ulong nopen; /* (bd_openers isn't available without sleeping) */
  106. ulong rttavg; /* round trip average of requests/responses */
  107. u16 fw_ver; /* version of blade's firmware */
  108. struct work_struct work;/* disk create work struct */
  109. struct gendisk *gd;
  110. request_queue_t blkq;
  111. struct hd_geometry geo;
  112. sector_t ssize;
  113. struct timer_list timer;
  114. spinlock_t lock;
  115. struct net_device *ifp; /* interface ed is attached to */
  116. struct sk_buff *skblist;/* packets needing to be sent */
  117. mempool_t *bufpool; /* for deadlock-free Buf allocation */
  118. struct list_head bufq; /* queue of bios to work on */
  119. struct buf *inprocess; /* the one we're currently working on */
  120. ulong lasttag; /* last tag sent */
  121. ulong nframes; /* number of frames below */
  122. struct frame *frames;
  123. };
  124. int aoeblk_init(void);
  125. void aoeblk_exit(void);
  126. void aoeblk_gdalloc(void *);
  127. void aoedisk_rm_sysfs(struct aoedev *d);
  128. int aoechr_init(void);
  129. void aoechr_exit(void);
  130. void aoechr_error(char *);
  131. void aoecmd_work(struct aoedev *d);
  132. void aoecmd_cfg(ushort, unsigned char);
  133. void aoecmd_ata_rsp(struct sk_buff *);
  134. void aoecmd_cfg_rsp(struct sk_buff *);
  135. int aoedev_init(void);
  136. void aoedev_exit(void);
  137. struct aoedev *aoedev_bymac(unsigned char *);
  138. void aoedev_downdev(struct aoedev *d);
  139. struct aoedev *aoedev_set(ulong, unsigned char *, struct net_device *, ulong);
  140. int aoedev_busy(void);
  141. int aoenet_init(void);
  142. void aoenet_exit(void);
  143. void aoenet_xmit(struct sk_buff *);
  144. int is_aoe_netif(struct net_device *ifp);
  145. int set_aoe_iflist(const char __user *str, size_t size);
  146. u64 mac_addr(char addr[6]);