iPXE
Data Structures | Functions | Variables
aoe.c File Reference

AoE protocol. More...

#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/list.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/features.h>
#include <ipxe/interface.h>
#include <ipxe/xfer.h>
#include <ipxe/uri.h>
#include <ipxe/open.h>
#include <ipxe/ata.h>
#include <ipxe/device.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/aoe.h>

Go to the source code of this file.

Data Structures

struct  aoe_command
 An AoE command. More...
 
struct  aoe_command_type
 An AoE command type. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FEATURE (FEATURE_PROTOCOL, "AoE", DHCP_EB_FEATURE_AOE, 1)
 
static LIST_HEAD (aoe_devices)
 List of all AoE devices. More...
 
static LIST_HEAD (aoe_commands)
 List of active AoE commands. More...
 
static struct aoe_deviceaoedev_get (struct aoe_device *aoedev)
 Get reference to AoE device. More...
 
static void aoedev_put (struct aoe_device *aoedev)
 Drop reference to AoE device. More...
 
static struct aoe_commandaoecmd_get (struct aoe_command *aoecmd)
 Get reference to AoE command. More...
 
static void aoecmd_put (struct aoe_command *aoecmd)
 Drop reference to AoE command. More...
 
static const char * aoedev_name (struct aoe_device *aoedev)
 Name AoE device. More...
 
static void aoecmd_free (struct refcnt *refcnt)
 Free AoE command. More...
 
static void aoecmd_close (struct aoe_command *aoecmd, int rc)
 Close AoE command. More...
 
static int aoecmd_tx (struct aoe_command *aoecmd)
 Transmit AoE command request. More...
 
static int aoecmd_rx (struct aoe_command *aoecmd, struct io_buffer *iobuf, const void *ll_source)
 Receive AoE command response. More...
 
static void aoecmd_expired (struct retry_timer *timer, int fail)
 Handle AoE retry timer expiry. More...
 
static size_t aoecmd_ata_cmd_len (struct aoe_command *aoecmd)
 Calculate length of AoE ATA command IU. More...
 
static void aoecmd_ata_cmd (struct aoe_command *aoecmd, void *data, size_t len)
 Build AoE ATA command IU. More...
 
static int aoecmd_ata_rsp (struct aoe_command *aoecmd, const void *data, size_t len, const void *ll_source __unused)
 Handle AoE ATA response IU. More...
 
static size_t aoecmd_cfg_cmd_len (struct aoe_command *aoecmd __unused)
 Calculate length of AoE configuration command IU. More...
 
static void aoecmd_cfg_cmd (struct aoe_command *aoecmd, void *data, size_t len)
 Build AoE configuration command IU. More...
 
static int aoecmd_cfg_rsp (struct aoe_command *aoecmd, const void *data, size_t len, const void *ll_source)
 Handle AoE configuration response IU. More...
 
static struct aoe_commandaoecmd_find_tag (uint32_t tag)
 Identify AoE command by tag. More...
 
static int aoecmd_new_tag (void)
 Choose an AoE command tag. More...
 
static struct aoe_commandaoecmd_create (struct aoe_device *aoedev, struct aoe_command_type *type)
 Create AoE command. More...
 
static int aoedev_ata_command (struct aoe_device *aoedev, struct interface *parent, struct ata_cmd *command)
 Issue AoE ATA command. More...
 
static int aoedev_cfg_command (struct aoe_device *aoedev, struct interface *parent)
 Issue AoE configuration command. More...
 
static void aoedev_free (struct refcnt *refcnt)
 Free AoE device. More...
 
static void aoedev_close (struct aoe_device *aoedev, int rc)
 Close AoE device. More...
 
static size_t aoedev_window (struct aoe_device *aoedev)
 Check AoE device flow-control window. More...
 
static void aoedev_config_done (struct aoe_device *aoedev, int rc)
 Handle AoE device configuration completion. More...
 
static struct deviceaoedev_identify_device (struct aoe_device *aoedev)
 Identify device underlying AoE device. More...
 
static struct acpi_descriptoraoedev_describe (struct aoe_device *aoedev)
 Get AoE ACPI descriptor. More...
 
static int aoedev_open (struct interface *parent, struct net_device *netdev, unsigned int major, unsigned int minor)
 Open AoE device. More...
 
static int aoe_rx (struct io_buffer *iobuf, struct net_device *netdev __unused, const void *ll_dest __unused, const void *ll_source, unsigned int flags __unused)
 Process incoming AoE packets. More...
 
static int aoe_parse_uri (struct uri *uri, unsigned int *major, unsigned int *minor)
 Parse AoE URI. More...
 
static int aoe_open (struct interface *parent, struct uri *uri)
 Open AoE URI. More...
 
static int abft_complete (struct acpi_descriptor *desc __unused)
 Check if AoE boot firmware table descriptor is complete. More...
 
static int abft_install (int(*install)(struct acpi_header *acpi))
 Install AoE boot firmware table(s) More...
 

Variables

struct net_protocol aoe_protocol __net_protocol
 AoE protocol. More...
 
struct acpi_model abft_model __acpi_model
 aBFT model More...
 
static struct aoe_command_type aoecmd_ata
 AoE ATA command. More...
 
static struct aoe_command_type aoecmd_cfg
 AoE configuration command. More...
 
static struct interface_operation aoecmd_ata_op []
 AoE command ATA interface operations. More...
 
static struct interface_descriptor aoecmd_ata_desc
 AoE command ATA interface descriptor. More...
 
static struct interface_operation aoedev_ata_op []
 AoE device ATA interface operations. More...
 
static struct interface_descriptor aoedev_ata_desc
 AoE device ATA interface descriptor. More...
 
static struct interface_operation aoedev_config_op []
 AoE device configuration interface operations. More...
 
static struct interface_descriptor aoedev_config_desc
 AoE device configuration interface descriptor. More...
 
struct uri_opener aoe_uri_opener __uri_opener
 AoE URI opener. More...
 

Detailed Description

AoE protocol.

Definition in file aoe.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FEATURE()

FEATURE ( FEATURE_PROTOCOL  ,
"AoE"  ,
DHCP_EB_FEATURE_AOE  ,
 
)

◆ LIST_HEAD() [1/2]

static LIST_HEAD ( aoe_devices  )
static

List of all AoE devices.

◆ LIST_HEAD() [2/2]

static LIST_HEAD ( aoe_commands  )
static

List of active AoE commands.

◆ aoedev_get()

static struct aoe_device* aoedev_get ( struct aoe_device aoedev)
inlinestatic

Get reference to AoE device.

Parameters
aoedevAoE device
Return values
aoedevAoE device

Definition at line 131 of file aoe.c.

131  {
132  ref_get ( &aoedev->refcnt );
133  return aoedev;
134 }
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct refcnt refcnt
Reference counter.
Definition: aoe.h:117

References ref_get, and aoe_device::refcnt.

Referenced by aoecmd_create().

◆ aoedev_put()

static void aoedev_put ( struct aoe_device aoedev)
inlinestatic

Drop reference to AoE device.

Parameters
aoedevAoE device

Definition at line 142 of file aoe.c.

142  {
143  ref_put ( &aoedev->refcnt );
144 }
struct refcnt refcnt
Reference counter.
Definition: aoe.h:117
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and aoe_device::refcnt.

Referenced by aoecmd_free().

◆ aoecmd_get()

static struct aoe_command* aoecmd_get ( struct aoe_command aoecmd)
inlinestatic

Get reference to AoE command.

Parameters
aoecmdAoE command
Return values
aoecmdAoE command

Definition at line 153 of file aoe.c.

153  {
154  ref_get ( &aoecmd->refcnt );
155  return aoecmd;
156 }
An AoE command.
Definition: aoe.h:62
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92

References ref_get.

Referenced by aoe_rx(), and aoedev_close().

◆ aoecmd_put()

static void aoecmd_put ( struct aoe_command aoecmd)
inlinestatic

Drop reference to AoE command.

Parameters
aoecmdAoE command

Definition at line 164 of file aoe.c.

164  {
165  ref_put ( &aoecmd->refcnt );
166 }
An AoE command.
Definition: aoe.h:62
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put.

Referenced by aoe_rx(), aoecmd_close(), and aoedev_close().

◆ aoedev_name()

static const char* aoedev_name ( struct aoe_device aoedev)
static

Name AoE device.

Parameters
aoedevAoE device
Return values
nameAoE device name

Definition at line 174 of file aoe.c.

174  {
175  static char buf[16];
176 
177  snprintf ( buf, sizeof ( buf ), "%s/e%d.%d", aoedev->netdev->name,
178  aoedev->major, aoedev->minor );
179  return buf;
180 }
uint16_t major
Major number.
Definition: aoe.h:125
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:362
uint8_t minor
Minor number.
Definition: aoe.h:127
struct net_device * netdev
Network device.
Definition: aoe.h:120
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References aoe_command::aoedev, aoe_device::major, aoe_device::minor, net_device::name, aoe_device::netdev, and snprintf().

