Skip to content

Commit

Permalink
net/nfp: fix address always related with PF ID 0
Browse files Browse the repository at this point in the history
[ upstream commit 467370c93d73267c1d4417bff975cf812b878f48 ]

Now the PCIE configure bar address is always related with PF ID 0.
For the NIC with multiple PCI device, this will lead the host crash.
Fix this problem by make the PCIE configure bar address related with
the PF ID.

Fixes: c7e9729 ("net/nfp: support CPP")

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
  • Loading branch information
Peng-Mu authored and kevintraynor committed Jul 12, 2023
1 parent f7a4bf2 commit 95e5d43
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
#define NFP_PCIE_P2C_GENERAL_TOKEN_OFFSET(bar, x) ((x) << ((bar)->bitsize - 4))
#define NFP_PCIE_P2C_GENERAL_SIZE(bar) (1 << ((bar)->bitsize - 4))

#define NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(bar, slot) \
(NFP_PCIE_BAR(0) + ((bar) * 8 + (slot)) * 4)
#define NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(id, bar, slot) \
(NFP_PCIE_BAR(id) + ((bar) * 8 + (slot)) * 4)

#define NFP_PCIE_CPP_BAR_PCIETOCPPEXPBAR(bar, slot) \
(((bar) * 8 + (slot)) * 4)
Expand Down Expand Up @@ -114,6 +114,7 @@ struct nfp_pcie_user {
int secondary_lock;
char busdev[BUSDEV_SZ];
int barsz;
int dev_id;
char *cfg;
};

Expand Down Expand Up @@ -255,7 +256,7 @@ nfp_bar_write(struct nfp_pcie_user *nfp, struct nfp_bar *bar,
return (-ENOMEM);

bar->csr = nfp->cfg +
NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(base, slot);
NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(nfp->dev_id, base, slot);

*(uint32_t *)(bar->csr) = newcfg;

Expand Down Expand Up @@ -325,10 +326,8 @@ nfp_enable_bars(struct nfp_pcie_user *nfp)
bar->base = 0;
bar->iomem = NULL;
bar->lock = 0;
bar->csr = nfp->cfg +
NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(bar->index >> 3,
bar->index & 7);

bar->csr = nfp->cfg + NFP_PCIE_CFG_BAR_PCIETOCPPEXPBAR(nfp->dev_id,
bar->index >> 3, bar->index & 7);
bar->iomem = nfp->cfg + (bar->index << bar->bitsize);
}
return 0;
Expand Down Expand Up @@ -843,6 +842,7 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)
goto error;

desc->cfg = (char *)dev->mem_resource[0].addr;
desc->dev_id = dev->addr.function & 0x7;

nfp_enable_bars(desc);

Expand Down

0 comments on commit 95e5d43

Please sign in to comment.