iPXE
Data Structures | Macros | Functions | Variables
nii.c File Reference

NII driver. More...

#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/umalloc.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_pci.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
#include <ipxe/efi/IndustryStandard/Acpi10.h>
#include "nii.h"

Go to the source code of this file.

Data Structures

struct  nii_mapping
 An NII memory mapping. More...
 
struct  nii_nic
 An NII NIC. More...
 

Macros

#define EIO_INVALID_CDB   __einfo_error ( EINFO_EIO_INVALID_CDB )
 
#define EINFO_EIO_INVALID_CDB
 
#define EIO_INVALID_CPB   __einfo_error ( EINFO_EIO_INVALID_CPB )
 
#define EINFO_EIO_INVALID_CPB
 
#define EIO_BUSY   __einfo_error ( EINFO_EIO_BUSY )
 
#define EINFO_EIO_BUSY
 
#define EIO_QUEUE_FULL   __einfo_error ( EINFO_EIO_QUEUE_FULL )
 
#define EINFO_EIO_QUEUE_FULL
 
#define EIO_ALREADY_STARTED   __einfo_error ( EINFO_EIO_ALREADY_STARTED )
 
#define EINFO_EIO_ALREADY_STARTED
 
#define EIO_NOT_STARTED   __einfo_error ( EINFO_EIO_NOT_STARTED )
 
#define EINFO_EIO_NOT_STARTED
 
#define EIO_NOT_SHUTDOWN   __einfo_error ( EINFO_EIO_NOT_SHUTDOWN )
 
#define EINFO_EIO_NOT_SHUTDOWN
 
#define EIO_ALREADY_INITIALIZED   __einfo_error ( EINFO_EIO_ALREADY_INITIALIZED )
 
#define EINFO_EIO_ALREADY_INITIALIZED
 
#define EIO_NOT_INITIALIZED   __einfo_error ( EINFO_EIO_NOT_INITIALIZED )
 
#define EINFO_EIO_NOT_INITIALIZED
 
#define EIO_DEVICE_FAILURE   __einfo_error ( EINFO_EIO_DEVICE_FAILURE )
 
#define EINFO_EIO_DEVICE_FAILURE
 
#define EIO_NVDATA_FAILURE   __einfo_error ( EINFO_EIO_NVDATA_FAILURE )
 
#define EINFO_EIO_NVDATA_FAILURE
 
#define EIO_UNSUPPORTED   __einfo_error ( EINFO_EIO_UNSUPPORTED )
 
#define EINFO_EIO_UNSUPPORTED
 
#define EIO_BUFFER_FULL   __einfo_error ( EINFO_EIO_BUFFER_FULL )
 
#define EINFO_EIO_BUFFER_FULL
 
#define EIO_INVALID_PARAMETER   __einfo_error ( EINFO_EIO_INVALID_PARAMETER )
 
#define EINFO_EIO_INVALID_PARAMETER
 
#define EIO_INVALID_UNDI   __einfo_error ( EINFO_EIO_INVALID_UNDI )
 
#define EINFO_EIO_INVALID_UNDI
 
#define EIO_IPV4_NOT_SUPPORTED   __einfo_error ( EINFO_EIO_IPV4_NOT_SUPPORTED )
 
#define EINFO_EIO_IPV4_NOT_SUPPORTED
 
#define EIO_IPV6_NOT_SUPPORTED   __einfo_error ( EINFO_EIO_IPV6_NOT_SUPPORTED )
 
#define EINFO_EIO_IPV6_NOT_SUPPORTED
 
#define EIO_NOT_ENOUGH_MEMORY   __einfo_error ( EINFO_EIO_NOT_ENOUGH_MEMORY )
 
#define EINFO_EIO_NOT_ENOUGH_MEMORY
 
#define EIO_NO_DATA   __einfo_error ( EINFO_EIO_NO_DATA )
 
#define EINFO_EIO_NO_DATA
 
#define EIO_STAT(stat)
 
#define PCI_MAX_BAR   6
 Maximum PCI BAR. More...
 
#define NII_RX_QUOTA   4
 Maximum number of received packets per poll. More...
 
#define NII_OP(opcode, opflags)   ( (opcode) | ( (opflags) << 16 ) )
 Construct operation from opcode and flags. More...
 
#define NII_OPCODE(op)   ( (op) & 0xffff )
 Extract opcode from operation. More...
 
#define NII_OPFLAGS(op)   ( (op) >> 16 )
 Extract flags from operation. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
static int nii_pci_open (struct nii_nic *nii)
 Open PCI I/O protocol and identify BARs. More...
 
static void nii_pci_close (struct nii_nic *nii)
 Close PCI I/O protocol. More...
 
static EFIAPI VOID nii_io (UINT64 unique_id, UINT8 op, UINT8 len, UINT64 addr, UINT64 data)
 I/O callback. More...
 
static EFIAPI VOID nii_map (UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
 Map callback. More...
 
static EFIAPI VOID nii_unmap (UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir __unused, UINT64 mapped)
 Unmap callback. More...
 
static EFIAPI VOID nii_sync (UINT64 unique_id __unused, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
 Sync callback. More...
 
static EFIAPI VOID nii_delay (UINT64 unique_id __unused, UINTN microseconds)
 Delay callback. More...
 
static EFIAPI VOID nii_block (UINT64 unique_id, UINT32 acquire)
 Block callback. More...
 
static int nii_issue_cpb_db (struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
 Issue command with parameter block and data block. More...
 
static int nii_issue_cpb (struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len)
 Issue command with parameter block. More...
 
static int nii_issue_db (struct nii_nic *nii, unsigned int op, void *db, size_t db_len)
 Issue command with data block. More...
 
static int nii_issue (struct nii_nic *nii, unsigned int op)
 Issue command. More...
 
static int nii_start_undi (struct nii_nic *nii)
 Start UNDI. More...
 
static void nii_stop_undi (struct nii_nic *nii)
 Stop UNDI. More...
 
static int nii_get_init_info (struct nii_nic *nii, struct net_device *netdev)
 Get initialisation information. More...
 
static int nii_initialise_flags (struct nii_nic *nii, unsigned int flags)
 Initialise UNDI. More...
 
static int nii_initialise_cable (struct nii_nic *nii)
 Initialise UNDI with cable detection. More...
 
static int nii_initialise (struct nii_nic *nii)
 Initialise UNDI. More...
 
static void nii_shutdown (struct nii_nic *nii)
 Shut down UNDI. More...
 
static int nii_get_station_address (struct nii_nic *nii, struct net_device *netdev)
 Get station addresses. More...
 
static int nii_set_station_address (struct nii_nic *nii, struct net_device *netdev)
 Set station address. More...
 
static int nii_set_rx_filters (struct nii_nic *nii, unsigned int flags)
 Set receive filters. More...
 
static int nii_enable_rx_filters (struct nii_nic *nii)
 Enable receive filters. More...
 
static int nii_disable_rx_filters (struct nii_nic *nii)
 Disable receive filters. More...
 
static int nii_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
static void nii_poll_tx (struct net_device *netdev, unsigned int stat)
 Poll for completed packets. More...
 
static void nii_poll_rx (struct net_device *netdev)
 Poll for received packets. More...
 
static void nii_poll_link (struct net_device *netdev, unsigned int stat)
 Check for link state changes. More...
 
static void nii_poll (struct net_device *netdev)
 Poll for completed packets. More...
 
static int nii_open (struct net_device *netdev)
 Open network device. More...
 
static void nii_close (struct net_device *netdev)
 Close network device. More...
 
int nii_exclude (EFI_HANDLE device)
 Exclude existing drivers. More...
 
int nii_start (struct efi_device *efidev)
 Attach driver to device. More...
 
void nii_stop (struct efi_device *efidev)
 Detach driver from device. More...
 

Variables

static struct net_device_operations nii_operations
 NII network device operations. More...
 

Detailed Description

NII driver.

Definition in file nii.c.

Macro Definition Documentation

◆ EIO_INVALID_CDB

#define EIO_INVALID_CDB   __einfo_error ( EINFO_EIO_INVALID_CDB )

Definition at line 51 of file nii.c.

◆ EINFO_EIO_INVALID_CDB

#define EINFO_EIO_INVALID_CDB
Value:
"Invalid CDB" )
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181
#define PXE_STATCODE_INVALID_CDB
Definition: UefiPxe.h:607

Definition at line 52 of file nii.c.

◆ EIO_INVALID_CPB

#define EIO_INVALID_CPB   __einfo_error ( EINFO_EIO_INVALID_CPB )

Definition at line 55 of file nii.c.

◆ EINFO_EIO_INVALID_CPB

#define EINFO_EIO_INVALID_CPB
Value:
"Invalid CPB" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_INVALID_CPB
Definition: UefiPxe.h:608
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 56 of file nii.c.

◆ EIO_BUSY

#define EIO_BUSY   __einfo_error ( EINFO_EIO_BUSY )

Definition at line 59 of file nii.c.

◆ EINFO_EIO_BUSY

#define EINFO_EIO_BUSY
Value:
"Busy" )
#define PXE_STATCODE_BUSY
Definition: UefiPxe.h:609
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 60 of file nii.c.

◆ EIO_QUEUE_FULL

#define EIO_QUEUE_FULL   __einfo_error ( EINFO_EIO_QUEUE_FULL )

Definition at line 63 of file nii.c.

◆ EINFO_EIO_QUEUE_FULL

#define EINFO_EIO_QUEUE_FULL
Value:
"Queue full" )
#define PXE_STATCODE_QUEUE_FULL
Definition: UefiPxe.h:610
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 64 of file nii.c.

◆ EIO_ALREADY_STARTED

#define EIO_ALREADY_STARTED   __einfo_error ( EINFO_EIO_ALREADY_STARTED )

Definition at line 67 of file nii.c.

◆ EINFO_EIO_ALREADY_STARTED

#define EINFO_EIO_ALREADY_STARTED
Value:
"Already started" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_ALREADY_STARTED
Definition: UefiPxe.h:611
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 68 of file nii.c.

◆ EIO_NOT_STARTED

#define EIO_NOT_STARTED   __einfo_error ( EINFO_EIO_NOT_STARTED )

Definition at line 71 of file nii.c.

◆ EINFO_EIO_NOT_STARTED

#define EINFO_EIO_NOT_STARTED
Value:
"Not started" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_NOT_STARTED
Definition: UefiPxe.h:612
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 72 of file nii.c.

◆ EIO_NOT_SHUTDOWN

#define EIO_NOT_SHUTDOWN   __einfo_error ( EINFO_EIO_NOT_SHUTDOWN )

Definition at line 75 of file nii.c.

◆ EINFO_EIO_NOT_SHUTDOWN

#define EINFO_EIO_NOT_SHUTDOWN
Value:
"Not shutdown" )
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181
#define PXE_STATCODE_NOT_SHUTDOWN
Definition: UefiPxe.h:613

Definition at line 76 of file nii.c.

◆ EIO_ALREADY_INITIALIZED

#define EIO_ALREADY_INITIALIZED   __einfo_error ( EINFO_EIO_ALREADY_INITIALIZED )

Definition at line 79 of file nii.c.

◆ EINFO_EIO_ALREADY_INITIALIZED

#define EINFO_EIO_ALREADY_INITIALIZED
Value:
"Already initialized" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_ALREADY_INITIALIZED
Definition: UefiPxe.h:614
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 80 of file nii.c.

◆ EIO_NOT_INITIALIZED

#define EIO_NOT_INITIALIZED   __einfo_error ( EINFO_EIO_NOT_INITIALIZED )

Definition at line 83 of file nii.c.

◆ EINFO_EIO_NOT_INITIALIZED

#define EINFO_EIO_NOT_INITIALIZED
Value:
"Not initialized" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_NOT_INITIALIZED
Definition: UefiPxe.h:615
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 84 of file nii.c.

◆ EIO_DEVICE_FAILURE

#define EIO_DEVICE_FAILURE   __einfo_error ( EINFO_EIO_DEVICE_FAILURE )

Definition at line 87 of file nii.c.

◆ EINFO_EIO_DEVICE_FAILURE