Referenced by abft_install(), aoecmd_ata_cmd(), aoecmd_ata_rsp(), aoecmd_cfg_cmd(), aoecmd_cfg_rsp(), aoecmd_rx(), aoecmd_tx(), aoedev_ata_command(), and aoedev_open().

◆ aoecmd_free()

static void aoecmd_free ( struct refcnt refcnt)
static

Free AoE command.

Parameters
refcntReference counter

Definition at line 187 of file aoe.c.

187  {
188  struct aoe_command *aoecmd =
189  container_of ( refcnt, struct aoe_command, refcnt );
190 
191  assert ( ! timer_running ( &aoecmd->timer ) );
192  assert ( list_empty ( &aoecmd->list ) );
193 
194  aoedev_put ( aoecmd->aoedev );
195  free ( aoecmd );
196 }
A reference counter.
Definition: refcnt.h:26
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An AoE command.
Definition: aoe.h:62
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void aoedev_put(struct aoe_device *aoedev)
Drop reference to AoE device.
Definition: aoe.c:142
An AoE command.
Definition: aoe.c:72

References aoedev_put(), assert(), container_of, free, and list_empty.

Referenced by aoecmd_create().

◆ aoecmd_close()

static void aoecmd_close ( struct aoe_command aoecmd,
int  rc 
)
static

Close AoE command.

Parameters
aoecmdAoE command
rcReason for close

Definition at line 204 of file aoe.c.

