mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 00:17:57 +03:00
Kill off hotplug.h and just make net devices normal reference-counted
structures. DHCP still broken and #if 0'd out.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user