drivers/net/ethernet/huawei/hinic/hinic_port.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_port.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_port.c- Extension
.c- Size
- 38167 bytes
- Lines
- 1413
- 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
linux/types.hlinux/netdevice.hlinux/etherdevice.hlinux/if_vlan.hlinux/pci.hlinux/device.hlinux/errno.hhinic_hw_if.hhinic_hw_dev.hhinic_port.hhinic_dev.h
Detected Declarations
enum mac_opfunction change_macfunction hinic_port_add_macfunction hinic_port_del_macfunction hinic_port_get_macfunction hinic_port_set_mtufunction hinic_port_add_vlanfunction hinic_port_del_vlanfunction hinic_port_set_rx_modefunction hinic_port_link_statefunction hinic_port_set_statefunction hinic_port_set_func_statefunction hinic_port_get_capfunction hinic_port_set_tsofunction hinic_set_rx_csum_offloadfunction hinic_set_rx_vlan_offloadfunction hinic_set_vlan_fliterfunction HINIC_IS_VFfunction hinic_set_max_qnumfunction hinic_set_rx_lrofunction hinic_set_rx_lro_timerfunction hinic_set_rx_lro_statefunction hinic_rss_set_indir_tblfunction hinic_rss_get_indir_tblfunction hinic_set_rss_typefunction hinic_get_rss_typefunction hinic_rss_set_template_tblfunction hinic_rss_get_template_tblfunction hinic_rss_set_hash_enginefunction hinic_rss_get_hash_enginefunction hinic_rss_cfgfunction hinic_rss_template_allocfunction hinic_rss_template_freefunction hinic_get_vport_statsfunction hinic_get_phy_port_statsfunction hinic_get_mgmt_versionfunction hinic_get_link_modefunction hinic_set_autonegfunction hinic_set_speedfunction hinic_set_link_settingsfunction hinic_get_hw_pause_infofunction hinic_set_hw_pause_infofunction hinic_dcb_set_pfcfunction hinic_set_loopback_modefunction _set_led_statusfunction hinic_set_led_statusfunction hinic_reset_led_statusfunction hinic_if_sfp_absent
Annotated Snippet
HINIC_IS_VF(hwif)) {
err = HINIC_MGMT_CMD_UNSUPPORTED;
} else if (err || !out_size || vlan_filter.status) {
dev_err(&pdev->dev,
"Failed to set vlan filter, err: %d, status: 0x%x, out size: 0x%x\n",
err, vlan_filter.status, out_size);
err = -EINVAL;
}
return err;
}
int hinic_set_max_qnum(struct hinic_dev *nic_dev, u8 num_rqs)
{
struct hinic_hwdev *hwdev = nic_dev->hwdev;
struct hinic_hwif *hwif = hwdev->hwif;
struct hinic_rq_num rq_num = { 0 };
struct pci_dev *pdev = hwif->pdev;
u16 out_size = sizeof(rq_num);
int err;
rq_num.func_id = HINIC_HWIF_FUNC_IDX(hwif);
rq_num.num_rqs = num_rqs;
rq_num.rq_depth = ilog2(nic_dev->rq_depth);
err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_RQ_IQ_MAP,
&rq_num, sizeof(rq_num),
&rq_num, &out_size);
if (err || !out_size || rq_num.status) {
dev_err(&pdev->dev,
"Failed to set rxq number, err: %d, status: 0x%x, out size: 0x%x\n",
err, rq_num.status, out_size);
return -EIO;
}
return 0;
}
static int hinic_set_rx_lro(struct hinic_dev *nic_dev, u8 ipv4_en, u8 ipv6_en,
u8 max_wqe_num)
{
struct hinic_hwdev *hwdev = nic_dev->hwdev;
struct hinic_lro_config lro_cfg = { 0 };
struct hinic_hwif *hwif = hwdev->hwif;
struct pci_dev *pdev = hwif->pdev;
u16 out_size = sizeof(lro_cfg);
int err;
lro_cfg.func_id = HINIC_HWIF_FUNC_IDX(hwif);
lro_cfg.lro_ipv4_en = ipv4_en;
lro_cfg.lro_ipv6_en = ipv6_en;
lro_cfg.lro_max_wqe_num = max_wqe_num;
err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO,
&lro_cfg, sizeof(lro_cfg),
&lro_cfg, &out_size);
if (err || !out_size || lro_cfg.status) {
dev_err(&pdev->dev,
"Failed to set lro offload, err: %d, status: 0x%x, out size: 0x%x\n",
err, lro_cfg.status, out_size);
return -EIO;
}
return 0;
}
static int hinic_set_rx_lro_timer(struct hinic_dev *nic_dev, u32 timer_value)
{
struct hinic_hwdev *hwdev = nic_dev->hwdev;
struct hinic_lro_timer lro_timer = { 0 };
struct hinic_hwif *hwif = hwdev->hwif;
struct pci_dev *pdev = hwif->pdev;
u16 out_size = sizeof(lro_timer);
int err;
lro_timer.status = 0;
lro_timer.type = 0;
lro_timer.enable = 1;
lro_timer.timer = timer_value;
err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LRO_TIMER,
&lro_timer, sizeof(lro_timer),
&lro_timer, &out_size);
if (lro_timer.status == 0xFF) {
/* For this case, we think status (0xFF) is OK */
lro_timer.status = 0;
dev_dbg(&pdev->dev,
"Set lro timer not supported by the current FW version, it will be 1ms default\n");
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/pci.h`, `linux/device.h`, `linux/errno.h`, `hinic_hw_if.h`.
- Detected declarations: `enum mac_op`, `function change_mac`, `function hinic_port_add_mac`, `function hinic_port_del_mac`, `function hinic_port_get_mac`, `function hinic_port_set_mtu`, `function hinic_port_add_vlan`, `function hinic_port_del_vlan`, `function hinic_port_set_rx_mode`, `function hinic_port_link_state`.
- 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.