[Skiboot] [PATCH 3/5] core/pci: Allow associating parameter with capability

Gavin Shan gwshan at linux.vnet.ibm.com
Fri Nov 18 16:05:17 AEDT 2016


When we start to support SRIOV capability in subsequent patches,
a data struct will be instantiated and associated with the SRIOV
capability. This extends the current implementation for that.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 core/pci.c    |  4 ++--
 include/pci.h | 27 ++++++++++++++++++++-------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index 02993e9..b38d5a0 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -160,7 +160,7 @@ static void pci_init_pcie_cap(struct phb *phb, struct pci_device *pd)
 		return;
 	}
 
-	pci_set_cap(pd, PCI_CFG_CAP_ID_EXP, ecap, false);
+	pci_set_cap(pd, PCI_CFG_CAP_ID_EXP, ecap, NULL, false);
 
 	/*
 	 * XXX We observe a problem on some PLX switches where one
@@ -197,7 +197,7 @@ static void pci_init_aer_cap(struct phb *phb, struct pci_device *pd)
 
 	pos = pci_find_ecap(phb, pd->bdfn, PCIECAP_ID_AER, NULL);
 	if (pos > 0)
-		pci_set_cap(pd, PCIECAP_ID_AER, pos, true);
+		pci_set_cap(pd, PCIECAP_ID_AER, pos, NULL, true);
 }
 
 void pci_init_capabilities(struct phb *phb, struct pci_device *pd)
diff --git a/include/pci.h b/include/pci.h
index c018e56..44bedf6 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -74,7 +74,10 @@ struct pci_device {
 	uint32_t		sub_vdid;
 	uint32_t		class;
 	uint64_t		cap_list;
-	uint32_t		cap[64];
+	struct {
+		uint32_t	pos;
+		void		*data;
+	} cap[64];
 	uint32_t		mps;		/* Max payload size capability */
 
 	uint32_t		pcrf_start;
@@ -88,15 +91,17 @@ struct pci_device {
 	struct list_node	link;
 };
 
-static inline void pci_set_cap(struct pci_device *pd,
-			       int id, int pos, bool ext)
+static inline void pci_set_cap(struct pci_device *pd, int id,
+			       int pos, void *data, bool ext)
 {
 	if (!ext) {
 		pd->cap_list |= (0x1ul << id);
-		pd->cap[id] = pos;
+		pd->cap[id].pos = pos;
+		pd->cap[id].data = data;
 	} else {
 		pd->cap_list |= (0x1ul << (id + 32));
-		pd->cap[id + 32] = pos;
+		pd->cap[id + 32].pos = pos;
+		pd->cap[id + 32].data = data;
 	}
 }
 
@@ -113,9 +118,17 @@ static inline int pci_cap(struct pci_device *pd,
 			  int id, bool ext)
 {
 	if (!ext)
-		return pd->cap[id];
+		return pd->cap[id].pos;
 	else
-		return pd->cap[id + 32];
+		return pd->cap[id + 32].pos;
+}
+
+static inline void *pci_cap_data(struct pci_device *pd, int id, bool ext)
+{
+	if (!ext)
+		return pd->cap[id].data;
+	else
+		return pd->cap[id + 32].data;
 }
 
 /*
-- 
2.1.0



More information about the Skiboot mailing list