drivers/net/ethernet/freescale/enetc/ntmp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/enetc/ntmp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/enetc/ntmp.c- Extension
.c- Size
- 35602 bytes
- Lines
- 1308
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/dma-mapping.hlinux/fsl/netc_global.hlinux/iopoll.hlinux/vmalloc.hntmp_private.h
Detected Declarations
function NTMPfunction ntmp_clear_eid_bitmapfunction ntmp_init_cbdrfunction ntmp_free_data_memfunction ntmp_free_cbdrfunction ntmp_get_free_cbd_numfunction ntmp_clean_cbdrfunction ntmp_select_and_lock_cbdrfunction ntmp_unlock_cbdrfunction netc_xmit_ntmp_cmdfunction ntmp_alloc_data_memfunction ntmp_fill_request_hdrfunction ntmp_fill_crdfunction ntmp_fill_crd_eidfunction ntmp_delete_entry_by_idfunction ntmp_query_entry_by_idfunction ntmp_maft_add_entryfunction ntmp_maft_query_entryfunction ntmp_maft_delete_entryfunction ntmp_rsst_update_entryfunction ntmp_rsst_query_entryfunction ntmp_ipft_add_entryfunction ntmp_ipft_delete_entryfunction ntmp_fdbt_add_entryfunction ntmp_fdbt_update_entryfunction ntmp_fdbt_delete_entryfunction ntmp_fdbt_search_port_entryfunction ntmp_fdbt_update_activity_elementfunction ntmp_fdbt_delete_ageing_entriesfunction ntmp_fdbt_delete_port_dynamic_entriesfunction ntmp_vft_set_entryfunction ntmp_vft_add_entryfunction ntmp_vft_update_entryfunction ntmp_vft_delete_entryfunction ntmp_ett_set_entryfunction ntmp_ett_add_entryfunction ntmp_ett_update_entryfunction ntmp_ett_delete_entryfunction ntmp_ect_update_entryfunction ntmp_bpt_update_entryexport ntmp_lookup_free_eidexport ntmp_clear_eid_bitmapexport ntmp_init_cbdrexport ntmp_free_cbdrexport ntmp_maft_add_entryexport ntmp_maft_query_entryexport ntmp_maft_delete_entryexport ntmp_rsst_update_entry
Annotated Snippet
if (unlikely(!ntmp_get_free_cbd_num(cbdr))) {
ntmp_free_data_mem(cbdr->dev, swcbd);
return -EBUSY;
}
}
i = cbdr->next_to_use;
cur_cbd = ntmp_get_cbd(cbdr, i);
*cur_cbd = *cbd;
cbdr->swcbd[i] = *swcbd;
dma_wmb();
/* Update producer index of both software and hardware */
i = (i + 1) % cbdr->bd_num;
cbdr->next_to_use = i;
netc_write(cbdr->regs.pir, i);
err = read_poll_timeout(netc_read, val,
(val & NETC_CBDRCIR_INDEX) == i,
NETC_CBDR_DELAY_US, NETC_CBDR_TIMEOUT,
true, cbdr->regs.cir);
if (unlikely(err))
return err;
if (unlikely(val & NETC_CBDRCIR_SBE)) {
dev_err(cbdr->dev, "Command BD system bus error\n");
return -EIO;
}
dma_rmb();
/* Get the writeback command BD, because the caller may need
* to check some other fields of the response header.
*/
*cbd = *cur_cbd;
/* Check the writeback error status */
status = le16_to_cpu(cbd->resp_hdr.error_rr) & NTMP_RESP_ERROR;
if (unlikely(status)) {
dev_err(cbdr->dev, "Command BD error: 0x%04x\n", status);
return -EIO;
}
return 0;
}
static int ntmp_alloc_data_mem(struct device *dev, struct netc_swcbd *swcbd,
void **buf_align)
{
void *buf;
buf = dma_alloc_coherent(dev, swcbd->size + NTMP_DATA_ADDR_ALIGN,
&swcbd->dma, GFP_KERNEL);
if (!buf)
return -ENOMEM;
swcbd->buf = buf;
*buf_align = PTR_ALIGN(buf, NTMP_DATA_ADDR_ALIGN);
return 0;
}
static void ntmp_fill_request_hdr(union netc_cbd *cbd, dma_addr_t dma,
int len, int table_id, int cmd,
int access_method)
{
dma_addr_t dma_align;
memset(cbd, 0, sizeof(*cbd));
dma_align = ALIGN(dma, NTMP_DATA_ADDR_ALIGN);
cbd->req_hdr.addr = cpu_to_le64(dma_align);
cbd->req_hdr.len = cpu_to_le32(len);
cbd->req_hdr.cmd = cmd;
cbd->req_hdr.access_method = FIELD_PREP(NTMP_ACCESS_METHOD,
access_method);
cbd->req_hdr.table_id = table_id;
cbd->req_hdr.ver_cci_rr = FIELD_PREP(NTMP_HDR_VERSION,
NTMP_HDR_VER2);
/* For NTMP version 2.0 or later version */
cbd->req_hdr.npf = cpu_to_le32(NTMP_NPF);
}
static void ntmp_fill_crd(struct ntmp_cmn_req_data *crd, u8 tblv,
u8 qa, u16 ua)
{
crd->update_act = cpu_to_le16(ua);
crd->tblv_qact = NTMP_TBLV_QACT(tblv, qa);
}
static void ntmp_fill_crd_eid(struct ntmp_req_by_eid *rbe, u8 tblv,
u8 qa, u16 ua, u32 entry_id)
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/fsl/netc_global.h`, `linux/iopoll.h`, `linux/vmalloc.h`, `ntmp_private.h`.
- Detected declarations: `function NTMP`, `function ntmp_clear_eid_bitmap`, `function ntmp_init_cbdr`, `function ntmp_free_data_mem`, `function ntmp_free_cbdr`, `function ntmp_get_free_cbd_num`, `function ntmp_clean_cbdr`, `function ntmp_select_and_lock_cbdr`, `function ntmp_unlock_cbdr`, `function netc_xmit_ntmp_cmd`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.