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.6KB

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