You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aoe.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #ifndef _GPXE_AOE_H
  2. #define _GPXE_AOE_H
  3. /** @file
  4. *
  5. * AoE protocol
  6. *
  7. */
  8. #include <stdint.h>
  9. #include <gpxe/list.h>
  10. #include <gpxe/if_ether.h>
  11. #include <gpxe/retry.h>
  12. #include <gpxe/ata.h>
  13. /** An AoE config command */
  14. struct aoecfg {
  15. /** AoE Queue depth */
  16. uint16_t bufcnt;
  17. /** ATA target firmware version */
  18. uint16_t fwver;
  19. /** ATA target sector count */
  20. uint8_t scnt;
  21. /** AoE config string subcommand */
  22. uint8_t aoeccmd;
  23. /** AoE config string length */
  24. uint16_t cfglen;
  25. /** AoE config string */
  26. uint8_t data[0];
  27. } __attribute__ (( packed ));
  28. /** An AoE ATA command */
  29. struct aoeata {
  30. /** AoE command flags */
  31. uint8_t aflags;
  32. /** ATA error/feature register */
  33. uint8_t err_feat;
  34. /** ATA sector count register */
  35. uint8_t count;
  36. /** ATA command/status register */
  37. uint8_t cmd_stat;
  38. /** Logical block address, in little-endian order */
  39. union {
  40. uint64_t u64;
  41. uint8_t bytes[6];
  42. } lba;
  43. /** Data payload */
  44. uint8_t data[0];
  45. } __attribute__ (( packed ));
  46. #define AOE_FL_EXTENDED 0x40 /**< LBA48 extended addressing */
  47. #define AOE_FL_DEV_HEAD 0x10 /**< Device/head flag */
  48. #define AOE_FL_ASYNC 0x02 /**< Asynchronous write */
  49. #define AOE_FL_WRITE 0x01 /**< Write command */
  50. /** An AoE command */
  51. union aoecmd {
  52. /** Config command */
  53. struct aoecfg cfg;
  54. /** ATA command */
  55. struct aoeata ata;
  56. };
  57. /** An AoE header */
  58. struct aoehdr {
  59. /** Protocol version number and flags */
  60. uint8_t ver_flags;
  61. /** Error code */
  62. uint8_t error;
  63. /** Major device number, in network byte order */
  64. uint16_t major;
  65. /** Minor device number */
  66. uint8_t minor;
  67. /** Command number */
  68. uint8_t command;
  69. /** Tag, in network byte order */
  70. uint32_t tag;
  71. /** Payload */
  72. union aoecmd cmd[0];
  73. } __attribute__ (( packed ));
  74. #define AOE_VERSION 0x10 /**< Version 1 */
  75. #define AOE_VERSION_MASK 0xf0 /**< Version part of ver_flags field */
  76. #define AOE_FL_RESPONSE 0x08 /**< Message is a response */
  77. #define AOE_FL_ERROR 0x04 /**< Command generated an error */
  78. #define AOE_MAJOR_BROADCAST 0xffff
  79. #define AOE_MINOR_BROADCAST 0xff
  80. #define AOE_CMD_ATA 0x00 /**< Issue ATA command */
  81. #define AOE_CMD_CONFIG 0x01 /**< Query Config Information */
  82. #define AOE_TAG_MAGIC 0xebeb0000
  83. #define AOE_ERR_BAD_COMMAND 1 /**< Unrecognised command code */
  84. #define AOE_ERR_BAD_PARAMETER 2 /**< Bad argument parameter */
  85. #define AOE_ERR_UNAVAILABLE 3 /**< Device unavailable */
  86. #define AOE_ERR_CONFIG_EXISTS 4 /**< Config string present */
  87. #define AOE_ERR_BAD_VERSION 5 /**< Unsupported version */
  88. /** An AoE session */
  89. struct aoe_session {
  90. /** Reference counter */
  91. struct refcnt refcnt;
  92. /** List of all AoE sessions */
  93. struct list_head list;
  94. /** Network device */
  95. struct net_device *netdev;
  96. /** Major number */
  97. uint16_t major;
  98. /** Minor number */
  99. uint8_t minor;
  100. /** Target MAC address */
  101. uint8_t target[ETH_ALEN];
  102. /** Tag for current AoE command */
  103. uint32_t tag;
  104. /** Current AOE command */
  105. uint8_t aoe_cmd_type;
  106. /** Current ATA command */
  107. struct ata_command *command;
  108. /** Overall status of current ATA command */
  109. unsigned int status;
  110. /** Byte offset within command's data buffer */
  111. unsigned int command_offset;
  112. /** Return status code for command */
  113. int rc;
  114. /** Retransmission timer */
  115. struct retry_timer timer;
  116. };
  117. #define AOE_STATUS_ERR_MASK 0x0f /**< Error portion of status code */
  118. #define AOE_STATUS_PENDING 0x80 /**< Command pending */
  119. /** Maximum number of sectors per packet */
  120. #define AOE_MAX_COUNT 2
  121. extern void aoe_detach ( struct ata_device *ata );
  122. extern int aoe_attach ( struct ata_device *ata, struct net_device *netdev,
  123. const char *root_path );
  124. #endif /* _GPXE_AOE_H */