drivers/net/ethernet/tehuti/tn40.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/tehuti/tn40.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/tehuti/tn40.c- Extension
.c- Size
- 53254 bytes
- Lines
- 1858
- 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/bitfield.hlinux/ethtool.hlinux/firmware.hlinux/if_vlan.hlinux/iopoll.hlinux/netdevice.hlinux/pci.hlinux/phylink.hlinux/vmalloc.hnet/netdev_queues.hnet/page_pool/helpers.htn40.h
Detected Declarations
struct tn40_mapping_infofunction tn40_enable_interruptsfunction tn40_disable_interruptsfunction tn40_fifo_allocfunction tn40_fifo_freefunction tn40_rxdb_freefunction tn40_rxdb_alloc_elemfunction tn40_rxdb_availablefunction tn40_rxdb_free_elemfunction tn40_create_rx_ringfunction tn40_rx_free_buffersfunction tn40_destroy_rx_ringfunction tn40_set_rx_descfunction themfunction tn40_recycle_rx_bufferfunction tn40_rx_receivefunction tn40_do_tx_db_ptr_nextfunction tn40_tx_db_inc_rptrfunction tn40_tx_db_inc_wptrfunction tn40_tx_db_initfunction tn40_tx_db_closefunction tn40_pbl_setfunction tn40_txdb_setfunction tn40_tx_map_skbfunction tn40_create_tx_ringfunction tn40_tx_spacefunction tn40_start_xmitfunction tn40_tx_cleanupfunction netif_carrier_okfunction tn40_tx_free_skbsfunction tn40_destroy_tx_ringfunction tn40_tx_push_descfunction tn40_tx_push_desc_safefunction tn40_set_link_speedfunction tn40_link_changedfunction tn40_isr_extrafunction tn40_isr_napifunction tn40_pollfunction tn40_fw_loadfunction tn40_restore_macfunction tn40_hw_startfunction tn40_hw_resetfunction tn40_sw_resetfunction tn40_startfunction tn40_stopfunction tn40_closefunction tn40_openfunction __tn40_vlan_rx_vid
Annotated Snippet
static const struct net_device_ops tn40_netdev_ops = {
.ndo_open = tn40_open,
.ndo_stop = tn40_close,
.ndo_start_xmit = tn40_start_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = tn40_setmulti,
.ndo_get_stats64 = tn40_get_stats,
.ndo_set_mac_address = tn40_set_mac,
.ndo_vlan_rx_add_vid = tn40_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = tn40_vlan_rx_kill_vid,
};
static int tn40_ethtool_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *cmd)
{
struct tn40_priv *priv = netdev_priv(ndev);
return phylink_ethtool_ksettings_get(priv->phylink, cmd);
}
static const struct ethtool_ops tn40_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_link_ksettings = tn40_ethtool_get_link_ksettings,
};
static void tn40_get_queue_stats_rx(struct net_device *ndev, int idx,
struct netdev_queue_stats_rx *stats)
{
struct tn40_priv *priv = netdev_priv(ndev);
unsigned int start;
do {
start = u64_stats_fetch_begin(&priv->syncp);
stats->packets = priv->stats.rx_packets;
stats->bytes = priv->stats.rx_bytes;
stats->alloc_fail = priv->alloc_fail;
} while (u64_stats_fetch_retry(&priv->syncp, start));
}
static void tn40_get_queue_stats_tx(struct net_device *ndev, int idx,
struct netdev_queue_stats_tx *stats)
{
struct tn40_priv *priv = netdev_priv(ndev);
unsigned int start;
do {
start = u64_stats_fetch_begin(&priv->syncp);
stats->packets = priv->stats.tx_packets;
stats->bytes = priv->stats.tx_bytes;
} while (u64_stats_fetch_retry(&priv->syncp, start));
}
static void tn40_get_base_stats(struct net_device *ndev,
struct netdev_queue_stats_rx *rx,
struct netdev_queue_stats_tx *tx)
{
rx->packets = 0;
rx->bytes = 0;
rx->alloc_fail = 0;
tx->packets = 0;
tx->bytes = 0;
}
static const struct netdev_stat_ops tn40_stat_ops = {
.get_queue_stats_rx = tn40_get_queue_stats_rx,
.get_queue_stats_tx = tn40_get_queue_stats_tx,
.get_base_stats = tn40_get_base_stats,
};
static int tn40_priv_init(struct tn40_priv *priv)
{
int ret;
tn40_set_link_speed(priv, 0);
/* Set GPIO[9:0] to output 0 */
tn40_write_reg(priv, 0x51E0, 0x30010006); /* GPIO_OE_ WR CMD */
tn40_write_reg(priv, 0x51F0, 0x0); /* GPIO_OE_ DATA */
tn40_write_reg(priv, TN40_REG_MDIO_CMD_STAT, 0x3ec8);
/* we use tx descriptors to load a firmware. */
ret = tn40_create_tx_ring(priv);
if (ret)
return ret;
ret = tn40_fw_load(priv);
tn40_destroy_tx_ring(priv);
return ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/ethtool.h`, `linux/firmware.h`, `linux/if_vlan.h`, `linux/iopoll.h`, `linux/netdevice.h`, `linux/pci.h`, `linux/phylink.h`.
- Detected declarations: `struct tn40_mapping_info`, `function tn40_enable_interrupts`, `function tn40_disable_interrupts`, `function tn40_fifo_alloc`, `function tn40_fifo_free`, `function tn40_rxdb_free`, `function tn40_rxdb_alloc_elem`, `function tn40_rxdb_available`, `function tn40_rxdb_free_elem`, `function tn40_create_rx_ring`.
- 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.