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

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