aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/netdevice.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2010-09-05 00:55:23 +0100
committerMichael Brown <mcb30@ipxe.org>2010-09-05 03:03:38 +0100
commitca4df90a6383d47617038328fb506bf273f1e80e (patch)
treeb079979a9eaccfa94f4453c547a425694cfdd43b /src/include/ipxe/netdevice.h
parent97ef28aea070f6d07b85fe16ef1b98da94a9f609 (diff)
downloadipxe-ca4df90a6383d47617038328fb506bf273f1e80e.tar.gz
[netdevice] Add the concept of a network upper-layer driver
Add the concept of a network upper-layer driver, which can create arbitrary devices on top of network devices. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/netdevice.h')
-rw-r--r--src/include/ipxe/netdevice.h60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h
index f829327c5..80bc1c6e2 100644
--- a/src/include/ipxe/netdevice.h
+++ b/src/include/ipxe/netdevice.h
@@ -344,6 +344,34 @@ struct net_device {
/** Declare a network-layer protocol */
#define __net_protocol __table_entry ( NET_PROTOCOLS, 01 )
+/** A network upper-layer driver */
+struct net_driver {
+ /** Name */
+ const char *name;
+ /** Probe device
+ *
+ * @v netdev Network device
+ * @ret rc Return status code
+ */
+ int ( * probe ) ( struct net_device *netdev );
+ /** Notify of device or link state change
+ *
+ * @v netdev Network device
+ */
+ void ( * notify ) ( struct net_device *netdev );
+ /** Remove device
+ *
+ * @v netdev Network device
+ */
+ void ( * remove ) ( struct net_device *netdev );
+};
+
+/** Network driver table */
+#define NET_DRIVERS __table ( struct net_driver, "net_drivers" )
+
+/** Declare a network driver */
+#define __net_driver __table_entry ( NET_DRIVERS, 01 )
+
extern struct list_head net_devices;
extern struct net_device_operations null_netdev_operations;
extern struct settings_operations netdev_settings_operations;
@@ -452,27 +480,6 @@ netdev_settings_init ( struct net_device *netdev ) {
}
/**
- * Mark network device as having link up
- *
- * @v netdev Network device
- */
-static inline __attribute__ (( always_inline )) void
-netdev_link_up ( struct net_device *netdev ) {
- netdev->link_rc = 0;
-}
-
-/**
- * Mark network device as having link down due to a specific error
- *
- * @v netdev Network device
- * @v rc Link status code
- */
-static inline __attribute__ (( always_inline )) void
-netdev_link_err ( struct net_device *netdev, int rc ) {
- netdev->link_rc = rc;
-}
-
-/**
* Check link state of network device
*
* @v netdev Network device
@@ -505,6 +512,7 @@ netdev_irq_enabled ( struct net_device *netdev ) {
return ( netdev->state & NETDEV_IRQ_ENABLED );
}
+extern void netdev_link_err ( struct net_device *netdev, int rc );
extern void netdev_link_down ( struct net_device *netdev );
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
extern void netdev_tx_complete_err ( struct net_device *netdev,
@@ -554,4 +562,14 @@ static inline void netdev_tx_complete_next ( struct net_device *netdev ) {
netdev_tx_complete_next_err ( netdev, 0 );
}
+/**
+ * Mark network device as having link up
+ *
+ * @v netdev Network device
+ */
+static inline __attribute__ (( always_inline )) void
+netdev_link_up ( struct net_device *netdev ) {
+ netdev_link_err ( netdev, 0 );
+}
+
#endif /* _IPXE_NETDEVICE_H */