drivers/net/ethernet/huawei/hinic/hinic_sriov.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_sriov.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_sriov.c- Extension
.c- Size
- 39360 bytes
- Lines
- 1365
- 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.
- 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/pci.hlinux/if_vlan.hlinux/interrupt.hlinux/etherdevice.hlinux/netdevice.hlinux/module.hhinic_hw_dev.hhinic_dev.hhinic_hw_mbox.hhinic_hw_cmdq.hhinic_port.hhinic_sriov.h
Detected Declarations
function hinic_set_macfunction hinic_notify_vf_link_statusfunction hinic_notify_all_vfs_link_changedfunction hinic_vf_info_vlanpriofunction hinic_set_vf_vlanfunction hinic_set_vf_tx_rate_max_minfunction hinic_set_vf_rate_limitfunction hinic_set_vf_tx_ratefunction hinic_init_vf_configfunction hinic_register_vf_msg_handlerfunction hinic_unregister_vf_msg_handlerfunction hinic_change_vf_mtu_msg_handlerfunction hinic_get_vf_mac_msg_handlerfunction hinic_set_vf_mac_msg_handlerfunction is_valid_ether_addrfunction hinic_del_vf_mac_msg_handlerfunction hinic_get_vf_link_status_msg_handlerfunction check_func_tablefunction hinic_check_mac_infofunction hinic_update_macfunction hinic_get_vf_configfunction hinic_ndo_get_vf_configfunction hinic_set_vf_macfunction hinic_ndo_set_vf_macfunction hinic_add_vf_vlanfunction hinic_kill_vf_vlanfunction hinic_update_mac_vlanfunction set_hw_vf_vlanfunction hinic_ndo_set_vf_vlanfunction hinic_set_vf_trustfunction hinic_ndo_set_vf_trustfunction hinic_ndo_set_vf_bwfunction hinic_set_vf_spoofchkfunction hinic_ndo_set_vf_spoofchkfunction hinic_set_vf_link_statefunction hinic_ndo_set_vf_link_statefunction nic_pf_mbox_handlerfunction cfg_mbx_pf_proc_vf_msgfunction hinic_init_vf_infosfunction hinic_clear_vf_infosfunction hinic_deinit_vf_hwfunction hinic_vf_func_initfunction hinic_vf_func_freefunction hinic_init_vf_hwfunction hinic_pci_sriov_disablefunction hinic_pci_sriov_enablefunction hinic_pci_sriov_configure
Annotated Snippet
if (err) {
dev_err(&hwdev->func_to_io.hwif->pdev->dev, "Failed to set VF %d MAC\n",
HW_VF_ID_TO_OS(vf_id));
return err;
}
}
if (hinic_vf_info_vlanprio(hwdev, vf_id)) {
err = hinic_set_vf_vlan(hwdev, true, vf_info->pf_vlan,
vf_info->pf_qos, vf_id);
if (err) {
dev_err(&hwdev->hwif->pdev->dev, "Failed to add VF %d VLAN_QOS\n",
HW_VF_ID_TO_OS(vf_id));
return err;
}
}
if (vf_info->max_rate) {
err = hinic_set_vf_tx_rate(hwdev, vf_id, vf_info->max_rate,
vf_info->min_rate);
if (err) {
dev_err(&hwdev->hwif->pdev->dev, "Failed to set VF %d max rate: %d, min rate: %d\n",
HW_VF_ID_TO_OS(vf_id), vf_info->max_rate,
vf_info->min_rate);
return err;
}
}
return 0;
}
static int hinic_register_vf_msg_handler(void *hwdev, u16 vf_id,
void *buf_in, u16 in_size,
void *buf_out, u16 *out_size)
{
struct hinic_register_vf *register_info = buf_out;
struct hinic_hwdev *hw_dev = hwdev;
struct hinic_func_to_io *nic_io;
int err;
nic_io = &hw_dev->func_to_io;
if (vf_id > nic_io->max_vfs) {
dev_err(&hw_dev->hwif->pdev->dev, "Register VF id %d exceed limit[0-%d]\n",
HW_VF_ID_TO_OS(vf_id), HW_VF_ID_TO_OS(nic_io->max_vfs));
register_info->status = EFAULT;
return -EFAULT;
}
*out_size = sizeof(*register_info);
err = hinic_init_vf_config(hw_dev, vf_id);
if (err) {
register_info->status = EFAULT;
return err;
}
nic_io->vf_infos[HW_VF_ID_TO_OS(vf_id)].registered = true;
return 0;
}
static int hinic_unregister_vf_msg_handler(void *hwdev, u16 vf_id,
void *buf_in, u16 in_size,
void *buf_out, u16 *out_size)
{
struct hinic_hwdev *hw_dev = hwdev;
struct hinic_func_to_io *nic_io;
nic_io = &hw_dev->func_to_io;
*out_size = 0;
if (vf_id > nic_io->max_vfs)
return 0;
nic_io->vf_infos[HW_VF_ID_TO_OS(vf_id)].registered = false;
return 0;
}
static int hinic_change_vf_mtu_msg_handler(void *hwdev, u16 vf_id,
void *buf_in, u16 in_size,
void *buf_out, u16 *out_size)
{
struct hinic_hwdev *hw_dev = hwdev;
int err;
err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_CHANGE_MTU, buf_in,
in_size, buf_out, out_size);
if (err) {
dev_err(&hw_dev->hwif->pdev->dev, "Failed to set VF %u mtu\n",
vf_id);
return err;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/if_vlan.h`, `linux/interrupt.h`, `linux/etherdevice.h`, `linux/netdevice.h`, `linux/module.h`, `hinic_hw_dev.h`, `hinic_dev.h`.
- Detected declarations: `function hinic_set_mac`, `function hinic_notify_vf_link_status`, `function hinic_notify_all_vfs_link_changed`, `function hinic_vf_info_vlanprio`, `function hinic_set_vf_vlan`, `function hinic_set_vf_tx_rate_max_min`, `function hinic_set_vf_rate_limit`, `function hinic_set_vf_tx_rate`, `function hinic_init_vf_config`, `function hinic_register_vf_msg_handler`.
- 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.