drivers/net/ethernet/qlogic/qed/qed_l2.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_l2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qed/qed_l2.c- Extension
.c- Size
- 81703 bytes
- Lines
- 2890
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/types.hasm/byteorder.hasm/param.hlinux/crc32.hlinux/delay.hlinux/dma-mapping.hlinux/etherdevice.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/pci.hlinux/slab.hlinux/stddef.hlinux/string.hlinux/workqueue.hlinux/bitops.hlinux/bug.hlinux/vmalloc.hqed.hlinux/qed/qed_chain.hqed_cxt.hqed_dcbx.hqed_dev_api.hlinux/qed/qed_eth_if.hqed_hsi.hqed_iro_hsi.hqed_hw.hqed_int.hqed_l2.hqed_mcp.hqed_ptp.hqed_reg_addr.h
Detected Declarations
struct qed_l2_infofunction qed_l2_allocfunction qed_l2_setupfunction qed_l2_freefunction qed_eth_queue_qid_usage_addfunction qed_eth_queue_qid_usage_delfunction qed_eth_queue_cid_releasefunction _qed_eth_queue_to_cidfunction qed_eth_queue_to_cidfunction qed_eth_queue_to_cid_pffunction qed_sp_eth_vport_startfunction qed_sp_vport_startfunction qed_sp_vport_update_rssfunction qed_sp_update_accept_modefunction qed_sp_vport_update_sge_tpafunction qed_sp_update_mcast_binfunction qed_sp_vport_updatefunction qed_sp_vport_stopfunction qed_vf_pf_accept_flagsfunction qed_filter_accept_cmdfunction for_each_hwfnfunction qed_eth_rxq_start_ramrodfunction qed_eth_pf_rx_queue_startfunction qed_eth_rx_queue_startfunction qed_sp_eth_rx_queues_updatefunction qed_eth_pf_rx_queue_stopfunction qed_eth_rx_queue_stopfunction qed_eth_txq_start_ramrodfunction qed_eth_pf_tx_queue_startfunction qed_eth_tx_queue_startfunction qed_eth_pf_tx_queue_stopfunction qed_eth_tx_queue_stopfunction qed_filter_actionfunction qed_filter_ucast_commonfunction qed_sp_eth_filter_ucastfunction qed_mcast_bin_from_macfunction qed_sp_eth_filter_mcastfunction qed_filter_mcast_cmdfunction for_each_hwfnfunction qed_filter_ucast_cmdfunction for_each_hwfnfunction __qed_get_vport_pstats_addrlenfunction __qed_get_vport_pstatsfunction __qed_get_vport_tstatsfunction __qed_get_vport_ustats_addrlenfunction __qed_get_vport_ustatsfunction __qed_get_vport_mstats_addrlenfunction __qed_get_vport_mstats
Annotated Snippet
struct qed_l2_info {
u32 queues;
unsigned long **pp_qid_usage;
/* The lock is meant to synchronize access to the qid usage */
struct mutex lock;
};
int qed_l2_alloc(struct qed_hwfn *p_hwfn)
{
struct qed_l2_info *p_l2_info;
unsigned long **pp_qids;
u32 i;
if (!QED_IS_L2_PERSONALITY(p_hwfn))
return 0;
p_l2_info = kzalloc_obj(*p_l2_info);
if (!p_l2_info)
return -ENOMEM;
p_hwfn->p_l2_info = p_l2_info;
if (IS_PF(p_hwfn->cdev)) {
p_l2_info->queues = RESC_NUM(p_hwfn, QED_L2_QUEUE);
} else {
u8 rx = 0, tx = 0;
qed_vf_get_num_rxqs(p_hwfn, &rx);
qed_vf_get_num_txqs(p_hwfn, &tx);
p_l2_info->queues = max_t(u8, rx, tx);
}
pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *),
GFP_KERNEL);
if (!pp_qids)
return -ENOMEM;
p_l2_info->pp_qid_usage = pp_qids;
for (i = 0; i < p_l2_info->queues; i++) {
pp_qids[i] = kzalloc(MAX_QUEUES_PER_QZONE / 8, GFP_KERNEL);
if (!pp_qids[i])
return -ENOMEM;
}
return 0;
}
void qed_l2_setup(struct qed_hwfn *p_hwfn)
{
if (!QED_IS_L2_PERSONALITY(p_hwfn))
return;
mutex_init(&p_hwfn->p_l2_info->lock);
}
void qed_l2_free(struct qed_hwfn *p_hwfn)
{
u32 i;
if (!QED_IS_L2_PERSONALITY(p_hwfn))
return;
if (!p_hwfn->p_l2_info)
return;
if (!p_hwfn->p_l2_info->pp_qid_usage)
goto out_l2_info;
/* Free until hit first uninitialized entry */
for (i = 0; i < p_hwfn->p_l2_info->queues; i++) {
if (!p_hwfn->p_l2_info->pp_qid_usage[i])
break;
kfree(p_hwfn->p_l2_info->pp_qid_usage[i]);
}
kfree(p_hwfn->p_l2_info->pp_qid_usage);
out_l2_info:
kfree(p_hwfn->p_l2_info);
p_hwfn->p_l2_info = NULL;
}
static bool qed_eth_queue_qid_usage_add(struct qed_hwfn *p_hwfn,
struct qed_queue_cid *p_cid)
{
struct qed_l2_info *p_l2_info = p_hwfn->p_l2_info;
u16 queue_id = p_cid->rel.queue_id;
bool b_rc = true;
u8 first;
Annotation
- Immediate include surface: `linux/types.h`, `asm/byteorder.h`, `asm/param.h`, `linux/crc32.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/etherdevice.h`, `linux/interrupt.h`.
- Detected declarations: `struct qed_l2_info`, `function qed_l2_alloc`, `function qed_l2_setup`, `function qed_l2_free`, `function qed_eth_queue_qid_usage_add`, `function qed_eth_queue_qid_usage_del`, `function qed_eth_queue_cid_release`, `function _qed_eth_queue_to_cid`, `function qed_eth_queue_to_cid`, `function qed_eth_queue_to_cid_pf`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.