Blame SOURCES/0001-Add-port-structure-to-PCI-device-handle-multiple-por.patch

8ebaa5
From f3e6790b7986a4f9dd4a407901717ef8de3cbbc6 Mon Sep 17 00:00:00 2001
8ebaa5
From: Jordan Hargrave <Jordan_Hargrave@dell.com>
8ebaa5
Date: Tue, 25 Feb 2014 16:35:40 -0600
8ebaa5
Subject: [PATCH] Add port structure to PCI device, handle multiple ports per
8ebaa5
 BDF (Mellanox)
8ebaa5
8ebaa5
---
8ebaa5
 src/pci.c | 21 +++++++++++++++++++++
8ebaa5
 src/pci.h |  7 +++++++
8ebaa5
 2 files changed, 28 insertions(+)
8ebaa5
8ebaa5
diff --git a/src/pci.c b/src/pci.c
8ebaa5
index e85cb03..a2d8145 100644
8ebaa5
--- a/src/pci.c
8ebaa5
+++ b/src/pci.c
8ebaa5
@@ -121,6 +121,25 @@ static int pci_vpd_find_info_subkey(const u8 *buf, unsigned int off, unsigned in
8ebaa5
 	return -1;
8ebaa5
 }
8ebaa5
 
8ebaa5
+/* Add port identifier(s) to PCI device */
8ebaa5
+static void add_port(struct pci_device *pdev, int port, int pfi)
8ebaa5
+{
8ebaa5
+	struct pci_port *p;
8ebaa5
+
8ebaa5
+	list_for_each_entry(p, &pdev->ports, node) {
8ebaa5
+		if (p->port == port && p->pfi == pfi)
8ebaa5
+			return;
8ebaa5
+	}
8ebaa5
+	p = malloc(sizeof(*p));
8ebaa5
+	if (p == NULL)
8ebaa5
+		return;
8ebaa5
+	memset(p, 0, sizeof(*p));
8ebaa5
+	INIT_LIST_HEAD(&p->node);
8ebaa5
+	p->port = port;
8ebaa5
+	p->pfi = pfi;
8ebaa5
+	list_add_tail(&p->node, &pdev->ports);
8ebaa5
+}
8ebaa5
+
8ebaa5
 static int parse_vpd(struct libbiosdevname_state *state, struct pci_device *pdev, int len, unsigned char *vpd)
8ebaa5
 {
8ebaa5
 	int i, j, k, isz, jsz, port, func, pfi;
8ebaa5
@@ -155,6 +174,7 @@ static int parse_vpd(struct libbiosdevname_state *state, struct pci_device *pdev
8ebaa5
 						   pdev->pci_dev->bus,
8ebaa5
 						   pdev->pci_dev->dev,
8ebaa5
 						   func)) != NULL) {
8ebaa5
+			add_port(vf, port, pfi);
8ebaa5
 			if (vf->vpd_port == INT_MAX) {
8ebaa5
 				vf->vpd_port = port;
8ebaa5
 				vf->vpd_pfi = pfi;
8ebaa5
@@ -597,6 +617,7 @@ static void add_pci_dev(struct libbiosdevname_state *state,
8ebaa5
 	INIT_LIST_HEAD(&dev->node);
8ebaa5
 	INIT_LIST_HEAD(&dev->vfnode);
8ebaa5
 	INIT_LIST_HEAD(&dev->vfs);
8ebaa5
+	INIT_LIST_HEAD(&dev->ports);
8ebaa5
 	dev->pci_dev = p;
8ebaa5
 	dev->physical_slot = PHYSICAL_SLOT_UNKNOWN;
8ebaa5
 	dev->class         = pci_read_word(p, PCI_CLASS_DEVICE);
8ebaa5
diff --git a/src/pci.h b/src/pci.h
8ebaa5
index 77b4746..eacb539 100644
8ebaa5
--- a/src/pci.h
8ebaa5
+++ b/src/pci.h
8ebaa5
@@ -20,6 +20,12 @@ struct slotlist
8ebaa5
 	int count;
8ebaa5
 };
8ebaa5
 
8ebaa5
+struct pci_port {
8ebaa5
+	struct list_head node;
8ebaa5
+	int port;
8ebaa5
+	int pfi;
8ebaa5
+};
8ebaa5
+
8ebaa5
 struct pci_device {
8ebaa5
 	struct list_head node;
8ebaa5
 	struct pci_dev *pci_dev;
8ebaa5
@@ -44,6 +50,7 @@ struct pci_device {
8ebaa5
 	struct pci_device *pf;
8ebaa5
 	struct list_head vfnode;
8ebaa5
 	struct list_head vfs;
8ebaa5
+	struct list_head ports;
8ebaa5
 	unsigned int is_sriov_physical_function:1;
8ebaa5
 	unsigned int is_sriov_virtual_function:1;
8ebaa5
 	unsigned int embedded_index_valid:1;
8ebaa5
-- 
8ebaa5
1.8.4.2
8ebaa5