drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c- Extension
.c- Size
- 44327 bytes
- Lines
- 1787
- 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.
- 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
crypto/aes.hlinux/rtnetlink.hlinux/bitfield.hotx2_common.h
Detected Declarations
function Copyrightfunction list_for_each_entryfunction list_for_each_entryfunction cn10k_mcs_alloc_rsrcfunction cn10k_mcs_free_rsrcfunction cn10k_mcs_alloc_txsafunction cn10k_mcs_alloc_rxsafunction cn10k_mcs_free_txsafunction cn10k_mcs_free_rxsafunction cn10k_mcs_write_rx_secyfunction cn10k_mcs_write_rx_flowidfunction cn10k_mcs_write_sc_camfunction cn10k_mcs_write_keysfunction cn10k_mcs_write_rx_sa_plcyfunction cn10k_mcs_write_rx_sa_pnfunction cn10k_mcs_write_tx_secyfunction cn10k_mcs_write_tx_flowidfunction cn10k_mcs_link_tx_sa2scfunction cn10k_mcs_write_tx_sa_plcyfunction cn10k_write_tx_sa_pnfunction cn10k_mcs_ena_dis_flowidfunction cn10k_mcs_sa_statsfunction cn10k_mcs_sc_statsfunction cn10k_mcs_secy_statsfunction cn10k_mcs_delete_txscfunction cn10k_mcs_delete_rxscfunction cn10k_mcs_secy_tx_cfgfunction cn10k_mcs_secy_rx_cfgfunction cn10k_mcs_disable_rxscsfunction cn10k_mcs_sync_statsfunction list_for_each_entryfunction cn10k_mdo_openfunction cn10k_mdo_stopfunction cn10k_mdo_add_secyfunction cn10k_mdo_upd_secyfunction cn10k_mdo_del_secyfunction cn10k_mdo_add_txsafunction cn10k_mdo_upd_txsafunction cn10k_mdo_del_txsafunction cn10k_mdo_add_rxscfunction cn10k_mdo_upd_rxscfunction cn10k_mdo_del_rxscfunction cn10k_mdo_add_rxsafunction cn10k_mdo_upd_rxsafunction cn10k_mdo_del_rxsafunction cn10k_mdo_get_dev_statsfunction cn10k_mdo_get_tx_sc_statsfunction cn10k_mdo_get_tx_sa_stats
Annotated Snippet
if (sa_bmap & 1) {
cn10k_mcs_write_tx_sa_plcy(pfvf, txsc->sw_secy,
txsc, sa_num);
cn10k_mcs_free_txsa(pfvf, txsc->hw_sa_id[sa_num]);
}
sa_num++;
sa_bmap >>= 1;
}
cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SC,
txsc->hw_sc_id, false);
cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SECY,
txsc->hw_secy_id_rx, false);
cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SECY,
txsc->hw_secy_id_tx, false);
cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_FLOWID,
txsc->hw_flow_id, false);
}
static struct cn10k_mcs_rxsc *cn10k_mcs_create_rxsc(struct otx2_nic *pfvf)
{
struct cn10k_mcs_rxsc *rxsc;
int ret;
rxsc = kzalloc_obj(*rxsc);
if (!rxsc)
return ERR_PTR(-ENOMEM);
ret = cn10k_mcs_alloc_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_FLOWID,
&rxsc->hw_flow_id);
if (ret)
goto fail;
ret = cn10k_mcs_alloc_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SC,
&rxsc->hw_sc_id);
if (ret)
goto free_flowid;
return rxsc;
free_flowid:
cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_FLOWID,
rxsc->hw_flow_id, false);
fail:
kfree(rxsc);
return ERR_PTR(ret);
}
/* Free Rx SC and its SAs(if any) resources to AF
*/
static void cn10k_mcs_delete_rxsc(struct otx2_nic *pfvf,
struct cn10k_mcs_rxsc *rxsc)
{
u8 sa_bmap = rxsc->sa_bmap;
u8 sa_num = 0;
while (sa_bmap) {
if (sa_bmap & 1) {
cn10k_mcs_write_rx_sa_plcy(pfvf, rxsc->sw_secy, rxsc,
sa_num, false);
cn10k_mcs_free_rxsa(pfvf, rxsc->hw_sa_id[sa_num]);
}
sa_num++;
sa_bmap >>= 1;
}
cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SC,
rxsc->hw_sc_id, false);
cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_FLOWID,
rxsc->hw_flow_id, false);
}
static int cn10k_mcs_secy_tx_cfg(struct otx2_nic *pfvf, struct macsec_secy *secy,
struct cn10k_mcs_txsc *txsc,
struct macsec_tx_sa *sw_tx_sa, u8 sa_num)
{
if (sw_tx_sa) {
cn10k_mcs_write_tx_sa_plcy(pfvf, secy, txsc, sa_num);
cn10k_write_tx_sa_pn(pfvf, txsc, sa_num, sw_tx_sa->next_pn);
cn10k_mcs_link_tx_sa2sc(pfvf, secy, txsc, sa_num,
sw_tx_sa->active);
}
cn10k_mcs_write_tx_secy(pfvf, secy, txsc);
cn10k_mcs_write_tx_flowid(pfvf, secy, txsc);
/* When updating secy, change RX secy also */
cn10k_mcs_write_rx_secy(pfvf, secy, txsc->hw_secy_id_rx);
return 0;
}
Annotation
- Immediate include surface: `crypto/aes.h`, `linux/rtnetlink.h`, `linux/bitfield.h`, `otx2_common.h`.
- Detected declarations: `function Copyright`, `function list_for_each_entry`, `function list_for_each_entry`, `function cn10k_mcs_alloc_rsrc`, `function cn10k_mcs_free_rsrc`, `function cn10k_mcs_alloc_txsa`, `function cn10k_mcs_alloc_rxsa`, `function cn10k_mcs_free_txsa`, `function cn10k_mcs_free_rxsa`, `function cn10k_mcs_write_rx_secy`.
- 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.
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.