aboutsummaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2013-10-31 15:37:52 +0000
committerMichael Brown <mcb30@ipxe.org>2013-11-05 17:30:15 +0000
commitf2bc13839144de0daf0250e03d51c3212b082dfb (patch)
tree95fa9764f5327425b8e9cc270ce623a2e61e2b0a /src/include
parent55e85ad1ee318aa559f071d95741391eaf2dc1de (diff)
downloadipxe-f2bc13839144de0daf0250e03d51c3212b082dfb.tar.gz
[netdevice] Add generic concept of a network device configurator
iPXE supports multiple mechanisms for network device configuration: DHCPv4 for IPv4, FIP for FCoE, and SLAAC for IPv6. At present, DHCPv4 requires an explicit action (e.g. a "dhcp" command), FIP is initiated implicitly upon opening a network device, and SLAAC takes place whenever a RA happens to be received. Add a generic concept of a network device configurator, which provides a common interface to triggering configuration and to reporting the result of the configuration process. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/netdevice.h79
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