#define EINFO_EIO_DEVICE_FAILURE
Value:
"Device failure" )
#define PXE_STATCODE_DEVICE_FAILURE
Definition: UefiPxe.h:616
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 88 of file nii.c.

◆ EIO_NVDATA_FAILURE

#define EIO_NVDATA_FAILURE   __einfo_error ( EINFO_EIO_NVDATA_FAILURE )

Definition at line 91 of file nii.c.

◆ EINFO_EIO_NVDATA_FAILURE

#define EINFO_EIO_NVDATA_FAILURE
Value:
"Non-volatile data failure" )
#define PXE_STATCODE_NVDATA_FAILURE
Definition: UefiPxe.h:617
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 92 of file nii.c.

◆ EIO_UNSUPPORTED

#define EIO_UNSUPPORTED   __einfo_error ( EINFO_EIO_UNSUPPORTED )

Definition at line 95 of file nii.c.

◆ EINFO_EIO_UNSUPPORTED

#define EINFO_EIO_UNSUPPORTED
Value:
"Unsupported" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_UNSUPPORTED
Definition: UefiPxe.h:618
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 96 of file nii.c.

◆ EIO_BUFFER_FULL

#define EIO_BUFFER_FULL   __einfo_error ( EINFO_EIO_BUFFER_FULL )

Definition at line 99 of file nii.c.

◆ EINFO_EIO_BUFFER_FULL

#define EINFO_EIO_BUFFER_FULL
Value:
"Buffer full" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_BUFFER_FULL
Definition: UefiPxe.h:619
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 100 of file nii.c.

◆ EIO_INVALID_PARAMETER

#define EIO_INVALID_PARAMETER   __einfo_error ( EINFO_EIO_INVALID_PARAMETER )

Definition at line 103 of file nii.c.

◆ EINFO_EIO_INVALID_PARAMETER

#define EINFO_EIO_INVALID_PARAMETER
Value:
"Invalid parameter" )
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181
#define PXE_STATCODE_INVALID_PARAMETER
Definition: UefiPxe.h:620

Definition at line 104 of file nii.c.

◆ EIO_INVALID_UNDI

#define EIO_INVALID_UNDI   __einfo_error ( EINFO_EIO_INVALID_UNDI )

Definition at line 107 of file nii.c.

◆ EINFO_EIO_INVALID_UNDI

#define EINFO_EIO_INVALID_UNDI
Value:
"Invalid UNDI" )
#define PXE_STATCODE_INVALID_UNDI
Definition: UefiPxe.h:621
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 108 of file nii.c.

◆ EIO_IPV4_NOT_SUPPORTED

#define EIO_IPV4_NOT_SUPPORTED   __einfo_error ( EINFO_EIO_IPV4_NOT_SUPPORTED )

Definition at line 111 of file nii.c.

◆ EINFO_EIO_IPV4_NOT_SUPPORTED

#define EINFO_EIO_IPV4_NOT_SUPPORTED
Value:
"IPv4 not supported" )
#define PXE_STATCODE_IPV4_NOT_SUPPORTED
Definition: UefiPxe.h:622
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 112 of file nii.c.

◆ EIO_IPV6_NOT_SUPPORTED

#define EIO_IPV6_NOT_SUPPORTED   __einfo_error ( EINFO_EIO_IPV6_NOT_SUPPORTED )

Definition at line 115 of file nii.c.

◆ EINFO_EIO_IPV6_NOT_SUPPORTED

#define EINFO_EIO_IPV6_NOT_SUPPORTED
Value:
"IPv6 not supported" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_IPV6_NOT_SUPPORTED
Definition: UefiPxe.h:623
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 116 of file nii.c.

◆ EIO_NOT_ENOUGH_MEMORY

#define EIO_NOT_ENOUGH_MEMORY   __einfo_error ( EINFO_EIO_NOT_ENOUGH_MEMORY )

Definition at line 119 of file nii.c.

◆ EINFO_EIO_NOT_ENOUGH_MEMORY

#define EINFO_EIO_NOT_ENOUGH_MEMORY
Value:
"Not enough memory" )
#define PXE_STATCODE_NOT_ENOUGH_MEMORY
Definition: UefiPxe.h:624
#define EINFO_EIO
Definition: errno.h:435
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 120 of file nii.c.

◆ EIO_NO_DATA

#define EIO_NO_DATA   __einfo_error ( EINFO_EIO_NO_DATA )

Definition at line 123 of file nii.c.

◆ EINFO_EIO_NO_DATA

#define EINFO_EIO_NO_DATA
Value:
"No data" )
#define EINFO_EIO
Definition: errno.h:435
#define PXE_STATCODE_NO_DATA
Definition: UefiPxe.h:625
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition: errno.h:181

Definition at line 124 of file nii.c.

◆ EIO_STAT

#define EIO_STAT (   stat)
Value:
#define EIO_DEVICE_FAILURE
Definition: nii.c:87
#define EIO_ALREADY_INITIALIZED
Definition: nii.c:79
#define EIO_INVALID_CPB
Definition: nii.c:55
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define EIO_QUEUE_FULL
Definition: nii.c:63
#define EIO_BUFFER_FULL
Definition: nii.c:99
#define EIO_INVALID_CDB
Definition: nii.c:51
#define EIO_NOT_ENOUGH_MEMORY
Definition: nii.c:119
#define EIO_UNSUPPORTED
Definition: nii.c:95
#define EIO_IPV4_NOT_SUPPORTED
Definition: nii.c:111
#define EIO_INVALID_PARAMETER
Definition: nii.c:103
#define EIO_IPV6_NOT_SUPPORTED
Definition: nii.c:115
#define EINFO_EIO
Definition: errno.h:435
#define EIO_NOT_SHUTDOWN
Definition: nii.c:75
#define EIO_NVDATA_FAILURE
Definition: nii.c:91
#define EIO_BUSY
Definition: nii.c:59
#define EIO_NOT_INITIALIZED
Definition: nii.c:83
#define EIO_NO_DATA
Definition: nii.c:123
#define EIO_INVALID_UNDI
Definition: nii.c:107
#define EUNIQ(einfo_base, uniq,...)
Disambiguate a base error based on non-constant information.
Definition: errno.h:226
#define EIO_ALREADY_STARTED
Definition: nii.c:67
#define EIO_NOT_STARTED
Definition: nii.c:71

Definition at line 127 of file nii.c.

◆ PCI_MAX_BAR

#define PCI_MAX_BAR   6

Maximum PCI BAR.

This is defined in <ipxe/efi/IndustryStandard/Pci22.h>, but we can't #include that since it collides with <ipxe/pci.h>.

Definition at line 141 of file nii.c.

◆ NII_RX_QUOTA

#define NII_RX_QUOTA   4

Maximum number of received packets per poll.

Definition at line 201 of file nii.c.

◆ NII_OP

#define NII_OP (   opcode,
  opflags 
)    ( (opcode) | ( (opflags) << 16 ) )

Construct operation from opcode and flags.

Parameters
opcodeOpcode
opflagsFlags
Return values
opOperation

Definition at line 529 of file nii.c.

◆ NII_OPCODE

#define NII_OPCODE (   op)    ( (op) & 0xffff )

Extract opcode from operation.

Parameters
opOperation
Return values
opcodeOpcode

Definition at line 537 of file nii.c.

◆ NII_OPFLAGS

#define NII_OPFLAGS (   op)    ( (op) >> 16 )

Extract flags from operation.

Parameters
opOperation
Return values
opflagsFlags

Definition at line 545 of file nii.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ nii_pci_open()

static int nii_pci_open ( struct nii_nic nii)
static

Open PCI I/O protocol and identify BARs.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 209 of file nii.c.

