00001 #ifndef _GPXE_AOE_H 00002 #define _GPXE_AOE_H 00003 00004 /** @file 00005 * 00006 * AoE protocol 00007 * 00008 */ 00009 00010 FILE_LICENCE ( GPL2_OR_LATER ); 00011 00012 #include <stdint.h> 00013 #include <gpxe/list.h> 00014 #include <gpxe/if_ether.h> 00015 #include <gpxe/retry.h> 00016 #include <gpxe/ata.h> 00017 00018 /** An AoE config command */ 00019 struct aoecfg { 00020 /** AoE Queue depth */ 00021 uint16_t bufcnt; 00022 /** ATA target firmware version */ 00023 uint16_t fwver; 00024 /** ATA target sector count */ 00025 uint8_t scnt; 00026 /** AoE config string subcommand */ 00027 uint8_t aoeccmd; 00028 /** AoE config string length */ 00029 uint16_t cfglen; 00030 /** AoE config string */ 00031 uint8_t data[0]; 00032 } __attribute__ (( packed )); 00033 00034 /** An AoE ATA command */ 00035 struct aoeata { 00036 /** AoE command flags */ 00037 uint8_t aflags; 00038 /** ATA error/feature register */ 00039 uint8_t err_feat; 00040 /** ATA sector count register */ 00041 uint8_t count; 00042 /** ATA command/status register */ 00043 uint8_t cmd_stat; 00044 /** Logical block address, in little-endian order */ 00045 union { 00046 uint64_t u64; 00047 uint8_t bytes[6]; 00048 } lba; 00049 /** Data payload */ 00050 uint8_t data[0]; 00051 } __attribute__ (( packed )); 00052 00053 #define AOE_FL_EXTENDED 0x40 /**< LBA48 extended addressing */ 00054 #define AOE_FL_DEV_HEAD 0x10 /**< Device/head flag */ 00055 #define AOE_FL_ASYNC 0x02 /**< Asynchronous write */ 00056 #define AOE_FL_WRITE 0x01 /**< Write command */ 00057 00058 /** An AoE command */ 00059 union aoecmd { 00060 /** Config command */ 00061 struct aoecfg cfg; 00062 /** ATA command */ 00063 struct aoeata ata; 00064 }; 00065 00066 /** An AoE header */ 00067 struct aoehdr { 00068 /** Protocol version number and flags */ 00069 uint8_t ver_flags; 00070 /** Error code */ 00071 uint8_t error; 00072 /** Major device number, in network byte order */ 00073 uint16_t major; 00074 /** Minor device number */ 00075 uint8_t minor; 00076 /** Command number */ 00077 uint8_t command; 00078 /** Tag, in network byte order */ 00079 uint32_t tag; 00080 /** Payload */ 00081 union aoecmd cmd[0]; 00082 } __attribute__ (( packed )); 00083 00084 #define AOE_VERSION 0x10 /**< Version 1 */ 00085 #define AOE_VERSION_MASK 0xf0 /**< Version part of ver_flags field */ 00086 00087 #define AOE_FL_RESPONSE 0x08 /**< Message is a response */ 00088 #define AOE_FL_ERROR 0x04 /**< Command generated an error */ 00089 00090 #define AOE_MAJOR_BROADCAST 0xffff 00091 #define AOE_MINOR_BROADCAST 0xff 00092 00093 #define AOE_CMD_ATA 0x00 /**< Issue ATA command */ 00094 #define AOE_CMD_CONFIG 0x01 /**< Query Config Information */ 00095 00096 #define AOE_TAG_MAGIC 0xebeb0000 00097 00098 #define AOE_ERR_BAD_COMMAND 1 /**< Unrecognised command code */ 00099 #define AOE_ERR_BAD_PARAMETER 2 /**< Bad argument parameter */ 00100 #define AOE_ERR_UNAVAILABLE 3 /**< Device unavailable */ 00101 #define AOE_ERR_CONFIG_EXISTS 4 /**< Config string present */ 00102 #define AOE_ERR_BAD_VERSION 5 /**< Unsupported version */ 00103 00104 /** An AoE session */ 00105 struct aoe_session { 00106 /** Reference counter */ 00107 struct refcnt refcnt; 00108 00109 /** List of all AoE sessions */ 00110 struct list_head list; 00111 00112 /** Network device */ 00113 struct net_device *netdev; 00114 00115 /** Major number */ 00116 uint16_t major; 00117 /** Minor number */ 00118 uint8_t minor; 00119 /** Target MAC address */ 00120 uint8_t target[ETH_ALEN]; 00121 00122 /** Tag for current AoE command */ 00123 uint32_t tag; 00124 00125 /** Current AOE command */ 00126 uint8_t aoe_cmd_type; 00127 /** Current ATA command */ 00128 struct ata_command *command; 00129 /** Overall status of current ATA command */ 00130 unsigned int status; 00131 /** Byte offset within command's data buffer */ 00132 unsigned int command_offset; 00133 /** Return status code for command */ 00134 int rc; 00135 00136 /** Retransmission timer */ 00137 struct retry_timer timer; 00138 }; 00139 00140 #define AOE_STATUS_ERR_MASK 0x0f /**< Error portion of status code */ 00141 #define AOE_STATUS_PENDING 0x80 /**< Command pending */ 00142 00143 /** Maximum number of sectors per packet */ 00144 #define AOE_MAX_COUNT 2 00145 00146 extern void aoe_detach ( struct ata_device *ata ); 00147 extern int aoe_attach ( struct ata_device *ata, struct net_device *netdev, 00148 const char *root_path ); 00149 00150 #endif /* _GPXE_AOE_H */
1.5.7.1