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