drivers/net/ethernet/hisilicon/hns/hns_enet.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hns_enet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hns_enet.c- Extension
.c- Size
- 63406 bytes
- Lines
- 2451
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/cpumask.hlinux/etherdevice.hlinux/if_vlan.hlinux/interrupt.hlinux/io.hlinux/ip.hlinux/ipv6.hlinux/irq.hlinux/module.hlinux/phy.hlinux/platform_device.hlinux/skbuff.hhnae.hhns_enet.hhns_dsaf_mac.h
Detected Declarations
function Copyrightfunction fill_v2_descfunction fill_descfunction unfill_descfunction hns_nic_maybe_stop_txfunction hns_nic_maybe_stop_tsofunction hns_nic_maybe_stop_tx_v2function fill_tso_descfunction fill_desc_v2function hns_nic_net_xmit_hwfunction hns_nic_reuse_pagefunction get_v2rx_desc_bnumfunction get_rx_desc_bnumfunction hns_nic_rx_checksumfunction hns_nic_poll_rx_skbfunction hns_nic_alloc_rx_buffersfunction hns_nic_rx_up_profunction hns_desc_unusedfunction hns_coal_rx_bdnumfunction hns_update_rx_ratefunction smooth_algfunction hns_nic_adpt_coalescefunction time_afterfunction hns_nic_rx_poll_onefunction hns_nic_rx_fini_profunction hns_nic_rx_fini_pro_v2function hns_nic_reclaim_one_descfunction is_valid_clean_headfunction hns_nic_tx_poll_onefunction hns_nic_tx_fini_profunction hns_nic_tx_fini_pro_v2function hns_nic_tx_clr_all_bufsfunction hns_nic_common_pollfunction hns_irq_handlefunction hns_nic_adjust_linkfunction hns_nic_init_phyfunction hns_nic_ring_openfunction hns_nic_net_set_mac_addressfunction hns_nic_update_statsfunction hns_init_mac_addrfunction hns_nic_ring_closefunction hns_nic_init_affinity_maskfunction hns_nic_free_irqfunction hns_nic_init_irqfunction hns_nic_net_upfunction hns_nic_net_downfunction hns_nic_net_resetfunction hns_nic_net_reinit
Annotated Snippet
static const struct net_device_ops hns_nic_netdev_ops = {
.ndo_open = hns_nic_net_open,
.ndo_stop = hns_nic_net_stop,
.ndo_start_xmit = hns_nic_net_xmit,
.ndo_tx_timeout = hns_nic_net_timeout,
.ndo_set_mac_address = hns_nic_net_set_mac_address,
.ndo_change_mtu = hns_nic_change_mtu,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_set_features = hns_nic_set_features,
.ndo_fix_features = hns_nic_fix_features,
.ndo_get_stats64 = hns_nic_get_stats64,
.ndo_set_rx_mode = hns_nic_set_rx_mode,
.ndo_select_queue = hns_nic_select_queue,
};
static void hns_nic_update_link_status(struct net_device *netdev)
{
struct hns_nic_priv *priv = netdev_priv(netdev);
struct hnae_handle *h = priv->ae_handle;
if (h->phy_dev) {
if (h->phy_if != PHY_INTERFACE_MODE_XGMII)
return;
(void)genphy_read_status(h->phy_dev);
}
hns_nic_adjust_link(netdev);
}
/* for dumping key regs*/
static void hns_nic_dump(struct hns_nic_priv *priv)
{
struct hnae_handle *h = priv->ae_handle;
struct hnae_ae_ops *ops = h->dev->ops;
u32 *data, reg_num, i;
if (ops->get_regs_len && ops->get_regs) {
reg_num = ops->get_regs_len(priv->ae_handle);
reg_num = (reg_num + 3ul) & ~3ul;
data = kcalloc(reg_num, sizeof(u32), GFP_KERNEL);
if (data) {
ops->get_regs(priv->ae_handle, data);
for (i = 0; i < reg_num; i += 4)
pr_info("0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
i, data[i], data[i + 1],
data[i + 2], data[i + 3]);
kfree(data);
}
}
for (i = 0; i < h->q_num; i++) {
pr_info("tx_queue%d_next_to_clean:%d\n",
i, h->qs[i]->tx_ring.next_to_clean);
pr_info("tx_queue%d_next_to_use:%d\n",
i, h->qs[i]->tx_ring.next_to_use);
pr_info("rx_queue%d_next_to_clean:%d\n",
i, h->qs[i]->rx_ring.next_to_clean);
pr_info("rx_queue%d_next_to_use:%d\n",
i, h->qs[i]->rx_ring.next_to_use);
}
}
/* for resetting subtask */
static void hns_nic_reset_subtask(struct hns_nic_priv *priv)
{
enum hnae_port_type type = priv->ae_handle->port_type;
if (!test_bit(NIC_STATE2_RESET_REQUESTED, &priv->state))
return;
clear_bit(NIC_STATE2_RESET_REQUESTED, &priv->state);
/* If we're already down, removing or resetting, just bail */
if (test_bit(NIC_STATE_DOWN, &priv->state) ||
test_bit(NIC_STATE_REMOVING, &priv->state) ||
test_bit(NIC_STATE_RESETTING, &priv->state))
return;
hns_nic_dump(priv);
netdev_info(priv->netdev, "try to reset %s port!\n",
(type == HNAE_PORT_DEBUG ? "debug" : "service"));
rtnl_lock();
/* put off any impending NetWatchDogTimeout */
netif_trans_update(priv->netdev);
hns_nic_net_reinit(priv->netdev);
rtnl_unlock();
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/cpumask.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/interrupt.h`, `linux/io.h`, `linux/ip.h`, `linux/ipv6.h`.
- Detected declarations: `function Copyright`, `function fill_v2_desc`, `function fill_desc`, `function unfill_desc`, `function hns_nic_maybe_stop_tx`, `function hns_nic_maybe_stop_tso`, `function hns_nic_maybe_stop_tx_v2`, `function fill_tso_desc`, `function fill_desc_v2`, `function hns_nic_net_xmit_hw`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.