drivers/net/ethernet/tehuti/tn40_phy.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/tehuti/tn40_phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/tehuti/tn40_phy.c- Extension
.c- Size
- 1907 bytes
- Lines
- 77
- 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/netdevice.hlinux/pci.hlinux/phylink.htn40.h
Detected Declarations
function tn40_link_upfunction tn40_link_downfunction tn40_mac_configfunction tn40_phy_registerfunction tn40_phy_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/* Copyright (c) Tehuti Networks Ltd. */
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <linux/phylink.h>
#include "tn40.h"
static struct tn40_priv *tn40_config_to_priv(struct phylink_config *config)
{
return container_of(config, struct tn40_priv, phylink_config);
}
static void tn40_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 tn40_priv *priv = tn40_config_to_priv(config);
tn40_set_link_speed(priv, speed);
netif_wake_queue(priv->ndev);
}
static void tn40_link_down(struct phylink_config *config, unsigned int mode,
phy_interface_t interface)
{
struct tn40_priv *priv = tn40_config_to_priv(config);
netif_stop_queue(priv->ndev);
tn40_set_link_speed(priv, 0);
}
static void tn40_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
}
static const struct phylink_mac_ops tn40_mac_ops = {
.mac_config = tn40_mac_config,
.mac_link_up = tn40_link_up,
.mac_link_down = tn40_link_down,
};
int tn40_phy_register(struct tn40_priv *priv)
{
struct phylink_config *config;
struct phy_device *phydev;
struct phylink *phylink;
phydev = phy_find_first(priv->mdio);
if (!phydev) {
dev_err(&priv->pdev->dev, "PHY isn't found\n");
return -ENODEV;
}
config = &priv->phylink_config;
config->dev = &priv->ndev->dev;
config->type = PHYLINK_NETDEV;
config->mac_capabilities = MAC_10000FD;
__set_bit(PHY_INTERFACE_MODE_XAUI, config->supported_interfaces);
phylink = phylink_create(config, NULL, PHY_INTERFACE_MODE_XAUI,
&tn40_mac_ops);
if (IS_ERR(phylink))
return PTR_ERR(phylink);
priv->phydev = phydev;
priv->phylink = phylink;
return 0;
}
void tn40_phy_unregister(struct tn40_priv *priv)
{
phylink_destroy(priv->phylink);
}
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/pci.h`, `linux/phylink.h`, `tn40.h`.
- Detected declarations: `function tn40_link_up`, `function tn40_link_down`, `function tn40_mac_config`, `function tn40_phy_register`, `function tn40_phy_unregister`.
- 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.