204  {
205  struct aoe_device *aoedev = aoecmd->aoedev;
206 
207  /* Stop timer */
208  stop_timer ( &aoecmd->timer );
209 
210  /* Preserve the timeout value for subsequent commands */
211  aoedev->timeout = aoecmd->timer.timeout;
212 
213  /* Remove from list of commands */
214  if ( ! list_empty ( &aoecmd->list ) ) {
215  list_del ( &aoecmd->list );
216  INIT_LIST_HEAD ( &aoecmd->list );
217  aoecmd_put ( aoecmd );
218  }
219 
220  /* Shut down interfaces */
221  intf_shutdown ( &aoecmd->ata, rc );
222 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
unsigned long timeout
Saved timeout value.
Definition: aoe.h:132
An AoE device.
Definition: aoe.h:115
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
An AoE command.
Definition: aoe.h:62
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
static void aoecmd_put(struct aoe_command *aoecmd)
Drop reference to AoE command.
Definition: aoe.c:164
struct aoeata ata
ATA command.
Definition: aoe.h:66

References aoecmd_put(), aoecmd::ata, INIT_LIST_HEAD, intf_shutdown(), list_del, list_empty, rc, stop_timer(), and aoe_device::timeout.

Referenced by aoecmd_expired(), aoecmd_rx(), and aoedev_close().

◆ aoecmd_tx()

static int aoecmd_tx ( struct aoe_command aoecmd)
static

Transmit AoE command request.

Parameters
aoecmdAoE command
Return values
rcReturn status code

Definition at line 230 of file aoe.c.

230  {
231  struct aoe_device *aoedev = aoecmd->aoedev;
232  struct net_device *netdev = aoedev->netdev;
233  struct io_buffer *iobuf;
234  struct aoehdr *aoehdr;
235  size_t cmd_len;
236  int rc;
237 
238  /* Sanity check */
239  assert ( netdev != NULL );
240 
241  /* If we are transmitting anything that requires a response,
242  * start the retransmission timer. Do this before attempting
243  * to allocate the I/O buffer, in case allocation itself
244  * fails.
245  */
246  start_timer ( &aoecmd->timer );
247 
248  /* Create outgoing I/O buffer */
249  cmd_len = aoecmd->type->cmd_len ( aoecmd );
250  iobuf = alloc_iob ( MAX_LL_HEADER_LEN + cmd_len );
251  if ( ! iobuf )
252  return -ENOMEM;
253  iob_reserve ( iobuf, MAX_LL_HEADER_LEN );
254  aoehdr = iob_put ( iobuf, cmd_len );
255 
256  /* Fill AoE header */
257  memset ( aoehdr, 0, sizeof ( *aoehdr ) );
259  aoehdr->major = htons ( aoedev->major );
260  aoehdr->minor = aoedev->minor;
261  aoehdr->tag = htonl ( aoecmd->tag );
262  aoecmd->type->cmd ( aoecmd, iobuf->data, iob_len ( iobuf ) );
263 
264  /* Send packet */
265  if ( ( rc = net_tx ( iobuf, netdev, &aoe_protocol, aoedev->target,
266  netdev->ll_addr ) ) != 0 ) {
267  DBGC ( aoedev, "AoE %s/%08x could not transmit: %s\n",
268  aoedev_name ( aoedev ), aoecmd->tag,
269  strerror ( rc ) );
270  return rc;
271  }
272 
273  return 0;
274 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:124
uint16_t major
Major number.
Definition: aoe.h:125
#define DBGC(...)
Definition: compiler.h:505
uint16_t major
Major device number, in network byte order.
Definition: aoe.h:76
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:130
#define htonl(value)
Definition: byteswap.h:133
An AoE device.
Definition: aoe.h:115
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define AOE_VERSION
Version 1.
Definition: aoe.h:87
static struct net_device * netdev
Definition: gdbudp.c:52
#define MAX_LL_HEADER_LEN
Maximum length of a link-layer header.
Definition: netdevice.h:45
uint8_t minor
Minor device number.
Definition: aoe.h:78
An AoE command.
Definition: aoe.h:62
uint8_t target[MAX_LL_ADDR_LEN]
Target MAC address.
Definition: aoe.h:129
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
uint32_t tag
Tag, in network byte order.
Definition: aoe.h:82
A network device.
Definition: netdevice.h:352
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
#define iob_reserve(iobuf, len)
Definition: iobuf.h:71
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
Definition: netdevice.c:1073
void * data
Start of data.
Definition: iobuf.h:52
uint8_t minor
Minor number.
Definition: aoe.h:127
struct net_device * netdev
Network device.
Definition: aoe.h:120
uint8_t ver_flags
Protocol version number and flags.
Definition: aoe.h:72
An AoE header.
Definition: aoe.h:70
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174
A persistent I/O buffer.
Definition: iobuf.h:37

References alloc_iob(), AOE_VERSION, aoedev_name(), assert(), io_buffer::data, DBGC, ENOMEM, htonl, htons, iob_len(), iob_put, iob_reserve, net_device::ll_addr, aoehdr::major, aoe_device::major, MAX_LL_HEADER_LEN, memset(), aoehdr::minor, aoe_device::minor, net_tx(), netdev, aoe_device::netdev, NULL, rc, start_timer(), strerror(), aoehdr::tag, aoe_device::target, and aoehdr::ver_flags.

Referenced by aoecmd_expired(), aoedev_ata_command(), and aoedev_cfg_command().

◆ aoecmd_rx()

static int aoecmd_rx ( struct aoe_command aoecmd,
struct io_buffer iobuf,
const void *  ll_source 
)
static

Receive AoE command response.

Parameters
aoecmdAoE command
iobufI/O buffer
ll_sourceLink-layer source address
Return values
rcReturn status code

Definition at line 284 of file aoe.c.

285  {
286  struct aoe_device *aoedev = aoecmd->aoedev;
287  struct aoehdr *aoehdr = iobuf->data;
288  int rc;
289 
290  /* Sanity check */
291  if ( iob_len ( iobuf ) < sizeof ( *aoehdr ) ) {
292  DBGC ( aoedev, "AoE %s/%08x received underlength response "
293  "(%zd bytes)\n", aoedev_name ( aoedev ),
294  aoecmd->tag, iob_len ( iobuf ) );
295  rc = -EINVAL;
296  goto done;
297  }
298  if ( ( ntohs ( aoehdr->major ) != aoedev->major ) ||
299  ( aoehdr->minor != aoedev->minor ) ) {
300  DBGC ( aoedev, "AoE %s/%08x received response for incorrect "
301  "device e%d.%d\n", aoedev_name ( aoedev ), aoecmd->tag,
302  ntohs ( aoehdr->major ), aoehdr->minor );
303  rc = -EINVAL;
304  goto done;
305  }
306 
307  /* Catch command failures */
308  if ( aoehdr->ver_flags & AOE_FL_ERROR ) {
309  DBGC ( aoedev, "AoE %s/%08x terminated in error\n",
310  aoedev_name ( aoedev ), aoecmd->tag );
311  aoecmd_close ( aoecmd, -EIO );
312  rc = -EIO;
313  goto done;
314  }
315 
316  /* Hand off to command completion handler */
317  if ( ( rc = aoecmd->type->rsp ( aoecmd, iobuf->data, iob_len ( iobuf ),
318  ll_source ) ) != 0 )
319  goto done;
320 
321  done:
322  /* Free I/O buffer */
323  free_iob ( iobuf );
324 
325  /* Terminate command */
326  aoecmd_close ( aoecmd, rc );
327 
328  return rc;
329 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
uint16_t major
Major number.
Definition: aoe.h:125
#define DBGC(...)
Definition: compiler.h:505
uint16_t major
Major device number, in network byte order.
Definition: aoe.h:76
#define ntohs(value)
Definition: byteswap.h:136
An AoE device.
Definition: aoe.h:115
uint8_t minor
Minor device number.
Definition: aoe.h:78
An AoE command.
Definition: aoe.h:62
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
void * data
Start of data.
Definition: iobuf.h:52
#define EIO
Input/output error.
Definition: errno.h:433
uint8_t minor
Minor number.
Definition: aoe.h:127
uint8_t ver_flags
Protocol version number and flags.
Definition: aoe.h:72
#define AOE_FL_ERROR
Command generated an error.
Definition: aoe.h:91
static void aoecmd_close(struct aoe_command *aoecmd, int rc)
Close AoE command.
Definition: aoe.c:204
An AoE header.
Definition: aoe.h:70
struct bofm_section_header done
Definition: bofm_test.c:46
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References AOE_FL_ERROR, aoecmd_close(), aoedev_name(), io_buffer::data, DBGC, done, EINVAL, EIO, free_iob(), iob_len(), aoehdr::major, aoe_device::major, aoehdr::minor, aoe_device::minor, ntohs, rc, and aoehdr::ver_flags.

Referenced by aoe_rx().

◆ aoecmd_expired()

static void aoecmd_expired ( struct retry_timer timer,
int  fail 
)
static

Handle AoE retry timer expiry.

Parameters
timerAoE retry timer
failFailure indicator

Definition at line 337 of file aoe.c.

337  {
338  struct aoe_command *aoecmd =
339  container_of ( timer, struct aoe_command, timer );
340 
341  if ( fail ) {
343  } else {
344  aoecmd_tx ( aoecmd );
345  }
346 }
static int aoecmd_tx(struct aoe_command *aoecmd)
Transmit AoE command request.
Definition: aoe.c:230
A timer.
Definition: timer.h:28
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An AoE command.
Definition: aoe.h:62
static void aoecmd_close(struct aoe_command *aoecmd, int rc)
Close AoE command.
Definition: aoe.c:204
An AoE command.
Definition: aoe.c:72
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References aoecmd_close(), aoecmd_tx(), container_of, and ETIMEDOUT.

Referenced by aoecmd_create().

◆ aoecmd_ata_cmd_len()

static size_t aoecmd_ata_cmd_len ( struct aoe_command aoecmd)
static

Calculate length of AoE ATA command IU.

Parameters
aoecmdAoE command
Return values
lenLength of command IU

Definition at line 354 of file aoe.c.

354  {
355  struct ata_cmd *command = &aoecmd->command;
356 
357  return ( sizeof ( struct aoehdr ) + sizeof ( struct aoeata ) +
358  command->data_out_len );
359 }
An AoE ATA command.
Definition: aoe.h:38
A command-line command.
Definition: command.h:9
An ATA command information unit.
Definition: ata.h:167
An AoE command.
Definition: aoe.h:62
An AoE header.
Definition: aoe.h:70

◆ aoecmd_ata_cmd()

static void aoecmd_ata_cmd ( struct aoe_command aoecmd,
void *  data,
size_t  len 
)
static

Build AoE ATA command IU.

Parameters
aoecmdAoE command
dataCommand IU
lenLength of command IU

Definition at line 368 of file aoe.c.

369  {
370  struct aoe_device *aoedev = aoecmd->aoedev;
371  struct ata_cmd *command = &aoecmd->command;
372  struct aoehdr *aoehdr = data;
373  struct aoeata *aoeata = &aoehdr->payload[0].ata;
374 
375  /* Sanity check */
377  assert ( len == ( sizeof ( *aoehdr ) + sizeof ( *aoeata ) +
378  command->data_out_len ) );
379 
380  /* Build IU */
382  memset ( aoeata, 0, sizeof ( *aoeata ) );
383  aoeata->aflags = ( ( command->cb.lba48 ? AOE_FL_EXTENDED : 0 ) |
384  ( command->cb.device & ATA_DEV_SLAVE ) |
385  ( command->data_out_len ? AOE_FL_WRITE : 0 ) );
386  aoeata->err_feat = command->cb.err_feat.bytes.cur;
387  aoeata->count = command->cb.count.native;
388  aoeata->cmd_stat = command->cb.cmd_stat;
389  aoeata->lba.u64 = cpu_to_le64 ( command->cb.lba.native );
390  if ( ! command->cb.lba48 )
391  aoeata->lba.bytes[3] |=
392  ( command->cb.device & ATA_DEV_MASK );
393  memcpy ( aoeata->data, command->data_out, command->data_out_len );
394 
395  DBGC2 ( aoedev, "AoE %s/%08x ATA cmd %02x:%02x:%02x:%02x:%08llx",
396  aoedev_name ( aoedev ), aoecmd->tag, aoeata->aflags,
398  aoeata->lba.u64 );
399  if ( command->data_out_len )
400  DBGC2 ( aoedev, " out %04zx", command->data_out_len );
401  if ( command->data_in_len )
402  DBGC2 ( aoedev, " in %04zx", command->data_in_len );
403  DBGC2 ( aoedev, "\n" );
404 }
uint8_t err_feat
ATA error/feature register.
Definition: aoe.h:42
An AoE ATA command.
Definition: aoe.h:38
A command-line command.
Definition: command.h:9
uint8_t bytes[6]
Definition: aoe.h:50
uint8_t data[0]
Data payload.
Definition: aoe.h:53
union aoecmd payload[0]
Payload.
Definition: aoe.h:84
#define cpu_to_le64(value)
Definition: byteswap.h:108
#define static_assert(x)
Assert a condition at build time.
Definition: assert.h:65
uint8_t cmd_stat
ATA command/status register.
Definition: aoe.h:46
An AoE device.
Definition: aoe.h:115
uint8_t command
Command number.
Definition: aoe.h:80
void * memcpy(void *dest, const void *src, size_t len) __nonnull
union aoeata::@508 lba
Logical block address, in little-endian order.
#define AOE_FL_WRITE
Write command.
Definition: aoe.h:59
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
An ATA command information unit.
Definition: ata.h:167
An AoE command.
Definition: aoe.h:62
uint8_t aflags
AoE command flags.
Definition: aoe.h:40
uint64_t u64
Definition: aoe.h:49
#define DBGC2(...)
Definition: compiler.h:522
uint8_t count
ATA sector count register.
Definition: aoe.h:44
uint8_t data[48]
Additional event data.
Definition: ena.h:22
struct aoeata ata
ATA command.
Definition: aoe.h:66
#define AOE_CMD_ATA
Issue ATA command.
Definition: aoe.h:96
An AoE header.
Definition: aoe.h:70
#define AOE_FL_EXTENDED
LBA48 extended addressing.
Definition: aoe.h:56
#define ATA_DEV_SLAVE
Slave ("device 1") flag in the ATA device register.
Definition: ata.h:116
#define ATA_DEV_MASK
Mask of non-LBA portion of device register.
Definition: ata.h:122
#define AOE_FL_DEV_HEAD
Device/head flag.
Definition: aoe.h:57
void * memset(void *dest, int character, size_t len) __nonnull
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References aoeata::aflags, AOE_CMD_ATA, AOE_FL_DEV_HEAD, AOE_FL_EXTENDED, AOE_FL_WRITE, aoedev_name(), assert(), aoecmd::ata, ATA_DEV_MASK, ATA_DEV_SLAVE, aoeata::bytes, aoeata::cmd_stat, aoehdr::command, aoeata::count, cpu_to_le64, data, aoeata::data, DBGC2, aoeata::err_feat, aoeata::lba, len, memcpy(), memset(), aoehdr::payload, static_assert, and aoeata::u64.

◆ aoecmd_ata_rsp()

static int aoecmd_ata_rsp ( struct aoe_command aoecmd,
const void *  data,
size_t  len,
const void *ll_source  __unused 
)
static

Handle AoE ATA response IU.

Parameters
aoecmdAoE command
dataResponse IU
lenLength of response IU
ll_sourceLink-layer source address
Return values
rcReturn status code

Definition at line 415 of file aoe.c.

416  {
417  struct aoe_device *aoedev = aoecmd->aoedev;
418  struct ata_cmd *command = &aoecmd->command;
419  const struct aoehdr *aoehdr = data;
420  const struct aoeata *aoeata = &aoehdr->payload[0].ata;
421  size_t data_len;
422 
423  /* Sanity check */
424  if ( len < ( sizeof ( *aoehdr ) + sizeof ( *aoeata ) ) ) {
425  DBGC ( aoedev, "AoE %s/%08x received underlength ATA response "
426  "(%zd bytes)\n", aoedev_name ( aoedev ),
427  aoecmd->tag, len );
428  return -EINVAL;
429  }
430  data_len = ( len - ( sizeof ( *aoehdr ) + sizeof ( *aoeata ) ) );
431  DBGC2 ( aoedev, "AoE %s/%08x ATA rsp %02x in %04zx\n",
432  aoedev_name ( aoedev ), aoecmd->tag, aoeata->cmd_stat,
433  data_len );
434 
435  /* Check for command failure */
436  if ( aoeata->cmd_stat & ATA_STAT_ERR ) {
437  DBGC ( aoedev, "AoE %s/%08x status %02x\n",
438  aoedev_name ( aoedev ), aoecmd->tag, aoeata->cmd_stat );
439  return -EIO;
440  }
441 
442  /* Check data-in length is sufficient. (There may be trailing
443  * garbage due to Ethernet minimum-frame-size padding.)
444  */
445  if ( data_len < command->data_in_len ) {
446  DBGC ( aoedev, "AoE %s/%08x data-in underrun (received %zd, "
447  "expected %zd)\n", aoedev_name ( aoedev ), aoecmd->tag,
448  data_len, command->data_in_len );
449  return -ERANGE;
450  }
451 
452  /* Copy out data payload */
453  memcpy ( command->data_in, aoeata->data, command->data_in_len );
454 
455  return 0;
456 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
An AoE ATA command.
Definition: aoe.h:38
A command-line command.
Definition: command.h:9
uint8_t data[0]
Data payload.
Definition: aoe.h:53
#define DBGC(...)
Definition: compiler.h:505
union aoecmd payload[0]
Payload.
Definition: aoe.h:84
uint32_t data_len
Microcode data size (or 0 to indicate 2000 bytes)
Definition: ucode.h:26
uint8_t cmd_stat
ATA command/status register.
Definition: aoe.h:46
An AoE device.
Definition: aoe.h:115
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
An ATA command information unit.
Definition: ata.h:167
An AoE command.
Definition: aoe.h:62
#define ERANGE
Result too large.
Definition: errno.h:639
#define ATA_STAT_ERR
Command completed in error.
Definition: ata.h:140
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
uint8_t data[48]
Additional event data.
Definition: ena.h:22
struct aoeata ata
ATA command.
Definition: aoe.h:66
An AoE header.
Definition: aoe.h:70
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References aoedev_name(), aoecmd::ata, ATA_STAT_ERR, aoeata::cmd_stat, data, aoeata::data, data_len, DBGC, DBGC2, EINVAL, EIO, ERANGE, len, memcpy(), and aoehdr::payload.

◆ aoecmd_cfg_cmd_len()

static size_t aoecmd_cfg_cmd_len ( struct aoe_command *aoecmd  __unused)
static

Calculate length of AoE configuration command IU.

Parameters
aoecmdAoE command
Return values
lenLength of command IU

Definition at line 471 of file aoe.c.

471  {
472  return ( sizeof ( struct aoehdr ) + sizeof ( struct aoecfg ) );
473 }
An AoE config command.
Definition: aoe.h:22
An AoE header.
Definition: aoe.h:70

◆ aoecmd_cfg_cmd()

static void aoecmd_cfg_cmd ( struct aoe_command aoecmd,
void *  data,
size_t  len 
)
static

Build AoE configuration command IU.

Parameters
aoecmdAoE command
dataCommand IU
lenLength of command IU

Definition at line 482 of file aoe.c.

483  {
484  struct aoe_device *aoedev = aoecmd->aoedev;
485  struct aoehdr *aoehdr = data;
486  struct aoecfg *aoecfg = &aoehdr->payload[0].cfg;
487 
488  /* Sanity check */
489  assert ( len == ( sizeof ( *aoehdr ) + sizeof ( *aoecfg ) ) );
490 
491  /* Build IU */
493  memset ( aoecfg, 0, sizeof ( *aoecfg ) );
494 
495  DBGC ( aoedev, "AoE %s/%08x CONFIG cmd\n",
496  aoedev_name ( aoedev ), aoecmd->tag );
497 }
struct aoecfg cfg
Config command.
Definition: aoe.h:64
#define DBGC(...)
Definition: compiler.h:505
union aoecmd payload[0]
Payload.
Definition: aoe.h:84
An AoE device.
Definition: aoe.h:115
uint8_t command
Command number.
Definition: aoe.h:80
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
ring len
Length.
Definition: dwmac.h:231
An AoE command.
Definition: aoe.h:62
An AoE config command.
Definition: aoe.h:22
#define AOE_CMD_CONFIG
Query Config Information.
Definition: aoe.h:97
uint8_t data[48]
Additional event data.
Definition: ena.h:22
An AoE header.
Definition: aoe.h:70
void * memset(void *dest, int character, size_t len) __nonnull
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References AOE_CMD_CONFIG, aoedev_name(), assert(), aoecmd::cfg, aoehdr::command, data, DBGC, len, memset(), and aoehdr::payload.

◆ aoecmd_cfg_rsp()

static int aoecmd_cfg_rsp ( struct aoe_command aoecmd,
const void *  data,
size_t  len,
const void *  ll_source 
)
static

Handle AoE configuration response IU.

Parameters
aoecmdAoE command
dataResponse IU
lenLength of response IU
ll_sourceLink-layer source address
Return values
rcReturn status code

Definition at line 508 of file aoe.c.

509  {
510  struct aoe_device *aoedev = aoecmd->aoedev;
511  struct ll_protocol *ll_protocol = aoedev->netdev->ll_protocol;
512  const struct aoehdr *aoehdr = data;
513  const struct aoecfg *aoecfg = &aoehdr->payload[0].cfg;
514 
515  /* Sanity check */
516  if ( len < ( sizeof ( *aoehdr ) + sizeof ( *aoecfg ) ) ) {
517  DBGC ( aoedev, "AoE %s/%08x received underlength "
518  "configuration response (%zd bytes)\n",
519  aoedev_name ( aoedev ), aoecmd->tag, len );
520  return -EINVAL;
521  }
522  DBGC ( aoedev, "AoE %s/%08x CONFIG rsp buf %04x fw %04x scnt %02x\n",
523  aoedev_name ( aoedev ), aoecmd->tag, ntohs ( aoecfg->bufcnt ),
524  aoecfg->fwver, aoecfg->scnt );
525 
526  /* Record target MAC address */
527  memcpy ( aoedev->target, ll_source, ll_protocol->ll_addr_len );
528  DBGC ( aoedev, "AoE %s has MAC address %s\n",
529  aoedev_name ( aoedev ), ll_protocol->ntoa ( aoedev->target ) );
530 
531  return 0;
532 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct aoecfg cfg
Config command.
Definition: aoe.h:64
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
#define DBGC(...)
Definition: compiler.h:505
union aoecmd payload[0]
Payload.
Definition: aoe.h:84
uint16_t fwver
ATA target firmware version.
Definition: aoe.h:26
#define ntohs(value)
Definition: byteswap.h:136
A link-layer protocol.
Definition: netdevice.h:114
An AoE device.
Definition: aoe.h:115
void * memcpy(void *dest, const void *src, size_t len) __nonnull
ring len
Length.
Definition: dwmac.h:231
An AoE command.
Definition: aoe.h:62
uint8_t target[MAX_LL_ADDR_LEN]
Target MAC address.
Definition: aoe.h:129
An AoE config command.
Definition: aoe.h:22
uint16_t bufcnt
AoE queue depth.
Definition: aoe.h:24
struct net_device * netdev
Network device.
Definition: aoe.h:120
uint8_t data[48]
Additional event data.
Definition: ena.h:22
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
Definition: netdevice.h:163
uint8_t scnt
ATA target sector count.
Definition: aoe.h:28
An AoE header.
Definition: aoe.h:70
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References aoedev_name(), aoecfg::bufcnt, aoecmd::cfg, data, DBGC, EINVAL, aoecfg::fwver, len, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), aoe_device::netdev, ll_protocol::ntoa, ntohs, aoehdr::payload, aoecfg::scnt, and aoe_device::target.

◆ aoecmd_find_tag()

static struct aoe_command* aoecmd_find_tag ( uint32_t  tag)
static

Identify AoE command by tag.

Parameters
tagCommand tag
Return values
aoecmdAoE command, or NULL

Definition at line 556 of file aoe.c.

556  {
557  struct aoe_command *aoecmd;
558 
559  list_for_each_entry ( aoecmd, &aoe_commands, list ) {
560  if ( aoecmd->tag == tag )
561  return aoecmd;
562  }
563  return NULL;
564 }
struct list_head list
List of active commands.
Definition: aoe.c:78
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
An AoE command.
Definition: aoe.h:62
uint64_t tag
Identity tag.
Definition: edd.h:30
An AoE command.
Definition: aoe.c:72
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References aoe_command::list, list_for_each_entry, NULL, and tag.

Referenced by aoe_rx(), and aoecmd_new_tag().

◆ aoecmd_new_tag()

static int aoecmd_new_tag ( void  )
static

Choose an AoE command tag.

Return values
tagNew tag, or negative error

Definition at line 571 of file aoe.c.

571  {
572  static uint16_t tag_idx;
573  unsigned int i;
574 
575  for ( i = 0 ; i < 65536 ; i++ ) {
576  tag_idx++;
577  if ( aoecmd_find_tag ( tag_idx ) == NULL )
578  return ( AOE_TAG_MAGIC | tag_idx );
579  }
580  return -EADDRINUSE;
581 }
unsigned short uint16_t
Definition: stdint.h:11
static struct aoe_command * aoecmd_find_tag(uint32_t tag)
Identify AoE command by tag.
Definition: aoe.c:556
#define AOE_TAG_MAGIC
AoE tag magic marker.
Definition: aoe.h:109
#define EADDRINUSE
Address already in use.
Definition: errno.h:303
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References AOE_TAG_MAGIC, aoecmd_find_tag(), EADDRINUSE, and NULL.

Referenced by aoecmd_create().

◆ aoecmd_create()

static struct aoe_command* aoecmd_create ( struct aoe_device aoedev,
struct aoe_command_type type 
)
static

Create AoE command.

Parameters
aoedevAoE device
typeAoE command type
Return values
aoecmdAoE command

Definition at line 590 of file aoe.c.

591  {
592  struct aoe_command *aoecmd;
593  int tag;
594 
595  /* Allocate command tag */
596  tag = aoecmd_new_tag();
597  if ( tag < 0 )
598  return NULL;
599 
600  /* Allocate and initialise structure */
601  aoecmd = zalloc ( sizeof ( *aoecmd ) );
602  if ( ! aoecmd )
603  return NULL;
604  ref_init ( &aoecmd->refcnt, aoecmd_free );
605  list_add ( &aoecmd->list, &aoe_commands );
606  intf_init ( &aoecmd->ata, &aoecmd_ata_desc, &aoecmd->refcnt );
607  timer_init ( &aoecmd->timer, aoecmd_expired, &aoecmd->refcnt );
608  aoecmd->aoedev = aoedev_get ( aoedev );
609  aoecmd->type = type;
610  aoecmd->tag = tag;
611 
612  /* Preserve timeout from last completed command */
613  aoecmd->timer.timeout = aoedev->timeout;
614 
615  /* Return already mortalised. (Reference is held by command list.) */
616  return aoecmd;
617 }
static struct aoe_device * aoedev_get(struct aoe_device *aoedev)
Get reference to AoE device.
Definition: aoe.c:131
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
static struct interface_descriptor aoecmd_ata_desc
AoE command ATA interface descriptor.
Definition: aoe.c:547
uint32_t type
Operating system type.
Definition: ena.h:12
static int aoecmd_new_tag(void)
Choose an AoE command tag.
Definition: aoe.c:571
unsigned long timeout
Saved timeout value.
Definition: aoe.h:132
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
An AoE command.
Definition: aoe.h:62
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
static void aoecmd_expired(struct retry_timer *timer, int fail)
Handle AoE retry timer expiry.
Definition: aoe.c:337
static void aoecmd_free(struct refcnt *refcnt)
Free AoE command.
Definition: aoe.c:187
struct aoeata ata
ATA command.
Definition: aoe.h:66
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
uint64_t tag
Identity tag.
Definition: edd.h:30
An AoE command.
Definition: aoe.c:72
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References aoecmd_ata_desc, aoecmd_expired(), aoecmd_free(), aoecmd_new_tag(), aoe_command::aoedev, aoedev_get(), aoecmd::ata, intf_init(), list_add, NULL, ref_init, tag, aoe_device::timeout, type, and zalloc().

Referenced by aoedev_ata_command(), and aoedev_cfg_command().

◆ aoedev_ata_command()

static int aoedev_ata_command ( struct aoe_device aoedev,
struct interface parent,
struct ata_cmd command 
)
static

Issue AoE ATA command.

Parameters
aoedevAoE device
parentParent interface
commandATA command
Return values
tagCommand tag, or negative error

Definition at line 627 of file aoe.c.

629  {
630  struct net_device *netdev = aoedev->netdev;
631  struct aoe_command *aoecmd;
632 
633  /* Fail immediately if net device is closed */
634  if ( ! netdev_is_open ( netdev ) ) {
635  DBGC ( aoedev, "AoE %s cannot issue command while net device "
636  "is closed\n", aoedev_name ( aoedev ) );
637  return -EWOULDBLOCK;
638  }
639 
640  /* Create command */
642  if ( ! aoecmd )
643  return -ENOMEM;
644  memcpy ( &aoecmd->command, command, sizeof ( aoecmd->command ) );
645 
646  /* Attempt to send command. Allow failures to be handled by
647  * the retry timer.
648  */
649  aoecmd_tx ( aoecmd );
650 
651  /* Attach to parent interface, leave reference with command
652  * list, and return.
653  */
654  intf_plug_plug ( &aoecmd->ata, parent );
655  return aoecmd->tag;
656 }
A command-line command.
Definition: command.h:9
#define DBGC(...)
Definition: compiler.h:505
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
static int aoecmd_tx(struct aoe_command *aoecmd)
Transmit AoE command request.
Definition: aoe.c:230
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:661
#define EWOULDBLOCK
Operation would block.
Definition: errno.h:679
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
static struct net_device * netdev
Definition: gdbudp.c:52
static struct aoe_command * aoecmd_create(struct aoe_device *aoedev, struct aoe_command_type *type)
Create AoE command.
Definition: aoe.c:590
An AoE command.
Definition: aoe.h:62
A network device.
Definition: netdevice.h:352
static struct aoe_command_type aoecmd_ata
AoE ATA command.
Definition: aoe.c:459
struct net_device * netdev
Network device.
Definition: aoe.h:120
struct aoeata ata
ATA command.
Definition: aoe.h:66
An AoE command.
Definition: aoe.c:72
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References aoecmd_ata, aoecmd_create(), aoecmd_tx(), aoe_command::aoedev, aoedev_name(), aoecmd::ata, DBGC, ENOMEM, EWOULDBLOCK, intf_plug_plug(), memcpy(), netdev, aoe_device::netdev, and netdev_is_open().

◆ aoedev_cfg_command()

static int aoedev_cfg_command ( struct aoe_device aoedev,
struct interface parent 
)
static

Issue AoE configuration command.

Parameters
aoedevAoE device
parentParent interface
Return values
tagCommand tag, or negative error

Definition at line 665 of file aoe.c.

666  {
667  struct aoe_command *aoecmd;
668 
669  /* Create command */
671  if ( ! aoecmd )
672  return -ENOMEM;
673 
674  /* Attempt to send command. Allow failures to be handled by
675  * the retry timer.
676  */
677  aoecmd_tx ( aoecmd );
678 
679  /* Attach to parent interface, leave reference with command
680  * list, and return.
681  */
682  intf_plug_plug ( &aoecmd->ata, parent );
683  return aoecmd->tag;
684 }
static struct aoe_command_type aoecmd_cfg
AoE configuration command.
Definition: aoe.c:535
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
static int aoecmd_tx(struct aoe_command *aoecmd)
Transmit AoE command request.
Definition: aoe.c:230
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
static struct aoe_command * aoecmd_create(struct aoe_device *aoedev, struct aoe_command_type *type)
Create AoE command.
Definition: aoe.c:590
An AoE command.
Definition: aoe.h:62
struct aoeata ata
ATA command.
Definition: aoe.h:66
An AoE command.
Definition: aoe.c:72

References aoecmd_cfg, aoecmd_create(), aoecmd_tx(), aoe_command::aoedev, aoecmd::ata, ENOMEM, and intf_plug_plug().

Referenced by aoedev_open().

◆ aoedev_free()

static void aoedev_free ( struct refcnt refcnt)
static

Free AoE device.

Parameters
refcntReference count

Definition at line 691 of file aoe.c.

691  {
692  struct aoe_device *aoedev =
693  container_of ( refcnt, struct aoe_device, refcnt );
694 
695  netdev_put ( aoedev->netdev );
696  free ( aoedev );
697 }
An AoE device.
Definition: aoe.h:115
A reference counter.
Definition: refcnt.h:26
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:575
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct net_device * netdev
Network device.
Definition: aoe.h:120

References container_of, free, aoe_device::netdev, and netdev_put().

Referenced by aoedev_open().

◆ aoedev_close()

static void aoedev_close ( struct aoe_device aoedev,
int  rc 
)
static

Close AoE device.

Parameters
aoedevAoE device
rcReason for close

Definition at line 705 of file aoe.c.

705  {
706  struct aoe_command *aoecmd;
707  struct aoe_command *tmp;
708 
709  /* Shut down interfaces */
710  intf_shutdown ( &aoedev->ata, rc );
711  intf_shutdown ( &aoedev->config, rc );
712 
713  /* Shut down any active commands */
714  list_for_each_entry_safe ( aoecmd, tmp, &aoe_commands, list ) {
715  if ( aoecmd->aoedev != aoedev )
716  continue;
717  aoecmd_get ( aoecmd );
718  aoecmd_close ( aoecmd, rc );
719  aoecmd_put ( aoecmd );
720  }
721 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
struct list_head list
List of active commands.
Definition: aoe.c:78
unsigned long tmp
Definition: linux_pci.h:64
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
struct interface ata
ATA command issuing interface.
Definition: aoe.h:122
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
An AoE command.
Definition: aoe.h:62
struct interface config
Configuration command interface.
Definition: aoe.h:135
static void aoecmd_put(struct aoe_command *aoecmd)
Drop reference to AoE command.
Definition: aoe.c:164
static void aoecmd_close(struct aoe_command *aoecmd, int rc)
Close AoE command.
Definition: aoe.c:204
static struct aoe_command * aoecmd_get(struct aoe_command *aoecmd)
Get reference to AoE command.
Definition: aoe.c:153
An AoE command.
Definition: aoe.c:72

References aoecmd_close(), aoecmd_get(), aoecmd_put(), aoe_command::aoedev, aoe_device::ata, aoe_device::config, intf_shutdown(), aoe_command::list, list_for_each_entry_safe, rc, and tmp.

Referenced by aoedev_config_done(), and aoedev_open().

◆ aoedev_window()

static size_t aoedev_window ( struct aoe_device aoedev)
static

Check AoE device flow-control window.

Parameters
aoedevAoE device
Return values
lenLength of window

Definition at line 729 of file aoe.c.

729  {
730  return ( aoedev->configured ? ~( ( size_t ) 0 ) : 0 );
731 }
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
int configured
Device is configued.
Definition: aoe.h:137

References aoe_command::aoedev, and aoe_device::configured.

◆ aoedev_config_done()

static void aoedev_config_done ( struct aoe_device aoedev,
int  rc 
)
static

Handle AoE device configuration completion.

Parameters
aoedevAoE device
rcReason for completion

Definition at line 739 of file aoe.c.

739  {
740 
741  /* Shut down interface */
742  intf_shutdown ( &aoedev->config, rc );
743 
744  /* Close device on failure */
745  if ( rc != 0 ) {
746  aoedev_close ( aoedev, rc );
747  return;
748  }
749 
750  /* Mark device as configured */
751  aoedev->configured = 1;
753 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:146
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
struct interface ata
ATA command issuing interface.
Definition: aoe.h:122
static void aoedev_close(struct aoe_device *aoedev, int rc)
Close AoE device.
Definition: aoe.c:705
struct interface config
Configuration command interface.
Definition: aoe.h:135
int configured
Device is configued.
Definition: aoe.h:137

References aoe_command::aoedev, aoedev_close(), aoe_device::ata, aoe_device::config, aoe_device::configured, intf_shutdown(), rc, and xfer_window_changed().

◆ aoedev_identify_device()

static struct device* aoedev_identify_device ( struct aoe_device aoedev)
static

Identify device underlying AoE device.

Parameters
aoedevAoE device
Return values
deviceUnderlying device

Definition at line 761 of file aoe.c.

761  {
762  return aoedev->netdev->dev;
763 }
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
struct net_device * netdev
Network device.
Definition: aoe.h:120

References net_device::dev, and aoe_device::netdev.

◆ aoedev_describe()

static struct acpi_descriptor* aoedev_describe ( struct aoe_device aoedev)
static

Get AoE ACPI descriptor.

Parameters
aoedevAoE device
Return values
descACPI descriptor

Definition at line 771 of file aoe.c.

771  {
772  return &aoedev->desc;
773 }
struct aoe_device * aoedev
AOE device.
Definition: aoe.c:76
struct acpi_descriptor desc
ACPI descriptor.
Definition: aoe.h:140

References aoe_device::desc.

◆ aoedev_open()

static int aoedev_open ( struct interface parent,
struct net_device netdev,
unsigned int  major,
unsigned int  minor 
)
static

Open AoE device.

Parameters
parentParent interface
netdevNetwork device
majorDevice major number
minorDevice minor number
Return values
rcReturn status code

Definition at line 808 of file aoe.c.

809  {
810  struct aoe_device *aoedev;
811  int rc;
812 
813  /* Allocate and initialise structure */
814  aoedev = zalloc ( sizeof ( *aoedev ) );
815  if ( ! aoedev ) {
816  rc = -ENOMEM;
817  goto err_zalloc;
818  }
819  ref_init ( &aoedev->refcnt, aoedev_free );
820  intf_init ( &aoedev->ata, &aoedev_ata_desc, &aoedev->refcnt );
821  intf_init ( &aoedev->config, &aoedev_config_desc, &aoedev->refcnt );
822  aoedev->netdev = netdev_get ( netdev );
823  aoedev->major = major;
824  aoedev->minor = minor;
825  memcpy ( aoedev->target, netdev->ll_broadcast,
827  acpi_init ( &aoedev->desc, &abft_model, &aoedev->refcnt );
828 
829  /* Initiate configuration */
830  if ( ( rc = aoedev_cfg_command ( aoedev, &aoedev->config ) ) < 0 ) {
831  DBGC ( aoedev, "AoE %s could not initiate configuration: %s\n",
832  aoedev_name ( aoedev ), strerror ( rc ) );
833  goto err_config;
834  }
835 
836  /* Attach ATA device to parent interface */
837  if ( ( rc = ata_open ( parent, &aoedev->ata, ATA_DEV_MASTER,
838  AOE_MAX_COUNT ) ) != 0 ) {
839  DBGC ( aoedev, "AoE %s could not create ATA device: %s\n",
840  aoedev_name ( aoedev ), strerror ( rc ) );
841  goto err_ata_open;
842  }
843 
844  /* Mortalise self and return */
845  ref_put ( &aoedev->refcnt );
846  return 0;
847 
848  err_ata_open:
849  err_config:
850  aoedev_close ( aoedev, rc );
851  ref_put ( &aoedev->refcnt );
852  err_zalloc:
853  return rc;
854 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:198
static struct interface_descriptor aoedev_config_desc
AoE device configuration interface descriptor.
Definition: aoe.c:796
#define AOE_MAX_COUNT
Maximum number of sectors per packet.
Definition: aoe.h:112
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
uint16_t major
Major number.
Definition: aoe.h:125
#define DBGC(...)
Definition: compiler.h:505
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:389
An AoE device.
Definition: aoe.h:115
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint32_t major
Major version.
Definition: netvsc.h:14
uint32_t minor
Minor version.
Definition: netvsc.h:16
#define ATA_DEV_MASTER
Master ("device 0") flag in the ATA device register.
Definition: ata.h:119
static struct net_device * netdev
Definition: gdbudp.c:52
struct acpi_descriptor desc
ACPI descriptor.
Definition: aoe.h:140
static int aoedev_cfg_command(struct aoe_device *aoedev, struct interface *parent)
Issue AoE configuration command.
Definition: aoe.c:665
struct interface ata
ATA command issuing interface.
Definition: aoe.h:122
uint8_t target[MAX_LL_ADDR_LEN]
Target MAC address.
Definition: aoe.h:129
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void aoedev_close(struct aoe_device *aoedev, int rc)
Close AoE device.
Definition: aoe.c:705
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
struct refcnt refcnt
Reference counter.
Definition: aoe.h:117
struct interface config
Configuration command interface.
Definition: aoe.h:135
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition: netdevice.h:564
uint8_t minor
Minor number.
Definition: aoe.h:127
struct net_device * netdev
Network device.
Definition: aoe.h:120
static void aoedev_free(struct refcnt *refcnt)
Free AoE device.
Definition: aoe.c:691
int ata_open(struct interface *block, struct interface *ata, unsigned int device, unsigned int max_count)
Open ATA device.
Definition: ata.c:662
static struct interface_descriptor aoedev_ata_desc
AoE device ATA interface descriptor.
Definition: aoe.c:787
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:372
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
static void acpi_init(struct acpi_descriptor *desc, struct acpi_model *model, struct refcnt *refcnt)
Initialise ACPI descriptor.
Definition: acpi.h:311
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References acpi_init(), AOE_MAX_COUNT, aoedev_ata_desc, aoedev_cfg_command(), aoedev_close(), aoedev_config_desc, aoedev_free(), aoedev_name(), aoe_device::ata, ATA_DEV_MASTER, ata_open(), aoe_device::config, DBGC, aoe_device::desc, ENOMEM, intf_init(), ll_protocol::ll_addr_len, net_device::ll_broadcast, net_device::ll_protocol, major, aoe_device::major, memcpy(), minor, aoe_device::minor, netdev, aoe_device::netdev, netdev_get(), rc, ref_init, ref_put, aoe_device::refcnt, strerror(), aoe_device::target, and zalloc().

Referenced by aoe_open().

◆ aoe_rx()

static int aoe_rx ( struct io_buffer iobuf,
struct net_device *netdev  __unused,
const void *ll_dest  __unused,
const void *  ll_source,
unsigned int flags  __unused 
)
static

Process incoming AoE packets.

Parameters
iobufI/O buffer
netdevNetwork device
ll_destLink-layer destination address
ll_sourceLink-layer source address
flagsPacket flags
Return values
rcReturn status code

Definition at line 873 of file aoe.c.

877  {
878  struct aoehdr *aoehdr = iobuf->data;
879  struct aoe_command *aoecmd;
880  int rc;
881 
882  /* Sanity check */
883  if ( iob_len ( iobuf ) < sizeof ( *aoehdr ) ) {
884  DBG ( "AoE received underlength packet (%zd bytes)\n",
885  iob_len ( iobuf ) );
886  rc = -EINVAL;
887  goto err_sanity;
888  }
889  if ( ( aoehdr->ver_flags & AOE_VERSION_MASK ) != AOE_VERSION ) {
890  DBG ( "AoE received packet for unsupported protocol version "
891  "%02x\n", ( aoehdr->ver_flags & AOE_VERSION_MASK ) );
892  rc = -EPROTONOSUPPORT;
893  goto err_sanity;
894  }
895  if ( ! ( aoehdr->ver_flags & AOE_FL_RESPONSE ) ) {
896  DBG ( "AoE received request packet\n" );
897  rc = -EOPNOTSUPP;
898  goto err_sanity;
899  }
900 
901  /* Demultiplex amongst active AoE commands */
903  if ( ! aoecmd ) {
904  DBG ( "AoE received packet for unused tag %08x\n",
905  ntohl ( aoehdr->tag ) );
906  rc = -ENOENT;
907  goto err_demux;
908  }
909 
910  /* Pass received frame to command */
911  aoecmd_get ( aoecmd );
912  if ( ( rc = aoecmd_rx ( aoecmd, iob_disown ( iobuf ),
913  ll_source ) ) != 0 )
914  goto err_rx;
915 
916  err_rx:
917  aoecmd_put ( aoecmd );
918  err_demux:
919  err_sanity:
920  free_iob ( iobuf );
921  return rc;
922 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct aoe_command * aoecmd_find_tag(uint32_t tag)
Identify AoE command by tag.
Definition: aoe.c:556
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:152
#define AOE_VERSION_MASK
Version part of ver_flags field.
Definition: aoe.h:88
#define ENOENT
No such file or directory.
Definition: errno.h:514
#define ntohl(value)
Definition: byteswap.h:134
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:216
#define AOE_VERSION
Version 1.
Definition: aoe.h:87
An AoE command.
Definition: aoe.h:62
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
uint32_t tag
Tag, in network byte order.
Definition: aoe.h:82
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
static int aoecmd_rx(struct aoe_command *aoecmd, struct io_buffer *iobuf, const void *ll_source)
Receive AoE command response.
Definition: aoe.c:284
#define EPROTONOSUPPORT
Protocol not supported.
Definition: errno.h:629
void * data
Start of data.
Definition: iobuf.h:52
static void aoecmd_put(struct aoe_command *aoecmd)
Drop reference to AoE command.
Definition: aoe.c:164
uint8_t ver_flags
Protocol version number and flags.
Definition: aoe.h:72
An AoE header.
Definition: aoe.h:70
#define AOE_FL_RESPONSE
Message is a response.
Definition: aoe.h:90
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static struct aoe_command * aoecmd_get(struct aoe_command *aoecmd)
Get reference to AoE command.
Definition: aoe.c:153
An AoE command.
Definition: aoe.c:72

References AOE_FL_RESPONSE, AOE_VERSION, AOE_VERSION_MASK, aoecmd_find_tag(), aoecmd_get(), aoecmd_put(), aoecmd_rx(), io_buffer::data, DBG, EINVAL, ENOENT, EOPNOTSUPP, EPROTONOSUPPORT, free_iob(), iob_disown, iob_len(), ntohl, rc, aoehdr::tag, and aoehdr::ver_flags.

◆ aoe_parse_uri()

static int aoe_parse_uri ( struct uri uri,
unsigned int *  major,
unsigned int *  minor 
)
static

Parse AoE URI.

Parameters
uriURI
Return values
majorMajor device number
minorMinor device number
rcReturn status code

An AoE URI has the form "aoe:e<major>.<minor>".

Definition at line 948 of file aoe.c.

949  {
950  const char *ptr;
951  char *end;
952 
953  /* Check for URI with opaque portion */
954  if ( ! uri->opaque )
955  return -EINVAL;
956  ptr = uri->opaque;
957 
958  /* Check for initial 'e' */
959  if ( *ptr != 'e' )
960  return -EINVAL;
961  ptr++;
962 
963  /* Parse major device number */
964  *major = strtoul ( ptr, &end, 10 );
965  if ( *end != '.' )
966  return -EINVAL;
967  ptr = ( end + 1 );
968 
969  /* Parse minor device number */
970  *minor = strtoul ( ptr, &end, 10 );
971  if ( *end )
972  return -EINVAL;
973 
974  return 0;
975 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:484
uint32_t major
Major version.
Definition: netvsc.h:14
uint32_t minor
Minor version.
Definition: netvsc.h:16
const char * opaque
Opaque part.
Definition: uri.h:70
uint32_t end
Ending offset.
Definition: netvsc.h:18
A Uniform Resource Identifier.
Definition: uri.h:64

References EINVAL, end, major, minor, uri::opaque, and strtoul().

Referenced by aoe_open().

◆ aoe_open()

static int aoe_open ( struct interface parent,
struct uri uri 
)
static

Open AoE URI.

Parameters
parentParent interface
uriURI
Return values
rcReturn status code

Definition at line 984 of file aoe.c.

984  {
985  struct net_device *netdev;
986  unsigned int major;
987  unsigned int minor;
988  int rc;
989 
990  /* Identify network device. This is something of a hack, but
991  * the AoE URI scheme that has been in use for some time now
992  * provides no way to specify a particular device.
993  */
995  if ( ! netdev ) {
996  DBG ( "AoE cannot identify network device\n" );
997  return -ENODEV;
998  }
999 
1000  /* Parse URI */
1001  if ( ( rc = aoe_parse_uri ( uri, &major, &minor ) ) != 0 ) {
1002  DBG ( "AoE cannot parse URI\n" );
1003  return rc;
1004  }
1005 
1006  /* Open AoE device */
1007  if ( ( rc = aoedev_open ( parent, netdev, major, minor ) ) != 0 )
1008  return rc;
1009 
1010  return 0;
1011 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int aoe_parse_uri(struct uri *uri, unsigned int *major, unsigned int *minor)
Parse AoE URI.
Definition: aoe.c:948
uint32_t major
Major version.
Definition: netvsc.h:14
uint32_t minor
Minor version.
Definition: netvsc.h:16
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
Definition: netdevice.c:1047
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
static int aoedev_open(struct interface *parent, struct net_device *netdev, unsigned int major, unsigned int minor)
Open AoE device.
Definition: aoe.c:808
A Uniform Resource Identifier.
Definition: uri.h:64
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References aoe_parse_uri(), aoedev_open(), DBG, ENODEV, last_opened_netdev(), major, minor, netdev, and rc.

◆ abft_complete()

static int abft_complete ( struct acpi_descriptor *desc  __unused)
static

Check if AoE boot firmware table descriptor is complete.

Parameters
descACPI descriptor
Return values
rcReturn status code

Definition at line 1032 of file aoe.c.

1032  {
1033  return 0;
1034 }

◆ abft_install()

static int abft_install ( int(*)(struct acpi_header *acpi install)
static

Install AoE boot firmware table(s)

Parameters
installInstallation method
Return values
rcReturn status code

Definition at line 1042 of file aoe.c.

1042  {
1043  struct aoe_device *aoedev;
1044  struct abft_table abft;
1045  int rc;
1046 
1047  list_for_each_entry ( aoedev, &abft_model.descs, desc.list ) {
1048 
1049  /* Populate table */
1050  memset ( &abft, 0, sizeof ( abft ) );
1051  abft.acpi.signature = cpu_to_le32 ( ABFT_SIG );
1052  abft.acpi.length = cpu_to_le32 ( sizeof ( abft ) );
1053  abft.acpi.revision = 1;
1054  abft.shelf = cpu_to_le16 ( aoedev->major );
1055  abft.slot = aoedev->minor;
1056  memcpy ( abft.mac, aoedev->netdev->ll_addr,
1057  sizeof ( abft.mac ) );
1058 
1059  /* Install table */
1060  if ( ( rc = install ( &abft.acpi ) ) != 0 ) {
1061  DBGC ( aoedev, "AoE %s could not install aBFT: %s\n",
1062  aoedev_name ( aoedev ), strerror ( rc ) );
1063  return rc;
1064  }
1065  }
1066 
1067  return 0;
1068 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint16_t major
Major number.
Definition: aoe.h:125
#define DBGC(...)
Definition: compiler.h:505
An AoE device.
Definition: aoe.h:115
struct ena_llq_option desc
Descriptor counts.
Definition: ena.h:20
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
#define cpu_to_le32(value)
Definition: byteswap.h:107
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
AoE Boot Firmware Table (aBFT)
Definition: aoe.h:149
#define ABFT_SIG
AoE boot firmware table signature.
Definition: aoe.h:144
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint8_t minor
Minor number.
Definition: aoe.h:127
struct net_device * netdev
Network device.
Definition: aoe.h:120
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:387
void * memset(void *dest, int character, size_t len) __nonnull
static const char * aoedev_name(struct aoe_device *aoedev)
Name AoE device.
Definition: aoe.c:174

References ABFT_SIG, abft_table::acpi, aoedev_name(), cpu_to_le16, cpu_to_le32, DBGC, desc, acpi_header::length, list_for_each_entry, net_device::ll_addr, abft_table::mac, aoe_device::major, memcpy(), memset(), aoe_device::minor, aoe_device::netdev, rc, acpi_header::revision, abft_table::shelf, acpi_header::signature, abft_table::slot, and strerror().

Variable Documentation

◆ __net_protocol

struct net_protocol aoe_protocol __net_protocol
Initial value:
= {
.name = "AoE",
.net_proto = htons ( ETH_P_AOE ),
.rx = aoe_rx,
}
static int aoe_rx(struct io_buffer *iobuf, struct net_device *netdev __unused, const void *ll_dest __unused, const void *ll_source, unsigned int flags __unused)
Process incoming AoE packets.
Definition: aoe.c:873
#define ETH_P_AOE
Definition: if_ether.h:25
#define htons(value)
Definition: byteswap.h:135

AoE protocol.

Definition at line 55 of file aoe.c.

◆ __acpi_model

struct acpi_model abft_model __acpi_model
Initial value:
= {
.descs = LIST_HEAD_INIT ( abft_model.descs ),
.complete = abft_complete,
.install = abft_install,
}
static int abft_complete(struct acpi_descriptor *desc __unused)
Check if AoE boot firmware table descriptor is complete.
Definition: aoe.c:1032
static int abft_install(int(*install)(struct acpi_header *acpi))
Install AoE boot firmware table(s)
Definition: aoe.c:1042
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30

aBFT model

Definition at line 56 of file aoe.c.

◆ aoecmd_ata

struct aoe_command_type aoecmd_ata
static
Initial value:
= {
.cmd_len = aoecmd_ata_cmd_len,
}
static size_t aoecmd_ata_cmd_len(struct aoe_command *aoecmd)
Calculate length of AoE ATA command IU.
Definition: aoe.c:354
static void aoecmd_ata_cmd(struct aoe_command *aoecmd, void *data, size_t len)
Build AoE ATA command IU.
Definition: aoe.c:368
static int aoecmd_ata_rsp(struct aoe_command *aoecmd, const void *data, size_t len, const void *ll_source __unused)
Handle AoE ATA response IU.
Definition: aoe.c:415

AoE ATA command.

Definition at line 459 of file aoe.c.

Referenced by aoedev_ata_command().

◆ aoecmd_cfg

struct aoe_command_type aoecmd_cfg
static
Initial value:
= {
.cmd_len = aoecmd_cfg_cmd_len,
}
static void aoecmd_cfg_cmd(struct aoe_command *aoecmd, void *data, size_t len)
Build AoE configuration command IU.
Definition: aoe.c:482
static int aoecmd_cfg_rsp(struct aoe_command *aoecmd, const void *data, size_t len, const void *ll_source)
Handle AoE configuration response IU.
Definition: aoe.c:508
static size_t aoecmd_cfg_cmd_len(struct aoe_command *aoecmd __unused)
Calculate length of AoE configuration command IU.
Definition: aoe.c:471

AoE configuration command.

Definition at line 535 of file aoe.c.

Referenced by aoedev_cfg_command().

◆ aoecmd_ata_op

struct interface_operation aoecmd_ata_op[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
static void aoecmd_close(struct aoe_command *aoecmd, int rc)
Close AoE command.
Definition: aoe.c:204
An AoE command.
Definition: aoe.c:72

AoE command ATA interface operations.

Definition at line 542 of file aoe.c.

◆ aoecmd_ata_desc

struct interface_descriptor aoecmd_ata_desc
static
Initial value:
=
static struct interface_operation aoecmd_ata_op[]
AoE command ATA interface operations.
Definition: aoe.c:542
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
An AoE command.
Definition: aoe.c:72

AoE command ATA interface descriptor.

Definition at line 547 of file aoe.c.

Referenced by aoecmd_create().

◆ aoedev_ata_op

struct interface_operation aoedev_ata_op[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
static size_t aoedev_window(struct aoe_device *aoedev)
Check AoE device flow-control window.
Definition: aoe.c:729
static int aoedev_ata_command(struct aoe_device *aoedev, struct interface *parent, struct ata_cmd *command)
Issue AoE ATA command.
Definition: aoe.c:627
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:116
An AoE device.
Definition: aoe.h:115
#define EFI_INTF_OP
Definition: efi.h:373
static void aoedev_close(struct aoe_device *aoedev, int rc)
Close AoE device.
Definition: aoe.c:705
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
struct acpi_descriptor * acpi_describe(struct interface *intf)
Get object's ACPI descriptor.
Definition: acpi.c:320
static struct device * aoedev_identify_device(struct aoe_device *aoedev)
Identify device underlying AoE device.
Definition: aoe.c:761
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition: efi_path.c:919
EFI_DEVICE_PATH_PROTOCOL * efi_aoe_path(struct aoe_device *aoedev)
Construct EFI device path for AoE device.
Definition: efi_path.c:571
struct device * identify_device(struct interface *intf)
Identify a device behind an interface.
Definition: device.c:125
An ATA command.
Definition: ata.c:109
static struct acpi_descriptor * aoedev_describe(struct aoe_device *aoedev)
Get AoE ACPI descriptor.
Definition: aoe.c:771

AoE device ATA interface operations.

Definition at line 776 of file aoe.c.

◆ aoedev_ata_desc

struct interface_descriptor aoedev_ata_desc
static
Initial value:
=
static struct interface_operation aoedev_ata_op[]
AoE device ATA interface operations.
Definition: aoe.c:776
An AoE device.
Definition: aoe.h:115
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80

AoE device ATA interface descriptor.

Definition at line 787 of file aoe.c.

Referenced by aoedev_open().

◆ aoedev_config_op

struct interface_operation aoedev_config_op[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
An AoE device.
Definition: aoe.h:115
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
static void aoedev_config_done(struct aoe_device *aoedev, int rc)
Handle AoE device configuration completion.
Definition: aoe.c:739

AoE device configuration interface operations.

Definition at line 791 of file aoe.c.

◆ aoedev_config_desc

struct interface_descriptor aoedev_config_desc
static
Initial value:
=
An AoE device.
Definition: aoe.h:115
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
static struct interface_operation aoedev_config_op[]
AoE device configuration interface operations.
Definition: aoe.c:791

AoE device configuration interface descriptor.

Definition at line 796 of file aoe.c.

Referenced by aoedev_open().

◆ __uri_opener

struct uri_opener aoe_uri_opener __uri_opener
Initial value:
= {
.scheme = "aoe",
.open = aoe_open,
}
static int aoe_open(struct interface *parent, struct uri *uri)
Open AoE URI.
Definition: aoe.c:984

AoE URI opener.

Definition at line 1014 of file aoe.c.