2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-22 17:41:55 +00:00

[settings] Add Bus ID setting

Users can find the bus type and PCI IDs for a network interface with:

netX/busid

Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
This commit is contained in:
Shao Miller 2009-11-09 08:57:23 -05:00 committed by Stefan Hajnoczi
parent 70928aeaa0
commit 177389fb73
3 changed files with 21 additions and 4 deletions

View File

@ -242,6 +242,7 @@ extern struct setting priority_setting __setting;
extern struct setting uuid_setting __setting;
extern struct setting next_server_setting __setting;
extern struct setting mac_setting __setting;
extern struct setting busid_setting __setting;
extern struct setting user_class_setting __setting;
/**

View File

@ -20,8 +20,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <gpxe/dhcp.h>
#include <gpxe/settings.h>
#include <gpxe/device.h>
#include <gpxe/netdevice.h>
/** @file
@ -36,6 +38,11 @@ struct setting mac_setting __setting = {
.description = "MAC address",
.type = &setting_type_hex,
};
struct setting busid_setting __setting = {
.name = "busid",
.description = "Bus ID",
.type = &setting_type_hex,
};
/**
* Store value of network device setting
@ -74,6 +81,8 @@ static int netdev_fetch ( struct settings *settings, struct setting *setting,
void *data, size_t len ) {
struct net_device *netdev = container_of ( settings, struct net_device,
settings.settings );
struct device_description *desc = &netdev->dev->desc;
struct dhcp_netdev_desc dhcp_desc;
if ( setting_cmp ( setting, &mac_setting ) == 0 ) {
if ( len > netdev->ll_protocol->ll_addr_len )
@ -81,6 +90,15 @@ static int netdev_fetch ( struct settings *settings, struct setting *setting,
memcpy ( data, netdev->ll_addr, len );
return netdev->ll_protocol->ll_addr_len;
}
if ( setting_cmp ( setting, &busid_setting ) == 0 ) {
dhcp_desc.type = desc->bus_type;
dhcp_desc.vendor = htons ( desc->vendor );
dhcp_desc.device = htons ( desc->device );
if ( len > sizeof ( dhcp_desc ) )
len = sizeof ( dhcp_desc );
memcpy ( data, &dhcp_desc, len );
return sizeof ( dhcp_desc );
}
return generic_settings_fetch ( settings, setting, data, len );
}

View File

@ -932,7 +932,6 @@ int dhcp_create_packet ( struct dhcp_packet *dhcppkt,
int dhcp_create_request ( struct dhcp_packet *dhcppkt,
struct net_device *netdev, unsigned int msgtype,
struct in_addr ciaddr, void *data, size_t max_len ) {
struct device_description *desc = &netdev->dev->desc;
struct dhcp_netdev_desc dhcp_desc;
struct dhcp_client_id client_id;
struct dhcp_client_uuid client_uuid;
@ -966,9 +965,8 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
}
/* Add options to identify the network device */
dhcp_desc.type = desc->bus_type;
dhcp_desc.vendor = htons ( desc->vendor );
dhcp_desc.device = htons ( desc->device );
fetch_setting ( &netdev->settings.settings, &busid_setting, &dhcp_desc,
sizeof ( dhcp_desc ) );
if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_EB_BUS_ID, &dhcp_desc,
sizeof ( dhcp_desc ) ) ) != 0 ) {
DBG ( "DHCP could not set bus ID option: %s\n",