drivers/net/ethernet/marvell/octeontx2/nic/rep.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/rep.c- Extension
.c- Size
- 21620 bytes
- Lines
- 881
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/etherdevice.hlinux/module.hlinux/pci.hlinux/net_tstamp.hlinux/sort.hotx2_common.hcn10k.hotx2_reg.hrep.h
Detected Declarations
function rvu_rep_mcam_flow_initfunction rvu_rep_setup_tc_cbfunction rvu_rep_setup_tcfunction rvu_rep_sp_stats64function rvu_rep_has_offload_statsfunction rvu_rep_get_offload_statsfunction rvu_rep_dl_port_fn_hw_addr_getfunction rvu_rep_dl_port_fn_hw_addr_setfunction rvu_rep_devlink_set_switch_idfunction rvu_rep_devlink_port_unregisterfunction rvu_rep_devlink_port_registerfunction rvu_rep_get_repidfunction rvu_rep_notify_pfvffunction rvu_rep_state_evt_handlerfunction rvu_event_up_notifyfunction rvu_rep_change_mtufunction rvu_rep_get_statsfunction rvu_rep_get_stats64function rvu_eswitch_configfunction rvu_rep_xmitfunction rvu_rep_openfunction rvu_rep_stopfunction rvu_rep_napi_initfunction rvu_rep_free_cq_rsrcfunction rvu_rep_rsrc_freefunction rvu_rep_rsrc_initfunction rvu_rep_destroyfunction rvu_rep_createfunction rvu_get_rep_cntfunction rvu_rep_probefunction rvu_rep_removefunction rvu_rep_init_modulefunction rvu_rep_cleanup_modulemodule init rvu_rep_init_module
Annotated Snippet
static const struct net_device_ops rvu_rep_netdev_ops = {
.ndo_open = rvu_rep_open,
.ndo_stop = rvu_rep_stop,
.ndo_start_xmit = rvu_rep_xmit,
.ndo_get_stats64 = rvu_rep_get_stats64,
.ndo_change_mtu = rvu_rep_change_mtu,
.ndo_has_offload_stats = rvu_rep_has_offload_stats,
.ndo_get_offload_stats = rvu_rep_get_offload_stats,
.ndo_setup_tc = rvu_rep_setup_tc,
};
static int rvu_rep_napi_init(struct otx2_nic *priv,
struct netlink_ext_ack *extack)
{
struct otx2_qset *qset = &priv->qset;
struct otx2_cq_poll *cq_poll = NULL;
struct otx2_hw *hw = &priv->hw;
int err = 0, qidx, vec;
char *irq_name;
qset->napi = kzalloc_objs(*cq_poll, hw->cint_cnt);
if (!qset->napi)
return -ENOMEM;
/* Register NAPI handler */
for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
cq_poll = &qset->napi[qidx];
cq_poll->cint_idx = qidx;
cq_poll->cq_ids[CQ_RX] =
(qidx < hw->rx_queues) ? qidx : CINT_INVALID_CQ;
cq_poll->cq_ids[CQ_TX] = (qidx < hw->tx_queues) ?
qidx + hw->rx_queues :
CINT_INVALID_CQ;
cq_poll->cq_ids[CQ_XDP] = CINT_INVALID_CQ;
cq_poll->cq_ids[CQ_QOS] = CINT_INVALID_CQ;
cq_poll->dev = (void *)priv;
netif_napi_add(priv->reps[qidx]->netdev, &cq_poll->napi,
otx2_napi_handler);
napi_enable(&cq_poll->napi);
}
/* Register CQ IRQ handlers */
vec = hw->nix_msixoff + NIX_LF_CINT_VEC_START;
for (qidx = 0; qidx < hw->cint_cnt; qidx++) {
irq_name = &hw->irq_name[vec * NAME_SIZE];
snprintf(irq_name, NAME_SIZE, "rep%d-rxtx-%d", qidx, qidx);
err = request_irq(pci_irq_vector(priv->pdev, vec),
otx2_cq_intr_handler, 0, irq_name,
&qset->napi[qidx]);
if (err) {
NL_SET_ERR_MSG_FMT_MOD(extack,
"RVU REP IRQ registration failed for CQ%d",
qidx);
goto err_free_cints;
}
vec++;
/* Enable CQ IRQ */
otx2_write64(priv, NIX_LF_CINTX_INT(qidx), BIT_ULL(0));
otx2_write64(priv, NIX_LF_CINTX_ENA_W1S(qidx), BIT_ULL(0));
}
priv->flags &= ~OTX2_FLAG_INTF_DOWN;
return 0;
err_free_cints:
otx2_free_cints(priv, qidx);
otx2_disable_napi(priv);
return err;
}
static void rvu_rep_free_cq_rsrc(struct otx2_nic *priv)
{
struct otx2_qset *qset = &priv->qset;
struct otx2_cq_poll *cq_poll = NULL;
int qidx, vec;
/* Cleanup CQ NAPI and IRQ */
vec = priv->hw.nix_msixoff + NIX_LF_CINT_VEC_START;
for (qidx = 0; qidx < priv->hw.cint_cnt; qidx++) {
/* Disable interrupt */
otx2_write64(priv, NIX_LF_CINTX_ENA_W1C(qidx), BIT_ULL(0));
synchronize_irq(pci_irq_vector(priv->pdev, vec));
cq_poll = &qset->napi[qidx];
napi_synchronize(&cq_poll->napi);
vec++;
}
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/module.h`, `linux/pci.h`, `linux/net_tstamp.h`, `linux/sort.h`, `otx2_common.h`, `cn10k.h`, `otx2_reg.h`.
- Detected declarations: `function rvu_rep_mcam_flow_init`, `function rvu_rep_setup_tc_cb`, `function rvu_rep_setup_tc`, `function rvu_rep_sp_stats64`, `function rvu_rep_has_offload_stats`, `function rvu_rep_get_offload_stats`, `function rvu_rep_dl_port_fn_hw_addr_get`, `function rvu_rep_dl_port_fn_hw_addr_set`, `function rvu_rep_devlink_set_switch_id`, `function rvu_rep_devlink_port_unregister`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.