Accepting request 144438 from home:posophe:branches:Base:System

add required changes

OBS-URL: https://build.opensuse.org/request/show/144438
OBS-URL: https://build.opensuse.org/package/show/Base:System/biosdevname?expand=0&rev=13
This commit is contained in:
Marcus Meissner 2012-12-07 09:06:02 +00:00 committed by Git OBS Bridge
parent 2130abc015
commit 790566a59e
7 changed files with 12 additions and 437 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f9bdfb1da4b9f93c28b8b53b5d8c6e572d2b21df2fa8e81d72191398f4e1ed60
size 189422

3
biosdevname-0.4.1.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:230e5bffd17f46b6d820faa46ea79ace3eecaf919852ee7ff231e73f6b9f8fe7
size 187782

View File

@ -1,4 +1,12 @@
-------------------------------------------------------------------
Mon Dec 3 13:51:01 UTC 2012 - p.drouand@gmail.com
- Update to 0.4.1 version:
* Use addslot() to track both embedded and physical index per slot
* Add fixes to ignore NPAR parsing on some cards
- Removed patchs: more-cmdline-args, verify-network-VPD, bug-706505
fixed on upstream releases bnc#706505
-------------------------------------------------------------------
Wed May 30 16:37:11 UTC 2012 - sweet_f_a@gmx.de
- remove useless automake dependecy

View File

@ -17,7 +17,7 @@
Name: biosdevname
Version: 0.3.8
Version: 0.4.1
Release: 0
Summary: Udev helper for naming devices per BIOS names
License: GPL-2.0
@ -30,11 +30,8 @@ Url: http://linux.dell.com/files/biosdevname/
ExclusiveArch: %{ix86} x86_64
Source0: http://linux.dell.com/files/%{name}/%{name}-%{version}/%{name}-%{version}.tar.gz
Source1: setup-biosdevname.sh
Patch1: more-cmdline-args
Patch2: ignore-broken-BIOSes
Patch3: whitelist-dell
Patch4: verify-network-VPD
Patch5: bug-706505
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: pciutils-devel
BuildRequires: zlib-devel
@ -57,11 +54,8 @@ You can enable/disable usage of biosdevname with boot option
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%build
# this is a udev rule, so it needs to live in / rather than /usr

View File

