drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c- Extension
.c- Size
- 33725 bytes
- Lines
- 1156
- 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
hclge_main.hhclge_mbx.hhnae3.hhclge_comm_rss.hhclge_trace.h
Detected Declarations
function hclge_errno_to_respfunction hclge_gen_resp_to_vffunction hclge_send_mbx_msgfunction hclge_inform_vf_resetfunction hclge_inform_reset_assert_to_vffunction hclge_free_vector_ring_chainfunction hclge_get_ring_chain_from_mbxfunction hclge_map_unmap_ring_to_vf_vectorfunction hclge_query_ring_vector_mapfunction hclge_get_vf_ring_vector_mapfunction hclge_set_vf_promisc_modefunction hclge_set_vf_uc_mac_addrfunction hclge_set_vf_mc_mac_addrfunction hclge_push_vf_port_base_vlan_infofunction hclge_set_vf_vlan_cfgfunction hclge_set_vf_alivefunction hclge_get_basic_infofunction hclge_get_vf_queue_infofunction hclge_get_vf_mac_addrfunction hclge_get_vf_queue_depthfunction hclge_get_vf_media_typefunction hclge_push_vf_link_statusfunction hclge_get_link_modefunction hclge_mbx_reset_vf_queuefunction hclge_reset_vffunction hclge_notify_vf_configfunction hclge_vf_keep_alivefunction hclge_set_vf_mtufunction hclge_get_queue_id_in_pffunction hclge_get_rss_keyfunction hclge_link_fail_parsefunction hclge_handle_link_change_eventfunction hclge_cmd_crq_emptyfunction hclge_handle_ncsi_errorfunction hclge_handle_vf_tblfunction hclge_mbx_map_ring_to_vector_handlerfunction hclge_mbx_unmap_ring_to_vector_handlerfunction hclge_mbx_get_ring_vector_map_handlerfunction hclge_mbx_set_promisc_mode_handlerfunction hclge_mbx_set_unicast_handlerfunction hclge_mbx_set_multicast_handlerfunction hclge_mbx_set_vlan_handlerfunction hclge_mbx_set_alive_handlerfunction hclge_mbx_get_qinfo_handlerfunction hclge_mbx_get_qdepth_handlerfunction hclge_mbx_get_basic_info_handlerfunction hclge_mbx_get_link_status_handlerfunction hclge_mbx_queue_reset_handler
Annotated Snippet
if (req->msg.param[i].tqp_index >= vport->nic.kinfo.num_tqps) {
dev_err(&hdev->pdev->dev, "tqp index(%u) is out of range(0-%u)\n",
req->msg.param[i].tqp_index,
vport->nic.kinfo.num_tqps - 1U);
return -EINVAL;
}
}
hnae3_set_bit(ring_chain->flag, HNAE3_RING_TYPE_B,
req->msg.param[0].ring_type);
ring_chain->tqp_index =
hclge_get_queue_id(vport->nic.kinfo.tqp
[req->msg.param[0].tqp_index]);
hnae3_set_field(ring_chain->int_gl_idx, HNAE3_RING_GL_IDX_M,
HNAE3_RING_GL_IDX_S, req->msg.param[0].int_gl_index);
cur_chain = ring_chain;
for (i = 1; i < ring_num; i++) {
new_chain = kzalloc_obj(*new_chain);
if (!new_chain)
goto err;
hnae3_set_bit(new_chain->flag, HNAE3_RING_TYPE_B,
req->msg.param[i].ring_type);
new_chain->tqp_index =
hclge_get_queue_id(vport->nic.kinfo.tqp
[req->msg.param[i].tqp_index]);
hnae3_set_field(new_chain->int_gl_idx, HNAE3_RING_GL_IDX_M,
HNAE3_RING_GL_IDX_S,
req->msg.param[i].int_gl_index);
cur_chain->next = new_chain;
cur_chain = new_chain;
}
return 0;
err:
hclge_free_vector_ring_chain(ring_chain);
return -ENOMEM;
}
static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en,
struct hclge_mbx_vf_to_pf_cmd *req)
{
struct hnae3_ring_chain_node ring_chain;
int vector_id = req->msg.vector_id;
int ret;
memset(&ring_chain, 0, sizeof(ring_chain));
ret = hclge_get_ring_chain_from_mbx(req, &ring_chain, vport);
if (ret)
return ret;
ret = hclge_bind_ring_with_vector(vport, vector_id, en, &ring_chain);
hclge_free_vector_ring_chain(&ring_chain);
return ret;
}
static int hclge_query_ring_vector_map(struct hclge_vport *vport,
struct hnae3_ring_chain_node *ring_chain,
struct hclge_desc *desc)
{
struct hclge_ctrl_vector_chain_cmd *req =
(struct hclge_ctrl_vector_chain_cmd *)desc->data;
struct hclge_dev *hdev = vport->back;
u16 tqp_type_and_id;
int status;
hclge_cmd_setup_basic_desc(desc, HCLGE_OPC_ADD_RING_TO_VECTOR, true);
tqp_type_and_id = le16_to_cpu(req->tqp_type_and_id[0]);
hnae3_set_field(tqp_type_and_id, HCLGE_INT_TYPE_M, HCLGE_INT_TYPE_S,
hnae3_get_bit(ring_chain->flag, HNAE3_RING_TYPE_B));
hnae3_set_field(tqp_type_and_id, HCLGE_TQP_ID_M, HCLGE_TQP_ID_S,
ring_chain->tqp_index);
req->tqp_type_and_id[0] = cpu_to_le16(tqp_type_and_id);
req->vfid = vport->vport_id;
status = hclge_cmd_send(&hdev->hw, desc, 1);
if (status)
dev_err(&hdev->pdev->dev,
"Get VF ring vector map info fail, status is %d.\n",
status);
return status;
Annotation
- Immediate include surface: `hclge_main.h`, `hclge_mbx.h`, `hnae3.h`, `hclge_comm_rss.h`, `hclge_trace.h`.
- Detected declarations: `function hclge_errno_to_resp`, `function hclge_gen_resp_to_vf`, `function hclge_send_mbx_msg`, `function hclge_inform_vf_reset`, `function hclge_inform_reset_assert_to_vf`, `function hclge_free_vector_ring_chain`, `function hclge_get_ring_chain_from_mbx`, `function hclge_map_unmap_ring_to_vf_vector`, `function hclge_query_ring_vector_map`, `function hclge_get_vf_ring_vector_map`.
- 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.