Message ID | 1479445519-23865-3-git-send-email-gwshan@linux.vnet.ibm.com |
---|---|
State | Superseded |
Headers | show |
On Fri, 2016-11-18 at 16:05 +1100, Gavin Shan wrote: > 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> > --- > 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) Does anything ever use this function? > +{ > + if (!ext) > + return pd->cap[id].data; > + else > + return pd->cap[id + 32].data; > } > > /*
On Mon, Feb 06, 2017 at 05:17:54PM +1100, Russell Currey wrote: >On Fri, 2016-11-18 at 16:05 +1100, Gavin Shan wrote: >> 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> >> --- >> 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) > >Does anything ever use this function? > IOV is the first thing to use this, to associate IOV capability descriptor with the position. So no, nothing has been used this functionality previously. >> +{ >> + if (!ext) >> + return pd->cap[id].data; >> + else >> + return pd->cap[id + 32].data; >> } >> >> /* >
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; } /*
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> --- core/pci.c | 4 ++-- include/pci.h | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-)