drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/ngbe/ngbe_mdio.c- Extension
.c- Size
- 4991 bytes
- Lines
- 204
- 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/ethtool.hlinux/iopoll.hlinux/pci.hlinux/phy.h../libwx/wx_type.h../libwx/wx_ptp.h../libwx/wx_hw.h../libwx/wx_sriov.hngbe_type.hngbe_mdio.h
Detected Declarations
function ngbe_phy_read_reg_internalfunction ngbe_phy_write_reg_internalfunction ngbe_phy_read_reg_c22function ngbe_phy_write_reg_c22function ngbe_mac_configfunction ngbe_mac_link_upfunction ngbe_phylink_initfunction ngbe_mdio_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2019 - 2022 Beijing WangXun Technology Co., Ltd. */
#include <linux/ethtool.h>
#include <linux/iopoll.h>
#include <linux/pci.h>
#include <linux/phy.h>
#include "../libwx/wx_type.h"
#include "../libwx/wx_ptp.h"
#include "../libwx/wx_hw.h"
#include "../libwx/wx_sriov.h"
#include "ngbe_type.h"
#include "ngbe_mdio.h"
static int ngbe_phy_read_reg_internal(struct mii_bus *bus, int phy_addr, int regnum)
{
struct wx *wx = bus->priv;
if (phy_addr != 0)
return 0xffff;
return (u16)rd32(wx, NGBE_PHY_CONFIG(regnum));
}
static int ngbe_phy_write_reg_internal(struct mii_bus *bus, int phy_addr, int regnum, u16 value)
{
struct wx *wx = bus->priv;
if (phy_addr == 0)
wr32(wx, NGBE_PHY_CONFIG(regnum), value);
return 0;
}
static int ngbe_phy_read_reg_c22(struct mii_bus *bus, int phy_addr, int regnum)
{
struct wx *wx = bus->priv;
u16 phy_data;
if (wx->mac_type == em_mac_type_mdi)
phy_data = ngbe_phy_read_reg_internal(bus, phy_addr, regnum);
else
phy_data = wx_phy_read_reg_mdi_c22(bus, phy_addr, regnum);
return phy_data;
}
static int ngbe_phy_write_reg_c22(struct mii_bus *bus, int phy_addr,
int regnum, u16 value)
{
struct wx *wx = bus->priv;
int ret;
if (wx->mac_type == em_mac_type_mdi)
ret = ngbe_phy_write_reg_internal(bus, phy_addr, regnum, value);
else
ret = wx_phy_write_reg_mdi_c22(bus, phy_addr, regnum, value);
return ret;
}
static void ngbe_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
}
static void ngbe_mac_link_down(struct phylink_config *config,
unsigned int mode, phy_interface_t interface)
{
struct wx *wx = phylink_to_wx(config);
wx->speed = SPEED_UNKNOWN;
if (test_bit(WX_STATE_PTP_RUNNING, wx->state))
wx_ptp_reset_cyclecounter(wx);
/* ping all the active vfs to let them know we are going down */
wx_ping_all_vfs_with_link_status(wx, false);
}
static void ngbe_mac_link_up(struct phylink_config *config,
struct phy_device *phy,
unsigned int mode, phy_interface_t interface,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
struct wx *wx = phylink_to_wx(config);
u32 lan_speed, reg;
wx_fc_enable(wx, tx_pause, rx_pause);
switch (speed) {
case SPEED_10:
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/iopoll.h`, `linux/pci.h`, `linux/phy.h`, `../libwx/wx_type.h`, `../libwx/wx_ptp.h`, `../libwx/wx_hw.h`, `../libwx/wx_sriov.h`.
- Detected declarations: `function ngbe_phy_read_reg_internal`, `function ngbe_phy_write_reg_internal`, `function ngbe_phy_read_reg_c22`, `function ngbe_phy_write_reg_c22`, `function ngbe_mac_config`, `function ngbe_mac_link_up`, `function ngbe_phylink_init`, `function ngbe_mdio_init`.
- 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.