209  {
211  EFI_HANDLE device = nii->efidev->device;
213  union {
215  void *resource;
216  } desc;
217  int bar;
218  EFI_STATUS efirc;
219  int rc;
220 
221  /* Locate PCI I/O protocol */
223  &pci_device, 0 ) ) != 0 ) {
224  DBGC ( nii, "NII %s could not locate PCI I/O protocol: %s\n",
225  nii->dev.name, strerror ( rc ) );
226  goto err_locate;
227  }
228  nii->pci_device = pci_device;
229 
230  /* Open PCI I/O protocol
231  *
232  * We cannot open this safely as a by-driver open, since doing
233  * so would disconnect the underlying NII driver. We must
234  * therefore use an unsafe open.
235  */
237  &nii->pci_io ) ) != 0 ) {
238  DBGC ( nii, "NII %s could not open PCI I/O protocol: %s\n",
239  nii->dev.name, strerror ( rc ) );
240  goto err_open;
241  }
242 
243  /* Identify memory and I/O BARs */
244  nii->mem_bar = PCI_MAX_BAR;
245  nii->io_bar = PCI_MAX_BAR;
246  for ( bar = ( PCI_MAX_BAR - 1 ) ; bar >= 0 ; bar-- ) {
247  efirc = nii->pci_io->GetBarAttributes ( nii->pci_io, bar, NULL,
248  &desc.resource );
249  if ( efirc == EFI_UNSUPPORTED ) {
250  /* BAR not present; ignore */
251  continue;
252  }
253  if ( efirc != 0 ) {
254  rc = -EEFI ( efirc );
255  DBGC ( nii, "NII %s could not get BAR %d attributes: "
256  "%s\n", nii->dev.name, bar, strerror ( rc ) );
257  goto err_get_bar_attributes;
258  }
259  if ( desc.acpi->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM ) {
260  nii->mem_bar = bar;
261  } else if ( desc.acpi->ResType == ACPI_ADDRESS_SPACE_TYPE_IO ) {
262  nii->io_bar = bar;
263  }
264  bs->FreePool ( desc.resource );
265  }
266  DBGC ( nii, "NII %s has ", nii->dev.name );
267  if ( nii->mem_bar < PCI_MAX_BAR ) {
268  DBGC ( nii, "memory BAR %d and ", nii->mem_bar );
269  } else {
270  DBGC ( nii, "no memory BAR and " );
271  }
272  if ( nii->io_bar < PCI_MAX_BAR ) {
273  DBGC ( nii, "I/O BAR %d\n", nii->io_bar );
274  } else {
275  DBGC ( nii, "no I/O BAR\n" );
276  }
277 
278  return 0;
279 
280  err_get_bar_attributes:
282  err_open:
283  err_locate:
284  return rc;
285 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:118
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
EFI_HANDLE pci_device
PCI device.
Definition: nii.c:167
PACKED struct @539 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
The common definition of QWORD, DWORD, and WORD Address Space Descriptors.
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:313
#define efi_open_unsafe(handle, protocol, interface)
Open protocol for unsafe persistent use.
Definition: efi.h:459
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:79
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:22
#define ACPI_ADDRESS_SPACE_TYPE_MEM
Definition: Acpi10.h:101
struct ena_llq_option desc
Descriptor counts.
Definition: ena.h:20
A hardware device.
Definition: device.h:77
void efi_close_unsafe(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for unsafe persistent use.
Definition: efi_open.c:219
#define PCI_MAX_BAR
Maximum PCI BAR.
Definition: nii.c:141
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition: efi_block.c:67
EFI_PCI_IO_PROTOCOL * pci_io
PCI I/O protocol.
Definition: nii.c:169
EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes
Definition: PciIo.h:533
unsigned int mem_bar
Memory BAR.
Definition: nii.c:171
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
EFI Boot Services Table.
Definition: UefiSpec.h:1931
A PCI device.
Definition: pci.h:211
struct efi_device * efidev
EFI device.
Definition: nii.c:156
#define ACPI_ADDRESS_SPACE_TYPE_IO
Definition: Acpi10.h:102
unsigned int io_bar
I/O BAR.
Definition: nii.c:173
int efi_locate_device(EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip)
Locate parent device supporting a given protocol.
Definition: efi_utils.c:46
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1950
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
struct device dev
Generic device.
Definition: nii.c:164
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: efi.h:62

References acpi, ACPI_ADDRESS_SPACE_TYPE_IO, ACPI_ADDRESS_SPACE_TYPE_MEM, EFI_SYSTEM_TABLE::BootServices, DBGC, desc, nii_nic::dev, efi_device::device, EEFI, efi_close_unsafe(), efi_locate_device(), efi_open_unsafe, efi_pci_io_protocol_guid, efi_systab, EFI_UNSUPPORTED, nii_nic::efidev, EFI_BOOT_SERVICES::FreePool, _EFI_PCI_IO_PROTOCOL::GetBarAttributes, nii_nic::io_bar, nii_nic::mem_bar, device::name, NULL, nii_nic::pci_device, nii_nic::pci_io, PCI_MAX_BAR, rc, and strerror().

Referenced by nii_start().

◆ nii_pci_close()

static void nii_pci_close ( struct nii_nic nii)
static

Close PCI I/O protocol.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 293 of file nii.c.

293  {
294  struct nii_mapping *map;
295  struct nii_mapping *tmp;
296 
297  /* Remove any stale mappings */
299  DBGC ( nii, "NII %s removing stale mapping %#llx\n",
300  nii->dev.name, ( ( unsigned long long ) map->addr ) );
301  nii->pci_io->Unmap ( nii->pci_io, map->mapping );
302  list_del ( &map->list );
303  free ( map );
304  }
305 
306  /* Close protocols */
308 }
EFI_HANDLE pci_device
PCI device.
Definition: nii.c:167
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:313
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:79
unsigned long tmp
Definition: linux_pci.h:65
#define list_del(list)
Delete an entry from a list.
Definition: list.h:120
void efi_close_unsafe(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for unsafe persistent use.
Definition: efi_open.c:219
EFI_PCI_IO_PROTOCOL * pci_io
PCI I/O protocol.
Definition: nii.c:169
An NII memory mapping.
Definition: nii.c:144
#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:459
EFI_PCI_IO_PROTOCOL_UNMAP Unmap
Definition: PciIo.h:527
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
static __always_inline int struct dma_mapping * map
Definition: dma.h:184
struct device dev
Generic device.
Definition: nii.c:164
struct list_head list
List of mappings.
Definition: nii.c:146
struct list_head mappings
Mapping list.
Definition: nii.c:197

References DBGC, nii_nic::dev, efi_close_unsafe(), efi_pci_io_protocol_guid, free, nii_mapping::list, list_del, list_for_each_entry_safe, map, nii_nic::mappings, device::name, nii_nic::pci_device, nii_nic::pci_io, tmp, and _EFI_PCI_IO_PROTOCOL::Unmap.

Referenced by nii_start(), and nii_stop().

◆ nii_io()

static EFIAPI VOID nii_io ( UINT64  unique_id,
UINT8  op,
UINT8  len,
UINT64  addr,
UINT64  data 
)
static

I/O callback.

Parameters
unique_idNII NIC
opOperations
lenLength of data
addrAddress
dataData buffer

Definition at line 319 of file nii.c.

320  {
321  struct nii_nic *nii = ( ( void * ) ( intptr_t ) unique_id );
325  unsigned int bar;
326  EFI_STATUS efirc;
327  int rc;
328 
329  /* Determine accessor and BAR */
330  if ( op & ( PXE_MEM_READ | PXE_MEM_WRITE ) ) {
331  access = &nii->pci_io->Mem;
332  bar = nii->mem_bar;
333  } else {
334  access = &nii->pci_io->Io;
335  bar = nii->io_bar;
336  }
337 
338  /* Determine operaton */
339  io = ( ( op & ( PXE_IO_WRITE | PXE_MEM_WRITE ) ) ?
340  access->Write : access->Read );
341 
342  /* Determine width */
343  width = ( fls ( len ) - 1 );
344 
345  /* Issue operation */
346  if ( ( efirc = io ( nii->pci_io, width, bar, addr, 1,
347  ( ( void * ) ( intptr_t ) data ) ) ) != 0 ) {
348  rc = -EEFI ( efirc );
349  DBGC ( nii, "NII %s I/O operation %#x failed: %s\n",
350  nii->dev.name, op, strerror ( rc ) );
351  /* No way to report failure */
352  return;
353  }
354 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
#define DBGC(...)
Definition: compiler.h:505
unsigned long intptr_t
Definition: stdint.h:21
An NII NIC.
Definition: nii.c:154
#define PXE_IO_WRITE
Definition: UefiPxe.h:1090
EFI_STATUS(EFIAPI * EFI_PCI_IO_PROTOCOL_IO_MEM)(IN EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_WIDTH Width, IN UINT8 BarIndex, IN UINT64 Offset, IN UINTN Count, IN OUT VOID *Buffer)
Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
Definition: PciIo.h:183
ring len
Length.
Definition: dwmac.h:231
EFI_PCI_IO_PROTOCOL_WIDTH
Definition: PciIo.h:31
EFI_PCI_IO_PROTOCOL_IO_MEM Write
Write PCI controller registers in the PCI memory or I/O space.
Definition: PciIo.h:200
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
uint32_t addr
Buffer address.
Definition: dwmac.h:20
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
EFI_PCI_IO_PROTOCOL_IO_MEM Read
Read PCI controller registers in the PCI memory or I/O space.
Definition: PciIo.h:196
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define PXE_MEM_READ
Definition: UefiPxe.h:1091
#define fls(x)
Find last (i.e.
Definition: strings.h:167
#define PXE_MEM_WRITE
Definition: UefiPxe.h:1092

References addr, data, DBGC, EEFI, fls, len, nii_nic::nii, op, PXE_IO_WRITE, PXE_MEM_READ, PXE_MEM_WRITE, rc, EFI_PCI_IO_PROTOCOL_ACCESS::Read, strerror(), and EFI_PCI_IO_PROTOCOL_ACCESS::Write.

Referenced by nii_start_undi().

◆ nii_map()

static EFIAPI VOID nii_map ( UINT64  unique_id,
UINT64  addr,
UINT32  len,
UINT32  dir,
UINT64  mapped 
)
static

Map callback.

Parameters
unique_idNII NIC
addrAddress of memory to be mapped
lenLength of memory to be mapped
dirDirection of data flow
mappedDevice mapped address to fill in

Definition at line 365 of file nii.c.

366  {
367  struct nii_nic *nii = ( ( void * ) ( intptr_t ) unique_id );
368  EFI_PHYSICAL_ADDRESS *phys = ( ( void * ) ( intptr_t ) mapped );
370  struct nii_mapping *map;
371  UINTN count = len;
372  EFI_STATUS efirc;
373  int rc;
374 
375  /* Return a zero mapped address on failure */
376  *phys = 0;
377 
378  /* Determine PCI mapping operation */
379  switch ( dir ) {
380  case TO_AND_FROM_DEVICE:
382  break;
383  case FROM_DEVICE:
385  break;
386  case TO_DEVICE:
388  break;
389  default:
390  DBGC ( nii, "NII %s unsupported mapping direction %d\n",
391  nii->dev.name, dir );
392  goto err_dir;
393  }
394 
395  /* Allocate a mapping record */
396  map = zalloc ( sizeof ( *map ) );
397  if ( ! map )
398  goto err_alloc;
399  map->addr = addr;
400 
401  /* Create map */
402  if ( ( efirc = nii->pci_io->Map ( nii->pci_io, op,
403  ( ( void * ) ( intptr_t ) addr ),
404  &count, phys, &map->mapping ) ) != 0){
405  rc = -EEFI ( efirc );
406  DBGC ( nii, "NII %s map operation failed: %s\n",
407  nii->dev.name, strerror ( rc ) );
408  goto err_map;
409  }
410 
411  /* Add to list of mappings */
412  list_add ( &map->list, &nii->mappings );
413  DBGC2 ( nii, "NII %s mapped %#llx+%#x->%#llx\n",
414  nii->dev.name, ( ( unsigned long long ) addr ),
415  len, ( ( unsigned long long ) *phys ) );
416  return;
417 
418  list_del ( &map->list );
419  err_map:
420  free ( map );
421  err_alloc:
422  err_dir:
423  return;
424 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:175
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:70
A read operation from system memory by a bus master.
Definition: PciIo.h:84
EFI_PCI_IO_PROTOCOL_MAP Map
Definition: PciIo.h:526
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:79
#define FROM_DEVICE
Definition: UefiPxe.h:1084
unsigned long intptr_t
Definition: stdint.h:21
UINT64 EFI_PHYSICAL_ADDRESS
64-bit physical memory address.
Definition: UefiBaseType.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:120
An NII NIC.
Definition: nii.c:154
static signed char phys[4]
Definition: epic100.c:88
ring len
Length.
Definition: dwmac.h:231
EFI_PCI_IO_PROTOCOL * pci_io
PCI I/O protocol.
Definition: nii.c:169
static unsigned int count
Number of entries.
Definition: dwmac.h:225
An NII memory mapping.
Definition: nii.c:144
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:662
#define TO_DEVICE
Definition: UefiPxe.h:1085
uint32_t addr
Buffer address.
Definition: dwmac.h:20
UINT64 UINTN
Unsigned value of native width.
Provides both read and write access to system memory by both the processor and a bus master.
Definition: PciIo.h:93
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
EFI_PCI_IO_PROTOCOL_OPERATION
Definition: PciIo.h:80
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
static __always_inline int struct dma_mapping * map
Definition: dma.h:184
#define DBGC2(...)
Definition: compiler.h:522
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:32
struct device dev
Generic device.
Definition: nii.c:164
#define TO_AND_FROM_DEVICE
Definition: UefiPxe.h:1083
A write operation from system memory by a bus master.
Definition: PciIo.h:88
struct list_head mappings
Mapping list.
Definition: nii.c:197

References addr, count, DBGC, DBGC2, nii_nic::dev, EEFI, EfiPciIoOperationBusMasterCommonBuffer, EfiPciIoOperationBusMasterRead, EfiPciIoOperationBusMasterWrite, free, FROM_DEVICE, len, list_add, list_del, map, _EFI_PCI_IO_PROTOCOL::Map, nii_nic::mappings, device::name, nii_nic::nii, op, nii_nic::pci_io, phys, rc, strerror(), TO_AND_FROM_DEVICE, TO_DEVICE, and zalloc().

Referenced by nii_start_undi().

◆ nii_unmap()

static EFIAPI VOID nii_unmap ( UINT64  unique_id,
UINT64  addr,
UINT32  len,
UINT32 dir  __unused,
UINT64  mapped 
)
static

Unmap callback.

Parameters
unique_idNII NIC
addrAddress of mapped memory
lenLength of mapped memory
dirDirection of data flow
mappedDevice mapped address

Definition at line 435 of file nii.c.

436  {
437  struct nii_nic *nii = ( ( void * ) ( intptr_t ) unique_id );
438  struct nii_mapping *map;
439 
440  /* Locate mapping record */
441  list_for_each_entry ( map, &nii->mappings, list ) {
442  if ( map->addr == addr ) {
443  nii->pci_io->Unmap ( nii->pci_io, map->mapping );
444  list_del ( &map->list );
445  free ( map );
446  DBGC2 ( nii, "NII %s unmapped %#llx+%#x->%#llx\n",
447  nii->dev.name, ( ( unsigned long long ) addr ),
448  len, ( ( unsigned long long ) mapped ) );
449  return;
450  }
451  }
452 
453  DBGC ( nii, "NII %s non-existent mapping %#llx+%#x->%#llx\n",
454  nii->dev.name, ( ( unsigned long long ) addr ),
455  len, ( ( unsigned long long ) mapped ) );
456 }
#define DBGC(...)
Definition: compiler.h:505
char name[40]
Name.
Definition: device.h:79
unsigned long intptr_t
Definition: stdint.h:21
#define list_del(list)
Delete an entry from a list.
Definition: list.h:120
An NII NIC.
Definition: nii.c:154
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:432
ring len
Length.
Definition: dwmac.h:231
EFI_PCI_IO_PROTOCOL * pci_io
PCI I/O protocol.
Definition: nii.c:169
An NII memory mapping.
Definition: nii.c:144
EFI_PCI_IO_PROTOCOL_UNMAP Unmap
Definition: PciIo.h:527
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
uint32_t addr
Buffer address.
Definition: dwmac.h:20
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static __always_inline int struct dma_mapping * map
Definition: dma.h:184
#define DBGC2(...)
Definition: compiler.h:522
struct device dev
Generic device.
Definition: nii.c:164
struct list_head list
List of mappings.
Definition: nii.c:146
struct list_head mappings
Mapping list.
Definition: nii.c:197

References addr, DBGC, DBGC2, nii_nic::dev, free, len, nii_mapping::list, list_del, list_for_each_entry, map, nii_nic::mappings, device::name, nii_nic::nii, nii_nic::pci_io, and _EFI_PCI_IO_PROTOCOL::Unmap.

Referenced by nii_start_undi().

◆ nii_sync()

static EFIAPI VOID nii_sync ( UINT64 unique_id  __unused,
UINT64  addr,
UINT32  len,
UINT32  dir,
UINT64  mapped 
)
static

Sync callback.

Parameters
unique_idNII NIC
addrAddress of mapped memory
lenLength of mapped memory
dirDirection of data flow
mappedDevice mapped address

Definition at line 467 of file nii.c.

468  {
469  const void *src;
470  void *dst;
471 
472  /* Do nothing if this is an identity mapping */
473  if ( addr == mapped )
474  return;
475 
476  /* Determine direction */
477  if ( dir == FROM_DEVICE ) {
478  src = ( ( void * ) ( intptr_t ) mapped );
479  dst = ( ( void * ) ( intptr_t ) addr );
480  } else {
481  src = ( ( void * ) ( intptr_t ) addr );
482  dst = ( ( void * ) ( intptr_t ) mapped );
483  }
484 
485  /* Copy data */
486  memcpy ( dst, src, len );
487 }
#define FROM_DEVICE
Definition: UefiPxe.h:1084
unsigned long intptr_t
Definition: stdint.h:21
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static const void * src
Definition: string.h:48
ring len
Length.
Definition: dwmac.h:231
uint32_t addr
Buffer address.
Definition: dwmac.h:20

References addr, FROM_DEVICE, len, memcpy(), and src.

Referenced by nii_start_undi().

◆ nii_delay()

static EFIAPI VOID nii_delay ( UINT64 unique_id  __unused,
UINTN  microseconds 
)
static

Delay callback.

Parameters
unique_idNII NIC
microsecondsDelay in microseconds

Definition at line 495 of file nii.c.

495  {
496 
497  udelay ( microseconds );
498 }
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:61

References udelay().

Referenced by nii_start_undi().

◆ nii_block()

static EFIAPI VOID nii_block ( UINT64  unique_id,
UINT32  acquire 
)
static

Block callback.

Parameters
unique_idNII NIC
acquireAcquire lock

Definition at line 506 of file nii.c.

506  {
507  struct nii_nic *nii = ( ( void * ) ( intptr_t ) unique_id );
509 
510  /* This functionality (which is copied verbatim from the
511  * SnpDxe implementation of this function) appears to be
512  * totally brain-dead, since it produces no actual blocking
513  * behaviour.
514  */
515  if ( acquire ) {
516  nii->saved_tpl = bs->RaiseTPL ( TPL_NOTIFY );
517  } else {
518  bs->RestoreTPL ( nii->saved_tpl );
519  }
520 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1940
unsigned long intptr_t
Definition: stdint.h:21
#define TPL_NOTIFY
Definition: UefiSpec.h:650
An NII NIC.
Definition: nii.c:154
EFI Boot Services Table.
Definition: UefiSpec.h:1931
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1941

References EFI_SYSTEM_TABLE::BootServices, efi_systab, nii_nic::nii, EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RestoreTPL, and TPL_NOTIFY.

Referenced by nii_start_undi().

◆ nii_issue_cpb_db()

static int nii_issue_cpb_db ( struct nii_nic nii,
unsigned int  op,
void *  cpb,
size_t  cpb_len,
void *  db,
size_t  db_len 
)
static

Issue command with parameter block and data block.

Parameters
niiNII NIC
opOperation
cpbCommand parameter block, or NULL
cpb_lenCommand parameter block length
dbData block, or NULL
db_lenData block length
Return values
statStatus flags, or negative status code

Definition at line 558 of file nii.c.

559  {
561  PXE_CDB cdb;
562  UINTN tpl;
563 
564  /* Prepare command descriptor block */
565  memset ( &cdb, 0, sizeof ( cdb ) );
566  cdb.OpCode = NII_OPCODE ( op );
567  cdb.OpFlags = NII_OPFLAGS ( op );
568  cdb.CPBaddr = ( ( intptr_t ) cpb );
569  cdb.CPBsize = cpb_len;
570  cdb.DBaddr = ( ( intptr_t ) db );
571  cdb.DBsize = db_len;
572  cdb.IFnum = nii->nii->IfNum;
573 
574  /* Raise task priority level */
575  tpl = bs->RaiseTPL ( efi_internal_tpl );
576 
577  /* Issue command */
578  DBGC2 ( nii, "NII %s issuing %02x:%04x ifnum %d%s%s\n",
579  nii->dev.name, cdb.OpCode, cdb.OpFlags, cdb.IFnum,
580  ( cpb ? " cpb" : "" ), ( db ? " db" : "" ) );
581  if ( cpb )
582  DBGC2_HD ( nii, cpb, cpb_len );
583  if ( db )
584  DBGC2_HD ( nii, db, db_len );
585  nii->issue ( ( intptr_t ) &cdb );
586 
587  /* Restore task priority level */
588  bs->RestoreTPL ( tpl );
589 
590  /* Check completion status */
591  if ( cdb.StatCode != PXE_STATCODE_SUCCESS )
592  return -cdb.StatCode;
593 
594  /* Return command-specific status flags */
595  return ( cdb.StatFlags & ~PXE_STATFLAGS_STATUS_MASK );
596 }
#define NII_OPFLAGS(op)
Extract flags from operation.
Definition: nii.c:545
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2099
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1940
PXE_UINT16 CPBsize
Definition: UefiPxe.h:879
PXE_UINT16 DBsize
Definition: UefiPxe.h:880
#define NII_OPCODE(op)
Extract opcode from operation.
Definition: nii.c:537
PXE_OPFLAGS OpFlags
Definition: UefiPxe.h:878
unsigned long intptr_t
Definition: stdint.h:21
EFI_TPL efi_internal_tpl
Internal task priority level.
Definition: efi_init.c:54
#define PXE_STATFLAGS_STATUS_MASK
Common StatFlags that can be returned by all commands.
Definition: UefiPxe.h:416
PXE_UINT64 CPBaddr
Definition: UefiPxe.h:881
EFI Boot Services Table.
Definition: UefiSpec.h:1931
#define DBGC2_HD(...)
Definition: compiler.h:524
UINT64 UINTN
Unsigned value of native width.
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static struct dmfe_private * db
Definition: dmfe.c:177
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define DBGC2(...)
Definition: compiler.h:522
EFI_SYSTEM_TABLE * efi_systab
UINT16 IfNum
The network interface number that is being identified by this Network Interface Identifier Protocol.
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1941
PXE_UINT16 IFnum
Definition: UefiPxe.h:885
PXE_OPCODE OpCode
Definition: UefiPxe.h:877
PXE_UINT64 DBaddr
Definition: UefiPxe.h:882
#define PXE_STATCODE_SUCCESS
Common StatCodes returned by all UNDI commands, UNDI protocol functions and BC protocol functions.
Definition: UefiPxe.h:605
void * memset(void *dest, int character, size_t len) __nonnull

References EFI_SYSTEM_TABLE::BootServices, s_pxe_cdb::CPBaddr, s_pxe_cdb::CPBsize, db, s_pxe_cdb::DBaddr, DBGC2, DBGC2_HD, s_pxe_cdb::DBsize, efi_internal_tpl, efi_systab, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::IfNum, s_pxe_cdb::IFnum, memset(), nii_nic::nii, NII_OPCODE, NII_OPFLAGS, op, s_pxe_cdb::OpCode, s_pxe_cdb::OpFlags, PXE_STATCODE_SUCCESS, PXE_STATFLAGS_STATUS_MASK, EFI_BOOT_SERVICES::RaiseTPL, and EFI_BOOT_SERVICES::RestoreTPL.

Referenced by nii_initialise_flags(), nii_issue(), nii_issue_cpb(), nii_issue_db(), and nii_poll_rx().

◆ nii_issue_cpb()

static int nii_issue_cpb ( struct nii_nic nii,
unsigned int  op,
void *  cpb,
size_t  cpb_len 
)
static

Issue command with parameter block.

Parameters
niiNII NIC
opOperation
cpbCommand parameter block, or NULL
cpb_lenCommand parameter block length
Return values
statStatus flags, or negative status code

Definition at line 607 of file nii.c.

608  {
609 
610  return nii_issue_cpb_db ( nii, op, cpb, cpb_len, NULL, 0 );
611 }
static int nii_issue_cpb_db(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
Issue command with parameter block and data block.
Definition: nii.c:558
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References nii_nic::nii, nii_issue_cpb_db(), NULL, and op.

Referenced by nii_set_station_address(), nii_start_undi(), and nii_transmit().

◆ nii_issue_db()

static int nii_issue_db ( struct nii_nic nii,
unsigned int  op,
void *  db,
size_t  db_len 
)
static

Issue command with data block.

Parameters
niiNII NIC
opOperation
dbData block, or NULL
db_lenData block length
Return values
statStatus flags, or negative status code

Definition at line 622 of file nii.c.

623  {
624 
625  return nii_issue_cpb_db ( nii, op, NULL, 0, db, db_len );
626 }
static int nii_issue_cpb_db(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
Issue command with parameter block and data block.
Definition: nii.c:558
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static struct dmfe_private * db
Definition: dmfe.c:177
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References db, nii_nic::nii, nii_issue_cpb_db(), NULL, and op.

Referenced by nii_get_init_info(), nii_get_station_address(), and nii_poll().

◆ nii_issue()

static int nii_issue ( struct nii_nic nii,
unsigned int  op 
)
static

Issue command.

Parameters
niiNII NIC
opOperation
Return values
statStatus flags, or negative status code

Definition at line 636 of file nii.c.

636  {
637 
638  return nii_issue_cpb_db ( nii, op, NULL, 0, NULL, 0 );
639 }
static int nii_issue_cpb_db(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
Issue command with parameter block and data block.
Definition: nii.c:558
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References nii_nic::nii, nii_issue_cpb_db(), NULL, and op.

Referenced by nii_set_rx_filters(), nii_shutdown(), and nii_stop_undi().

◆ nii_start_undi()

static int nii_start_undi ( struct nii_nic nii)
static

Start UNDI.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 647 of file nii.c.

647  {
648  PXE_CPB_START_31 cpb;
649  int stat;
650  int rc;
651 
652  /* Construct parameter block */
653  memset ( &cpb, 0, sizeof ( cpb ) );
654  cpb.Delay = ( ( intptr_t ) nii_delay );
655  cpb.Block = ( ( intptr_t ) nii_block );
656  cpb.Mem_IO = ( ( intptr_t ) nii_io );
657  cpb.Map_Mem = ( ( intptr_t ) nii_map );
658  cpb.UnMap_Mem = ( ( intptr_t ) nii_unmap );
659  cpb.Sync_Mem = ( ( intptr_t ) nii_sync );
660  cpb.Unique_ID = ( ( intptr_t ) nii );
661 
662  /* Issue command */
663  if ( ( stat = nii_issue_cpb ( nii, PXE_OPCODE_START, &cpb,
664  sizeof ( cpb ) ) ) < 0 ) {
665  rc = -EIO_STAT ( stat );
666  DBGC ( nii, "NII %s could not start: %s\n",
667  nii->dev.name, strerror ( rc ) );
668  return rc;
669  }
670 
671  return 0;
672 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t stat
Completion status.
Definition: dwmac.h:12
static EFIAPI VOID nii_delay(UINT64 unique_id __unused, UINTN microseconds)
Delay callback.
Definition: nii.c:495
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
unsigned long intptr_t
Definition: stdint.h:21
static EFIAPI VOID nii_sync(UINT64 unique_id __unused, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
Sync callback.
Definition: nii.c:467
static EFIAPI VOID nii_map(UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
Map callback.
Definition: nii.c:365
UINT64 Mem_IO
PXE_VOID Mem_IO(UINT64 UnqId, UINT8 read_write, UINT8 len, UINT64 port, UINT64 buf_addr);.
Definition: UefiPxe.h:1032
static EFIAPI VOID nii_io(UINT64 unique_id, UINT8 op, UINT8 len, UINT64 addr, UINT64 data)
I/O callback.
Definition: nii.c:319
UINT64 Map_Mem
PXE_VOID Map_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, UINT32 Direction,...
Definition: UefiPxe.h:1049
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static EFIAPI VOID nii_block(UINT64 unique_id, UINT32 acquire)
Block callback.
Definition: nii.c:506
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
UINT64 Delay
PXE_VOID Delay(UINT64 UnqId, UINTN microseconds);.
Definition: UefiPxe.h:991
UINT64 Sync_Mem
PXE_VOID Sync_Mem(UINT64 unq_id, UINT64 virtual, UINT32 size, UINT32 Direction, UINT64 mapped_addr);.
Definition: UefiPxe.h:1072
UINT64 Block
PXE_VOID Block(UINT64 unq_id, UINT32 enable);.
Definition: UefiPxe.h:1007
UINT64 Unique_ID
protocol driver can provide anything for this Unique_ID, UNDI remembers that as just a 64bit value as...
Definition: UefiPxe.h:1080
static EFIAPI VOID nii_unmap(UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir __unused, UINT64 mapped)
Unmap callback.
Definition: nii.c:435
#define PXE_OPCODE_START
Change UNDI operational state from Stopped to Started.
Definition: UefiPxe.h:93
UINT64 UnMap_Mem
PXE_VOID UnMap_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, UINT32 Direction,...
Definition: UefiPxe.h:1060
static int nii_issue_cpb(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len)
Issue command with parameter block.
Definition: nii.c:607
void * memset(void *dest, int character, size_t len) __nonnull

References s_pxe_cpb_start_31::Block, DBGC, s_pxe_cpb_start_31::Delay, EIO_STAT, s_pxe_cpb_start_31::Map_Mem, s_pxe_cpb_start_31::Mem_IO, memset(), nii_nic::nii, nii_block(), nii_delay(), nii_io(), nii_issue_cpb(), nii_map(), nii_sync(), nii_unmap(), PXE_OPCODE_START, rc, stat, strerror(), s_pxe_cpb_start_31::Sync_Mem, s_pxe_cpb_start_31::Unique_ID, and s_pxe_cpb_start_31::UnMap_Mem.

Referenced by nii_start().

◆ nii_stop_undi()

static void nii_stop_undi ( struct nii_nic nii)
static

Stop UNDI.

Parameters
niiNII NIC

Definition at line 679 of file nii.c.

679  {
680  int stat;
681  int rc;
682 
683  /* Issue command */
684  if ( ( stat = nii_issue ( nii, PXE_OPCODE_STOP ) ) < 0 ) {
685  rc = -EIO_STAT ( stat );
686  DBGC ( nii, "NII %s could not stop: %s\n",
687  nii->dev.name, strerror ( rc ) );
688  /* Nothing we can do about it */
689  return;
690  }
691 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PXE_OPCODE_STOP
Change UNDI operational state from Started to Stopped.
Definition: UefiPxe.h:98
static int nii_issue(struct nii_nic *nii, unsigned int op)
Issue command.
Definition: nii.c:636
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158

References DBGC, EIO_STAT, nii_nic::nii, nii_issue(), PXE_OPCODE_STOP, rc, stat, and strerror().

Referenced by nii_start(), and nii_stop().

◆ nii_get_init_info()

static int nii_get_init_info ( struct nii_nic nii,
struct net_device netdev 
)
static

Get initialisation information.

Parameters
niiNII NIC
netdevNetwork device to fill in
Return values
rcReturn status code

Definition at line 700 of file nii.c.

701  {
703  int stat;
704  int rc;
705 
706  /* Issue command */
708  sizeof ( db ) ) ) < 0 ) {
709  rc = -EIO_STAT ( stat );
710  DBGC ( nii, "NII %s could not get initialisation info: %s\n",
711  nii->dev.name, strerror ( rc ) );
712  return rc;
713  }
714 
715  /* Determine link layer protocol */
716  switch ( db.IFtype ) {
717  case PXE_IFTYPE_ETHERNET :
718  netdev->ll_protocol = &ethernet_protocol;
719  break;
720  default:
721  DBGC ( nii, "NII %s unknown interface type %#02x\n",
722  nii->dev.name, db.IFtype );
723  return -ENOTSUP;
724  }
725 
726  /* Sanity checks */
727  assert ( db.MediaHeaderLen == netdev->ll_protocol->ll_header_len );
728  assert ( db.HWaddrLen == netdev->ll_protocol->hw_addr_len );
729  assert ( db.HWaddrLen == netdev->ll_protocol->ll_addr_len );
730 
731  /* Extract parameters */
732  nii->buffer_len = db.MemoryRequired;
733  nii->mtu = ( db.FrameDataLen + db.MediaHeaderLen );
734  netdev->max_pkt_len = nii->mtu;
736 
737  return 0;
738 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t ll_header_len
Link-layer header length.
Definition: netdevice.h:201
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:199
uint32_t stat
Completion status.
Definition: dwmac.h:12
static int nii_issue_db(struct nii_nic *nii, unsigned int op, void *db, size_t db_len)
Issue command with data block.
Definition: nii.c:622
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
#define PXE_IFTYPE_ETHERNET
This information is from the ARP section of RFC 1700.
Definition: UefiPxe.h:709
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:197
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED
Definition: UefiPxe.h:444
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static struct dmfe_private * db
Definition: dmfe.c:177
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:410
#define PXE_OPCODE_GET_INIT_INFO
Get UNDI initialization information.
Definition: UefiPxe.h:103
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:373

References assert(), db, DBGC, EIO_STAT, ENOTSUP, ll_protocol::hw_addr_len, ll_protocol::ll_addr_len, ll_protocol::ll_header_len, net_device::ll_protocol, net_device::max_pkt_len, netdev, nii_nic::nii, nii_issue_db(), PXE_IFTYPE_ETHERNET, PXE_OPCODE_GET_INIT_INFO, PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED, rc, stat, and strerror().

Referenced by nii_start().

◆ nii_initialise_flags()

static int nii_initialise_flags ( struct nii_nic nii,
unsigned int  flags 
)
static

Initialise UNDI.

Parameters
niiNII NIC
flagsFlags
Return values
rcReturn status code

Definition at line 747 of file nii.c.

747  {
748  PXE_CPB_INITIALIZE cpb;
750  unsigned int op;
751  int stat;
752  int rc;
753 
754  /* Allocate memory buffer */
755  nii->buffer = umalloc ( nii->buffer_len );
756  if ( ! nii->buffer ) {
757  rc = -ENOMEM;
758  goto err_alloc;
759  }
760 
761  /* Construct parameter block */
762  memset ( &cpb, 0, sizeof ( cpb ) );
763  cpb.MemoryAddr = ( ( intptr_t ) nii->buffer );
764  cpb.MemoryLength = nii->buffer_len;
765 
766  /* Construct data block */
767  memset ( &db, 0, sizeof ( db ) );
768 
769  /* Issue command */
771  if ( ( stat = nii_issue_cpb_db ( nii, op, &cpb, sizeof ( cpb ),
772  &db, sizeof ( db ) ) ) < 0 ) {
773  rc = -EIO_STAT ( stat );
774  DBGC ( nii, "NII %s could not initialise: %s\n",
775  nii->dev.name, strerror ( rc ) );
776  goto err_initialize;
777  }
778 
779  return 0;
780 
781  err_initialize:
782  ufree ( nii->buffer );
783  err_alloc:
784  return rc;
785 }
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:68
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t stat
Completion status.
Definition: dwmac.h:12
PXE_UINT32 MemoryLength
MemoryLength must be greater than or equal to MemoryRequired returned by the Get Init Info command.
Definition: UefiPxe.h:1255
#define DBGC(...)
Definition: compiler.h:505
#define PXE_OPCODE_INITIALIZE
Changed UNDI operational state from Started to Initialized.
Definition: UefiPxe.h:113
#define EIO_STAT(stat)
Definition: nii.c:127
unsigned long intptr_t
Definition: stdint.h:21
PXE_UINT64 MemoryAddr
Address of first (lowest) byte of the memory buffer.
Definition: UefiPxe.h:1249
#define ENOMEM
Not enough space.
Definition: errno.h:535
uint8_t flags
Flags.
Definition: ena.h:18
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static int nii_issue_cpb_db(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
Issue command with parameter block and data block.
Definition: nii.c:558
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static struct dmfe_private * db
Definition: dmfe.c:177
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:57
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529
void * memset(void *dest, int character, size_t len) __nonnull

References db, DBGC, EIO_STAT, ENOMEM, flags, s_pxe_cpb_initialize::MemoryAddr, s_pxe_cpb_initialize::MemoryLength, memset(), nii_nic::nii, nii_issue_cpb_db(), NII_OP, op, PXE_OPCODE_INITIALIZE, rc, stat, strerror(), ufree(), and umalloc().

Referenced by nii_initialise(), and nii_initialise_cable().

◆ nii_initialise_cable()

static int nii_initialise_cable ( struct nii_nic nii)
static

Initialise UNDI with cable detection.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 793 of file nii.c.

793  {
794  unsigned int flags;
795 
796  /* Initialise UNDI */
798  return nii_initialise_flags ( nii, flags );
799 }
static int nii_initialise_flags(struct nii_nic *nii, unsigned int flags)
Initialise UNDI.
Definition: nii.c:747
#define PXE_OPFLAGS_INITIALIZE_DETECT_CABLE
Definition: UefiPxe.h:214
uint8_t flags
Flags.
Definition: ena.h:18
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158

References flags, nii_nic::nii, nii_initialise_flags(), and PXE_OPFLAGS_INITIALIZE_DETECT_CABLE.

Referenced by nii_open().

◆ nii_initialise()

static int nii_initialise ( struct nii_nic nii)
static

Initialise UNDI.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 807 of file nii.c.

807  {
808  unsigned int flags;
809 
810  /* Initialise UNDI */
812  return nii_initialise_flags ( nii, flags );
813 }
static int nii_initialise_flags(struct nii_nic *nii, unsigned int flags)
Initialise UNDI.
Definition: nii.c:747
uint8_t flags
Flags.
Definition: ena.h:18
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
#define PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE
Definition: UefiPxe.h:215

References flags, nii_nic::nii, nii_initialise_flags(), and PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE.

Referenced by nii_get_station_address(), and nii_open().

◆ nii_shutdown()

static void nii_shutdown ( struct nii_nic nii)
static

Shut down UNDI.

Parameters
niiNII NIC

Definition at line 820 of file nii.c.

820  {
821  int stat;
822  int rc;
823 
824  /* Issue command */
825  if ( ( stat = nii_issue ( nii, PXE_OPCODE_SHUTDOWN ) ) < 0 ) {
826  rc = -EIO_STAT ( stat );
827  DBGC ( nii, "NII %s could not shut down: %s\n",
828  nii->dev.name, strerror ( rc ) );
829  /* Leak memory to avoid corruption */
830  return;
831  }
832 
833  /* Free buffer */
834  ufree ( nii->buffer );
835 }
static __always_inline void ufree(void *ptr)
Free external memory.
Definition: umalloc.h:68
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define PXE_OPCODE_SHUTDOWN
Change the UNDI operational state from Initialized to Started.
Definition: UefiPxe.h:123
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static int nii_issue(struct nii_nic *nii, unsigned int op)
Issue command.
Definition: nii.c:636
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158

References DBGC, EIO_STAT, nii_nic::nii, nii_issue(), PXE_OPCODE_SHUTDOWN, rc, stat, strerror(), and ufree().

Referenced by nii_close(), nii_get_station_address(), and nii_open().

◆ nii_get_station_address()

static int nii_get_station_address ( struct nii_nic nii,
struct net_device netdev 
)
static

Get station addresses.

Parameters
niiNII NIC
netdevNetwork device to fill in
Return values
rcReturn status code

Definition at line 844 of file nii.c.

845  {
847  unsigned int op;
848  int stat;
849  int rc;
850 
851  /* Initialise UNDI */
852  if ( ( rc = nii_initialise ( nii ) ) != 0 )
853  goto err_initialise;
854 
855  /* Issue command */
858  if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
859  rc = -EIO_STAT ( stat );
860  DBGC ( nii, "NII %s could not get station address: %s\n",
861  nii->dev.name, strerror ( rc ) );
862  goto err_station_address;
863  }
864 
865  /* Copy MAC addresses */
866  memcpy ( netdev->ll_addr, db.StationAddr,
868  memcpy ( netdev->hw_addr, db.PermanentAddr,
870  memcpy ( nii->broadcast, db.BroadcastAddr,
871  sizeof ( nii->broadcast ) );
872 
873  err_station_address:
874  nii_shutdown ( nii );
875  err_initialise:
876  return rc;
877 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:199
uint32_t stat
Completion status.
Definition: dwmac.h:12
static int nii_issue_db(struct nii_nic *nii, unsigned int op, void *db, size_t db_len)
Issue command with data block.
Definition: nii.c:622
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
#define PXE_OPCODE_STATION_ADDRESS
Read & change station MAC address.
Definition: UefiPxe.h:138
static void nii_shutdown(struct nii_nic *nii)
Shut down UNDI.
Definition: nii.c:820
void * memcpy(void *dest, const void *src, size_t len) __nonnull
uint8_t hw_addr_len
Hardware address length.
Definition: netdevice.h:197
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static int nii_initialise(struct nii_nic *nii)
Initialise UNDI.
Definition: nii.c:807
static struct dmfe_private * db
Definition: dmfe.c:177
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:388
#define PXE_OPFLAGS_STATION_ADDRESS_READ
UNDI Station Address.
Definition: UefiPxe.h:316
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:382
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:373
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529

References db, DBGC, EIO_STAT, net_device::hw_addr, ll_protocol::hw_addr_len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), netdev, nii_nic::nii, nii_initialise(), nii_issue_db(), NII_OP, nii_shutdown(), op, PXE_OPCODE_STATION_ADDRESS, PXE_OPFLAGS_STATION_ADDRESS_READ, rc, stat, and strerror().

Referenced by nii_start().

◆ nii_set_station_address()

static int nii_set_station_address ( struct nii_nic nii,
struct net_device netdev 
)
static

Set station address.

Parameters
niiNII NIC
netdevNetwork device
Return values
rcReturn status code

Definition at line 886 of file nii.c.

887  {
888  uint32_t implementation = nii->undi->Implementation;
890  unsigned int op;
891  int stat;
892  int rc;
893 
894  /* Fail if setting station address is unsupported */
896  return -ENOTSUP;
897 
898  /* Construct parameter block */
899  memset ( &cpb, 0, sizeof ( cpb ) );
902 
903  /* Issue command */
906  if ( ( stat = nii_issue_cpb ( nii, op, &cpb, sizeof ( cpb ) ) ) < 0 ) {
907  rc = -EIO_STAT ( stat );
908  DBGC ( nii, "NII %s could not set station address: %s\n",
909  nii->dev.name, strerror ( rc ) );
910  return rc;
911  }
912 
913  return 0;
914 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t ll_addr_len
Link-layer address length.
Definition: netdevice.h:199
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define DBGC(...)
Definition: compiler.h:505
#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE
Definition: UefiPxe.h:866
#define EIO_STAT(stat)
Definition: nii.c:127
PXE_MAC_ADDR StationAddr
If supplied and supported, the current station MAC address will be changed.
Definition: UefiPxe.h:1339
uint32_t implementation
Implementation.
Definition: ena.h:12
#define PXE_OPCODE_STATION_ADDRESS
Read & change station MAC address.
Definition: UefiPxe.h:138
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PXE_OPFLAGS_STATION_ADDRESS_WRITE
Definition: UefiPxe.h:317
unsigned int uint32_t
Definition: stdint.h:12
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition: netdevice.h:388
struct ll_protocol * ll_protocol
Link-layer protocol.
Definition: netdevice.h:373
static int nii_issue_cpb(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len)
Issue command with parameter block.
Definition: nii.c:607
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, EIO_STAT, ENOTSUP, implementation, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), memset(), netdev, nii_nic::nii, nii_issue_cpb(), NII_OP, op, PXE_OPCODE_STATION_ADDRESS, PXE_OPFLAGS_STATION_ADDRESS_WRITE, PXE_ROMID_IMP_STATION_ADDR_SETTABLE, rc, stat, s_pxe_cpb_station_address::StationAddr, and strerror().

Referenced by nii_open().

◆ nii_set_rx_filters()

static int nii_set_rx_filters ( struct nii_nic nii,
unsigned int  flags 
)
static

Set receive filters.

Parameters
niiNII NIC
flagsFlags
Return values
rcReturn status code

Definition at line 923 of file nii.c.

923  {
924  uint32_t implementation = nii->undi->Implementation;
925  unsigned int op;
926  int stat;
927  int rc;
928 
929  /* Construct receive filter set */
937 
938  /* Issue command */
940  if ( ( stat = nii_issue ( nii, op ) ) < 0 ) {
941  rc = -EIO_STAT ( stat );
942  DBGC ( nii, "NII %s could not %s%sable receive filters "
943  "%#04x: %s\n", nii->dev.name,
945  "en" : "" ),
947  "dis" : "" ), flags, strerror ( rc ) );
948  return rc;
949  }
950 
951  return 0;
952 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE
Definition: UefiPxe.h:274
#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED
Definition: UefiPxe.h:869
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
uint32_t implementation
Implementation.
Definition: ena.h:12
#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST
Enable broadcast packet receiving.
Definition: UefiPxe.h:293
#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE
Definition: UefiPxe.h:273
uint8_t flags
Flags.
Definition: ena.h:18
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED
Definition: UefiPxe.h:868
#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST
Enable unicast packet receiving.
Definition: UefiPxe.h:287
static int nii_issue(struct nii_nic *nii, unsigned int op)
Issue command.
Definition: nii.c:636
unsigned int uint32_t
Definition: stdint.h:12
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST
Enable promiscuous multicast packet receiving.
Definition: UefiPxe.h:311
#define PXE_OPCODE_RECEIVE_FILTERS
Read & change state of packet receive filters.
Definition: UefiPxe.h:133
#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS
Enable promiscuous packet receiving.
Definition: UefiPxe.h:305
#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED
Definition: UefiPxe.h:867
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529

References DBGC, EIO_STAT, flags, implementation, nii_nic::nii, nii_issue(), NII_OP, op, PXE_OPCODE_RECEIVE_FILTERS, PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST, PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST, PXE_OPFLAGS_RECEIVE_FILTER_DISABLE, PXE_OPFLAGS_RECEIVE_FILTER_ENABLE, PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS, PXE_OPFLAGS_RECEIVE_FILTER_UNICAST, PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED, PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED, PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED, rc, stat, and strerror().

Referenced by nii_disable_rx_filters(), and nii_enable_rx_filters().

◆ nii_enable_rx_filters()

static int nii_enable_rx_filters ( struct nii_nic nii)
static

Enable receive filters.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 960 of file nii.c.

960  {
961 
963 }
static int nii_set_rx_filters(struct nii_nic *nii, unsigned int flags)
Set receive filters.
Definition: nii.c:923
#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE
Definition: UefiPxe.h:273
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158

References nii_nic::nii, nii_set_rx_filters(), and PXE_OPFLAGS_RECEIVE_FILTER_ENABLE.

Referenced by nii_open().

◆ nii_disable_rx_filters()

static int nii_disable_rx_filters ( struct nii_nic nii)
static

Disable receive filters.

Parameters
niiNII NIC
Return values
rcReturn status code

Definition at line 971 of file nii.c.

971  {
972 
974 }
#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE
Definition: UefiPxe.h:274
static int nii_set_rx_filters(struct nii_nic *nii, unsigned int flags)
Set receive filters.
Definition: nii.c:923
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158

References nii_nic::nii, nii_set_rx_filters(), and PXE_OPFLAGS_RECEIVE_FILTER_DISABLE.

Referenced by nii_open().

◆ nii_transmit()

static int nii_transmit ( struct net_device netdev,
struct io_buffer iobuf 
)
static

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 983 of file nii.c.

984  {
985  struct nii_nic *nii = netdev->priv;
986  PXE_CPB_TRANSMIT cpb;
987  unsigned int op;
988  int stat;
989  int rc;
990 
991  /* Defer the packet if there is already a transmission in progress */
992  if ( nii->txbuf ) {
993  netdev_tx_defer ( netdev, iobuf );
994  return 0;
995  }
996 
997  /* Pad to minimum Ethernet length, to work around underlying
998  * drivers that do not correctly handle frame padding
999  * themselves.
1000  */
1001  iob_pad ( iobuf, ETH_ZLEN );
1002 
1003  /* Construct parameter block */
1004  memset ( &cpb, 0, sizeof ( cpb ) );
1005  cpb.FrameAddr = ( ( intptr_t ) iobuf->data );
1006  cpb.DataLen = iob_len ( iobuf );
1007 
1008  /* Transmit packet */
1012  if ( ( stat = nii_issue_cpb ( nii, op, &cpb, sizeof ( cpb ) ) ) < 0 ) {
1013  rc = -EIO_STAT ( stat );
1014  DBGC ( nii, "NII %s could not transmit: %s\n",
1015  nii->dev.name, strerror ( rc ) );
1016  return rc;
1017  }
1018  nii->txbuf = iobuf;
1019 
1020  return 0;
1021 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
Definition: netdevice.c:413
uint32_t stat
Completion status.
Definition: dwmac.h:12
PXE_UINT32 DataLen
Length of the data portion of the frame buffer in bytes.
Definition: UefiPxe.h:1675
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
unsigned long intptr_t
Definition: stdint.h:21
PXE_UINT64 FrameAddr
Address of first byte of frame buffer.
Definition: UefiPxe.h:1669
An NII NIC.
Definition: nii.c:154
#define PXE_OPFLAGS_TRANSMIT_WHOLE
Definition: UefiPxe.h:393
#define PXE_OPCODE_TRANSMIT
Transmit packet(s).
Definition: UefiPxe.h:168
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:160
#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK
Definition: UefiPxe.h:389
#define ETH_ZLEN
Definition: if_ether.h:11
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
void * data
Start of data.
Definition: iobuf.h:53
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition: iobpad.c:50
static int nii_issue_cpb(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len)
Issue command with parameter block.
Definition: nii.c:607
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529
void * memset(void *dest, int character, size_t len) __nonnull

References io_buffer::data, s_pxe_cpb_transmit::DataLen, DBGC, EIO_STAT, ETH_ZLEN, s_pxe_cpb_transmit::FrameAddr, iob_len(), iob_pad(), memset(), netdev, netdev_tx_defer(), nii_nic::nii, nii_issue_cpb(), NII_OP, op, net_device::priv, PXE_OPCODE_TRANSMIT, PXE_OPFLAGS_TRANSMIT_DONT_BLOCK, PXE_OPFLAGS_TRANSMIT_WHOLE, rc, stat, and strerror().

◆ nii_poll_tx()

static void nii_poll_tx ( struct net_device netdev,
unsigned int  stat 
)
static

Poll for completed packets.

Parameters
netdevNetwork device
statStatus flags

Definition at line 1029 of file nii.c.

1029  {
1030  struct nii_nic *nii = netdev->priv;
1031  struct io_buffer *iobuf;
1032 
1033  /* Do nothing unless we have a completion */
1035  return;
1036 
1037  /* Ignore spurious completions reported by some devices */
1038  if ( ! nii->txbuf )
1039  return;
1040 
1041  /* Complete transmission */
1042  iobuf = nii->txbuf;
1043  nii->txbuf = NULL;
1044  netdev_tx_complete ( netdev, iobuf );
1045 }
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition: netdevice.h:767
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN
This flag is set if no transmitted buffer addresses were written into the DB.
Definition: UefiPxe.h:572
An NII NIC.
Definition: nii.c:154
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
struct io_buffer * txbuf
Current transmit buffer.
Definition: nii.c:192
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
A persistent I/O buffer.
Definition: iobuf.h:38

References netdev, netdev_tx_complete(), nii_nic::nii, NULL, net_device::priv, PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN, stat, and nii_nic::txbuf.

Referenced by nii_poll().

◆ nii_poll_rx()

static void nii_poll_rx ( struct net_device netdev)
static

Poll for received packets.

Parameters
netdevNetwork device

Definition at line 1052 of file nii.c.

1052  {
1053  struct nii_nic *nii = netdev->priv;
1054  PXE_CPB_RECEIVE cpb;
1056  unsigned int quota;
1057  int stat;
1058  int rc;
1059 
1060  /* Retrieve up to NII_RX_QUOTA packets */
1061  for ( quota = NII_RX_QUOTA ; quota ; quota-- ) {
1062 
1063  /* Allocate buffer, if required */
1064  if ( ! nii->rxbuf ) {
1065  nii->rxbuf = alloc_iob ( nii->mtu );
1066  if ( ! nii->rxbuf ) {
1067  /* Leave for next poll */
1068  break;
1069  }
1070  }
1071 
1072  /* Construct parameter block */
1073  memset ( &cpb, 0, sizeof ( cpb ) );
1074  cpb.BufferAddr = ( ( intptr_t ) nii->rxbuf->data );
1075  cpb.BufferLen = iob_tailroom ( nii->rxbuf );
1076 
1077  /* Issue command */
1079  &cpb, sizeof ( cpb ),
1080  &db, sizeof ( db ) ) ) < 0 ) {
1081 
1082  /* PXE_STATCODE_NO_DATA is just the usual "no packet"
1083  * status indicator; ignore it.
1084  */
1085  if ( stat == -PXE_STATCODE_NO_DATA )
1086  break;
1087 
1088  /* Anything else is an error */
1089  rc = -EIO_STAT ( stat );
1090  DBGC ( nii, "NII %s could not receive: %s\n",
1091  nii->dev.name, strerror ( rc ) );
1092  netdev_rx_err ( netdev, NULL, rc );
1093  break;
1094  }
1095 
1096  /* Hand off to network stack */
1097  iob_put ( nii->rxbuf, db.FrameLen );
1098  netdev_rx ( netdev, nii->rxbuf );
1099  nii->rxbuf = NULL;
1100  }
1101 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:125
PXE_UINT32 BufferLen
Length of receive buffer.
Definition: UefiPxe.h:1738
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition: netdevice.c:587
uint32_t stat
Completion status.
Definition: dwmac.h:12
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
unsigned long intptr_t
Definition: stdint.h:21
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:131
An NII NIC.
Definition: nii.c:154
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
PXE_UINT64 BufferAddr
Address of first byte of receive buffer.
Definition: UefiPxe.h:1731
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:180
static int nii_issue_cpb_db(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len, void *db, size_t db_len)
Issue command with parameter block and data block.
Definition: nii.c:558
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:549
static struct dmfe_private * db
Definition: dmfe.c:177
#define PXE_STATCODE_NO_DATA
Definition: UefiPxe.h:625
#define PXE_OPCODE_RECEIVE
Receive packet.
Definition: UefiPxe.h:173
#define NII_RX_QUOTA
Maximum number of received packets per poll.
Definition: nii.c:201
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_iob(), s_pxe_cpb_receive::BufferAddr, s_pxe_cpb_receive::BufferLen, db, DBGC, EIO_STAT, iob_put, iob_tailroom(), memset(), netdev, netdev_rx(), netdev_rx_err(), nii_nic::nii, nii_issue_cpb_db(), NII_RX_QUOTA, NULL, net_device::priv, PXE_OPCODE_RECEIVE, PXE_STATCODE_NO_DATA, rc, stat, and strerror().

Referenced by nii_poll().

◆ nii_poll_link()

static void nii_poll_link ( struct net_device netdev,
unsigned int  stat 
)
static

Check for link state changes.

Parameters
netdevNetwork device
statStatus flags

Definition at line 1109 of file nii.c.

1109  {
1110  int no_media = ( stat & PXE_STATFLAGS_GET_STATUS_NO_MEDIA );
1111 
1112  if ( no_media && netdev_link_ok ( netdev ) ) {
1114  } else if ( ( ! no_media ) && ( ! netdev_link_ok ( netdev ) ) ) {
1115  netdev_link_up ( netdev );
1116  }
1117 }
uint32_t stat
Completion status.
Definition: dwmac.h:12
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:231
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:789
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:640
static struct net_device * netdev
Definition: gdbudp.c:52
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA
This flag is set if there is no media detected.
Definition: UefiPxe.h:577

References netdev, netdev_link_down(), netdev_link_ok(), netdev_link_up(), PXE_STATFLAGS_GET_STATUS_NO_MEDIA, and stat.

Referenced by nii_poll().

◆ nii_poll()

static void nii_poll ( struct net_device netdev)
static

Poll for completed packets.

Parameters
netdevNetwork device

Definition at line 1124 of file nii.c.

1124  {
1125  struct nii_nic *nii = netdev->priv;
1127  unsigned int op;
1128  int stat;
1129  int rc;
1130 
1131  /* Construct data block */
1132  memset ( &db, 0, sizeof ( db ) );
1133 
1134  /* Get status */
1138  ( nii->media ? PXE_OPFLAGS_GET_MEDIA_STATUS : 0 ) ) );
1139  if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
1140  rc = -EIO_STAT ( stat );
1141  DBGC ( nii, "NII %s could not get status: %s\n",
1142  nii->dev.name, strerror ( rc ) );
1143  return;
1144  }
1145 
1146  /* Process any TX completions */
1147  nii_poll_tx ( netdev, stat );
1148 
1149  /* Process any RX completions */
1150  nii_poll_rx ( netdev );
1151 
1152  /* Check for link state changes */
1153  if ( nii->media )
1154  nii_poll_link ( netdev, stat );
1155 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void nii_poll_link(struct net_device *netdev, unsigned int stat)
Check for link state changes.
Definition: nii.c:1109
uint32_t stat
Completion status.
Definition: dwmac.h:12
static int nii_issue_db(struct nii_nic *nii, unsigned int op, void *db, size_t db_len)
Issue command with data block.
Definition: nii.c:622
#define DBGC(...)
Definition: compiler.h:505
#define EIO_STAT(stat)
Definition: nii.c:127
#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
Return list of transmitted buffers for recycling.
Definition: UefiPxe.h:365
static void nii_poll_tx(struct net_device *netdev, unsigned int stat)
Poll for completed packets.
Definition: nii.c:1029
An NII NIC.
Definition: nii.c:154
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
#define PXE_OPFLAGS_GET_INTERRUPT_STATUS
UNDI Get Status.
Definition: UefiPxe.h:355
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
#define PXE_OPCODE_GET_STATUS
Get & clear interrupt status.
Definition: UefiPxe.h:158
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static struct dmfe_private * db
Definition: dmfe.c:177
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
static void nii_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: nii.c:1052
#define PXE_OPFLAGS_GET_MEDIA_STATUS
Return current media status.
Definition: UefiPxe.h:370
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
Definition: nii.c:529
void * memset(void *dest, int character, size_t len) __nonnull

References db, DBGC, EIO_STAT, memset(), netdev, nii_nic::nii, nii_issue_db(), NII_OP, nii_poll_link(), nii_poll_rx(), nii_poll_tx(), op, net_device::priv, PXE_OPCODE_GET_STATUS, PXE_OPFLAGS_GET_INTERRUPT_STATUS, PXE_OPFLAGS_GET_MEDIA_STATUS, PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS, rc, stat, and strerror().

◆ nii_open()

static int nii_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 1163 of file nii.c.

1163  {
1164  struct nii_nic *nii = netdev->priv;
1165  int rc;
1166 
1167  /* Initialise NIC
1168  *
1169  * We don't care about link state here, and would prefer to
1170  * have the NIC initialise even if no cable is present, to
1171  * match the behaviour of all other iPXE drivers.
1172  *
1173  * Some Emulex NII drivers have a bug which prevents packets
1174  * from being sent or received unless we specifically ask it
1175  * to detect cable presence during initialisation.
1176  *
1177  * Unfortunately, some other NII drivers (e.g. Mellanox) may
1178  * time out and report failure if asked to detect cable
1179  * presence during initialisation on links that are physically
1180  * slow to reach link-up.
1181  *
1182  * Attempt to work around both of these problems by first
1183  * attempting to initialise with cable presence detection,
1184  * then falling back to initialising without cable presence
1185  * detection.
1186  */
1187  if ( ( rc = nii_initialise_cable ( nii ) ) != 0 ) {
1188  DBGC ( nii, "NII %s could not initialise with cable "
1189  "detection: %s\n", nii->dev.name, strerror ( rc ) );
1190  if ( ( rc = nii_initialise ( nii ) ) != 0 ) {
1191  DBGC ( nii, "NII %s could not initialise without "
1192  "cable detection: %s\n",
1193  nii->dev.name, strerror ( rc ) );
1194  goto err_initialise;
1195  }
1196  }
1197 
1198  /* Attempt to set station address */
1199  if ( ( rc = nii_set_station_address ( nii, netdev ) ) != 0 ) {
1200  DBGC ( nii, "NII %s could not set station address: %s\n",
1201  nii->dev.name, strerror ( rc ) );
1202  /* Treat as non-fatal */
1203  }
1204 
1205  /* Disable receive filters
1206  *
1207  * We have no reason to disable receive filters here (or
1208  * anywhere), but some NII drivers have a bug which prevents
1209  * packets from being received unless we attempt to disable
1210  * the receive filters.
1211  *
1212  * Ignore any failures, since we genuinely don't care if the
1213  * NII driver cannot disable the filters.
1214  */
1216 
1217  /* Enable receive filters */
1218  if ( ( rc = nii_enable_rx_filters ( nii ) ) != 0 )
1219  goto err_enable_rx_filters;
1220 
1221  return 0;
1222 
1223  err_enable_rx_filters:
1224  nii_shutdown ( nii );
1225  err_initialise:
1226  return rc;
1227 }
static int nii_disable_rx_filters(struct nii_nic *nii)
Disable receive filters.
Definition: nii.c:971
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static void nii_shutdown(struct nii_nic *nii)
Shut down UNDI.
Definition: nii.c:820
An NII NIC.
Definition: nii.c:154
static int nii_set_station_address(struct nii_nic *nii, struct net_device *netdev)
Set station address.
Definition: nii.c:886
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
static int nii_initialise_cable(struct nii_nic *nii)
Initialise UNDI with cable detection.
Definition: nii.c:793
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static int nii_initialise(struct nii_nic *nii)
Initialise UNDI.
Definition: nii.c:807
static int nii_enable_rx_filters(struct nii_nic *nii)
Enable receive filters.
Definition: nii.c:960

References DBGC, netdev, nii_nic::nii, nii_disable_rx_filters(), nii_enable_rx_filters(), nii_initialise(), nii_initialise_cable(), nii_set_station_address(), nii_shutdown(), net_device::priv, rc, and strerror().

◆ nii_close()

static void nii_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 1234 of file nii.c.

1234  {
1235  struct nii_nic *nii = netdev->priv;
1236 
1237  /* Shut down NIC */
1238  nii_shutdown ( nii );
1239 
1240  /* Discard transmit buffer, if applicable */
1241  if ( nii->txbuf ) {
1243  nii->txbuf = NULL;
1244  }
1245 
1246  /* Discard receive buffer, if applicable */
1247  if ( nii->rxbuf ) {
1248  free_iob ( nii->rxbuf );
1249  nii->rxbuf = NULL;
1250  }
1251 }
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:153
#define ECANCELED
Operation canceled.
Definition: errno.h:344
static void nii_shutdown(struct nii_nic *nii)
Shut down UNDI.
Definition: nii.c:820
An NII NIC.
Definition: nii.c:154
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition: netdevice.c:471
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

References ECANCELED, free_iob(), netdev, netdev_tx_complete_err(), nii_nic::nii, nii_shutdown(), NULL, and net_device::priv.

◆ nii_exclude()

int nii_exclude ( EFI_HANDLE  device)

Exclude existing drivers.

Parameters
deviceEFI device handle
Return values
rcReturn status code

Definition at line 1267 of file nii.c.

1267  {
1269  int rc;
1270 
1271  /* Exclude existing NII protocol drivers */
1272  if ( ( rc = efi_driver_exclude ( device, protocol ) ) != 0 ) {
1273  DBGC ( device, "NII %s could not exclude drivers: %s\n",
1274  efi_handle_name ( device ), strerror ( rc ) );
1275  return rc;
1276  }
1277 
1278  return 0;
1279 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:309
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
#define DBGC(...)
Definition: compiler.h:505
A hardware device.
Definition: device.h:77
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
int efi_driver_exclude(EFI_HANDLE device, EFI_GUID *protocol)
Try to disconnect an existing EFI driver.
Definition: efi_driver.c:438
uint16_t protocol
Protocol ID.
Definition: stp.h:19

References DBGC, efi_driver_exclude(), efi_handle_name(), efi_nii31_protocol_guid, protocol, rc, and strerror().

◆ nii_start()

int nii_start ( struct efi_device efidev)

Attach driver to device.

Parameters
efidevEFI device
Return values
rcReturn status code

Definition at line 1287 of file nii.c.

1287  {
1289  struct net_device *netdev;
1290  struct nii_nic *nii;
1291  int rc;
1292 
1293  /* Allocate and initialise structure */
1294  netdev = alloc_netdev ( sizeof ( *nii ) );
1295  if ( ! netdev ) {
1296  rc = -ENOMEM;
1297  goto err_alloc;
1298  }
1300  nii = netdev->priv;
1301  nii->efidev = efidev;
1302  INIT_LIST_HEAD ( &nii->mappings );
1303  netdev->ll_broadcast = nii->broadcast;
1305 
1306  /* Populate underlying device information */
1307  efi_device_info ( device, "NII", &nii->dev );
1308  nii->dev.driver_name = "NII";
1309  nii->dev.parent = &efidev->dev;
1310  list_add ( &nii->dev.siblings, &efidev->dev.children );
1311  INIT_LIST_HEAD ( &nii->dev.children );
1312  netdev->dev = &nii->dev;
1313 
1314  /* Open NII protocol */
1316  &nii->nii ) ) != 0 ) {
1317  DBGC ( nii, "NII %s cannot open NII protocol: %s\n",
1318  nii->dev.name, strerror ( rc ) );
1320  goto err_open_protocol;
1321  }
1322 
1323  /* Locate UNDI and entry point */
1324  nii->undi = ( ( void * ) ( intptr_t ) nii->nii->Id );
1325  if ( ! nii->undi ) {
1326  DBGC ( nii, "NII %s has no UNDI\n", nii->dev.name );
1327  rc = -ENODEV;
1328  goto err_no_undi;
1329  }
1330  if ( nii->undi->Implementation & PXE_ROMID_IMP_HW_UNDI ) {
1331  DBGC ( nii, "NII %s is a mythical hardware UNDI\n",
1332  nii->dev.name );
1333  rc = -ENOTSUP;
1334  goto err_hw_undi;
1335  }
1336  if ( nii->undi->Implementation & PXE_ROMID_IMP_SW_VIRT_ADDR ) {
1337  nii->issue = ( ( void * ) ( intptr_t ) nii->undi->EntryPoint );
1338  } else {
1339  nii->issue = ( ( ( void * ) nii->undi ) +
1340  nii->undi->EntryPoint );
1341  }
1342  DBGC ( nii, "NII %s using UNDI v%x.%x at %p entry %p impl %#08x\n",
1343  nii->dev.name, nii->nii->MajorVer, nii->nii->MinorVer,
1344  nii->undi, nii->issue, nii->undi->Implementation );
1345 
1346  /* Open PCI I/O protocols and locate BARs */
1347  if ( ( rc = nii_pci_open ( nii ) ) != 0 )
1348  goto err_pci_open;
1349 
1350  /* Start UNDI */
1351  if ( ( rc = nii_start_undi ( nii ) ) != 0 )
1352  goto err_start_undi;
1353 
1354  /* Get initialisation information */
1355  if ( ( rc = nii_get_init_info ( nii, netdev ) ) != 0 )
1356  goto err_get_init_info;
1357 
1358  /* Get MAC addresses */
1359  if ( ( rc = nii_get_station_address ( nii, netdev ) ) != 0 )
1360  goto err_get_station_address;
1361 
1362  /* Register network device */
1363  if ( ( rc = register_netdev ( netdev ) ) != 0 )
1364  goto err_register_netdev;
1365  DBGC ( nii, "NII %s registered as %s for %s\n", nii->dev.name,
1367 
1368  /* Set initial link state (if media detection is not supported) */
1369  if ( ! nii->media )
1370  netdev_link_up ( netdev );
1371 
1372  return 0;
1373 
1375  err_register_netdev:
1376  err_get_station_address:
1377  err_get_init_info:
1378  nii_stop_undi ( nii );
1379  err_start_undi:
1380  nii_pci_close ( nii );
1381  err_pci_open:
1382  err_hw_undi:
1383  err_no_undi:
1385  err_open_protocol:
1386  list_del ( &nii->dev.siblings );
1387  netdev_nullify ( netdev );
1388  netdev_put ( netdev );
1389  err_alloc:
1390  return rc;
1391 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:309
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:70
#define DBGC(...)
Definition: compiler.h:505
const uint8_t * ll_broadcast
Link-layer broadcast address.
Definition: netdevice.h:390
#define DBGC_EFI_OPENERS(...)
Definition: efi.h:345
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:22
unsigned long intptr_t
Definition: stdint.h:21
#define ENOTSUP
Operation not supported.
Definition: errno.h:590
UINT64 Id
The address of the first byte of the identifying structure for this network interface.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:519
struct net_device * alloc_netdev(size_t priv_len)
Allocate network device.
Definition: netdevice.c:722
#define list_del(list)
Delete an entry from a list.
Definition: list.h:120
#define ENOMEM
Not enough space.
Definition: errno.h:535
An NII NIC.
Definition: nii.c:154
A hardware device.
Definition: device.h:77
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:576
void efi_close_by_driver(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for persistent use by a driver.
Definition: efi_open.c:279
void * priv
Driver private data.
Definition: netdevice.h:432
#define efi_open_by_driver(handle, protocol, interface)
Open protocol for persistent use by a driver.
Definition: efi.h:474
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:789
static struct net_device * netdev
Definition: gdbudp.c:52
#define PXE_ROMID_IMP_HW_UNDI
Implementation flags.
Definition: UefiPxe.h:853
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:942
static struct net_device_operations nii_operations
NII network device operations.
Definition: nii.c:1254
#define PXE_ROMID_IMP_SW_VIRT_ADDR
Definition: UefiPxe.h:854
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:79
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:760
A network device.
Definition: netdevice.h:353
struct efi_device * efidev
EFI device.
Definition: nii.c:156
#define ENODEV
No such device.
Definition: errno.h:510
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:532
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
struct device * dev
Underlying hardware device.
Definition: netdevice.h:365
static int nii_get_station_address(struct nii_nic *nii, struct net_device *netdev)
Get station addresses.
Definition: nii.c:844
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:46
char name[NETDEV_NAME_LEN]
Name of this network device.
Definition: netdevice.h:363
static int nii_start_undi(struct nii_nic *nii)
Start UNDI.
Definition: nii.c:647
struct list_head children
Devices attached to this device.
Definition: device.h:87
static void nii_pci_close(struct nii_nic *nii)
Close PCI I/O protocol.
Definition: nii.c:293
static int nii_get_init_info(struct nii_nic *nii, struct net_device *netdev)
Get initialisation information.
Definition: nii.c:700
static void nii_stop_undi(struct nii_nic *nii)
Stop UNDI.
Definition: nii.c:679
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
Definition: efi_driver.h:84
struct device dev
Generic device.
Definition: efi_driver.h:20
Definition: efi.h:62
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
Definition: efi_utils.c:189
static int nii_pci_open(struct nii_nic *nii)
Open PCI I/O protocol and identify BARs.
Definition: nii.c:209

References alloc_netdev(), device::children, DBGC, DBGC_EFI_OPENERS, efi_device::dev, net_device::dev, efi_device::device, efi_close_by_driver(), efi_device_info(), efi_handle_name(), efi_nii31_protocol_guid, efi_open_by_driver, nii_nic::efidev, efidev_set_drvdata(), ENODEV, ENOMEM, ENOTSUP, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::Id, INIT_LIST_HEAD, list_add, list_del, net_device::ll_broadcast, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::MajorVer, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::MinorVer, net_device::name, netdev, netdev_init(), netdev_link_up(), netdev_nullify(), netdev_put(), nii_nic::nii, nii_get_init_info(), nii_get_station_address(), nii_operations, nii_pci_close(), nii_pci_open(), nii_start_undi(), nii_stop_undi(), net_device::priv, PXE_ROMID_IMP_HW_UNDI, PXE_ROMID_IMP_SW_VIRT_ADDR, rc, register_netdev(), strerror(), and unregister_netdev().

◆ nii_stop()

void nii_stop ( struct efi_device efidev)

Detach driver from device.

Parameters
efidevEFI device

Definition at line 1398 of file nii.c.

1398  {
1399  struct net_device *netdev = efidev_get_drvdata ( efidev );
1400  struct nii_nic *nii = netdev->priv;
1402 
1403  /* Unregister network device */
1405 
1406  /* Stop UNDI */
1407  nii_stop_undi ( nii );
1408 
1409  /* Close PCI I/O protocols */
1410  nii_pci_close ( nii );
1411 
1412  /* Close NII protocol */
1414 
1415  /* Free network device */
1416  list_del ( &nii->dev.siblings );
1417  netdev_nullify ( netdev );
1418  netdev_put ( netdev );
1419 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:309
EFI_HANDLE device
EFI device handle.
Definition: efi_driver.h:22
#define list_del(list)
Delete an entry from a list.
Definition: list.h:120
An NII NIC.
Definition: nii.c:154
A hardware device.
Definition: device.h:77
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:576
void efi_close_by_driver(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for persistent use by a driver.
Definition: efi_open.c:279
void * priv
Driver private data.
Definition: netdevice.h:432
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:942
static void * efidev_get_drvdata(struct efi_device *efidev)
Get EFI driver-private data.
Definition: efi_driver.h:95
A network device.
Definition: netdevice.h:353
struct efi_device * efidev
EFI device.
Definition: nii.c:156
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:532
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
Definition: nii.c:158
static void nii_pci_close(struct nii_nic *nii)
Close PCI I/O protocol.
Definition: nii.c:293
static void nii_stop_undi(struct nii_nic *nii)
Stop UNDI.
Definition: nii.c:679
Definition: efi.h:62

References efi_device::device, efi_close_by_driver(), efi_nii31_protocol_guid, nii_nic::efidev, efidev_get_drvdata(), list_del, netdev, netdev_nullify(), netdev_put(), nii_nic::nii, nii_pci_close(), nii_stop_undi(), net_device::priv, and unregister_netdev().

Variable Documentation

◆ nii_operations

struct net_device_operations nii_operations
static
Initial value:
= {
.open = nii_open,
.close = nii_close,
.transmit = nii_transmit,
.poll = nii_poll,
}
static void nii_poll(struct net_device *netdev)
Poll for completed packets.
Definition: nii.c:1124
static int nii_open(struct net_device *netdev)
Open network device.
Definition: nii.c:1163
static void nii_close(struct net_device *netdev)
Close network device.
Definition: nii.c:1234
static int nii_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: nii.c:983

NII network device operations.

Definition at line 1254 of file nii.c.

Referenced by nii_start().