drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c- Extension
.c- Size
- 20291 bytes
- Lines
- 741
- 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
linux/if_vlan.hhinic3_hwdev.hhinic3_hwif.hhinic3_mbox.hhinic3_nic_cfg.hhinic3_nic_dev.hhinic3_nic_io.h
Detected Declarations
function hinic3_feature_negofunction hinic3_get_nic_feature_from_hwfunction hinic3_set_nic_feature_to_hwfunction hinic3_test_supportfunction hinic3_set_rx_lrofunction hinic3_set_rx_lro_timerfunction hinic3_set_rx_lro_statefunction hinic3_set_rx_vlan_offloadfunction hinic3_set_vlan_filterfunction hinic3_update_nic_featurefunction hinic3_set_function_tablefunction hinic3_init_function_tablefunction hinic3_set_port_mtufunction hinic3_check_vf_set_by_pffunction hinic3_check_mac_infofunction hinic3_get_default_macfunction hinic3_set_macfunction hinic3_del_macfunction hinic3_update_macfunction hinic3_set_ci_tablefunction hinic3_flush_qps_resfunction hinic3_force_drop_tx_pktfunction hinic3_set_rx_modefunction hinic3_config_vlanfunction hinic3_add_vlanfunction hinic3_del_vlanfunction hinic3_set_port_enablefunction hinic3_sync_dcb_statefunction hinic3_get_link_statusfunction hinic3_get_port_infofunction hinic3_set_vport_enablefunction hinic3_cfg_hw_pausefunction hinic3_get_pause_info
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
#include <linux/if_vlan.h>
#include "hinic3_hwdev.h"
#include "hinic3_hwif.h"
#include "hinic3_mbox.h"
#include "hinic3_nic_cfg.h"
#include "hinic3_nic_dev.h"
#include "hinic3_nic_io.h"
#define MGMT_MSG_CMD_OP_ADD 1
#define MGMT_MSG_CMD_OP_DEL 0
static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
u64 *s_feature, u16 size)
{
struct l2nic_cmd_feature_nego feature_nego = {};
struct mgmt_msg_params msg_params = {};
int err;
feature_nego.func_id = hinic3_global_func_id(hwdev);
feature_nego.opcode = opcode;
if (opcode == MGMT_MSG_CMD_OP_SET)
memcpy(feature_nego.s_feature, s_feature,
array_size(size, sizeof(u64)));
mgmt_msg_params_init_default(&msg_params, &feature_nego,
sizeof(feature_nego));
err = hinic3_send_mbox_to_mgmt(hwdev, MGMT_MOD_L2NIC,
L2NIC_CMD_FEATURE_NEGO, &msg_params);
if (err || feature_nego.msg_head.status) {
dev_err(hwdev->dev, "Failed to negotiate nic feature, err:%d, status: 0x%x\n",
err, feature_nego.msg_head.status);
return -EIO;
}
if (opcode == MGMT_MSG_CMD_OP_GET)
memcpy(s_feature, feature_nego.s_feature,
array_size(size, sizeof(u64)));
return 0;
}
int hinic3_get_nic_feature_from_hw(struct hinic3_nic_dev *nic_dev)
{
return hinic3_feature_nego(nic_dev->hwdev, MGMT_MSG_CMD_OP_GET,
&nic_dev->nic_io->feature_cap, 1);
}
int hinic3_set_nic_feature_to_hw(struct hinic3_nic_dev *nic_dev)
{
return hinic3_feature_nego(nic_dev->hwdev, MGMT_MSG_CMD_OP_SET,
&nic_dev->nic_io->feature_cap, 1);
}
bool hinic3_test_support(struct hinic3_nic_dev *nic_dev,
enum hinic3_nic_feature_cap feature_bits)
{
return (nic_dev->nic_io->feature_cap & feature_bits) == feature_bits;
}
static int hinic3_set_rx_lro(struct hinic3_hwdev *hwdev, u8 ipv4_en, u8 ipv6_en,
u8 lro_max_pkt_len)
{
struct l2nic_cmd_lro_config lro_cfg = {};
struct mgmt_msg_params msg_params = {};
int err;
lro_cfg.func_id = hinic3_global_func_id(hwdev);
lro_cfg.opcode = MGMT_MSG_CMD_OP_SET;
lro_cfg.lro_ipv4_en = ipv4_en;
lro_cfg.lro_ipv6_en = ipv6_en;
lro_cfg.lro_max_pkt_len = lro_max_pkt_len;
mgmt_msg_params_init_default(&msg_params, &lro_cfg,
sizeof(lro_cfg));
err = hinic3_send_mbox_to_mgmt(hwdev, MGMT_MOD_L2NIC,
L2NIC_CMD_CFG_RX_LRO,
&msg_params);
if (err || lro_cfg.msg_head.status) {
dev_err(hwdev->dev, "Failed to set lro offload, err: %d, status: 0x%x\n",
err, lro_cfg.msg_head.status);
return -EFAULT;
}
Annotation
- Immediate include surface: `linux/if_vlan.h`, `hinic3_hwdev.h`, `hinic3_hwif.h`, `hinic3_mbox.h`, `hinic3_nic_cfg.h`, `hinic3_nic_dev.h`, `hinic3_nic_io.h`.
- Detected declarations: `function hinic3_feature_nego`, `function hinic3_get_nic_feature_from_hw`, `function hinic3_set_nic_feature_to_hw`, `function hinic3_test_support`, `function hinic3_set_rx_lro`, `function hinic3_set_rx_lro_timer`, `function hinic3_set_rx_lro_state`, `function hinic3_set_rx_vlan_offload`, `function hinic3_set_vlan_filter`, `function hinic3_update_nic_feature`.
- 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.