@ -1,245 +0,0 @@
diff -ur biosdevname-0.3.8.old/src/naming_policy.c biosdevname-0.3.8/src/naming_policy.c
--- biosdevname-0.3.8.old/src/naming_policy.c 2011-09-23 14:09:52.000000000 +0200
+++ biosdevname-0.3.8/src/naming_policy.c 2011-09-23 14:10:11.000000000 +0200
@@ -37,38 +37,39 @@
char interface[IFNAMSIZ];
unsigned int portnum=0;
int known=0;
-
- memset(buffer, 0, sizeof(buffer));
- memset(location, 0, sizeof(location));
- memset(port, 0, sizeof(port));
- memset(interface, 0, sizeof(interface));
+ struct pci_device *vf;
list_for_each_entry(dev, &state->bios_devices, node) {
known = 0;
+ memset(buffer, 0, sizeof(buffer));
+ memset(location, 0, sizeof(location));
+ memset(port, 0, sizeof(port));
+ memset(interface, 0, sizeof(interface));
+
if (is_pci(dev)) {
+ vf = dev->pcidev;
if (dev->pcidev->physical_slot == 0) { /* embedded devices only */
- if (dev->pcidev->uses_sysfs & HAS_SYSFS_INDEX) {
- portnum = dev->pcidev->sysfs_index;
- snprintf(location, sizeof(location), "%s%u", prefix, portnum);
- known=1;
- }
- else if (dev->pcidev->uses_smbios & HAS_SMBIOS_INSTANCE && is_pci_smbios_type_ethernet(dev->pcidev)) {
- portnum = dev->pcidev->smbios_instance;
- snprintf(location, sizeof(location), "%s%u", prefix, portnum);
- known=1;
- }
- else if (dev->pcidev->embedded_index_valid) {
- portnum = dev->pcidev->embedded_index;
+ portnum = INT_MAX;
+ /* Use master VPD device if available */
+ if (vf->vpd_pf)
+ vf = vf->vpd_pf;
+ if (vf->uses_sysfs & HAS_SYSFS_INDEX)
+ portnum = vf->sysfs_index;
+ else if (vf->uses_smbios & HAS_SMBIOS_INSTANCE && is_pci_smbios_type_ethernet(vf))
+ portnum = vf->smbios_instance;
+ else if (vf->embedded_index_valid)
+ portnum = vf->embedded_index;
+ if (portnum != INT_MAX) {
snprintf(location, sizeof(location), "%s%u", prefix, portnum);
known=1;
}
}
else if (dev->pcidev->physical_slot < PHYSICAL_SLOT_UNKNOWN) {
snprintf(location, sizeof(location), "p%u", dev->pcidev->physical_slot);
- if (!dev->pcidev->is_sriov_virtual_function)
- portnum = dev->pcidev->index_in_slot;
- else if (dev->pcidev->vpd_port < INT_MAX)
+ if (dev->pcidev->vpd_port < INT_MAX)
portnum = dev->pcidev->vpd_port;
+ else if (!dev->pcidev->is_sriov_virtual_function)
+ portnum = dev->pcidev->index_in_slot;
else
portnum = dev->pcidev->pf->index_in_slot;
snprintf(port, sizeof(port), "p%u", portnum);
diff -ur biosdevname-0.3.8.old/src/pci.c biosdevname-0.3.8/src/pci.c
--- biosdevname-0.3.8.old/src/pci.c 2011-09-23 14:09:52.000000000 +0200
+++ biosdevname-0.3.8/src/pci.c 2011-09-23 14:10:15.000000000 +0200
@@ -114,9 +114,10 @@
return -1;
}
-static int parse_vpd(struct pci_device *pdev, int len, unsigned char *vpd)
+static int parse_vpd(struct libbiosdevname_state *state, struct pci_device *pdev, int len, unsigned char *vpd)
{
int i, j, k, isz, jsz, port, func, pfi;
+ struct pci_device *vf;
i = pci_vpd_find_tag(vpd, 0, len, 0x90);
if (i < 0)
@@ -133,15 +134,6 @@
if (memcmp(vpd+j+3, "1028VPDR.VER1.0", 15))
return 1;
- /* Lookup NPY Num Ports */
- j = pci_vpd_find_info_subkey(vpd, i, isz, "**", "NPY");
- if (j < 0)
- return 1;
- jsz = pci_vpd_info_field_size(&vpd[j]);
- j += PCI_VPD_INFO_FLD_HDR_SIZE;
- sscanf((char *)vpd+j+3, "%1x", &port);
- pdev->vpd_nports = port;
-
/* Lookup Port Mappings */
j = pci_vpd_find_info_subkey(vpd, i, isz, "**", "DCM");
if (j < 0)
@@ -152,16 +144,21 @@
for (k=3; k<jsz; k+=10) {
/* Parse Port Info */
sscanf((char *)vpd+j+k, "%1x%1x%2x", &port, &func, &pfi);
- if (func == pdev->pci_dev->func) {
- pdev->vpd_port = port;
- pdev->vpd_pfi = pfi;
+ if ((vf = find_pci_dev_by_pci_addr(state, pdev->pci_dev->domain,
+ pdev->pci_dev->bus,
+ pdev->pci_dev->dev,
+ func)) != NULL) {
+ if (vf->vpd_port == INT_MAX) {
+ vf->vpd_port = port;
+ vf->vpd_pfi = pfi;
+ }
}
}
return 0;
}
/* Read and parse PCI VPD section if it exists */
-static int read_pci_vpd(struct pci_device *pdev)
+static int read_pci_vpd(struct libbiosdevname_state *state, struct pci_device *pdev)
{
char path[PATH_MAX];
char pci_name[16];
@@ -172,13 +169,13 @@
unparse_pci_name(pci_name, sizeof(pci_name), pdev->pci_dev);
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/vpd", pci_name);
- if ((fd = open(path, O_RDONLY)) >= 0) {
+ if ((fd = open(path, O_RDONLY|O_SYNC)) >= 0) {
size = pci_vpd_size(pdev, fd);
if (size > 0) {
vpd = malloc(size);
if (vpd != NULL) {
if ((nrd = pread(fd, vpd, size, 0)) > 0)
- rc = parse_vpd(pdev, nrd, vpd);
+ rc = parse_vpd(state, pdev, nrd, vpd);
free(vpd);
}
}
@@ -189,10 +186,36 @@
static void set_pci_vpd_instance(struct libbiosdevname_state *state)
{
- struct pci_device *dev;
+ struct pci_device *dev, *dev2;
+
+ /* Read VPD information for each device */
+ list_for_each_entry(dev, &state->pci_devices, node) {
+ read_pci_vpd(state, dev);
+ }
+ /* Now match VPD master device */
list_for_each_entry(dev, &state->pci_devices, node) {
- read_pci_vpd(dev);
+ if (dev->vpd_port == INT_MAX)
+ continue;
+ list_for_each_entry(dev2, &state->pci_devices, node) {
+ if (dev2->pci_dev->domain == dev->pci_dev->domain &&
+ dev2->pci_dev->bus == dev->pci_dev->bus &&
+ dev2->pci_dev->dev == dev->pci_dev->dev &&
+ dev2->vpd_port == dev->vpd_port) {
+ dev2->vpd_count++;
+ dev->vpd_pf = dev2;
+ break;
+ }
+ }
+ }
+
+ /* Delete all VPD devices with single function */
+ list_for_each_entry(dev, &state->pci_devices, node) {
+ if (dev->vpd_count == 1) {
+ dev->vpd_port = INT_MAX;
+ dev->vpd_pfi = INT_MAX;
+ dev->vpd_pf = NULL;
+ }
}
}
@@ -495,6 +518,7 @@
dev->vf_index = INT_MAX;
dev->vpd_port = INT_MAX;
dev->vpd_pfi = INT_MAX;
+ dev->vpd_pf = NULL;
fill_pci_dev_sysfs(dev, p);
list_add(&dev->node, &state->pci_devices);
}
@@ -559,6 +583,8 @@
continue;
if (pcidev->is_sriov_virtual_function) /* skip sriov VFs, they're handled later */
continue;
+ if (pcidev->vpd_port != INT_MAX)
+ continue;
pcidev->embedded_index = index;
pcidev->embedded_index_valid = 1;
index++;
@@ -644,11 +670,11 @@
/* ordering here is important */
dmidecode_main(state); /* this will fail on Xen guests, that's OK */
sort_device_list(state);
+ set_pci_vpd_instance(state);
set_pci_slots(state);
set_embedded_index(state);
set_pci_slot_index(state);
set_sriov_pf_vf(state);
- set_pci_vpd_instance(state);
return rc;
}
@@ -711,8 +737,8 @@
if (p->smbios_type) {
s += snprintf(s, size-(s-buf), "SMBIOS Device Type: ");
s += unparse_smbios_type41_type(s, size-(s-buf), p->smbios_type);
- s += snprintf(s, size-(s-buf), "SMBIOS Instance: %u\n", p->smbios_instance);
- s += snprintf(s, size-(s-buf), "SMBIOS Enabled: %s\n", p->smbios_instance?"True":"False");
+ if (p->smbios_instance)
+ s += snprintf(s, size-(s-buf), "SMBIOS Instance: %u\n", p->smbios_instance);
}
if (p->uses_smbios & HAS_SMBIOS_LABEL && p->smbios_label)
s += snprintf(s, size-(s-buf), "SMBIOS Label: %s\n", p->smbios_label);
@@ -727,7 +753,11 @@
if (p->vpd_port < INT_MAX) {
s += snprintf(s, size-(s-buf), "VPD Port: %u\n", p->vpd_port);
s += snprintf(s, size-(s-buf), "VPD Index: %u\n", p->vpd_pfi);
- s += snprintf(s, size-(s-buf), "VPD #Ports: %u\n", p->vpd_nports);
+ if (p->vpd_pf) {
+ s += snprintf(s, size-(s-buf), "VPD PCI master: ");
+ s += unparse_pci_name(s, size-(s-buf), p->vpd_pf->pci_dev);
+ s += snprintf(s, size-(s-buf), " count %d\n", p->vpd_pf->vpd_count);
+ }
}
if (!list_empty(&p->vfs)) {
s += snprintf(s, size-(s-buf), "Virtual Functions:\n");
Only in biosdevname-0.3.8/src: pci.c.orig
diff -ur biosdevname-0.3.8.old/src/pci.h biosdevname-0.3.8/src/pci.h
--- biosdevname-0.3.8.old/src/pci.h 2011-09-23 14:09:52.000000000 +0200
+++ biosdevname-0.3.8/src/pci.h 2011-09-23 14:10:15.000000000 +0200
@@ -29,9 +29,10 @@
char * sysfs_label;
unsigned char uses_sysfs;
unsigned int vf_index;
+ unsigned int vpd_count;
unsigned int vpd_pfi;
- unsigned int vpd_nports;
unsigned int vpd_port;
+ struct pci_device *vpd_pf;
struct pci_device *pf;
struct list_head vfnode;
struct list_head vfs;

View File

@ -1,122 +0,0 @@
From: Jordan Hargrave <Jordan_Hargrave@dell.com>
Date: Thu, 31 Mar 2011 17:48:00 +0000 (-0500)
Subject: Add command line arguments for checking SMBIOS version and ignore $PIRQ.
X-Git-Url: http://linux.dell.com/cgi-bin/gitweb/gitweb.cgi?p=biosdevname.git;a=commitdiff_plain;h=8dde4129ab403f4df5f013209e5dd21d25b43f05
Add command line arguments for checking SMBIOS version and ignore $PIRQ.
---
diff --git a/src/bios_dev_name.c b/src/bios_dev_name.c
index 81e7620..e2f8454 100644
--- a/src/bios_dev_name.c
+++ b/src/bios_dev_name.c
@@ -14,6 +14,9 @@
#include "bios_dev_name.h"
static struct bios_dev_name_opts opts;
+int nopirq;
+int smver_mjr;
+int smver_mnr;
static void usage(void)
{
@@ -23,6 +26,8 @@ static void usage(void)
fprintf(stderr, " -d or --debug enable debugging\n");
fprintf(stderr, " --policy [physical | all_ethN ]\n");
fprintf(stderr, " --prefix [string] string use for embedded NICs (default='em')\n");
+ fprintf(stderr, " --smbios [x.y] Require SMBIOS x.y or greater\n");
+ fprintf(stderr, " --nopirq Don't use $PIR table for slot numbers\n");
fprintf(stderr, " Example: biosdevname -i eth0\n");
fprintf(stderr, " returns: em1\n");
fprintf(stderr, " when eth0 is an embedded NIC with label '1' on the chassis.\n");
@@ -55,6 +60,8 @@ parse_opts(int argc, char **argv)
{"interface", no_argument, 0, 'i'},
{"policy", required_argument, 0, 'p'},
{"prefix", required_argument, 0, 'P'},
+ {"nopirq", no_argument, 0, 'x'},
+ {"smbios", required_argument, 0, 's'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv,
@@ -75,6 +82,12 @@ parse_opts(int argc, char **argv)
case 'P':
opts.prefix = optarg;
break;
+ case 's':
+ sscanf(optarg, "%u.%u", &smver_mjr, &smver_mnr);
+ break;
+ case 'x':
+ nopirq = 1;
+ break;
default:
usage();
exit(1);
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
index ec91305..7bedc3a 100644
--- a/src/dmidecode/dmidecode.c
+++ b/src/dmidecode/dmidecode.c
@@ -40,6 +40,8 @@
#include "../pci.h"
#include "../naming_policy.h"
+extern int smver_mjr, smver_mnr;
+
static const char *bad_index = "<BAD INDEX>";
/*
@@ -176,12 +178,27 @@ static void to_dmi_header(struct dmi_header *h, u8 *data)
h->data=data;
}
+static int isvalidsmbios(int mjr, int mnr)
+{
+ if (!smver_mjr && !smver_mnr)
+ return 1;
+ if (mjr > smver_mjr)
+ return 1;
+ if ((mjr == smver_mjr) && (mnr >= smver_mnr))
+ return 1;
+ return 0;
+}
+
static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, const struct libbiosdevname_state *state)
{
u8 *buf;
u8 *data;
int i=0;
+ /* Verify SMBIOS version */
+ if (!isvalidsmbios(ver >> 8, ver & 0xFF)) {
+ return;
+ }
if((buf=mem_chunk(base, len, devmem))==NULL)
{
#ifndef USE_MMAP
diff --git a/src/pirq.c b/src/pirq.c
index 14685bb..8eb4c97 100644
--- a/src/pirq.c
+++ b/src/pirq.c
@@ -18,6 +18,8 @@
#include <sys/mman.h>
#include "pirq.h"
+extern int nopirq;
+
/* If unknown, use INT_MAX so they get sorted last */
int pirq_pci_dev_to_slot(struct routing_table *table, int domain, int bus, int dev)
{
@@ -49,8 +51,13 @@ struct routing_table * pirq_alloc_read_table()
int i;
void *mem;
off_t offset=0L;
- int fd=open("/dev/mem", O_RDONLY);
+ int fd;
+ /* Skip PIRQ table parsing */
+ if (nopirq) {
+ return NULL;
+ }
+ fd = open("/dev/mem", O_RDONLY);
if(fd==-1)
return NULL;

View File

@ -1,60 +0,0 @@
X-Git-Url: http://linux.dell.com/cgi-bin/gitweb/gitweb.cgi?p=biosdevname.git;a=blobdiff_plain;f=src%2Fpci.c;h=2175c87f815b33af09bd00d00387d0cec22cd993;hp=7220afc24753c83152acf2ae13b8f1529505a18b;hb=199c98f7bf3ae05f3ecdefcaa776278e7c535cba;hpb=473634364dbc28573faff4ab27d637f7fc842e74
diff --git a/src/pci.c b/src/pci.c
index 7220afc..2175c87 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -45,6 +45,32 @@ static inline u8 pci_vpd_info_field_size(const u8 *info_field)
return info_field[2];
}
+static int pci_vpd_size(struct pci_device *pdev, int fd)
+{
+ uint8_t buf[3], tag;
+ int off;
+
+ if (!is_pci_network(pdev))
+ return 0;
+ off = 0;
+ for(;;) {
+ if (pread(fd, buf, 1, off) != 1)
+ break;
+ if (buf[0] & PCI_VPD_LRDT) {
+ tag = buf[0];
+ if (pread(fd, buf, 3, off) != 3)
+ break;
+ off += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf);
+ } else {
+ tag = buf[0] & ~PCI_VPD_SRDT_LEN_MASK;
+ off += PCI_VPD_SRDT_TAG_SIZE + pci_vpd_srdt_size(buf);
+ }
+ if (tag == 0 || tag == 0xFF || tag == PCI_VPD_SRDT_END)
+ break;
+ }
+ return off;
+}
+
static int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt)
{
int i;
@@ -147,12 +173,14 @@ static int read_pci_vpd(struct pci_device *pdev)
unparse_pci_name(pci_name, sizeof(pci_name), pdev->pci_dev);
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/vpd", pci_name);
if ((fd = open(path, O_RDONLY)) >= 0) {
- size = lseek(fd, 0, SEEK_END);
- vpd = malloc(size);
- if (vpd != NULL) {
- if ((nrd = pread(fd, vpd, size, 0)) > 0)
- rc = parse_vpd(pdev, nrd, vpd);
- free(vpd);
+ size = pci_vpd_size(pdev, fd);
+ if (size > 0) {
+ vpd = malloc(size);
+ if (vpd != NULL) {
+ if ((nrd = pread(fd, vpd, size, 0)) > 0)
+ rc = parse_vpd(pdev, nrd, vpd);
+ free(vpd);
+ }
}
close(fd);
}