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.

Dependency Surface

Detected Declarations

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

Implementation Notes