|
| | 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.
|
| static void | nii_pci_close (struct nii_nic *nii) |
| | Close PCI I/O protocol.
|
| static EFIAPI VOID | nii_io (UINT64 unique_id, UINT8 op, UINT8 len, UINT64 addr, UINT64 data) |
| | I/O callback.
|
| static EFIAPI VOID | nii_map (UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped) |
| | Map callback.
|
| static EFIAPI VOID | nii_unmap (UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir __unused, UINT64 mapped) |
| | Unmap callback.
|
| static EFIAPI VOID | nii_sync (UINT64 unique_id __unused, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped) |
| | Sync callback.
|
| static EFIAPI VOID | nii_delay (UINT64 unique_id __unused, UINTN microseconds) |
| | Delay callback.
|
| static EFIAPI VOID | nii_block (UINT64 unique_id, UINT32 acquire) |
| | Block callback.
|
| 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.
|
| static int | nii_issue_cpb (struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len) |
| | Issue command with parameter block.
|
| static int | nii_issue_db (struct nii_nic *nii, unsigned int op, void *db, size_t db_len) |
| | Issue command with data block.
|
| static int | nii_issue (struct nii_nic *nii, unsigned int op) |
| | Issue command.
|
| static int | nii_start_undi (struct nii_nic *nii) |
| | Start UNDI.
|
| static void | nii_stop_undi (struct nii_nic *nii) |
| | Stop UNDI.
|
| static int | nii_get_init_info (struct nii_nic *nii, struct net_device *netdev) |
| | Get initialisation information.
|
| static int | nii_initialise_flags (struct nii_nic *nii, unsigned int flags) |
| | Initialise UNDI.
|
| static int | nii_initialise_cable (struct nii_nic *nii) |
| | Initialise UNDI with cable detection.
|
| static int | nii_initialise (struct nii_nic *nii) |
| | Initialise UNDI.
|
| static void | nii_shutdown (struct nii_nic *nii) |
| | Shut down UNDI.
|
| static int | nii_get_station_address (struct nii_nic *nii, struct net_device *netdev) |
| | Get station addresses.
|
| static int | nii_set_station_address (struct nii_nic *nii, struct net_device *netdev) |
| | Set station address.
|
| static int | nii_set_rx_filters (struct nii_nic *nii, unsigned int flags) |
| | Set receive filters.
|
| static int | nii_enable_rx_filters (struct nii_nic *nii) |
| | Enable receive filters.
|
| static int | nii_disable_rx_filters (struct nii_nic *nii) |
| | Disable receive filters.
|
| static int | nii_transmit (struct net_device *netdev, struct io_buffer *iobuf) |
| | Transmit packet.
|
| static void | nii_poll_tx (struct net_device *netdev, unsigned int stat) |
| | Poll for completed packets.
|
| static void | nii_poll_rx (struct net_device *netdev) |
| | Poll for received packets.
|
| static void | nii_poll_link (struct net_device *netdev, unsigned int stat) |
| | Check for link state changes.
|
| static void | nii_poll (struct net_device *netdev) |
| | Poll for completed packets.
|
| static int | nii_open (struct net_device *netdev) |
| | Open network device.
|
| static void | nii_close (struct net_device *netdev) |
| | Close network device.
|
| int | nii_exclude (EFI_HANDLE device) |
| | Exclude existing drivers.
|
| int | nii_start (struct efi_device *efidev) |
| | Attach driver to device.
|
| void | nii_stop (struct efi_device *efidev) |
| | Detach driver from device.
|
NII driver.
Definition in file nii.c.
| int nii_pci_open |
( |
struct nii_nic * | nii | ) |
|
|
static |
Open PCI I/O protocol and identify BARs.
- Parameters
-
- Return values
-
Definition at line 209 of file nii.c.
209 {
213 union {
215 void *resource;
217 int bar;
220
221
224 DBGC ( nii,
"NII %s could not locate PCI I/O protocol: %s\n",
226 goto err_locate;
227 }
229
230
231
232
233
234
235
238 DBGC ( nii,
"NII %s could not open PCI I/O protocol: %s\n",
240 goto err_open;
241 }
242
243
246 for ( bar = (
PCI_MAX_BAR - 1 ) ; bar >= 0 ; bar-- ) {
250
251 continue;
252 }
253 if ( efirc != 0 ) {
255 DBGC ( nii,
"NII %s could not get BAR %d attributes: "
257 goto err_get_bar_attributes;
258 }
263 }
265 }
269 } else {
270 DBGC ( nii,
"no memory BAR and " );
271 }
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:
285}
#define ACPI_ADDRESS_SPACE_TYPE_IO
PACKED struct @070126363266142000122014272037224307124317056203 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR
The common definition of QWORD, DWORD, and WORD Address Space Descriptors.
#define ACPI_ADDRESS_SPACE_TYPE_MEM
#define NULL
NULL pointer (VOID *)
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct arbelprm_rc_send_wqe rc
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
void efi_close_unsafe(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for unsafe persistent use.
int efi_locate_device(EFI_HANDLE device, EFI_GUID *protocol, EFI_HANDLE *parent, unsigned int skip)
Locate parent device supporting a given protocol.
struct ena_llq_option desc
Descriptor counts.
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
#define efi_open_unsafe(handle, protocol, interface)
Open protocol for unsafe persistent use.
EFI_SYSTEM_TABLE * efi_systab
#define PCI_MAX_BAR
Maximum PCI BAR.
char * strerror(int errno)
Retrieve string representation of error number.
EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes
EFI_HANDLE device
EFI device handle.
struct device dev
Generic device.
unsigned int io_bar
I/O BAR.
unsigned int mem_bar
Memory BAR.
struct efi_device * efidev
EFI device.
EFI_HANDLE pci_device
PCI device.
EFI_PCI_IO_PROTOCOL * pci_io
PCI I/O protocol.
References acpi, ACPI_ADDRESS_SPACE_TYPE_IO, ACPI_ADDRESS_SPACE_TYPE_MEM, DBGC, desc, nii_nic::dev, efi_device::device, EEFI, efi_close_unsafe(), EFI_HANDLE, 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().
| void nii_pci_close |
( |
struct nii_nic * | nii | ) |
|
|
static |
Close PCI I/O protocol.
- Parameters
-
- Return values
-
Definition at line 293 of file nii.c.
293 {
296
297
299 DBGC ( nii,
"NII %s removing stale mapping %#llx\n",
300 nii->
dev.
name, ( (
unsigned long long )
map->addr ) );
304 }
305
306
308}
static __always_inline int struct dma_mapping * map
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
#define list_del(list)
Delete an entry from a list.
static void(* free)(struct refcnt *refcnt))
EFI_PCI_IO_PROTOCOL_UNMAP Unmap
struct list_head list
List of mappings.
struct list_head mappings
Mapping list.
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().
I/O callback.
- Parameters
-
| unique_id | NII NIC |
| op | Operations |
| len | Length of data |
| addr | Address |
| data | Data buffer |
Definition at line 319 of file nii.c.
320 {
325 unsigned int bar;
328
329
331 access = &
nii->pci_io->Mem;
333 } else {
334 access = &
nii->pci_io->Io;
336 }
337
338
341
342
343 width = (
fls (
len ) - 1 );
344
345
346 if ( ( efirc = io (
nii->pci_io, width, bar,
addr, 1,
349 DBGC (
nii,
"NII %s I/O operation %#x failed: %s\n",
351
352 return;
353 }
354}
EFI_PCI_IO_PROTOCOL_WIDTH
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.
uint32_t addr
Buffer address.
uint8_t data[48]
Additional event data.
#define fls(x)
Find last (i.e.
EFI_PCI_IO_PROTOCOL_IO_MEM Write
Write PCI controller registers in the PCI memory or I/O space.
EFI_PCI_IO_PROTOCOL_IO_MEM Read
Read PCI controller registers in the PCI memory or I/O space.
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL * nii
Network interface identifier protocol.
References addr, data, DBGC, EEFI, EFIAPI, fls, len, nii_nic::nii, op, PXE_IO_WRITE, PXE_MEM_READ, PXE_MEM_WRITE, rc, EFI_PCI_IO_PROTOCOL_ACCESS::Read, strerror(), VOID, and EFI_PCI_IO_PROTOCOL_ACCESS::Write.
Referenced by nii_start_undi().
Map callback.
- Parameters
-
| unique_id | NII NIC |
| addr | Address of memory to be mapped |
| len | Length of memory to be mapped |
| dir | Direction of data flow |
| mapped | Device mapped address to fill in |
Definition at line 365 of file nii.c.
366 {
374
375
377
378
379 switch ( dir ) {
382 break;
385 break;
388 break;
389 default:
390 DBGC ( nii,
"NII %s unsupported mapping direction %d\n",
392 goto err_dir;
393 }
394
395
398 goto err_alloc;
400
401
406 DBGC ( nii,
"NII %s map operation failed: %s\n",
408 goto err_map;
409 }
410
411
413 DBGC2 ( nii,
"NII %s mapped %#llx+%#x->%#llx\n",
415 len, ( (
unsigned long long ) *
phys ) );
416 return;
417
419 err_map:
421 err_alloc:
422 err_dir:
423 return;
424}
UINT64 UINTN
Unsigned value of native width.
EFI_PCI_IO_PROTOCOL_OPERATION
@ EfiPciIoOperationBusMasterWrite
A write operation from system memory by a bus master.
@ EfiPciIoOperationBusMasterRead
A read operation from system memory by a bus master.
@ EfiPciIoOperationBusMasterCommonBuffer
Provides both read and write access to system memory by both the processor and a bus master.
UINT64 EFI_PHYSICAL_ADDRESS
64-bit physical memory address.
#define TO_AND_FROM_DEVICE
static signed char phys[4]
static unsigned int count
Number of entries.
#define list_add(new, head)
Add a new entry to the head of a list.
void * zalloc(size_t size)
Allocate cleared memory.
EFI_PCI_IO_PROTOCOL_MAP Map
References addr, count, DBGC, DBGC2, nii_nic::dev, EEFI, EFIAPI, EfiPciIoOperationBusMasterCommonBuffer, EfiPciIoOperationBusMasterRead, EfiPciIoOperationBusMasterWrite, free, FROM_DEVICE, len, list_add, list_del, _EFI_PCI_IO_PROTOCOL::Map, map, nii_nic::mappings, device::name, nii_nic::nii, op, nii_nic::pci_io, phys, rc, strerror(), TO_AND_FROM_DEVICE, TO_DEVICE, VOID, and zalloc().
Referenced by nii_start_undi().
Unmap callback.
- Parameters
-
| unique_id | NII NIC |
| addr | Address of mapped memory |
| len | Length of mapped memory |
| dir | Direction of data flow |
| mapped | Device mapped address |
Definition at line 435 of file nii.c.
436 {
439
440
446 DBGC2 ( nii,
"NII %s unmapped %#llx+%#x->%#llx\n",
448 len, ( (
unsigned long long ) mapped ) );
449 return;
450 }
451 }
452
453 DBGC ( nii,
"NII %s non-existent mapping %#llx+%#x->%#llx\n",
455 len, ( (
unsigned long long ) mapped ) );
456}
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
References __unused, addr, DBGC, DBGC2, nii_nic::dev, EFIAPI, free, len, nii_mapping::list, list_del, list_for_each_entry, map, nii_nic::mappings, device::name, nii_nic::nii, nii_nic::pci_io, _EFI_PCI_IO_PROTOCOL::Unmap, and VOID.
Referenced by nii_start_undi().
| 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
-
| nii | NII NIC |
| op | Operation |
| cpb | Command parameter block, or NULL |
| cpb_len | Command parameter block length |
| db | Data block, or NULL |
| db_len | Data block length |
- Return values
-
| stat | Status flags, or negative status code |
Definition at line 558 of file nii.c.
559 {
563
564
565 memset ( &cdb, 0,
sizeof ( cdb ) );
573
574
576
577
578 DBGC2 ( nii,
"NII %s issuing %02x:%04x ifnum %d%s%s\n",
580 ( cpb ?
" cpb" :
"" ), (
db ?
" db" :
"" ) );
581 if ( cpb )
586
587
589
590
592 return -cdb.StatCode;
593
594
596}
#define PXE_STATFLAGS_STATUS_MASK
Common StatFlags that can be returned by all commands.
#define PXE_STATCODE_SUCCESS
Common StatCodes returned by all UNDI commands, UNDI protocol functions and BC protocol functions.
static struct dmfe_private * db
EFI_TPL efi_internal_tpl
Internal task priority level.
void * memset(void *dest, int character, size_t len) __nonnull
#define NII_OPCODE(op)
Extract opcode from operation.
#define NII_OPFLAGS(op)
Extract flags from operation.
UINT16 IfNum
The network interface number that is being identified by this Network Interface Identifier Protocol.
EFIAPI VOID(* issue)(UINT64 cdb)
Entry point.
References 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, s_pxe_cdb::IFnum, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::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, EFI_BOOT_SERVICES::RestoreTPL, s_pxe_cdb::StatCode, and s_pxe_cdb::StatFlags.
Referenced by nii_initialise_flags(), nii_issue(), nii_issue_cpb(), nii_issue_db(), and nii_poll_rx().
| int nii_start_undi |
( |
struct nii_nic * | nii | ) |
|
|
static |
Start UNDI.
- Parameters
-
- Return values
-
Definition at line 647 of file nii.c.
647 {
651
652
653 memset ( &cpb, 0,
sizeof ( cpb ) );
661
662
664 sizeof ( cpb ) ) ) < 0 ) {
666 DBGC ( nii,
"NII %s could not start: %s\n",
669 }
670
671 return 0;
672}
struct s_pxe_cpb_start_31 PXE_CPB_START_31
#define PXE_OPCODE_START
Change UNDI operational state from Stopped to Started.
static EFIAPI VOID nii_map(UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
Map callback.
static EFIAPI VOID nii_io(UINT64 unique_id, UINT8 op, UINT8 len, UINT64 addr, UINT64 data)
I/O callback.
static EFIAPI VOID nii_block(UINT64 unique_id, UINT32 acquire)
Block callback.
static EFIAPI VOID nii_sync(UINT64 unique_id __unused, UINT64 addr, UINT32 len, UINT32 dir, UINT64 mapped)
Sync callback.
static EFIAPI VOID nii_delay(UINT64 unique_id __unused, UINTN microseconds)
Delay callback.
static int nii_issue_cpb(struct nii_nic *nii, unsigned int op, void *cpb, size_t cpb_len)
Issue command with parameter block.
static EFIAPI VOID nii_unmap(UINT64 unique_id, UINT64 addr, UINT32 len, UINT32 dir __unused, UINT64 mapped)
Unmap callback.
UINT64 UnMap_Mem
PXE_VOID UnMap_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, UINT32 Direction,...
UINT64 Sync_Mem
PXE_VOID Sync_Mem(UINT64 unq_id, UINT64 virtual, UINT32 size, UINT32 Direction,...
UINT64 Unique_ID
protocol driver can provide anything for this Unique_ID, UNDI remembers that as just a 64bit value as...
UINT64 Delay
PXE_VOID Delay(UINT64 UnqId, UINTN microseconds);.
UINT64 Map_Mem
PXE_VOID Map_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size, UINT32 Direction,...
UINT64 Mem_IO
PXE_VOID Mem_IO(UINT64 UnqId, UINT8 read_write, UINT8 len, UINT64 port, UINT64 buf_addr);...
UINT64 Block
PXE_VOID Block(UINT64 unq_id, UINT32 enable);.
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().
Get initialisation information.
- Parameters
-
| nii | NII NIC |
| netdev | Network device to fill in |
- Return values
-
Definition at line 700 of file nii.c.
701 {
705
706
708 sizeof (
db ) ) ) < 0 ) {
710 DBGC ( nii,
"NII %s could not get initialisation info: %s\n",
713 }
714
715
716 switch (
db.IFtype ) {
718 netdev->ll_protocol = ðernet_protocol;
719 break;
720 default:
721 DBGC ( nii,
"NII %s unknown interface type %#02x\n",
724 }
725
726
727 assert (
db.MediaHeaderLen ==
netdev->ll_protocol->ll_header_len );
730
731
733 nii->
mtu = (
db.FrameDataLen +
db.MediaHeaderLen );
736
737 return 0;
738}
#define PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED
#define PXE_IFTYPE_ETHERNET
This information is from the ARP section of RFC 1700.
struct s_pxe_db_get_init_info PXE_DB_GET_INIT_INFO
#define PXE_OPCODE_GET_INIT_INFO
Get UNDI initialization information.
#define assert(condition)
Assert a condition at run-time.
static struct net_device * netdev
#define ENOTSUP
Operation not supported.
static int nii_issue_db(struct nii_nic *nii, unsigned int op, void *db, size_t db_len)
Issue command with data block.
int media
Media status is supported.
size_t buffer_len
Hardware transmit/receive buffer length.
size_t mtu
Maximum packet length.
References assert, db, DBGC, EIO_STAT, ENOTSUP, 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().
| int nii_initialise_flags |
( |
struct nii_nic * | nii, |
|
|
unsigned int | flags ) |
|
static |
Initialise UNDI.
- Parameters
-
- Return values
-
Definition at line 747 of file nii.c.
747 {
753
754
758 goto err_alloc;
759 }
760
761
762 memset ( &cpb, 0,
sizeof ( cpb ) );
765
766
768
769
772 &
db,
sizeof (
db ) ) ) < 0 ) {
774 DBGC ( nii,
"NII %s could not initialise: %s\n",
776 goto err_initialize;
777 }
778
779 return 0;
780
781 err_initialize:
783 err_alloc:
785}
struct s_pxe_db_initialize PXE_DB_INITIALIZE
struct s_pxe_cpb_initialize PXE_CPB_INITIALIZE
#define PXE_OPCODE_INITIALIZE
Changed UNDI operational state from Started to Initialized.
#define ENOMEM
Not enough space.
static __always_inline void * umalloc(size_t size)
Allocate external memory.
static __always_inline void ufree(void *ptr)
Free external memory.
#define NII_OP(opcode, opflags)
Construct operation from opcode and flags.
void * buffer
Hardware transmit/receive buffer.
PXE_UINT32 MemoryLength
MemoryLength must be greater than or equal to MemoryRequired returned by the Get Init Info command.
PXE_UINT64 MemoryAddr
Address of first (lowest) byte of the memory buffer.
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().
Get station addresses.
- Parameters
-
| nii | NII NIC |
| netdev | Network device to fill in |
- Return values
-
Definition at line 844 of file nii.c.
845 {
850
851
853 goto err_initialise;
854
855
860 DBGC ( nii,
"NII %s could not get station address: %s\n",
862 goto err_station_address;
863 }
864
865
867 netdev->ll_protocol->ll_addr_len );
869 netdev->ll_protocol->hw_addr_len );
872
873 err_station_address:
875 err_initialise:
877}
struct s_pxe_dpb_station_address PXE_DB_STATION_ADDRESS
#define PXE_OPCODE_STATION_ADDRESS
Read & change station MAC address.
#define PXE_OPFLAGS_STATION_ADDRESS_READ
UNDI Station Address.
static void nii_shutdown(struct nii_nic *nii)
Shut down UNDI.
static int nii_initialise(struct nii_nic *nii)
Initialise UNDI.
PXE_MAC_ADDR broadcast
Broadcast address.
References db, DBGC, EIO_STAT, 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().
Set station address.
- Parameters
-
| nii | NII NIC |
| netdev | Network device |
- Return values
-
Definition at line 886 of file nii.c.
887 {
893
894
897
898
899 memset ( &cpb, 0,
sizeof ( cpb ) );
901 netdev->ll_protocol->ll_addr_len );
902
903
908 DBGC ( nii,
"NII %s could not set station address: %s\n",
911 }
912
913 return 0;
914}
struct s_pxe_cpb_station_address PXE_CPB_STATION_ADDRESS
#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE
#define PXE_OPFLAGS_STATION_ADDRESS_WRITE
uint32_t implementation
Implementation.
PXE_SW_UNDI * undi
!PXE structure
PXE_MAC_ADDR StationAddr
If supplied and supported, the current station MAC address will be changed.
PXE_UINT32 Implementation
Implementation flags.
References DBGC, EIO_STAT, ENOTSUP, implementation, 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().
Transmit packet.
- Parameters
-
| netdev | Network device |
| iobuf | I/O buffer |
- Return values
-
Definition at line 983 of file nii.c.
984 {
990
991
994 return 0;
995 }
996
997
998
999
1000
1002
1003
1004 memset ( &cpb, 0,
sizeof ( cpb ) );
1007
1008
1014 DBGC (
nii,
"NII %s could not transmit: %s\n",
1017 }
1019
1020 return 0;
1021}
#define PXE_OPCODE_TRANSMIT
Transmit packet(s).
#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK
struct s_pxe_cpb_transmit PXE_CPB_TRANSMIT
#define PXE_OPFLAGS_TRANSMIT_WHOLE
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
void * data
Start of data.
PXE_UINT32 DataLen
Length of the data portion of the frame buffer in bytes.
PXE_UINT64 FrameAddr
Address of first byte of frame buffer.
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, PXE_OPCODE_TRANSMIT, PXE_OPFLAGS_TRANSMIT_DONT_BLOCK, PXE_OPFLAGS_TRANSMIT_WHOLE, rc, stat, and strerror().
Poll for received packets.
- Parameters
-
Definition at line 1052 of file nii.c.
1052 {
1056 unsigned int quota;
1059
1060
1062
1063
1064 if ( !
nii->rxbuf ) {
1066 if ( !
nii->rxbuf ) {
1067
1068 break;
1069 }
1070 }
1071
1072
1073 memset ( &cpb, 0,
sizeof ( cpb ) );
1076
1077
1079 &cpb, sizeof ( cpb ),
1080 &
db,
sizeof (
db ) ) ) < 0 ) {
1081
1082
1083
1084
1086 break;
1087
1088
1090 DBGC (
nii,
"NII %s could not receive: %s\n",
1093 break;
1094 }
1095
1096
1100 }
1101}
struct s_pxe_db_receive PXE_DB_RECEIVE
#define PXE_OPCODE_RECEIVE
Receive packet.
struct s_pxe_cpb_receive PXE_CPB_RECEIVE
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
#define iob_put(iobuf, len)
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
#define NII_RX_QUOTA
Maximum number of received packets per poll.
PXE_UINT32 BufferLen
Length of receive buffer.
PXE_UINT64 BufferAddr
Address of first byte of receive buffer.
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, PXE_OPCODE_RECEIVE, PXE_STATCODE_NO_DATA, rc, stat, and strerror().
Referenced by nii_poll().
Poll for completed packets.
- Parameters
-
Definition at line 1124 of file nii.c.
1124 {
1130
1131
1133
1134
1141 DBGC (
nii,
"NII %s could not get status: %s\n",
1143 return;
1144 }
1145
1146
1148
1149
1151
1152
1155}
#define PXE_OPCODE_GET_STATUS
Get & clear interrupt status.
#define PXE_OPFLAGS_GET_INTERRUPT_STATUS
UNDI Get Status.
#define PXE_OPFLAGS_GET_MEDIA_STATUS
Return current media status.
#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS
Return list of transmitted buffers for recycling.
struct s_pxe_db_get_status PXE_DB_GET_STATUS
static void nii_poll_rx(struct net_device *netdev)
Poll for received packets.
static void nii_poll_link(struct net_device *netdev, unsigned int stat)
Check for link state changes.
static void nii_poll_tx(struct net_device *netdev, unsigned int stat)
Poll for completed packets.
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, PXE_OPCODE_GET_STATUS, PXE_OPFLAGS_GET_INTERRUPT_STATUS, PXE_OPFLAGS_GET_MEDIA_STATUS, PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS, rc, stat, and strerror().
Attach driver to device.
- Parameters
-
- Return values
-
Definition at line 1287 of file nii.c.
1287 {
1292
1293
1297 goto err_alloc;
1298 }
1305
1306
1308 nii->dev.driver_name =
"NII";
1313
1314
1316 &
nii->nii ) ) != 0 ) {
1317 DBGC (
nii,
"NII %s cannot open NII protocol: %s\n",
1320 goto err_open_protocol;
1321 }
1322
1323
1325 if ( !
nii->undi ) {
1326 DBGC (
nii,
"NII %s has no UNDI\n",
nii->dev.name );
1328 goto err_no_undi;
1329 }
1331 DBGC (
nii,
"NII %s is a mythical hardware UNDI\n",
1334 goto err_hw_undi;
1335 }
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",
1344 nii->undi,
nii->issue,
nii->undi->Implementation );
1345
1346
1348 goto err_pci_open;
1349
1350
1352 goto err_start_undi;
1353
1354
1356 goto err_get_init_info;
1357
1358
1360 goto err_get_station_address;
1361
1362
1364 goto err_register_netdev;
1365 DBGC (
nii,
"NII %s registered as %s for %s\n",
nii->dev.name,
1367
1368
1371
1372 return 0;
1373
1375 err_register_netdev:
1376 err_get_station_address:
1377 err_get_init_info:
1379 err_start_undi:
1381 err_pci_open:
1382 err_hw_undi:
1383 err_no_undi:
1385 err_open_protocol:
1389 err_alloc:
1391}
#define PXE_ROMID_IMP_HW_UNDI
Implementation flags.
#define PXE_ROMID_IMP_SW_VIRT_ADDR
static void efidev_set_drvdata(struct efi_device *efidev, void *priv)
Set EFI driver-private data.
void efi_close_by_driver(EFI_HANDLE handle, EFI_GUID *protocol)
Close protocol opened for persistent use by a driver.
void efi_device_info(EFI_HANDLE device, const char *prefix, struct device *dev)
Get underlying device information.
#define ENODEV
No such device.
#define efi_open_by_driver(handle, protocol, interface)
Open protocol for persistent use by a driver.
#define DBGC_EFI_OPENERS(...)
#define INIT_LIST_HEAD(list)
Initialise a list head.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
struct net_device * alloc_netdev(size_t priv_len)
Allocate network device.
int register_netdev(struct net_device *netdev)
Register network device.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
static int nii_pci_open(struct nii_nic *nii)
Open PCI I/O protocol and identify BARs.
static void nii_pci_close(struct nii_nic *nii)
Close PCI I/O protocol.
static void nii_stop_undi(struct nii_nic *nii)
Stop UNDI.
static int nii_start_undi(struct nii_nic *nii)
Start UNDI.
static struct net_device_operations nii_operations
NII network device operations.
static int nii_get_station_address(struct nii_nic *nii, struct net_device *netdev)
Get station addresses.
static int nii_get_init_info(struct nii_nic *nii, struct net_device *netdev)
Get initialisation information.
UINT8 MajorVer
Major version number.
UINT8 MinorVer
Minor version number.
UINT64 Id
The address of the first byte of the identifying structure for this network interface.
struct list_head children
Devices attached to this device.
struct device dev
Generic device.
References alloc_netdev(), device::children, DBGC, DBGC_EFI_OPENERS, efi_device::dev, efi_device::device, efi_close_by_driver(), efi_device_info(), EFI_HANDLE, 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, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::MajorVer, _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL::MinorVer, 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(), PXE_ROMID_IMP_HW_UNDI, PXE_ROMID_IMP_SW_VIRT_ADDR, rc, register_netdev(), strerror(), and unregister_netdev().
Referenced by __efi_driver().