drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/aquantia/atlantic/aq_macsec.c- Extension
.c- Size
- 46674 bytes
- Lines
- 1771
- 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
aq_macsec.haq_nic.hlinux/rtnetlink.hmacsec/macsec_api.h
Detected Declarations
enum aq_clear_typefunction aq_ether_addr_to_macfunction aq_get_txsc_idx_from_secyfunction aq_get_rxsc_idx_from_rxscfunction aq_get_txsc_idx_from_sc_idxfunction aq_rotate_keysfunction aq_get_macsec_common_statsfunction aq_get_rxsa_statsfunction aq_get_txsa_statsfunction aq_get_txsa_next_pnfunction aq_get_rxsa_next_pnfunction aq_get_txsc_statsfunction aq_mdo_dev_openfunction aq_mdo_dev_stopfunction aq_set_txscfunction aq_sc_idx_maxfunction aq_to_hw_sc_idxfunction sc_sa_from_num_anfunction aq_mdo_add_secyfunction aq_mdo_upd_secyfunction aq_clear_txscfunction for_each_set_bitfunction aq_mdo_del_secyfunction aq_update_txsafunction aq_mdo_add_txsafunction aq_mdo_upd_txsafunction aq_clear_txsafunction aq_mdo_del_txsafunction aq_rxsc_validate_framesfunction aq_set_rxscfunction aq_mdo_add_rxscfunction aq_mdo_upd_rxscfunction aq_clear_rxscfunction for_each_set_bitfunction aq_mdo_del_rxscfunction aq_update_rxsafunction aq_mdo_add_rxsafunction aq_mdo_upd_rxsafunction aq_clear_rxsafunction aq_mdo_del_rxsafunction aq_mdo_get_dev_statsfunction aq_mdo_get_tx_sc_statsfunction aq_mdo_get_tx_sa_statsfunction aq_mdo_get_rx_sc_statsfunction aq_mdo_get_rx_sa_statsfunction apply_txsc_cfgfunction apply_rxsc_cfgfunction aq_clear_secy
Annotated Snippet
if (tx_sa) {
ret = aq_update_txsa(nic, aq_txsc->hw_sc_idx, secy,
tx_sa, aq_txsc->tx_sa_key[i], i);
if (ret)
return ret;
}
}
return ret;
}
static int apply_rxsc_cfg(struct aq_nic_s *nic, const int rxsc_idx)
{
struct aq_macsec_rxsc *aq_rxsc = &nic->macsec_cfg->aq_rxsc[rxsc_idx];
const struct macsec_secy *secy = aq_rxsc->sw_secy;
struct macsec_rx_sa *rx_sa;
int ret = 0;
int i;
if (!netif_running(secy->netdev))
return ret;
ret = aq_set_rxsc(nic, rxsc_idx);
if (ret)
return ret;
for (i = 0; i < MACSEC_NUM_AN; i++) {
rx_sa = rcu_dereference_bh(aq_rxsc->sw_rxsc->sa[i]);
if (rx_sa) {
ret = aq_update_rxsa(nic, aq_rxsc->hw_sc_idx, secy,
rx_sa, aq_rxsc->rx_sa_key[i], i);
if (ret)
return ret;
}
}
return ret;
}
static int aq_clear_secy(struct aq_nic_s *nic, const struct macsec_secy *secy,
enum aq_clear_type clear_type)
{
struct macsec_rx_sc *rx_sc;
int txsc_idx;
int rxsc_idx;
int ret = 0;
txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy);
if (txsc_idx >= 0) {
ret = aq_clear_txsc(nic, txsc_idx, clear_type);
if (ret)
return ret;
}
for (rx_sc = rcu_dereference_bh(secy->rx_sc); rx_sc;
rx_sc = rcu_dereference_bh(rx_sc->next)) {
rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc);
if (rxsc_idx < 0)
continue;
ret = aq_clear_rxsc(nic, rxsc_idx, clear_type);
if (ret)
return ret;
}
return ret;
}
static int aq_apply_secy_cfg(struct aq_nic_s *nic,
const struct macsec_secy *secy)
{
struct macsec_rx_sc *rx_sc;
int txsc_idx;
int rxsc_idx;
int ret = 0;
txsc_idx = aq_get_txsc_idx_from_secy(nic->macsec_cfg, secy);
if (txsc_idx >= 0)
apply_txsc_cfg(nic, txsc_idx);
for (rx_sc = rcu_dereference_bh(secy->rx_sc); rx_sc && rx_sc->active;
rx_sc = rcu_dereference_bh(rx_sc->next)) {
rxsc_idx = aq_get_rxsc_idx_from_rxsc(nic->macsec_cfg, rx_sc);
if (unlikely(rxsc_idx < 0))
continue;
ret = apply_rxsc_cfg(nic, rxsc_idx);
if (ret)
return ret;
}
Annotation
- Immediate include surface: `aq_macsec.h`, `aq_nic.h`, `linux/rtnetlink.h`, `macsec/macsec_api.h`.
- Detected declarations: `enum aq_clear_type`, `function aq_ether_addr_to_mac`, `function aq_get_txsc_idx_from_secy`, `function aq_get_rxsc_idx_from_rxsc`, `function aq_get_txsc_idx_from_sc_idx`, `function aq_rotate_keys`, `function aq_get_macsec_common_stats`, `function aq_get_rxsa_stats`, `function aq_get_txsa_stats`, `function aq_get_txsa_next_pn`.
- 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.