Skip to content

Commit b200ee0

Browse files
Gavin Shanstewartsmith
authored andcommitted
core/pci: Allow associating parameter with capability
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@linux.vnet.ibm.com> Reviewed-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent 6f05217 commit b200ee0

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

core/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void pci_init_pcie_cap(struct phb *phb, struct pci_device *pd)
160160
return;
161161
}
162162

163-
pci_set_cap(pd, PCI_CFG_CAP_ID_EXP, ecap, false);
163+
pci_set_cap(pd, PCI_CFG_CAP_ID_EXP, ecap, NULL, false);
164164

165165
/*
166166
* 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)
197197

198198
pos = pci_find_ecap(phb, pd->bdfn, PCIECAP_ID_AER, NULL);
199199
if (pos > 0)
200-
pci_set_cap(pd, PCIECAP_ID_AER, pos, true);
200+
pci_set_cap(pd, PCIECAP_ID_AER, pos, NULL, true);
201201
}
202202

203203
void pci_init_capabilities(struct phb *phb, struct pci_device *pd)

include/pci.h

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ struct pci_device {
7474
uint32_t sub_vdid;
7575
uint32_t class;
7676
uint64_t cap_list;
77-
uint32_t cap[64];
77+
struct {
78+
uint32_t pos;
79+
void *data;
80+
} cap[64];
7881
uint32_t mps; /* Max payload size capability */
7982

8083
uint32_t pcrf_start;
@@ -88,15 +91,17 @@ struct pci_device {
8891
struct list_node link;
8992
};
9093

91-
static inline void pci_set_cap(struct pci_device *pd,
92-
int id, int pos, bool ext)
94+
static inline void pci_set_cap(struct pci_device *pd, int id,
95+
int pos, void *data, bool ext)
9396
{
9497
if (!ext) {
9598
pd->cap_list |= (0x1ul << id);
96-
pd->cap[id] = pos;
99+
pd->cap[id].pos = pos;
100+
pd->cap[id].data = data;
97101
} else {
98102
pd->cap_list |= (0x1ul << (id + 32));
99-
pd->cap[id + 32] = pos;
103+
pd->cap[id + 32].pos = pos;
104+
pd->cap[id + 32].data = data;
100105
}
101106
}
102107

@@ -113,9 +118,17 @@ static inline int pci_cap(struct pci_device *pd,
113118
int id, bool ext)
114119
{
115120
if (!ext)
116-
return pd->cap[id];
121+
return pd->cap[id].pos;
117122
else
118-
return pd->cap[id + 32];
123+
return pd->cap[id + 32].pos;
124+
}
125+
126+
static inline void *pci_cap_data(struct pci_device *pd, int id, bool ext)
127+
{
128+
if (!ext)
129+
return pd->cap[id].data;
130+
else
131+
return pd->cap[id + 32].data;
119132
}
120133

121134
/*

0 commit comments

Comments
 (0)