Lines Matching refs:aoe
37 #include <gpxe/aoe.h>
41 * AoE protocol
45 FEATURE ( FEATURE_PROTOCOL, "AoE", DHCP_EB_FEATURE_AOE, 1 );
49 /** List of all AoE sessions */
53 struct aoe_session *aoe =
56 netdev_put ( aoe->netdev );
57 free ( aoe );
61 * Mark current AoE command complete
63 * @v aoe AoE session
66 static void aoe_done ( struct aoe_session *aoe, int rc ) {
69 if ( aoe->command ) {
70 aoe->command->cb.cmd_stat = aoe->status;
71 aoe->command->rc = rc;
72 aoe->command = NULL;
76 stop_timer ( &aoe->timer );
79 aoe->rc = rc;
83 * Send AoE command
85 * @v aoe AoE session
88 * This transmits an AoE command packet. It does not wait for a
91 static int aoe_send_command ( struct aoe_session *aoe ) {
92 struct ata_command *command = aoe->command;
102 if ( ! aoe->netdev ) {
103 aoe_done ( aoe, -ENETUNREACH );
112 start_timer ( &aoe->timer );
115 switch ( aoe->aoe_cmd_type ) {
144 /* Fill AoE header */
146 aoehdr->major = htons ( aoe->major );
147 aoehdr->minor = aoe->minor;
148 aoehdr->command = aoe->aoe_cmd_type;
149 aoehdr->tag = htonl ( ++aoe->tag );
151 /* Fill AoE payload */
152 switch ( aoe->aoe_cmd_type ) {
154 /* Fill AoE command */
171 command->data_out, aoe->command_offset,
182 return net_tx ( iobuf, aoe->netdev, &aoe_protocol, aoe->target );
186 * Handle AoE retry timer expiry
188 * @v timer AoE retry timer
192 struct aoe_session *aoe =
196 aoe_done ( aoe, -ETIMEDOUT );
198 aoe_send_command ( aoe );
203 * Handle AoE configuration command response
205 * @v aoe AoE session
209 static int aoe_rx_cfg ( struct aoe_session *aoe, const void *ll_source ) {
212 memcpy ( aoe->target, ll_source, sizeof ( aoe->target ) );
213 DBGC ( aoe, "AoE %p target MAC address %s\n",
214 aoe, eth_ntoa ( aoe->target ) );
217 aoe_done ( aoe, 0 );
223 * Handle AoE ATA command response
225 * @v aoe AoE session
226 * @v aoeata AoE ATA command
227 * @v len Length of AoE ATA command
230 static int aoe_rx_ata ( struct aoe_session *aoe, struct aoeata *aoeata,
232 struct ata_command *command = aoe->command;
251 aoe->status |= aoeata->cmd_stat;
257 copy_to_user ( command->data_in, aoe->command_offset,
262 aoe->command_offset += data_len;
268 aoe_done ( aoe, 0 );
273 stop_timer ( &aoe->timer );
274 aoe_send_command ( aoe );
280 * Process incoming AoE packets
292 struct aoe_session *aoe;
305 /* Ignore AoE requests that we happen to see */
310 /* Demultiplex amongst active AoE sessions */
311 list_for_each_entry ( aoe, &aoe_sessions, list ) {
312 if ( ntohs ( aoehdr->major ) != aoe->major )
314 if ( aoehdr->minor != aoe->minor )
316 if ( ntohl ( aoehdr->tag ) != aoe->tag )
319 aoe_done ( aoe, -EIO );
324 rc = aoe_rx_ata ( aoe, iobuf->data, iob_len ( iobuf ));
327 rc = aoe_rx_cfg ( aoe, ll_source );
330 DBGC ( aoe, "AoE %p ignoring command %02x\n",
331 aoe, aoehdr->command );
342 /** AoE protocol */
344 .name = "AoE",
350 * Issue ATA command via an open AoE session
358 struct aoe_session *aoe =
361 aoe->command = command;
362 aoe->status = 0;
363 aoe->command_offset = 0;
364 aoe->aoe_cmd_type = AOE_CMD_ATA;
366 aoe_send_command ( aoe );
372 * Issue AoE config query for AoE target discovery
374 * @v aoe AoE session
377 static int aoe_discover ( struct aoe_session *aoe ) {
380 aoe->status = 0;
381 aoe->aoe_cmd_type = AOE_CMD_CONFIG;
382 aoe->command = NULL;
384 aoe_send_command ( aoe );
386 aoe->rc = -EINPROGRESS;
387 while ( aoe->rc == -EINPROGRESS )
389 rc = aoe->rc;
400 struct aoe_session *aoe =
403 stop_timer ( &aoe->timer );
405 list_del ( &aoe->list );
410 static int aoe_parse_root_path ( struct aoe_session *aoe,
414 if ( strncmp ( root_path, "aoe:", 4 ) != 0 )
421 aoe->major = strtoul ( ptr, &ptr, 10 );
425 aoe->minor = strtoul ( ptr, &ptr, 10 );
434 struct aoe_session *aoe;
438 aoe = zalloc ( sizeof ( *aoe ) );
439 if ( ! aoe )
441 aoe->refcnt.free = aoe_free;
442 aoe->netdev = netdev_get ( netdev );
443 memcpy ( aoe->target, netdev->ll_broadcast, sizeof ( aoe->target ) );
444 aoe->tag = AOE_TAG_MAGIC;
445 aoe->timer.expired = aoe_timer_expired;
448 if ( ( rc = aoe_parse_root_path ( aoe, root_path ) ) != 0 )
454 ata->backend = ref_get ( &aoe->refcnt );
456 list_add ( &aoe->list, &aoe_sessions );
463 if ( ( rc = aoe_discover( aoe ) ) != 0 )
469 ref_put ( &aoe->refcnt );