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

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