drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c- Extension
.c- Size
- 32510 bytes
- Lines
- 1275
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/etherdevice.hlinux/interrupt.hlinux/module.hlinux/platform_device.hhns_enet.h
Detected Declarations
function Copyrightfunction hns_get_mdix_modefunction hns_nic_get_link_ksettingsfunction hns_nic_set_link_ksettingsfunction hns_nic_config_phy_loopbackfunction __lb_setupfunction __lb_upfunction __lb_other_processfunction __lb_clean_ringsfunction __lb_run_testfunction __lb_downfunction hns_nic_self_testfunction hns_nic_get_drvinfofunction hns_get_ringparamfunction hns_get_pauseparamfunction hns_set_pauseparamfunction hns_get_coalescefunction hns_set_coalescefunction hns_get_channelsfunction hns_get_ethtool_statsfunction hns_get_stringsfunction hns_get_sset_countfunction hns_phy_led_setfunction hns_set_phys_idfunction hns_get_regsfunction hns_get_regs_lenfunction hns_nic_nway_resetfunction hns_get_rss_key_sizefunction hns_get_rss_indir_sizefunction hns_get_rssfunction hns_set_rssfunction hns_get_rx_ring_countfunction hns_ethtool_set_ops
Annotated Snippet
if (!ret && h->dev->ops->set_loopback) {
if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)
ret = h->dev->ops->set_loopback(h,
MAC_INTERNALLOOP_MAC, 0x0);
if (!ret)
ret = h->dev->ops->set_loopback(h,
MAC_INTERNALLOOP_SERDES, 0x0);
}
break;
default:
ret = -EINVAL;
break;
}
if (!ret) {
if (loop == MAC_LOOP_NONE)
h->dev->ops->set_promisc_mode(
h, ndev->flags & IFF_PROMISC);
else
h->dev->ops->set_promisc_mode(h, 1);
}
return ret;
}
static int __lb_up(struct net_device *ndev,
enum hnae_loop loop_mode)
{
#define NIC_LB_TEST_WAIT_PHY_LINK_TIME 300
struct hns_nic_priv *priv = netdev_priv(ndev);
struct hnae_handle *h = priv->ae_handle;
int speed, duplex;
int ret;
hns_nic_net_reset(ndev);
ret = __lb_setup(ndev, loop_mode);
if (ret)
return ret;
msleep(200);
ret = h->dev->ops->start ? h->dev->ops->start(h) : 0;
if (ret)
return ret;
/* link adjust duplex*/
if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)
speed = 1000;
else
speed = 10000;
duplex = 1;
h->dev->ops->adjust_link(h, speed, duplex);
/* wait adjust link done and phy ready */
msleep(NIC_LB_TEST_WAIT_PHY_LINK_TIME);
return 0;
}
static void __lb_other_process(struct hns_nic_ring_data *ring_data,
struct sk_buff *skb)
{
struct net_device *ndev;
struct hns_nic_priv *priv;
struct hnae_ring *ring;
struct netdev_queue *dev_queue;
struct sk_buff *new_skb;
unsigned int frame_size;
int check_ok;
u32 i;
char buff[33]; /* 32B data and the last character '\0' */
if (!ring_data) { /* Just for doing create frame*/
ndev = skb->dev;
priv = netdev_priv(ndev);
frame_size = skb->len;
memset(skb->data, 0xFF, frame_size);
if ((!AE_IS_VER1(priv->enet_ver)) &&
(priv->ae_handle->port_type == HNAE_PORT_SERVICE)) {
memcpy(skb->data, ndev->dev_addr, 6);
skb->data[5] += 0x1f;
}
frame_size &= ~1ul;
memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
memset(&skb->data[frame_size / 2 + 10], 0xBE,
frame_size / 2 - 11);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/interrupt.h`, `linux/module.h`, `linux/platform_device.h`, `hns_enet.h`.
- Detected declarations: `function Copyright`, `function hns_get_mdix_mode`, `function hns_nic_get_link_ksettings`, `function hns_nic_set_link_ksettings`, `function hns_nic_config_phy_loopback`, `function __lb_setup`, `function __lb_up`, `function __lb_other_process`, `function __lb_clean_rings`, `function __lb_run_test`.
- 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.