drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c- Extension
.c- Size
- 36835 bytes
- Lines
- 1369
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/kernel.hlinux/module.hlinux/kref.hlinux/io.hlinux/delay.hlinux/interrupt.hlinux/sort.hlinux/sched.hlinux/types.hlinux/pci.hnfp_cpp.hnfp_dev.hnfp6000/nfp6000.hnfp6000_pcie.h
Detected Declarations
struct nfp6000_pciestruct nfp6000_area_privstruct nfp_barstruct nfp6000_pciestruct nfp6000_area_privstruct nfp6000_explicit_privfunction nfp_bar_maptypefunction nfp_bar_resource_lenfunction nfp_bar_resource_startfunction compute_barfunction nfp6000_bar_writefunction reconfigure_barfunction matching_barfunction find_matching_barfunction find_unused_bar_noblockfunction find_unused_bar_and_lockfunction nfp_bar_getfunction nfp_bar_putfunction nfp_wait_for_barfunction nfp_alloc_barfunction bar_cmpfunction enable_barsfunction disable_barsfunction nfp6000_area_initfunction nfp6000_area_cleanupfunction priv_area_putfunction nfp6000_area_acquirefunction nfp6000_area_releasefunction nfp6000_area_physfunction nfp6000_area_readfunction nfp6000_area_writefunction nfp6000_explicit_acquirefunction nfp6000_explicit_releasefunction nfp6000_explicit_putfunction nfp6000_explicit_dofunction nfp6000_explicit_getfunction nfp6000_initfunction nfp6000_freefunction nfp6000_read_serialfunction nfp6000_get_interfacefunction nfp_cpp_from_nfp6000_pcie
Annotated Snippet
struct nfp_bar {
struct nfp6000_pcie *nfp;
u32 barcfg;
u64 base; /* CPP address base */
u64 mask; /* Bit mask of the bar */
u32 bitsize; /* Bit size of the bar */
int index;
atomic_t refcnt;
void __iomem *iomem;
struct resource *resource;
};
#define NFP_PCI_BAR_MAX (PCI_64BIT_BAR_COUNT * 8)
struct nfp6000_pcie {
struct pci_dev *pdev;
struct device *dev;
const struct nfp_dev_info *dev_info;
/* PCI BAR management */
spinlock_t bar_lock; /* Protect the PCI2CPP BAR cache */
int bars;
struct nfp_bar bar[NFP_PCI_BAR_MAX];
wait_queue_head_t bar_waiters;
/* Reserved BAR access */
struct {
void __iomem *csr;
void __iomem *em;
void __iomem *expl[4];
} iomem;
/* Explicit IO access */
struct {
struct mutex mutex; /* Lock access to this explicit group */
u8 master_id;
u8 signal_ref;
void __iomem *data;
struct {
void __iomem *addr;
int bitsize;
int free[4];
} group[4];
} expl;
};
static u32 nfp_bar_maptype(struct nfp_bar *bar)
{
return NFP_PCIE_BAR_PCIE2CPP_MapType_of(bar->barcfg);
}
static resource_size_t nfp_bar_resource_len(struct nfp_bar *bar)
{
return pci_resource_len(bar->nfp->pdev, (bar->index / 8) * 2) / 8;
}
static resource_size_t nfp_bar_resource_start(struct nfp_bar *bar)
{
return pci_resource_start(bar->nfp->pdev, (bar->index / 8) * 2)
+ nfp_bar_resource_len(bar) * (bar->index & 7);
}
#define TARGET_WIDTH_32 4
#define TARGET_WIDTH_64 8
static int
compute_bar(const struct nfp6000_pcie *nfp, const struct nfp_bar *bar,
u32 *bar_config, u64 *bar_base,
int tgt, int act, int tok, u64 offset, size_t size, int width)
{
int bitsize;
u32 newcfg;
if (tgt >= NFP_CPP_NUM_TARGETS)
return -EINVAL;
switch (width) {
case 8:
newcfg = NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
NFP_PCIE_BAR_PCIE2CPP_LengthSelect_64BIT);
break;
case 4:
newcfg = NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
NFP_PCIE_BAR_PCIE2CPP_LengthSelect_32BIT);
break;
case 0:
newcfg = NFP_PCIE_BAR_PCIE2CPP_LengthSelect(
NFP_PCIE_BAR_PCIE2CPP_LengthSelect_0BYTE);
break;
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/kernel.h`, `linux/module.h`, `linux/kref.h`, `linux/io.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/sort.h`.
- Detected declarations: `struct nfp6000_pcie`, `struct nfp6000_area_priv`, `struct nfp_bar`, `struct nfp6000_pcie`, `struct nfp6000_area_priv`, `struct nfp6000_explicit_priv`, `function nfp_bar_maptype`, `function nfp_bar_resource_len`, `function nfp_bar_resource_start`, `function compute_bar`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.