summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/phantom
diff options
context:
space:
mode:
authorMichael Brown2008-10-29 19:17:02 +0100
committerMichael Brown2008-10-30 22:47:14 +0100
commit0a6c66a83018c64d961ee4e8601ae8950cbee00b (patch)
treec4adb1baea7c87b4e0bbd9f7d1f9127e738065d5 /src/drivers/net/phantom
parent[romprefix] Further sanity checks for the PCI 3 runtime segment address (diff)
downloadipxe-0a6c66a83018c64d961ee4e8601ae8950cbee00b.tar.gz
ipxe-0a6c66a83018c64d961ee4e8601ae8950cbee00b.tar.xz
ipxe-0a6c66a83018c64d961ee4e8601ae8950cbee00b.zip
[settings] Add the notion of a "tag magic" to numbered settings
Settings can be constructed using a dotted-decimal notation, to allow for access to unnamed settings. The default interpretation is as a DHCP option number (with encapsulated options represented as "<encapsulating option>.<encapsulated option>". In several contexts (e.g. SMBIOS, Phantom CLP), it is useful to interpret the dotted-decimal notation as referring to non-DHCP options. In this case, it becomes necessary for these contexts to ignore standard DHCP options, otherwise we end up trying to, for example, retrieve the boot filename from SMBIOS. Allow settings blocks to specify a "tag magic". When dotted-decimal notation is used to construct a setting, the tag magic value of the originating settings block will be ORed in to the tag number. Store/fetch methods can then check for the magic number before interpreting arbitrarily-numbered settings.
Diffstat (limited to 'src/drivers/net/phantom')
-rw-r--r--src/drivers/net/phantom/phantom.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c
index 659bd2c1..47bbcb9a 100644
--- a/src/drivers/net/phantom/phantom.c
+++ b/src/drivers/net/phantom/phantom.c
@@ -1589,6 +1589,12 @@ static struct net_device_operations phantom_operations = {
*
*/
+/** Phantom CLP settings tag magic */
+#define PHN_CLP_TAG_MAGIC 0xc19c1900UL
+
+/** Phantom CLP settings tag magic mask */
+#define PHN_CLP_TAG_MAGIC_MASK 0xffffff00UL
+
/** Phantom CLP data
*
*/
@@ -1790,7 +1796,7 @@ struct phantom_clp_setting {
/** gPXE setting */
struct setting *setting;
/** Setting number */
- unsigned int number;
+ unsigned int clp_setting;
};
/** Phantom CLP settings */
@@ -1802,25 +1808,29 @@ static struct phantom_clp_setting clp_settings[] = {
* Find Phantom CLP setting
*
* @v setting gPXE setting
- * @v clp_setting Equivalent Phantom CLP setting, or NULL
+ * @v clp_setting Setting number, or 0 if not found
*/
-static struct phantom_clp_setting *
-phantom_find_clp_setting ( struct phantom_nic *phantom,
- struct setting *setting ) {
+static unsigned int
+phantom_clp_setting ( struct phantom_nic *phantom, struct setting *setting ) {
struct phantom_clp_setting *clp_setting;
unsigned int i;
+ /* Search the list of explicitly-defined settings */
for ( i = 0 ; i < ( sizeof ( clp_settings ) /
sizeof ( clp_settings[0] ) ) ; i++ ) {
clp_setting = &clp_settings[i];
if ( setting_cmp ( setting, clp_setting->setting ) == 0 )
- return clp_setting;
+ return clp_setting->clp_setting;
}
+ /* Allow for use of numbered settings */
+ if ( ( setting->tag & PHN_CLP_TAG_MAGIC_MASK ) == PHN_CLP_TAG_MAGIC )
+ return ( setting->tag & ~PHN_CLP_TAG_MAGIC_MASK );
+
DBGC2 ( phantom, "Phantom %p has no \"%s\" setting\n",
phantom, setting->name );
- return NULL;
+ return 0;
}
/**
@@ -1838,18 +1848,17 @@ static int phantom_store_setting ( struct settings *settings,
struct phantom_nic_port *phantom_port =
container_of ( settings, struct phantom_nic_port, settings );
struct phantom_nic *phantom = phantom_port->phantom;
- struct phantom_clp_setting *clp_setting;
+ unsigned int clp_setting;
int rc;
/* Find Phantom setting equivalent to gPXE setting */
- clp_setting = phantom_find_clp_setting ( phantom, setting );
+ clp_setting = phantom_clp_setting ( phantom, setting );
if ( ! clp_setting )
return -ENOTSUP;
/* Store setting */
if ( ( rc = phantom_clp_store ( phantom, phantom_port->port,
- clp_setting->number,
- data, len ) ) != 0 ) {
+ clp_setting, data, len ) ) != 0 ) {
DBGC ( phantom, "Phantom %p could not store setting \"%s\": "
"%s\n", phantom, setting->name, strerror ( rc ) );
return rc;
@@ -1873,19 +1882,18 @@ static int phantom_fetch_setting ( struct settings *settings,
struct phantom_nic_port *phantom_port =
container_of ( settings, struct phantom_nic_port, settings );
struct phantom_nic *phantom = phantom_port->phantom;
- struct phantom_clp_setting *clp_setting;
+ unsigned int clp_setting;
int read_len;
int rc;
/* Find Phantom setting equivalent to gPXE setting */
- clp_setting = phantom_find_clp_setting ( phantom, setting );
+ clp_setting = phantom_clp_setting ( phantom, setting );
if ( ! clp_setting )
return -ENOTSUP;
/* Fetch setting */
if ( ( read_len = phantom_clp_fetch ( phantom, phantom_port->port,
- clp_setting->number,
- data, len ) ) < 0 ) {
+ clp_setting, data, len ) ) < 0 ){
rc = read_len;
DBGC ( phantom, "Phantom %p could not fetch setting \"%s\": "
"%s\n", phantom, setting->name, strerror ( rc ) );
@@ -2269,7 +2277,7 @@ static int phantom_probe ( struct pci_device *pci,
phantom_port->port = i;
settings_init ( &phantom_port->settings,
&phantom_settings_operations,
- &netdev->refcnt, "clp" );
+ &netdev->refcnt, "clp", PHN_CLP_TAG_MAGIC );
}
/* BUG5945 - need to hack PCI config space on P3 B1 silicon.