From dd33892e7e955ae036481a02c73803646286db95 Mon Sep 17 00:00:00 2001
From: sujithpshankar <sujithpandel@gmail.com>
Date: Tue, 14 Mar 2017 12:55:24 +0530
Subject: [PATCH] Prevent reading of VPD-DCM strings for SRIOV-vfs.
Reading DCM strings of SRIOV-vfs results in a confusion that leads to interface being assumed as a NIC partition rather than a SRIOV-vf.
This patch prevents the reading and setting of VPD data to SRIOV-vf interfaces.
(cherry picked from commit 02811d5165c2eeecf8797fe9b5088d6e78bd25db)
---
src/pci.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/pci.c b/src/pci.c
index 1724394..74ed9e6 100644
--- a/src/pci.c
+++ b/src/pci.c
@@ -119,6 +119,10 @@ static void parse_dcm(struct libbiosdevname_state *state, struct pci_device *pde
struct vpd_tag *dcm;
const char *fmt;
+ if (pdev->is_sriov_virtual_function) {
+ return ;
+ }
+
fmt = "%1x%1x%2x";
step = 10;
dcm = pci_vpd_findtag(vpd, len, "DCM");
@@ -139,7 +143,7 @@ static void parse_dcm(struct libbiosdevname_state *state, struct pci_device *pde
vf = find_pci_dev_by_pci_addr(state, pdev->pci_dev->domain,
pdev->pci_dev->bus,
devfn >> 3, devfn & 7);
- if (vf != NULL) {
+ if (vf != NULL && !vf->is_sriov_virtual_function) {
add_port(vf, port, pfi);
if (vf->vpd_port == INT_MAX) {
vf->vpd_port = port;
@@ -157,7 +161,7 @@ static int read_pci_vpd(struct libbiosdevname_state *state, struct pci_device *p
int fd, len;
unsigned char *vpd;
- if (!is_pci_network(pdev))
+ if (!is_pci_network(pdev) || pdev->is_sriov_virtual_function)
return 1;
unparse_pci_name(pci_name, sizeof(pci_name), pdev->pci_dev);
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/physfn/vpd", pci_name);
@@ -214,12 +218,15 @@ static void set_pci_vpd_instance(struct libbiosdevname_state *state)
/* Ignore already parsed devices */
continue;
}
+ if (dev->is_sriov_virtual_function) {
+ continue;
+ }
read_pci_vpd(state, dev);
}
/* Now match VPD master device */
list_for_each_entry(dev, &state->pci_devices, node) {
- if (dev->vpd_port == INT_MAX)
+ if (dev->vpd_port == INT_MAX || dev->is_sriov_virtual_function)
continue;
list_for_each_entry(dev2, &state->pci_devices, node) {
if (dev2->pci_dev->domain == dev->pci_dev->domain &&
--
2.9.3