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