mirror of
https://github.com/ipxe/ipxe
synced 2025-12-12 23:15:10 +03:00
[Settings] Add per-netdevice settings block
Add a configuration settings block for each net device. This will provide the parent scope for settings applicable only to that network device (e.g. non-volatile options stored on the NIC, options obtained via DHCP, etc.). Expose the MAC address as a setting.
This commit is contained in:
@@ -266,6 +266,9 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
|
||||
netdev->refcnt.free = free_netdev;
|
||||
INIT_LIST_HEAD ( &netdev->tx_queue );
|
||||
INIT_LIST_HEAD ( &netdev->rx_queue );
|
||||
settings_init ( &netdev->settings,
|
||||
&netdev_settings_operations, &netdev->refcnt,
|
||||
netdev->name );
|
||||
netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) );
|
||||
}
|
||||
return netdev;
|
||||
@@ -282,11 +285,19 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
|
||||
*/
|
||||
int register_netdev ( struct net_device *netdev ) {
|
||||
static unsigned int ifindex = 0;
|
||||
int rc;
|
||||
|
||||
/* Create device name */
|
||||
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
|
||||
ifindex++ );
|
||||
|
||||
/* Register per-netdev configuration settings */
|
||||
if ( ( rc = register_settings ( &netdev->settings, NULL ) ) != 0 ) {
|
||||
DBGC ( netdev, "NETDEV %p could not register settings: %s\n",
|
||||
netdev, strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Add to device list */
|
||||
netdev_get ( netdev );
|
||||
list_add_tail ( &netdev->list, &net_devices );
|
||||
@@ -357,6 +368,9 @@ void unregister_netdev ( struct net_device *netdev ) {
|
||||
/* Ensure device is closed */
|
||||
netdev_close ( netdev );
|
||||
|
||||
/* Unregister per-netdev configuration settings */
|
||||
unregister_settings ( &netdev->settings );
|
||||
|
||||
/* Remove from device list */
|
||||
list_del ( &netdev->list );
|
||||
netdev_put ( netdev );
|
||||
|
||||
Reference in New Issue
Block a user