1#ifndef _IPXE_NETDEVICE_H
2#define _IPXE_NETDEVICE_H
31#define MAX_HW_ADDR_LEN 8
37#define MAX_LL_ADDR_LEN 20
46#define MAX_LL_HEADER_LEN 64
49#define MAX_NET_ADDR_LEN 16
56#define MAX_NET_HEADER_LEN 40
59#define MAX_LL_NET_HEADER_LEN ( MAX_LL_HEADER_LEN + MAX_NET_HEADER_LEN )
81 const void *ll_dest,
const void *ll_source,
95 const char * ( *ntoa ) (
const void * net_addr );
106#define LL_MULTICAST 0x0001
109#define LL_BROADCAST 0x0002
129 const void *ll_dest,
const void *ll_source,
143 const void **ll_dest,
const void **ll_source,
151 void ( *
init_addr ) (
const void *hw_addr,
void *ll_addr );
164 const char * ( * ntoa ) (
const void *ll_addr );
173 int ( *
mc_hash ) (
unsigned int af,
const void *net_addr,
211#define LL_NAME_ONLY 0x0001
289#define NETDEV_MAX_UNIQUE_ERRORS 4
333#define NET_DEVICE_CONFIGURATORS \
334 __table ( struct net_device_configurator, "net_device_configurators" )
337#define __net_device_configurator \
338 __table_entry ( NET_DEVICE_CONFIGURATORS, 01 )
341#define NETDEV_NAME_LEN 12
439#define NETDEV_OPEN 0x0001
442#define NETDEV_IRQ_ENABLED 0x0002
445#define NETDEV_RX_FROZEN 0x0004
453#define NETDEV_IRQ_UNSUPPORTED 0x0008
456#define NETDEV_TX_IN_PROGRESS 0x0010
459#define NETDEV_POLL_IN_PROGRESS 0x0020
462#define NETDEV_INSOMNIAC 0x0040
465#define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
468#define __ll_protocol __table_entry ( LL_PROTOCOLS, 01 )
471#define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" )
474#define __net_protocol __table_entry ( NET_PROTOCOLS, 01 )
504#define NET_DRIVERS __table ( struct net_driver, "net_drivers" )
507#define __net_driver __table_entry ( NET_DRIVERS, 01 )
547#define for_each_netdev( netdev ) \
548 list_for_each_entry ( (netdev), &net_devices, list )
588 return &
netdev->settings.settings;
641 return (
netdev->link_rc == 0 );
652 return ( timer_running ( &
netdev->link_block ) );
742 unsigned int location );
746 const void *ll_source );
748 uint16_t net_proto,
const void *ll_dest,
749 const void *ll_source,
unsigned int flags );
#define NULL
NULL pointer (VOID *)
struct arbelprm_rc_send_wqe rc
static struct net_device * netdev
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
static void generic_settings_init(struct generic_settings *generics, struct refcnt *refcnt)
Initialise a settings block.
#define list_empty(list)
Test whether a list is empty.
struct settings_operations netdev_settings_operations
Network device configuration settings operations.
struct list_head net_devices
List of network devices.
struct net_device * alloc_netdev(size_t priv_size)
Allocate network device.
void netdev_rx_unfreeze(struct net_device *netdev)
Unfreeze network device receive queue processing.
int net_tx(struct io_buffer *iobuf, struct net_device *netdev, struct net_protocol *net_protocol, const void *ll_dest, const void *ll_source)
Transmit network-layer packet.
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.
int netdev_configure_all(struct net_device *netdev)
Start network device configuration via all supported configurators.
static int netdev_link_blocked(struct net_device *netdev)
Check link block state of network device.
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
static void netdev_settings_init(struct net_device *netdev)
Initialise a per-netdevice configuration settings block.
struct net_device * find_netdev_by_scope_id(unsigned int scope_id)
Get network device by scope ID.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
#define NETDEV_RX_FROZEN
Network device receive queue processing is frozen.
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
static int netdev_irq_enabled(struct net_device *netdev)
Check whether or not network device interrupts are currently enabled.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
struct io_buffer * netdev_rx_dequeue(struct net_device *netdev)
Remove packet from device's receive queue.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
static int netdev_irq_supported(struct net_device *netdev)
Check whether or not network device supports interrupts.
int netdev_configuration_ok(struct net_device *netdev)
Check if network device has at least one successful configuration.
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
void * netdev_priv(struct net_device *netdev, struct net_driver *driver)
Get network device driver private data.
void netdev_rx_freeze(struct net_device *netdev)
Freeze network device receive queue processing.
#define NETDEV_INSOMNIAC
Network device must be polled even when closed.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
int netdev_open(struct net_device *netdev)
Open network device.
#define NETDEV_NAME_LEN
Maximum length of a network device name.
void netdev_link_block(struct net_device *netdev, unsigned long timeout)
Mark network device link as being blocked.
#define MAX_HW_ADDR_LEN
Maximum length of a hardware address.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
static int netdev_insomniac(struct net_device *netdev)
Check whether or not network device must be polled even while closed.
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
void netdev_close(struct net_device *netdev)
Close network device.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
#define NETDEV_IRQ_UNSUPPORTED
Network device interrupts are unsupported.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
void net_poll(void)
Poll the network stack.
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
int register_netdev(struct net_device *netdev)
Register network device.
static int netdev_rx_frozen(struct net_device *netdev)
Check whether or not network device receive queue processing is frozen.
void netdev_link_unblock(struct net_device *netdev)
Mark network device link as being unblocked.
void netdev_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
struct net_device_configurator * find_netdev_configurator(const char *name)
Find network device configurator.
int net_rx(struct io_buffer *iobuf, struct net_device *netdev, uint16_t net_proto, const void *ll_dest, const void *ll_source, unsigned int flags)
Process received network-layer packet.
struct net_device * find_netdev(const char *name)
Get network device by name.
#define NETDEV_IRQ_ENABLED
Network device interrupts are enabled.
int netdev_configure(struct net_device *netdev, struct net_device_configurator *configurator)
Start network device configuration.
#define NET_DEVICE_CONFIGURATORS
Network device configurator table.
static struct net_device_configuration * netdev_configuration(struct net_device *netdev, struct net_device_configurator *configurator)
Get network device configuration.
void netdev_poll(struct net_device *netdev)
Poll for completed and received packets on network device.
static int netdev_configurator_applies(struct net_device *netdev, struct net_device_configurator *configurator)
Check if configurator applies to network device.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
struct net_device * find_netdev_by_location(unsigned int bus_type, unsigned int location)
Get network device by PCI bus:dev.fn address.
#define NETDEV_OPEN
Network device is open.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
#define NETDEV_MAX_UNIQUE_ERRORS
Maximum number of unique errors that we will keep track of.
int netdev_configuration_in_progress(struct net_device *netdev)
Check if network device configuration is in progress.
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
static int have_netdevs(void)
There exist some network devices.
static uint16_t struct vmbus_xfer_pages_operations * op
struct net_device_operations null_netdev_operations
#define ref_get(refcnt)
Get additional reference to object.
#define ref_put(refcnt)
Drop reference to object.
A generic settings block.
A doubly-linked list entry (or list head)
int(* eui64)(const void *ll_addr, void *eui64)
Generate EUI-64 address.
int(* push)(struct net_device *netdev, struct io_buffer *iobuf, const void *ll_dest, const void *ll_source, uint16_t net_proto)
Add link-layer header.
const char * name
Protocol name.
void(* init_addr)(const void *hw_addr, void *ll_addr)
Initialise link-layer address.
int(* eth_addr)(const void *ll_addr, void *eth_addr)
Generate Ethernet-compatible compressed link-layer address.
int(* mc_hash)(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
int(* pull)(struct net_device *netdev, struct io_buffer *iobuf, const void **ll_dest, const void **ll_source, uint16_t *net_proto, unsigned int *flags)
Remove link-layer header.
uint8_t ll_addr_len
Link-layer address length.
uint8_t ll_header_len
Link-layer header length.
uint8_t hw_addr_len
Hardware address length.
uint16_t ll_proto
Link-layer protocol.
A network device configuration.
int rc
Configuration status.
struct net_device_configurator * configurator
Network device configurator.
struct net_device * netdev
Network device.
struct interface job
Job control interface.
A network device configurator.
int(* applies)(struct net_device *netdev)
Check applicability of configurator.
int(* start)(struct interface *job, struct net_device *netdev)
Start configuring network device.
unsigned int count
Error count.
Network device operations.
void(* close)(struct net_device *netdev)
Close network device.
void(* irq)(struct net_device *netdev, int enable)
Enable or disable interrupts.
void(* poll)(struct net_device *netdev)
Poll for completed and received packets.
int(* open)(struct net_device *netdev)
Open network device.
int(* transmit)(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Network device statistics.
unsigned int good
Count of successful completions.
struct net_device_error errors[NETDEV_MAX_UNIQUE_ERRORS]
Error breakdowns.
unsigned int bad
Count of error completions.
size_t max_pkt_len
Maximum packet length.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
void * priv
Driver private data.
struct list_head tx_queue
TX packet queue.
struct net_device_configuration configs[0]
Network device configurations (variable length)
struct refcnt refcnt
Reference counter.
struct net_device_stats rx_stats
RX statistics.
struct list_head rx_queue
RX packet queue.
struct dma_device * dma
DMA device.
struct ll_protocol * ll_protocol
Link-layer protocol.
struct net_device_operations * op
Network device operations.
char name[NETDEV_NAME_LEN]
Name of this network device.
struct list_head open_list
List of open network devices.
struct retry_timer link_block
Link block timer.
int link_rc
Link status code.
struct device * dev
Underlying hardware device.
struct list_head list
List of network devices.
struct generic_settings settings
Configuration settings applicable to this device.
unsigned int scope_id
Scope ID.
struct net_device_stats tx_stats
TX statistics.
const uint8_t * ll_broadcast
Link-layer broadcast address.
struct list_head tx_deferred
Deferred TX packet queue.
size_t mtu
Maximum transmission unit length.
unsigned int state
Current device state.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
A network upper-layer driver.
int(* probe)(struct net_device *netdev, void *priv)
Probe device.
size_t priv_len
Size of private data.
void(* remove)(struct net_device *netdev, void *priv)
Remove device.
void(* notify)(struct net_device *netdev, void *priv)
Notify of device or link state change.
A network-layer protocol.
const char * name
Protocol name.
uint16_t net_proto
Network-layer protocol.
uint8_t net_addr_len
Network-layer address length.
int(* rx)(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags)
Process received packet.
Settings block operations.
#define table_index(table, entry)
Get index of entry within linker table.
static struct tlan_private * priv