diff -Nru biosdevname-0.4.1/debian/changelog biosdevname-0.4.1/debian/changelog --- biosdevname-0.4.1/debian/changelog 2014-06-04 13:59:52.000000000 +0000 +++ biosdevname-0.4.1/debian/changelog 2015-09-01 16:50:38.000000000 +0000 @@ -1,3 +1,14 @@ +biosdevname (0.4.1-0ubuntu6.2) trusty; urgency=medium + + * Added upstream Mellanox fixes to biosdevname per their request: (LP: #1455871) + + d/p/Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch + + d/p/Scan-for-devid-for-Mellanox-cards.patch + + d/p/Add-port-structure-to-PCI-device-handle-multiple-por.patch + + d/p/Add-port-code-for-Mellanox-driver.patch + + d/p/Add-dev_port-attribute-for-new-Mellanox-driver.patch + + -- Rafael David Tinoco (Inaddy) Tue, 01 Sep 2015 11:50:38 -0500 + biosdevname (0.4.1-0ubuntu6.1) trusty; urgency=high * Backport upstream patch to fix regression introduced by the addslot diff -Nru biosdevname-0.4.1/debian/patches/Add-dev_port-attribute-for-new-Mellanox-driver.patch biosdevname-0.4.1/debian/patches/Add-dev_port-attribute-for-new-Mellanox-driver.patch --- biosdevname-0.4.1/debian/patches/Add-dev_port-attribute-for-new-Mellanox-driver.patch 1970-01-01 00:00:00.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/Add-dev_port-attribute-for-new-Mellanox-driver.patch 2015-09-01 16:50:36.000000000 +0000 @@ -0,0 +1,35 @@ +Description: Add dev_port attribute for new Mellanox driver + +Author: Jordan Hargrave +Origin: http://linux.dell.com/git/biosdevname.git, commit: 30cedbc +Bug-Ubuntu: https://launchpad.net/bugs/1455871 +Last-Update: 2015-06-24 +--- biosdevname-0.4.1.orig/src/eths.c ++++ biosdevname-0.4.1/src/eths.c +@@ -34,18 +34,23 @@ char *pr_ether(char *buf, const int size + return (buf); + } + +-static int eths_get_devid(const char *devname, int *devid) ++static void eths_get_devid(const char *devname, int *devid) + { + char path[PATH_MAX]; + char *devidstr = NULL; + + *devid = -1; +- snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", devname); ++ snprintf(path, sizeof(path), "/sys/class/net/%s/dev_port", devname); + if (sysfs_read_file(path, &devidstr) == 0) { + sscanf(devidstr, "%i", devid); + free(devidstr); ++ } else { ++ snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", devname); ++ if (sysfs_read_file(path, &devidstr) == 0) { ++ sscanf(devidstr, "%i", devid); ++ free(devidstr); ++ } + } +- return NULL; + } + + static int eths_get_ifindex(const char *devname, int *ifindex) diff -Nru biosdevname-0.4.1/debian/patches/Add-port-code-for-Mellanox-driver.patch biosdevname-0.4.1/debian/patches/Add-port-code-for-Mellanox-driver.patch --- biosdevname-0.4.1/debian/patches/Add-port-code-for-Mellanox-driver.patch 1970-01-01 00:00:00.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/Add-port-code-for-Mellanox-driver.patch 2015-09-01 16:50:36.000000000 +0000 @@ -0,0 +1,161 @@ +Description: Add port code for Mellanox driver + +Conflicts: + configure.ac - kept version 0.4.1 + +Author: Jordan Hargrave +Origin: http://linux.dell.com/git/biosdevname.git, commit: 45ea4d6 +Bug-Ubuntu: https://launchpad.net/bugs/1455871 +Last-Update: 2015-06-24 +--- + configure.ac | 2 +- + src/bios_device.c | 47 ++++++++++++++++++++++++++++++++++------------- + src/bios_device.h | 2 ++ + src/naming_policy.c | 12 +++++++++--- + 4 files changed, 46 insertions(+), 17 deletions(-) + +diff --git a/configure.ac b/configure.ac +index ce6d4ee..9e78a05 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3,7 +3,7 @@ + # vim:tw=0:ts=8:sw=8:et + + AC_PREREQ(2.59) +-AC_INIT([biosdevname],[0.4.1],[Jordan_Hargrave@dell.com]) ++AC_INIT([biosdevname],[0.4.1],[Jordan_Hargrave@dell.com]) + AC_LANG([C]) + AC_USE_SYSTEM_EXTENSIONS + AC_CONFIG_SRCDIR([src/read_proc.c]) +diff --git a/src/bios_device.c b/src/bios_device.c +index 132877e..ba0661f 100644 +--- a/src/bios_device.c ++++ b/src/bios_device.c +@@ -212,6 +212,16 @@ static void sort_device_list(struct libbiosdevname_state *state) + list_splice(&sorted_devices, &state->bios_devices); + } + ++/* Check for Mellanox/Chelsio drivers */ ++int ismultiport(const char *driver) ++{ ++ if (!strncmp(driver, "mlx", 3)) ++ return 1; ++ if (!strncmp(driver, "cxgb", 4)) ++ return 1; ++ return 0; ++} ++ + static void match_pci_and_eth_devs(struct libbiosdevname_state *state) + { + struct pci_device *p; +@@ -223,20 +233,30 @@ static void match_pci_and_eth_devs(struct libbiosdevname_state *state) + if (!is_pci_network(p)) + continue; + ++ /* Loop through all ether devices to find match */ + unparse_pci_name(pci_name, sizeof(pci_name), p->pci_dev); +- n = find_net_device_by_bus_info(state, pci_name); +- if (!n) +- continue; +- +- b = malloc(sizeof(*b)); +- if (!b) +- continue; +- memset(b, 0, sizeof(*b)); +- INIT_LIST_HEAD(&b->node); +- b->pcidev = p; +- b->netdev = n; +- claim_netdev(b->netdev); +- list_add(&b->node, &state->bios_devices); ++ list_for_each_entry(n, &state->network_devices, node) { ++ if (strncmp(n->drvinfo.bus_info, pci_name, sizeof(n->drvinfo.bus_info))) ++ continue; ++ b = malloc(sizeof(*b)); ++ if (!b) ++ continue; ++ memset(b, 0, sizeof(*b)); ++ INIT_LIST_HEAD(&b->node); ++ b->pcidev = p; ++ b->netdev = n; ++ b->port = NULL; ++ if (ismultiport(n->drvinfo.driver)) { ++ b->port = malloc(sizeof(struct pci_port)); ++ if (b->port != NULL) { ++ b->port->port = n->devid+1; ++ b->port->pfi = p->is_sriov_virtual_function ? ++ p->vf_index : -1; ++ } ++ } ++ claim_netdev(b->netdev); ++ list_add(&b->node, &state->bios_devices); ++ } + } + } + +@@ -258,6 +278,7 @@ static void match_unknown_eths(struct libbiosdevname_state *state) + memset(b, 0, sizeof(*b)); + INIT_LIST_HEAD(&b->node); + b->netdev = n; ++ b->port = NULL; + list_add(&b->node, &state->bios_devices); + } + } +diff --git a/src/bios_device.h b/src/bios_device.h +index 690ed6f..158a2af 100644 +--- a/src/bios_device.h ++++ b/src/bios_device.h +@@ -12,12 +12,14 @@ + #include "pci.h" + #include "naming_policy.h" + ++struct pci_port; + + struct bios_device { + struct list_head node; + struct network_device *netdev; + struct pci_device *pcidev; + char *bios_name; ++ struct pci_port *port; + int duplicate; + }; + +diff --git a/src/naming_policy.c b/src/naming_policy.c +index 4f2033c..7138a4b 100644 +--- a/src/naming_policy.c ++++ b/src/naming_policy.c +@@ -55,7 +55,9 @@ static void use_physical(const struct libbiosdevname_state *state, const char *p + vf = vf->vpd_pf; + if (vf->pf) + vf = vf->pf; +- if (vf->uses_sysfs & HAS_SYSFS_INDEX) ++ if (dev->port) ++ portnum = dev->port->port; ++ else 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; +@@ -68,7 +70,9 @@ static void use_physical(const struct libbiosdevname_state *state, const char *p + } + else if (dev->pcidev->physical_slot < PHYSICAL_SLOT_UNKNOWN) { + snprintf(location, sizeof(location), "p%u", dev->pcidev->physical_slot); +- if (dev->pcidev->vpd_port < INT_MAX) ++ if (dev->port) ++ portnum = dev->port->port; ++ else 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; +@@ -78,7 +82,9 @@ static void use_physical(const struct libbiosdevname_state *state, const char *p + known=1; + } + +- if (dev->pcidev->is_sriov_virtual_function) ++ if (dev->port && dev->port->pfi != -1) ++ snprintf(interface, sizeof(interface), "_%u", dev->port->pfi); ++ else if (dev->pcidev->is_sriov_virtual_function) + snprintf(interface, sizeof(interface), "_%u", dev->pcidev->vf_index); + else if (dev->pcidev->vpd_pfi < INT_MAX) + snprintf(interface, sizeof(interface), "_%u", dev->pcidev->vpd_pfi); +-- +1.9.1 + diff -Nru biosdevname-0.4.1/debian/patches/Add-port-structure-to-PCI-device-handle-multiple-por.patch biosdevname-0.4.1/debian/patches/Add-port-structure-to-PCI-device-handle-multiple-por.patch --- biosdevname-0.4.1/debian/patches/Add-port-structure-to-PCI-device-handle-multiple-por.patch 1970-01-01 00:00:00.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/Add-port-structure-to-PCI-device-handle-multiple-por.patch 2015-09-01 16:50:36.000000000 +0000 @@ -0,0 +1,85 @@ +Description: Add port structure to PCI device, handle multiple ports per BDF (Mellanox) + +Author: Jordan Hargrave +Origin: http://linux.dell.com/git/biosdevname.git, commit: 1c63d55 +Bug-Ubuntu: https://launchpad.net/bugs/1455871 +Last-Update: 2015-06-24 +--- + src/pci.c | 21 +++++++++++++++++++++ + src/pci.h | 7 +++++++ + 2 files changed, 28 insertions(+) + +diff --git a/src/pci.c b/src/pci.c +index 31bc9b2..2992474 100644 +--- a/src/pci.c ++++ b/src/pci.c +@@ -121,6 +121,25 @@ static int pci_vpd_find_info_subkey(const u8 *buf, unsigned int off, unsigned in + return -1; + } + ++/* Add port identifier(s) to PCI device */ ++static void add_port(struct pci_device *pdev, int port, int pfi) ++{ ++ struct pci_port *p; ++ ++ list_for_each_entry(p, &pdev->ports, node) { ++ if (p->port == port && p->pfi == pfi) ++ return; ++ } ++ p = malloc(sizeof(*p)); ++ if (p == NULL) ++ return; ++ memset(p, 0, sizeof(*p)); ++ INIT_LIST_HEAD(&p->node); ++ p->port = port; ++ p->pfi = pfi; ++ list_add_tail(&p->node, &pdev->ports); ++} ++ + 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; +@@ -155,6 +174,7 @@ static int parse_vpd(struct libbiosdevname_state *state, struct pci_device *pdev + pdev->pci_dev->bus, + pdev->pci_dev->dev, + func)) != NULL) { ++ add_port(vf, port, pfi); + if (vf->vpd_port == INT_MAX) { + vf->vpd_port = port; + vf->vpd_pfi = pfi; +@@ -595,6 +615,7 @@ static void add_pci_dev(struct libbiosdevname_state *state, + INIT_LIST_HEAD(&dev->node); + INIT_LIST_HEAD(&dev->vfnode); + INIT_LIST_HEAD(&dev->vfs); ++ INIT_LIST_HEAD(&dev->ports); + dev->pci_dev = p; + dev->physical_slot = PHYSICAL_SLOT_UNKNOWN; + dev->class = pci_read_word(p, PCI_CLASS_DEVICE); +diff --git a/src/pci.h b/src/pci.h +index c30c014..3dd3d37 100644 +--- a/src/pci.h ++++ b/src/pci.h +@@ -20,6 +20,12 @@ struct slotlist + int count; + }; + ++struct pci_port { ++ struct list_head node; ++ int port; ++ int pfi; ++}; ++ + struct pci_device { + struct list_head node; + struct pci_dev *pci_dev; +@@ -43,6 +49,7 @@ struct pci_device { + struct pci_device *pf; + struct list_head vfnode; + struct list_head vfs; ++ struct list_head ports; + unsigned int is_sriov_physical_function:1; + unsigned int is_sriov_virtual_function:1; + unsigned int embedded_index_valid:1; +-- +1.9.1 + diff -Nru biosdevname-0.4.1/debian/patches/Scan-for-devid-for-Mellanox-cards.patch biosdevname-0.4.1/debian/patches/Scan-for-devid-for-Mellanox-cards.patch --- biosdevname-0.4.1/debian/patches/Scan-for-devid-for-Mellanox-cards.patch 1970-01-01 00:00:00.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/Scan-for-devid-for-Mellanox-cards.patch 2015-09-01 16:50:36.000000000 +0000 @@ -0,0 +1,59 @@ +Description: Scan for devid for Mellanox cards + +Author: Jordan Hargrave +Origin: http://linux.dell.com/git/biosdevname.git, commit: 0a3684e +Bug-Ubuntu: https://launchpad.net/bugs/1455871 +Last-Update: 2015-06-24 +--- + src/eths.c | 15 +++++++++++++++ + src/eths.h | 1 + + 2 files changed, 16 insertions(+) + +diff --git a/src/eths.c b/src/eths.c +index bcd02e1..38bb7fe 100644 +--- a/src/eths.c ++++ b/src/eths.c +@@ -34,6 +34,20 @@ char *pr_ether(char *buf, const int size, const unsigned char *s) + return (buf); + } + ++static int eths_get_devid(const char *devname, int *devid) ++{ ++ char path[PATH_MAX]; ++ char *devidstr = NULL; ++ ++ *devid = -1; ++ snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", devname); ++ if (sysfs_read_file(path, &devidstr) == 0) { ++ sscanf(devidstr, "%i", devid); ++ free(devidstr); ++ } ++ return NULL; ++} ++ + static int eths_get_ifindex(const char *devname, int *ifindex) + { + int fd, err; +@@ -149,6 +163,7 @@ static void fill_eth_dev(struct network_device *dev) + eths_get_ifindex(dev->kernel_name, &dev->ifindex); + eths_get_hwaddr(dev->kernel_name, dev->dev_addr, sizeof(dev->dev_addr), &dev->arphrd_type); + eths_get_permaddr(dev->kernel_name, dev->perm_addr, sizeof(dev->perm_addr)); ++ eths_get_devid(dev->kernel_name, &dev->devid); + rc = eths_get_info(dev->kernel_name, &dev->drvinfo); + if (rc == 0) + dev->drvinfo_valid = 1; +diff --git a/src/eths.h b/src/eths.h +index f686136..12c278b 100644 +--- a/src/eths.h ++++ b/src/eths.h +@@ -27,6 +27,7 @@ struct network_device { + int arphrd_type; /* e.g. ARPHDR_ETHER */ + int hardware_claimed; /* true when recognized as PCI or PCMCIA and added to list of bios_devices */ + int ifindex; ++ int devid; + }; + + extern void get_eths(struct libbiosdevname_state *state); +-- +1.9.1 + diff -Nru biosdevname-0.4.1/debian/patches/series biosdevname-0.4.1/debian/patches/series --- biosdevname-0.4.1/debian/patches/series 2014-06-04 13:55:19.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/series 2015-09-01 16:50:36.000000000 +0000 @@ -1,2 +1,7 @@ smbios-2.6-check.patch fix_addslot_function_rename.patch +Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch +Scan-for-devid-for-Mellanox-cards.patch +Add-port-structure-to-PCI-device-handle-multiple-por.patch +Add-port-code-for-Mellanox-driver.patch +Add-dev_port-attribute-for-new-Mellanox-driver.patch diff -Nru biosdevname-0.4.1/debian/patches/Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch biosdevname-0.4.1/debian/patches/Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch --- biosdevname-0.4.1/debian/patches/Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch 1970-01-01 00:00:00.000000000 +0000 +++ biosdevname-0.4.1/debian/patches/Stop-reading-VPD-data-once-VPD-R-section-has-been-re.patch 2015-09-01 16:50:36.000000000 +0000 @@ -0,0 +1,45 @@ +Description: Stop reading VPD data once VPD-R section has been read + +Mellanox cards were taking too long to read entire VPD + +Author: Jordan Hargrave +Origin: http://linux.dell.com/git/biosdevname.git, commit: bcf7bfa +Bug-Ubuntu: https://launchpad.net/bugs/1455871 +Last-Update: 2015-06-24 +--- + src/pci.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/pci.c b/src/pci.c +index 019815e..31bc9b2 100644 +--- a/src/pci.c ++++ b/src/pci.c +@@ -30,6 +30,7 @@ extern int is_valid_smbios; + /* Borrowed from kernel vpd code */ + #define PCI_VPD_LRDT 0x80 + #define PCI_VPD_SRDT_END 0x78 ++#define PCI_VPDR_TAG 0x90 + + #define PCI_VPD_SRDT_LEN_MASK 0x7 + #define PCI_VPD_LRDT_TAG_SIZE 3 +@@ -71,7 +72,7 @@ static int pci_vpd_size(struct pci_device *pdev, int fd) + 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) ++ if (tag == 0 || tag == 0xFF || tag == PCI_VPD_SRDT_END || tag == PCI_VPDR_TAG) + break; + } + return off; +@@ -125,7 +126,7 @@ static int parse_vpd(struct libbiosdevname_state *state, struct pci_device *pdev + int i, j, k, isz, jsz, port, func, pfi; + struct pci_device *vf; + +- i = pci_vpd_find_tag(vpd, 0, len, 0x90); ++ i = pci_vpd_find_tag(vpd, 0, len, PCI_VPDR_TAG); + if (i < 0) + return 1; + isz = pci_vpd_lrdt_size(&vpd[i]); +-- +1.9.1 +