drivers/net/ethernet/qlogic/qed/qed_mcp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_mcp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/qlogic/qed/qed_mcp.c- Extension
.c- Size
- 118816 bytes
- Lines
- 4234
- 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.
- 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.hlinux/delay.hlinux/errno.hlinux/kernel.hlinux/slab.hlinux/spinlock.hlinux/string.hlinux/etherdevice.hqed.hqed_cxt.hqed_dcbx.hqed_hsi.hqed_mfw_hsi.hqed_hw.hqed_mcp.hqed_reg_addr.hqed_sriov.h
Detected Declarations
struct qed_mcp_cmd_elemstruct qed_load_req_in_paramsstruct qed_load_req_out_paramsstruct qed_mdump_cmd_paramsstruct qed_resc_alloc_in_paramsstruct qed_resc_alloc_out_paramsenum qed_load_req_forceenum qed_mcp_dbg_data_typefunction Copyrightfunction qed_mcp_cmd_port_initfunction qed_mcp_read_mbfunction qed_mcp_cmd_add_elemfunction qed_mcp_cmd_del_elemfunction list_for_each_entryfunction qed_mcp_freefunction list_for_each_entry_safefunction qed_load_mcp_offsetsfunction qed_mcp_cmd_initfunction qed_mcp_reread_offsetsfunction qed_mcp_resetfunction qed_mcp_has_pending_cmdfunction qed_mcp_update_pending_cmdfunction __qed_mcp_cmd_and_unionfunction qed_mcp_cmd_set_blockingfunction qed_mcp_print_cpu_infofunction _qed_mcp_cmd_and_unionfunction qed_mcp_cmd_and_unionfunction _qed_mcp_cmdfunction qed_mcp_cmdfunction qed_mcp_cmd_nosleepfunction qed_mcp_nvm_wr_cmdfunction qed_mcp_nvm_rd_cmdfunction qed_mcp_can_force_loadfunction qed_mcp_cancel_load_reqfunction qed_get_config_bitmapfunction __qed_mcp_load_reqfunction eocre_get_mfw_drv_rolefunction qed_get_mfw_force_cmdfunction qed_mcp_load_reqfunction qed_mcp_load_donefunction qed_mcp_unload_reqfunction qed_mcp_unload_donefunction qed_mcp_handle_vf_flrfunction qed_mcp_ack_vf_flrfunction qed_mcp_handle_transceiver_changefunction qed_mcp_read_eee_configfunction qed_mcp_get_shmem_funcfunction qed_read_pf_bandwidth
Annotated Snippet
struct qed_mcp_cmd_elem {
struct list_head list;
struct qed_mcp_mb_params *p_mb_params;
u16 expected_seq_num;
bool b_is_completed;
};
/* Must be called while cmd_lock is acquired */
static struct qed_mcp_cmd_elem *
qed_mcp_cmd_add_elem(struct qed_hwfn *p_hwfn,
struct qed_mcp_mb_params *p_mb_params,
u16 expected_seq_num)
{
struct qed_mcp_cmd_elem *p_cmd_elem = NULL;
p_cmd_elem = kzalloc_obj(*p_cmd_elem, GFP_ATOMIC);
if (!p_cmd_elem)
goto out;
p_cmd_elem->p_mb_params = p_mb_params;
p_cmd_elem->expected_seq_num = expected_seq_num;
list_add(&p_cmd_elem->list, &p_hwfn->mcp_info->cmd_list);
out:
return p_cmd_elem;
}
/* Must be called while cmd_lock is acquired */
static void qed_mcp_cmd_del_elem(struct qed_hwfn *p_hwfn,
struct qed_mcp_cmd_elem *p_cmd_elem)
{
list_del(&p_cmd_elem->list);
kfree(p_cmd_elem);
}
/* Must be called while cmd_lock is acquired */
static struct qed_mcp_cmd_elem *qed_mcp_cmd_get_elem(struct qed_hwfn *p_hwfn,
u16 seq_num)
{
struct qed_mcp_cmd_elem *p_cmd_elem = NULL;
list_for_each_entry(p_cmd_elem, &p_hwfn->mcp_info->cmd_list, list) {
if (p_cmd_elem->expected_seq_num == seq_num)
return p_cmd_elem;
}
return NULL;
}
int qed_mcp_free(struct qed_hwfn *p_hwfn)
{
if (p_hwfn->mcp_info) {
struct qed_mcp_cmd_elem *p_cmd_elem = NULL, *p_tmp;
kfree(p_hwfn->mcp_info->mfw_mb_cur);
kfree(p_hwfn->mcp_info->mfw_mb_shadow);
spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
list_for_each_entry_safe(p_cmd_elem,
p_tmp,
&p_hwfn->mcp_info->cmd_list, list) {
qed_mcp_cmd_del_elem(p_hwfn, p_cmd_elem);
}
spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
}
kfree(p_hwfn->mcp_info);
p_hwfn->mcp_info = NULL;
return 0;
}
/* Maximum of 1 sec to wait for the SHMEM ready indication */
#define QED_MCP_SHMEM_RDY_MAX_RETRIES 20
#define QED_MCP_SHMEM_RDY_ITER_MS 50
static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
{
struct qed_mcp_info *p_info = p_hwfn->mcp_info;
u8 cnt = QED_MCP_SHMEM_RDY_MAX_RETRIES;
u8 msec = QED_MCP_SHMEM_RDY_ITER_MS;
u32 drv_mb_offsize, mfw_mb_offsize;
u32 mcp_pf_id = MCP_PF_ID(p_hwfn);
p_info->public_base = qed_rd(p_hwfn, p_ptt, MISC_REG_SHARED_MEM_ADDR);
if (!p_info->public_base) {
DP_NOTICE(p_hwfn,
"The address of the MCP scratch-pad is not configured\n");
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/types.h`, `asm/byteorder.h`, `linux/delay.h`, `linux/errno.h`, `linux/kernel.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/string.h`.
- Detected declarations: `struct qed_mcp_cmd_elem`, `struct qed_load_req_in_params`, `struct qed_load_req_out_params`, `struct qed_mdump_cmd_params`, `struct qed_resc_alloc_in_params`, `struct qed_resc_alloc_out_params`, `enum qed_load_req_force`, `enum qed_mcp_dbg_data_type`, `function Copyright`, `function qed_mcp_cmd_port_init`.
- 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.
- 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.