summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe
diff options
context:
space:
mode:
authorMichael Brown2007-06-27 15:48:31 +0200
committerMichael Brown2007-06-27 15:48:31 +0200
commitf77815f2b1ecf9f14441110ca61c0cffa48ce0e3 (patch)
treee55993b9b5acd1fbe2163b655ce3214390fdbbd3 /src/include/gpxe
parentPartial migration of UDP to data-xfer interface. (Will not link at (diff)
downloadipxe-f77815f2b1ecf9f14441110ca61c0cffa48ce0e3.tar.gz
ipxe-f77815f2b1ecf9f14441110ca61c0cffa48ce0e3.tar.xz
ipxe-f77815f2b1ecf9f14441110ca61c0cffa48ce0e3.zip
Kill off hotplug.h and just make net devices normal reference-counted
structures. DHCP still broken and #if 0'd out.
Diffstat (limited to 'src/include/gpxe')
-rw-r--r--src/include/gpxe/aoe.h3
-rw-r--r--src/include/gpxe/dhcp.h5
-rw-r--r--src/include/gpxe/hotplug.h58
-rw-r--r--src/include/gpxe/ip.h3
-rw-r--r--src/include/gpxe/netdevice.h29
5 files changed, 27 insertions, 71 deletions
diff --git a/src/include/gpxe/aoe.h b/src/include/gpxe/aoe.h
index 3c54b6bb1..eb5e11337 100644
--- a/src/include/gpxe/aoe.h
+++ b/src/include/gpxe/aoe.h
@@ -13,7 +13,6 @@
#include <gpxe/retry.h>
#include <gpxe/async.h>
#include <gpxe/ata.h>
-#include <gpxe/hotplug.h>
/** An AoE ATA command */
struct aoecmd {
@@ -87,8 +86,6 @@ struct aoe_session {
/** Network device */
struct net_device *netdev;
- /** Reference to network device */
- struct reference netdev_ref;
/** Major number */
uint16_t major;
diff --git a/src/include/gpxe/dhcp.h b/src/include/gpxe/dhcp.h
index 1ec7ca038..16609bafc 100644
--- a/src/include/gpxe/dhcp.h
+++ b/src/include/gpxe/dhcp.h
@@ -13,7 +13,6 @@
#include <gpxe/udp.h>
#include <gpxe/async.h>
#include <gpxe/retry.h>
-#include <gpxe/hotplug.h>
/** BOOTP/DHCP server port */
#define BOOTPS_PORT 67
@@ -449,6 +448,8 @@ struct dhcp_packet {
struct dhcp_option_block options[NUM_OPT_BLOCKS];
};
+struct udp_connection {};
+
/** A DHCP session */
struct dhcp_session {
/** UDP connection for this session */
@@ -456,8 +457,6 @@ struct dhcp_session {
/** Network device being configured */
struct net_device *netdev;
- /** Persistent reference to network device */
- struct reference netdev_ref;
/** Options obtained from server */
struct dhcp_option_block *options;
diff --git a/src/include/gpxe/hotplug.h b/src/include/gpxe/hotplug.h
deleted file mode 100644
index e6e132de1..000000000
--- a/src/include/gpxe/hotplug.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef _GPXE_HOTPLUG_H
-#define _GPXE_HOTPLUG_H
-
-/** @file
- *
- * Hotplug support
- *
- */
-
-#include <gpxe/list.h>
-
-/**
- * A persistent reference to another data structure
- *
- * This data structure should be embedded within any data structure
- * (the referrer) which holds a persistent reference to a separate,
- * volatile data structure (the referee).
- */
-struct reference {
- /** List of persistent references */
- struct list_head list;
- /** Forget persistent reference
- *
- * @v ref Persistent reference
- *
- * This method is called immediately before the referred-to
- * data structure is destroyed. The reference holder must
- * forget all references to the referee before returning from
- * this method.
- *
- * This method must also call ref_del() to remove the
- * reference.
- */
- void ( * forget ) ( struct reference *ref );
-};
-
-/**
- * Add persistent reference
- *
- * @v ref Persistent reference
- * @v list List of persistent references
- */
-static inline void ref_add ( struct reference *ref, struct list_head *list ) {
- list_add ( &ref->list, list );
-}
-
-/**
- * Remove persistent reference
- *
- * @v ref Persistent reference
- */
-static inline void ref_del ( struct reference *ref ) {
- list_del ( &ref->list );
-}
-
-extern void forget_references ( struct list_head *list );
-
-#endif /* _GPXE_HOTPLUG_H */
diff --git a/src/include/gpxe/ip.h b/src/include/gpxe/ip.h
index 9a5b7a81f..974c6457d 100644
--- a/src/include/gpxe/ip.h
+++ b/src/include/gpxe/ip.h
@@ -9,7 +9,6 @@
#include <ip.h>
#include <gpxe/retry.h>
-#include <gpxe/hotplug.h>
/* IP constants */
@@ -44,8 +43,6 @@ struct ipv4_miniroute {
/** Network device */
struct net_device *netdev;
- /** Reference to network device */
- struct reference netdev_ref;
/** IPv4 address */
struct in_addr address;
diff --git a/src/include/gpxe/netdevice.h b/src/include/gpxe/netdevice.h
index c71c09284..9800ef569 100644
--- a/src/include/gpxe/netdevice.h
+++ b/src/include/gpxe/netdevice.h
@@ -10,7 +10,7 @@
#include <stdint.h>
#include <gpxe/list.h>
#include <gpxe/tables.h>
-#include <gpxe/hotplug.h>
+#include <gpxe/refcnt.h>
struct io_buffer;
struct net_device;
@@ -137,14 +137,14 @@ struct ll_protocol {
* not just an Ethernet device.
*/
struct net_device {
+ /** Reference counter */
+ struct refcnt refcnt;
/** List of network devices */
struct list_head list;
/** Name of this network device */
char name[8];
/** Underlying hardware device */
struct device *dev;
- /** List of persistent reference holders */
- struct list_head references;
/** Open network device
*
@@ -251,6 +251,28 @@ static inline int have_netdevs ( void ) {
return ( ! list_empty ( &net_devices ) );
}
+/**
+ * Get reference to network device
+ *
+ * @v netdev Network device
+ * @ret netdev Network device
+ */
+static inline __attribute__ (( always_inline )) struct net_device *
+netdev_get ( struct net_device *netdev ) {
+ ref_get ( &netdev->refcnt );
+ return netdev;
+}
+
+/**
+ * Drop reference to network device
+ *
+ * @v netdev Network device
+ */
+static inline __attribute__ (( always_inline )) void
+netdev_put ( struct net_device *netdev ) {
+ ref_put ( &netdev->refcnt );
+}
+
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
void netdev_tx_complete ( struct net_device *netdev, struct io_buffer *iobuf );
void netdev_tx_complete_next ( struct net_device *netdev );
@@ -262,7 +284,6 @@ extern int register_netdev ( struct net_device *netdev );
extern int netdev_open ( struct net_device *netdev );
extern void netdev_close ( struct net_device *netdev );
extern void unregister_netdev ( struct net_device *netdev );
-extern void free_netdev ( struct net_device *netdev );
struct net_device * find_netdev ( const char *name );
struct net_device * find_pci_netdev ( unsigned int busdevfn );