1 #ifndef _IPXE_NETDEVICE_H 2 #define _IPXE_NETDEVICE_H 30 #define MAX_HW_ADDR_LEN 8 36 #define MAX_LL_ADDR_LEN 20 45 #define MAX_LL_HEADER_LEN 64 48 #define MAX_NET_ADDR_LEN 16 55 #define MAX_NET_HEADER_LEN 40 58 #define MAX_LL_NET_HEADER_LEN ( MAX_LL_HEADER_LEN + MAX_NET_HEADER_LEN ) 80 const void *ll_dest,
const void *ll_source,
94 const char * ( *ntoa ) (
const void * net_addr );
105 #define LL_MULTICAST 0x0001 108 #define LL_BROADCAST 0x0002 128 const void *ll_dest,
const void *ll_source,
142 const void **ll_dest,
const void **ll_source,
150 void ( *
init_addr ) (
const void *hw_addr,
void *ll_addr );
163 const char * ( * ntoa ) (
const void *ll_addr );
172 int ( *
mc_hash ) (
unsigned int af,
const void *net_addr,
210 #define LL_NAME_ONLY 0x0001 288 #define NETDEV_MAX_UNIQUE_ERRORS 4 332 #define NET_DEVICE_CONFIGURATORS \ 333 __table ( struct net_device_configurator, "net_device_configurators" ) 336 #define __net_device_configurator \ 337 __table_entry ( NET_DEVICE_CONFIGURATORS, 01 ) 340 #define NETDEV_NAME_LEN 12 438 #define NETDEV_OPEN 0x0001 441 #define NETDEV_IRQ_ENABLED 0x0002 444 #define NETDEV_RX_FROZEN 0x0004 452 #define NETDEV_IRQ_UNSUPPORTED 0x0008 455 #define NETDEV_TX_IN_PROGRESS 0x0010 458 #define NETDEV_POLL_IN_PROGRESS 0x0020 461 #define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" ) 464 #define __ll_protocol __table_entry ( LL_PROTOCOLS, 01 ) 467 #define NET_PROTOCOLS __table ( struct net_protocol, "net_protocols" ) 470 #define __net_protocol __table_entry ( NET_PROTOCOLS, 01 ) 500 #define NET_DRIVERS __table ( struct net_driver, "net_drivers" ) 503 #define __net_driver __table_entry ( NET_DRIVERS, 01 ) 543 #define for_each_netdev( netdev ) \ 544 list_for_each_entry ( (netdev), &net_devices, list ) 727 unsigned int location );
731 const void *ll_source );
733 uint16_t net_proto,
const void *ll_dest,
734 const void *ll_source,
unsigned int flags );
struct net_device * alloc_netdev(size_t priv_size)
Allocate network device.
struct arbelprm_rc_send_wqe rc
const char * name
Protocol name.
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
static void netdev_settings_init(struct net_device *netdev)
Initialise a per-netdevice configuration settings block.
uint8_t ll_header_len
Link-layer header length.
uint8_t ll_addr_len
Link-layer address length.
int(* start)(struct interface *job, struct net_device *netdev)
Start configuring network device.
struct list_head net_devices
List of network devices.
#define NETDEV_RX_FROZEN
Network device receive queue processing is frozen.
void netdev_close(struct net_device *netdev)
Close network device.
void netdev_rx_freeze(struct net_device *netdev)
Freeze network device receive queue processing.
int(* open)(struct net_device *netdev)
Open network device.
#define NETDEV_OPEN
Network device is open.
void netdev_poll(struct net_device *netdev)
Poll for completed and received packets on network device.
struct interface job
Job control interface.
static void generic_settings_init(struct generic_settings *generics, struct refcnt *refcnt)
Initialise a settings block.
struct net_device * find_netdev_by_location(unsigned int bus_type, unsigned int location)
Get network device by PCI bus:dev.fn address.
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
int netdev_configuration_ok(struct net_device *netdev)
Check if network device has at least one successful configuration.
struct retry_timer link_block
Link block timer.
int register_netdev(struct net_device *netdev)
Register network device.
struct net_device_operations null_netdev_operations
size_t mtu
Maximum transmission unit length.
struct list_head list
List of network devices.
void netdev_link_block(struct net_device *netdev, unsigned long timeout)
Mark network device link as being blocked.
const uint8_t * ll_broadcast
Link-layer broadcast address.
void netdev_link_unblock(struct net_device *netdev)
Mark network device link as being unblocked.
unsigned int state
Current device state.
struct dma_device * dma
DMA device.
struct net_device * last_opened_netdev(void)
Get most recently opened network device.
struct net_device * find_netdev_by_scope_id(unsigned int scope_id)
Get network device by scope ID.
static int have_netdevs(void)
There exist some network devices.
static int netdev_link_blocked(struct net_device *netdev)
Check link block state of network device.
struct net_device_operations * op
Network device operations.
#define NETDEV_NAME_LEN
Maximum length of a network device name.
static const char * netdev_addr(struct net_device *netdev)
Get printable network device link-layer address.
struct settings_operations * op
Settings block operations.
struct net_device_stats tx_stats
TX statistics.
unsigned int scope_id
Scope ID.
void(* init_addr)(const void *hw_addr, void *ll_addr)
Initialise link-layer address.
A network upper-layer driver.
int(* probe)(struct net_device *netdev, void *priv)
Probe device.
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
size_t priv_len
Size of private data.
struct list_head rx_queue
RX packet queue.
unsigned int count
Error count.
A doubly-linked list entry (or list head)
void(* poll)(struct net_device *netdev)
Poll for completed and received packets.
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.
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.
#define list_empty(list)
Test whether a list is empty.
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
const char * name
Protocol name.
void(* irq)(struct net_device *netdev, int enable)
Enable or disable interrupts.
int netdev_open(struct net_device *netdev)
Open network device.
void netdev_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
struct settings_operations netdev_settings_operations
Network device configuration settings operations.
#define NETDEV_MAX_UNIQUE_ERRORS
Maximum number of unique errors that we will keep track of.
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
#define MAX_LL_ADDR_LEN
Maximum length of a link-layer address.
int link_rc
Link status code.
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
uint8_t hw_addr_len
Hardware address length.
void * priv
Driver private data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
struct list_head tx_queue
TX packet queue.
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
#define MAX_HW_ADDR_LEN
Maximum length of a hardware address.
struct net_device_configuration configs[0]
Network device configurations (variable length)
static struct net_device * netdev
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
struct list_head tx_deferred
Deferred TX packet queue.
static int netdev_irq_enabled(struct net_device *netdev)
Check whether or not network device interrupts are currently enabled.
struct refcnt refcnt
Reference counter.
#define ref_get(refcnt)
Get additional reference to object.
struct net_device_stats rx_stats
RX statistics.
int(* eui64)(const void *ll_addr, void *eui64)
Generate EUI-64 address.
unsigned int bad
Count of error completions.
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Settings block operations.
struct net_device_error errors[NETDEV_MAX_UNIQUE_ERRORS]
Error breakdowns.
Network device statistics.
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
void(* notify)(struct net_device *netdev, void *priv)
Notify of device or link state change.
void(* close)(struct net_device *netdev)
Close network device.
uint16_t net_proto
Network-layer protocol.
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
uint16_t ll_proto
Link-layer protocol.
int(* mc_hash)(unsigned int af, const void *net_addr, void *ll_addr)
Hash multicast address.
void * netdev_priv(struct net_device *netdev, struct net_driver *driver)
Get network device driver private data.
int(* transmit)(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
int(* applies)(struct net_device *netdev)
Check applicability of configurator.
Network device operations.
struct device * dev
Underlying hardware device.
A network-layer protocol.
void net_poll(void)
Poll the network stack.
static int netdev_configurator_applies(struct net_device *netdev, struct net_device_configurator *configurator)
Check if configurator applies to network device.
static uint16_t struct vmbus_xfer_pages_operations * op
A generic settings block.
void unregister_netdev(struct net_device *netdev)
Unregister network device.
unsigned int good
Count of successful completions.
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.
char name[NETDEV_NAME_LEN]
Name of this network device.
struct settings settings
Settings block.
int netdev_configure_all(struct net_device *netdev)
Start network device configuration via all supported configurators.
static struct tlan_private * priv
uint8_t net_addr_len
Network-layer address length.
struct net_device * netdev
Network device.
void(* remove)(struct net_device *netdev, void *priv)
Remove device.
struct io_buffer * netdev_rx_dequeue(struct net_device *netdev)
Remove packet from device's receive queue.
int rc
Configuration status.
struct list_head open_list
List of open network devices.
A 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.
int netdev_configuration_in_progress(struct net_device *netdev)
Check if network device configuration is in progress.
const char *(* ntoa)(const void *ll_addr)
Transcribe link-layer address.
int netdev_tx(struct net_device *netdev, struct io_buffer *iobuf)
Transmit raw packet via network device.
void netdev_tx_defer(struct net_device *netdev, struct io_buffer *iobuf)
Defer transmitted packet.
struct net_device_configurator * configurator
Network device configurator.
#define NET_DEVICE_CONFIGURATORS
Network device configurator table.
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
size_t max_pkt_len
Maximum packet length.
void netdev_tx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard transmitted packet.
A network device configuration.
static int netdev_rx_frozen(struct net_device *netdev)
Check whether or not network device receive queue processing is frozen.
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
#define NETDEV_IRQ_UNSUPPORTED
Network device interrupts are unsupported.
struct generic_settings settings
Configuration settings applicable to this device.
void netdev_rx_unfreeze(struct net_device *netdev)
Unfreeze network device receive queue processing.
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
#define NULL
NULL pointer (VOID *)
static int netdev_irq_supported(struct net_device *netdev)
Check whether or not network device supports interrupts.
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
#define NETDEV_IRQ_ENABLED
Network device interrupts are enabled.
static struct net_device_configuration * netdev_configuration(struct net_device *netdev, struct net_device_configurator *configurator)
Get network device configuration.
struct ll_protocol * ll_protocol
Link-layer protocol.
int netdev_configure(struct net_device *netdev, struct net_device_configurator *configurator)
Start network device configuration.
#define table_index(table, entry)
Get index of entry within linker table.
#define ref_put(refcnt)
Drop reference to object.
struct net_device_configurator * find_netdev_configurator(const char *name)
Find network device configurator.
int(* rx)(struct io_buffer *iobuf, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags)
Process received packet.
int(* eth_addr)(const void *ll_addr, void *eth_addr)
Generate Ethernet-compatible compressed link-layer address.
struct net_device * find_netdev(const char *name)
Get network device by name.
void netdev_link_err(struct net_device *netdev, int rc)
Mark network device as having a specific link state.