drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c- Extension
.c- Size
- 31404 bytes
- Lines
- 1256
- 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/acpi.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/of_address.hlinux/of_mdio.hlinux/phy.hlinux/platform_device.hhns_dsaf_main.hhns_dsaf_misc.hhns_dsaf_rcb.h
Detected Declarations
function hns_get_enet_interfacefunction hns_mac_link_anti_shakefunction hns_mac_get_link_statusfunction hns_mac_get_port_infofunction hns_mac_need_adjust_linkfunction hns_mac_adjust_linkfunction hns_mac_get_inner_port_numfunction hns_mac_change_vf_addrfunction hns_mac_add_uc_addrfunction hns_mac_rm_uc_addrfunction hns_mac_set_multifunction hns_mac_clr_multicastfunction hns_mac_param_getfunction hns_mac_port_config_bc_enfunction hns_mac_vm_config_bc_enfunction hns_mac_wait_fifo_cleanfunction hns_mac_resetfunction hns_mac_set_mtufunction hns_mac_startfunction hns_mac_stopfunction hns_mac_get_autonegfunction hns_mac_get_pauseparamfunction hns_mac_set_autonegfunction hns_mac_set_pauseparamfunction hns_mac_init_exfunction hns_mac_phy_parse_addrfunction hns_mac_register_phydevfunction hns_mac_register_phyfunction hns_mac_remove_phydevfunction hns_mac_get_infofunction hns_mac_get_modefunction hns_mac_get_vaddrfunction hns_mac_get_cfgfunction hns_mac_get_max_port_numfunction hns_mac_enablefunction hns_mac_disablefunction hns_mac_initfunction device_for_each_child_node_scopedfunction hns_mac_uninitfunction hns_mac_config_mac_loopbackfunction hns_mac_update_statsfunction hns_mac_get_statsfunction hns_mac_get_stringsfunction hns_mac_get_sset_countfunction hns_mac_set_promiscfunction hns_mac_get_regs_countfunction hns_mac_get_regsfunction hns_set_led_opt
Annotated Snippet
if (ret) {
dev_err(mac_cb->dev,
"adjust_link failed, %s mac%d ret = %#x!\n",
mac_cb->dsaf_dev->ae_dev.name,
mac_cb->mac_id, ret);
return;
}
}
}
/**
*hns_mac_get_inner_port_num - get mac table inner port number
*@mac_cb: mac device
*@vmid: vm id
*@port_num:port number
*
*/
int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb, u8 vmid, u8 *port_num)
{
int q_num_per_vf, vf_num_per_port;
int vm_queue_id;
u8 tmp_port;
if (mac_cb->dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) {
if (mac_cb->mac_id != DSAF_MAX_PORT_NUM) {
dev_err(mac_cb->dev,
"input invalid, %s mac%d vmid%d !\n",
mac_cb->dsaf_dev->ae_dev.name,
mac_cb->mac_id, vmid);
return -EINVAL;
}
} else if (mac_cb->dsaf_dev->dsaf_mode < DSAF_MODE_MAX) {
if (mac_cb->mac_id >= DSAF_MAX_PORT_NUM) {
dev_err(mac_cb->dev,
"input invalid, %s mac%d vmid%d!\n",
mac_cb->dsaf_dev->ae_dev.name,
mac_cb->mac_id, vmid);
return -EINVAL;
}
} else {
dev_err(mac_cb->dev, "dsaf mode invalid, %s mac%d!\n",
mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id);
return -EINVAL;
}
if (vmid >= mac_cb->dsaf_dev->rcb_common[0]->max_vfn) {
dev_err(mac_cb->dev, "input invalid, %s mac%d vmid%d !\n",
mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id, vmid);
return -EINVAL;
}
q_num_per_vf = mac_cb->dsaf_dev->rcb_common[0]->max_q_per_vf;
vf_num_per_port = mac_cb->dsaf_dev->rcb_common[0]->max_vfn;
vm_queue_id = vmid * q_num_per_vf +
vf_num_per_port * q_num_per_vf * mac_cb->mac_id;
switch (mac_cb->dsaf_dev->dsaf_mode) {
case DSAF_MODE_ENABLE_FIX:
tmp_port = 0;
break;
case DSAF_MODE_DISABLE_FIX:
tmp_port = 0;
break;
case DSAF_MODE_ENABLE_0VM:
case DSAF_MODE_ENABLE_8VM:
case DSAF_MODE_ENABLE_16VM:
case DSAF_MODE_ENABLE_32VM:
case DSAF_MODE_ENABLE_128VM:
case DSAF_MODE_DISABLE_2PORT_8VM:
case DSAF_MODE_DISABLE_2PORT_16VM:
case DSAF_MODE_DISABLE_2PORT_64VM:
case DSAF_MODE_DISABLE_6PORT_0VM:
case DSAF_MODE_DISABLE_6PORT_2VM:
case DSAF_MODE_DISABLE_6PORT_4VM:
case DSAF_MODE_DISABLE_6PORT_16VM:
tmp_port = vm_queue_id;
break;
default:
dev_err(mac_cb->dev, "dsaf mode invalid, %s mac%d!\n",
mac_cb->dsaf_dev->ae_dev.name, mac_cb->mac_id);
return -EINVAL;
}
tmp_port += DSAF_BASE_INNER_PORT_NUM;
*port_num = tmp_port;
return 0;
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/netdevice.h`, `linux/of.h`.
- Detected declarations: `function hns_get_enet_interface`, `function hns_mac_link_anti_shake`, `function hns_mac_get_link_status`, `function hns_mac_get_port_info`, `function hns_mac_need_adjust_link`, `function hns_mac_adjust_link`, `function hns_mac_get_inner_port_num`, `function hns_mac_change_vf_addr`, `function hns_mac_add_uc_addr`, `function hns_mac_rm_uc_addr`.
- 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.