drivers/net/ethernet/aquantia/atlantic/macsec/macsec_api.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/aquantia/atlantic/macsec/macsec_api.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/aquantia/atlantic/macsec/macsec_api.c- Extension
.c- Size
- 67407 bytes
- Lines
- 2478
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
macsec_api.hlinux/mdio.hMSS_Ingress_registers.hMSS_Egress_registers.haq_phy.h
Detected Declarations
function aq_mss_mdio_sem_getfunction aq_mss_mdio_sem_putfunction aq_mss_mdio_readfunction aq_mss_mdio_writefunction set_raw_ingress_recordfunction get_raw_ingress_recordfunction set_raw_egress_recordfunction get_raw_egress_recordfunction set_ingress_prectlf_recordfunction aq_mss_set_ingress_prectlf_recordfunction get_ingress_prectlf_recordfunction aq_mss_get_ingress_prectlf_recordfunction set_ingress_preclass_recordfunction aq_mss_set_ingress_preclass_recordfunction get_ingress_preclass_recordfunction aq_mss_get_ingress_preclass_recordfunction set_ingress_sc_recordfunction aq_mss_set_ingress_sc_recordfunction get_ingress_sc_recordfunction aq_mss_get_ingress_sc_recordfunction set_ingress_sa_recordfunction aq_mss_set_ingress_sa_recordfunction get_ingress_sa_recordfunction aq_mss_get_ingress_sa_recordfunction set_ingress_sakey_recordfunction aq_mss_set_ingress_sakey_recordfunction get_ingress_sakey_recordfunction aq_mss_get_ingress_sakey_recordfunction set_ingress_postclass_recordfunction aq_mss_set_ingress_postclass_recordfunction get_ingress_postclass_recordfunction aq_mss_get_ingress_postclass_recordfunction set_ingress_postctlf_recordfunction aq_mss_set_ingress_postctlf_recordfunction get_ingress_postctlf_recordfunction aq_mss_get_ingress_postctlf_recordfunction set_egress_ctlf_recordfunction aq_mss_set_egress_ctlf_recordfunction get_egress_ctlf_recordfunction aq_mss_get_egress_ctlf_recordfunction set_egress_class_recordfunction aq_mss_set_egress_class_recordfunction get_egress_class_recordfunction aq_mss_get_egress_class_recordfunction set_egress_sc_recordfunction aq_mss_set_egress_sc_recordfunction get_egress_sc_recordfunction aq_mss_get_egress_sc_record
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Atlantic Network Driver
* Copyright (C) 2020 Marvell International Ltd.
*/
#include "macsec_api.h"
#include <linux/mdio.h>
#include "MSS_Ingress_registers.h"
#include "MSS_Egress_registers.h"
#include "aq_phy.h"
#define AQ_API_CALL_SAFE(func, ...) \
({ \
int ret; \
do { \
ret = aq_mss_mdio_sem_get(hw); \
if (unlikely(ret)) \
break; \
\
ret = func(__VA_ARGS__); \
\
aq_mss_mdio_sem_put(hw); \
} while (0); \
ret; \
})
/*******************************************************************************
* MDIO wrappers
******************************************************************************/
static int aq_mss_mdio_sem_get(struct aq_hw_s *hw)
{
u32 val;
return readx_poll_timeout_atomic(hw_atl_sem_mdio_get, hw, val,
val == 1U, 10U, 100000U);
}
static void aq_mss_mdio_sem_put(struct aq_hw_s *hw)
{
hw_atl_reg_glb_cpu_sem_set(hw, 1U, HW_ATL_FW_SM_MDIO);
}
static int aq_mss_mdio_read(struct aq_hw_s *hw, u16 mmd, u16 addr, u16 *data)
{
*data = aq_mdio_read_word(hw, mmd, addr);
return (*data != 0xffff) ? 0 : -ETIME;
}
static int aq_mss_mdio_write(struct aq_hw_s *hw, u16 mmd, u16 addr, u16 data)
{
aq_mdio_write_word(hw, mmd, addr, data);
return 0;
}
/*******************************************************************************
* MACSEC config and status
******************************************************************************/
static int set_raw_ingress_record(struct aq_hw_s *hw, u16 *packed_record,
u8 num_words, u8 table_id,
u16 table_index)
{
struct mss_ingress_lut_addr_ctl_register lut_sel_reg;
struct mss_ingress_lut_ctl_register lut_op_reg;
unsigned int i;
/* NOTE: MSS registers must always be read/written as adjacent pairs.
* For instance, to write either or both 1E.80A0 and 80A1, we have to:
* 1. Write 1E.80A0 first
* 2. Then write 1E.80A1
*
* For HHD devices: These writes need to be performed consecutively, and
* to ensure this we use the PIF mailbox to delegate the reads/writes to
* the FW.
*
* For EUR devices: Not need to use the PIF mailbox; it is safe to
* write to the registers directly.
*/
/* Write the packed record words to the data buffer registers. */
for (i = 0; i < num_words; i += 2) {
aq_mss_mdio_write(hw, MDIO_MMD_VEND1,
MSS_INGRESS_LUT_DATA_CTL_REGISTER_ADDR + i,
packed_record[i]);
aq_mss_mdio_write(hw, MDIO_MMD_VEND1,
MSS_INGRESS_LUT_DATA_CTL_REGISTER_ADDR + i +
1,
packed_record[i + 1]);
}
Annotation
- Immediate include surface: `macsec_api.h`, `linux/mdio.h`, `MSS_Ingress_registers.h`, `MSS_Egress_registers.h`, `aq_phy.h`.
- Detected declarations: `function aq_mss_mdio_sem_get`, `function aq_mss_mdio_sem_put`, `function aq_mss_mdio_read`, `function aq_mss_mdio_write`, `function set_raw_ingress_record`, `function get_raw_ingress_record`, `function set_raw_egress_record`, `function get_raw_egress_record`, `function set_ingress_prectlf_record`, `function aq_mss_set_ingress_prectlf_record`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.