drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mip.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mip.c- Extension
.c- Size
- 3473 bytes
- Lines
- 152
- 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.
- 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/kernel.hlinux/slab.hnfp.hnfp_cpp.hnfp_nffw.h
Detected Declarations
struct nfp_mipfunction nfp_mip_try_readfunction nfp_mip_read_resourcefunction nfp_mip_openfunction nfp_mip_closefunction nfp_mip_symtabfunction nfp_mip_strtab
Annotated Snippet
struct nfp_mip {
__le32 signature;
__le32 mip_version;
__le32 mip_size;
__le32 first_entry;
__le32 version;
__le32 buildnum;
__le32 buildtime;
__le32 loadtime;
__le32 symtab_addr;
__le32 symtab_size;
__le32 strtab_addr;
__le32 strtab_size;
char name[16];
char toolchain[32];
};
/* Read memory and check if it could be a valid MIP */
static int
nfp_mip_try_read(struct nfp_cpp *cpp, u32 cpp_id, u64 addr, struct nfp_mip *mip)
{
int ret;
ret = nfp_cpp_read(cpp, cpp_id, addr, mip, sizeof(*mip));
if (ret != sizeof(*mip)) {
nfp_err(cpp, "Failed to read MIP data (%d, %zu)\n",
ret, sizeof(*mip));
return -EIO;
}
if (mip->signature != NFP_MIP_SIGNATURE) {
nfp_warn(cpp, "Incorrect MIP signature (0x%08x)\n",
le32_to_cpu(mip->signature));
return -EINVAL;
}
if (mip->mip_version != NFP_MIP_VERSION) {
nfp_warn(cpp, "Unsupported MIP version (%d)\n",
le32_to_cpu(mip->mip_version));
return -EINVAL;
}
return 0;
}
/* Try to locate MIP using the resource table */
static int nfp_mip_read_resource(struct nfp_cpp *cpp, struct nfp_mip *mip)
{
struct nfp_nffw_info *nffw_info;
u32 cpp_id;
u64 addr;
int err;
nffw_info = nfp_nffw_info_open(cpp);
if (IS_ERR(nffw_info))
return PTR_ERR(nffw_info);
err = nfp_nffw_info_mip_first(nffw_info, &cpp_id, &addr);
if (err)
goto exit_close_nffw;
err = nfp_mip_try_read(cpp, cpp_id, addr, mip);
exit_close_nffw:
nfp_nffw_info_close(nffw_info);
return err;
}
/**
* nfp_mip_open() - Get device MIP structure
* @cpp: NFP CPP Handle
*
* Copy MIP structure from NFP device and return it. The returned
* structure is handled internally by the library and should be
* freed by calling nfp_mip_close().
*
* Return: pointer to mip, NULL on failure.
*/
const struct nfp_mip *nfp_mip_open(struct nfp_cpp *cpp)
{
struct nfp_mip *mip;
int err;
mip = kmalloc_obj(*mip);
if (!mip)
return NULL;
err = nfp_mip_read_resource(cpp, mip);
if (err) {
kfree(mip);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `nfp.h`, `nfp_cpp.h`, `nfp_nffw.h`.
- Detected declarations: `struct nfp_mip`, `function nfp_mip_try_read`, `function nfp_mip_read_resource`, `function nfp_mip_open`, `function nfp_mip_close`, `function nfp_mip_symtab`, `function nfp_mip_strtab`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.