mirror of
https://github.com/ipxe/ipxe
synced 2025-12-24 15:23:42 +03:00
[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>
This commit is contained in:
@@ -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;
|
||||
@@ -451,27 +479,6 @@ netdev_settings_init ( struct net_device *netdev ) {
|
||||
netdev->settings.settings.op = &netdev_settings_operations;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user