diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/netdevice.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index ae6e5585a..2ea3c8bb1 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/tables.h> #include <ipxe/refcnt.h> #include <ipxe/settings.h> +#include <ipxe/interface.h> struct io_buffer; struct net_device; @@ -292,6 +293,45 @@ struct net_device_stats { struct net_device_error errors[NETDEV_MAX_UNIQUE_ERRORS]; }; +/** A network device configuration */ +struct net_device_configuration { + /** Network device */ + struct net_device *netdev; + /** Network device configurator */ + struct net_device_configurator *configurator; + /** Configuration status */ + int rc; + /** Job control interface */ + struct interface job; +}; + +/** A network device configurator */ +struct net_device_configurator { + /** Name */ + const char *name; + /** Check applicability of configurator + * + * @v netdev Network device + * @ret applies Configurator applies to this network device + */ + int ( * applies ) ( struct net_device *netdev ); + /** Start configuring network device + * + * @v job Job control interface + * @v netdev Network device + * @ret rc Return status code + */ + int ( * start ) ( struct interface *job, struct net_device *netdev ); +}; + +/** Network device configurator table */ +#define NET_DEVICE_CONFIGURATORS \ + __table ( struct net_device_configurator, "net_device_configurators" ) + +/** Declare a network device configurator */ +#define __net_device_configurator \ + __table_entry ( NET_DEVICE_CONFIGURATORS, 01 ) + /** Maximum length of a network device name */ #define NETDEV_NAME_LEN 12 @@ -374,6 +414,9 @@ struct net_device { /** Driver private data */ void *priv; + + /** Network device configurations (variable length) */ + struct net_device_configuration configs[0]; }; /** Network device is open */ @@ -532,6 +575,35 @@ netdev_settings_init ( struct net_device *netdev ) { } /** + * Get network device configuration + * + * @v netdev Network device + * @v configurator Network device configurator + * @ret config Network device configuration + */ +static inline struct net_device_configuration * +netdev_configuration ( struct net_device *netdev, + struct net_device_configurator *configurator ) { + + return &netdev->configs[ table_index ( NET_DEVICE_CONFIGURATORS, + configurator ) ]; +} + +/** + * Check if configurator applies to network device + * + * @v netdev Network device + * @v configurator Network device configurator + * @ret applies Configurator applies to network device + */ +static inline int +netdev_configurator_applies ( struct net_device *netdev, + struct net_device_configurator *configurator ) { + return ( ( configurator->applies == NULL ) || + configurator->applies ( netdev ) ); +} + +/** * Check link state of network device * * @v netdev Network device @@ -619,6 +691,13 @@ extern 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 ); extern void net_poll ( void ); +extern struct net_device_configurator * +find_netdev_configurator ( const char *name ); +extern int netdev_configure ( struct net_device *netdev, + struct net_device_configurator *configurator ); +extern int netdev_configure_all ( struct net_device *netdev ); +extern int netdev_configuration_in_progress ( struct net_device *netdev ); +extern int netdev_configuration_ok ( struct net_device *netdev ); /** * Complete network transmission |