drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c- Extension
.c- Size
- 25751 bytes
- Lines
- 739
- 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/delay.hlinux/of_mdio.hhns_dsaf_main.hhns_dsaf_mac.hhns_dsaf_gmac.h
Detected Declarations
function hns_gmac_enablefunction hns_gmac_disablefunction hns_gmac_get_enfunction hns_gmac_freefunction hns_gmac_set_tx_auto_pause_framesfunction hns_gmac_get_tx_auto_pause_framesfunction hns_gmac_config_max_frame_lengthfunction hns_gmac_config_pad_and_crcfunction hns_gmac_config_an_modefunction hns_gmac_tx_loop_pkt_disfunction hns_gmac_get_duplex_typefunction hns_gmac_get_port_modefunction hns_gmac_port_mode_getfunction hns_gmac_pause_frm_cfgfunction hns_gmac_get_pausefrm_cfgfunction hns_gmac_need_adjust_linkfunction hns_gmac_adjust_linkfunction hns_gmac_set_uc_matchfunction hns_gmac_set_promiscfunction hns_gmac_wait_fifo_cleanfunction hns_gmac_initfunction hns_gmac_update_statsfunction hns_gmac_set_mac_addrfunction hns_gmac_config_loopbackfunction hns_gmac_get_infofunction hns_gmac_autoneg_statfunction hns_gmac_get_link_statusfunction hns_gmac_get_regsfunction hns_gmac_get_statsfunction hns_gmac_get_stringsfunction hns_gmac_get_sset_countfunction hns_gmac_get_regs_count
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2014-2015 Hisilicon Limited.
*/
#include <linux/delay.h>
#include <linux/of_mdio.h>
#include "hns_dsaf_main.h"
#include "hns_dsaf_mac.h"
#include "hns_dsaf_gmac.h"
static const struct mac_stats_string g_gmac_stats_string[] = {
{"gmac_rx_octets_total_ok", MAC_STATS_FIELD_OFF(rx_good_bytes)},
{"gmac_rx_octets_bad", MAC_STATS_FIELD_OFF(rx_bad_bytes)},
{"gmac_rx_uc_pkts", MAC_STATS_FIELD_OFF(rx_uc_pkts)},
{"gmac_rx_mc_pkts", MAC_STATS_FIELD_OFF(rx_mc_pkts)},
{"gmac_rx_bc_pkts", MAC_STATS_FIELD_OFF(rx_bc_pkts)},
{"gmac_rx_pkts_64octets", MAC_STATS_FIELD_OFF(rx_64bytes)},
{"gmac_rx_pkts_65to127", MAC_STATS_FIELD_OFF(rx_65to127)},
{"gmac_rx_pkts_128to255", MAC_STATS_FIELD_OFF(rx_128to255)},
{"gmac_rx_pkts_256to511", MAC_STATS_FIELD_OFF(rx_256to511)},
{"gmac_rx_pkts_512to1023", MAC_STATS_FIELD_OFF(rx_512to1023)},
{"gmac_rx_pkts_1024to1518", MAC_STATS_FIELD_OFF(rx_1024to1518)},
{"gmac_rx_pkts_1519tomax", MAC_STATS_FIELD_OFF(rx_1519tomax)},
{"gmac_rx_fcs_errors", MAC_STATS_FIELD_OFF(rx_fcs_err)},
{"gmac_rx_tagged", MAC_STATS_FIELD_OFF(rx_vlan_pkts)},
{"gmac_rx_data_err", MAC_STATS_FIELD_OFF(rx_data_err)},
{"gmac_rx_align_errors", MAC_STATS_FIELD_OFF(rx_align_err)},
{"gmac_rx_long_errors", MAC_STATS_FIELD_OFF(rx_oversize)},
{"gmac_rx_jabber_errors", MAC_STATS_FIELD_OFF(rx_jabber_err)},
{"gmac_rx_pause_maccontrol", MAC_STATS_FIELD_OFF(rx_pfc_tc0)},
{"gmac_rx_unknown_maccontrol", MAC_STATS_FIELD_OFF(rx_unknown_ctrl)},
{"gmac_rx_very_long_err", MAC_STATS_FIELD_OFF(rx_long_err)},
{"gmac_rx_runt_err", MAC_STATS_FIELD_OFF(rx_minto64)},
{"gmac_rx_short_err", MAC_STATS_FIELD_OFF(rx_under_min)},
{"gmac_rx_filt_pkt", MAC_STATS_FIELD_OFF(rx_filter_pkts)},
{"gmac_rx_octets_total_filt", MAC_STATS_FIELD_OFF(rx_filter_bytes)},
{"gmac_rx_overrun_cnt", MAC_STATS_FIELD_OFF(rx_fifo_overrun_err)},
{"gmac_rx_length_err", MAC_STATS_FIELD_OFF(rx_len_err)},
{"gmac_rx_fail_comma", MAC_STATS_FIELD_OFF(rx_comma_err)},
{"gmac_tx_octets_ok", MAC_STATS_FIELD_OFF(tx_good_bytes)},
{"gmac_tx_octets_bad", MAC_STATS_FIELD_OFF(tx_bad_bytes)},
{"gmac_tx_uc_pkts", MAC_STATS_FIELD_OFF(tx_uc_pkts)},
{"gmac_tx_mc_pkts", MAC_STATS_FIELD_OFF(tx_mc_pkts)},
{"gmac_tx_bc_pkts", MAC_STATS_FIELD_OFF(tx_bc_pkts)},
{"gmac_tx_pkts_64octets", MAC_STATS_FIELD_OFF(tx_64bytes)},
{"gmac_tx_pkts_65to127", MAC_STATS_FIELD_OFF(tx_65to127)},
{"gmac_tx_pkts_128to255", MAC_STATS_FIELD_OFF(tx_128to255)},
{"gmac_tx_pkts_256to511", MAC_STATS_FIELD_OFF(tx_256to511)},
{"gmac_tx_pkts_512to1023", MAC_STATS_FIELD_OFF(tx_512to1023)},
{"gmac_tx_pkts_1024to1518", MAC_STATS_FIELD_OFF(tx_1024to1518)},
{"gmac_tx_pkts_1519tomax", MAC_STATS_FIELD_OFF(tx_1519tomax)},
{"gmac_tx_excessive_length_drop", MAC_STATS_FIELD_OFF(tx_jabber_err)},
{"gmac_tx_underrun", MAC_STATS_FIELD_OFF(tx_underrun_err)},
{"gmac_tx_tagged", MAC_STATS_FIELD_OFF(tx_vlan)},
{"gmac_tx_crc_error", MAC_STATS_FIELD_OFF(tx_crc_err)},
{"gmac_tx_pause_frames", MAC_STATS_FIELD_OFF(tx_pfc_tc0)}
};
static void hns_gmac_enable(void *mac_drv, enum mac_commom_mode mode)
{
struct mac_driver *drv = (struct mac_driver *)mac_drv;
/*enable GE rX/tX */
if (mode == MAC_COMM_MODE_TX || mode == MAC_COMM_MODE_RX_AND_TX)
dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_TX_EN_B, 1);
if (mode == MAC_COMM_MODE_RX || mode == MAC_COMM_MODE_RX_AND_TX) {
/* enable rx pcs */
dsaf_set_dev_bit(drv, GMAC_PCS_RX_EN_REG, 0, 0);
dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_RX_EN_B, 1);
}
}
static void hns_gmac_disable(void *mac_drv, enum mac_commom_mode mode)
{
struct mac_driver *drv = (struct mac_driver *)mac_drv;
/*disable GE rX/tX */
if (mode == MAC_COMM_MODE_TX || mode == MAC_COMM_MODE_RX_AND_TX)
dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_TX_EN_B, 0);
if (mode == MAC_COMM_MODE_RX || mode == MAC_COMM_MODE_RX_AND_TX) {
/* disable rx pcs */
dsaf_set_dev_bit(drv, GMAC_PCS_RX_EN_REG, 0, 1);
dsaf_set_dev_bit(drv, GMAC_PORT_EN_REG, GMAC_PORT_RX_EN_B, 0);
}
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/of_mdio.h`, `hns_dsaf_main.h`, `hns_dsaf_mac.h`, `hns_dsaf_gmac.h`.
- Detected declarations: `function hns_gmac_enable`, `function hns_gmac_disable`, `function hns_gmac_get_en`, `function hns_gmac_free`, `function hns_gmac_set_tx_auto_pause_frames`, `function hns_gmac_get_tx_auto_pause_frames`, `function hns_gmac_config_max_frame_length`, `function hns_gmac_config_pad_and_crc`, `function hns_gmac_config_an_mode`, `function hns_gmac_tx_loop_pkt_dis`.
- 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.