drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c- Extension
.c- Size
- 24485 bytes
- Lines
- 981
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/types.hlinux/module.hlinux/pci.hlinux/netdevice.hlinux/string.hlinux/etherdevice.hlinux/phylink.hnet/udp_tunnel.hnet/ip.hlinux/if_vlan.h../libwx/wx_type.h../libwx/wx_lib.h../libwx/wx_ptp.h../libwx/wx_hw.h../libwx/wx_mbx.h../libwx/wx_sriov.htxgbe_type.htxgbe_hw.htxgbe_phy.htxgbe_aml.htxgbe_irq.htxgbe_fdir.htxgbe_ethtool.h
Detected Declarations
function txgbe_check_minimum_linkfunction txgbe_enumerate_functionsfunction list_for_each_entryfunction txgbe_module_detection_subtaskfunction txgbe_link_config_subtaskfunction txgbe_service_taskfunction txgbe_init_servicefunction txgbe_up_completefunction txgbe_resetfunction txgbe_disable_devicefunction txgbe_downfunction txgbe_upfunction txgbe_init_type_codefunction txgbe_sw_initfunction txgbe_init_fdirfunction systemfunction txgbe_close_suspendfunction txgbe_closefunction txgbe_dev_shutdownfunction txgbe_shutdownfunction txgbe_setup_tcfunction txgbe_reinit_lockedfunction txgbe_do_resetfunction txgbe_udp_tunnel_syncfunction txgbe_probefunction txgbe_remove
Annotated Snippet
static const struct net_device_ops txgbe_netdev_ops = {
.ndo_open = txgbe_open,
.ndo_stop = txgbe_close,
.ndo_change_mtu = wx_change_mtu,
.ndo_start_xmit = wx_xmit_frame,
.ndo_set_rx_mode = wx_set_rx_mode,
.ndo_set_features = wx_set_features,
.ndo_fix_features = wx_fix_features,
.ndo_features_check = wx_features_check,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = wx_set_mac,
.ndo_get_stats64 = wx_get_stats64,
.ndo_vlan_rx_add_vid = wx_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = wx_vlan_rx_kill_vid,
.ndo_hwtstamp_set = wx_hwtstamp_set,
.ndo_hwtstamp_get = wx_hwtstamp_get,
};
/**
* txgbe_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in txgbe_pci_tbl
*
* Returns 0 on success, negative on failure
*
* txgbe_probe initializes an adapter identified by a pci_dev structure.
* The OS initialization, configuring of the wx private structure,
* and a hardware reset occur.
**/
static int txgbe_probe(struct pci_dev *pdev,
const struct pci_device_id __always_unused *ent)
{
struct net_device *netdev;
int err, expected_gts;
struct wx *wx = NULL;
struct txgbe *txgbe;
u16 eeprom_verh = 0, eeprom_verl = 0, offset = 0;
u16 eeprom_cfg_blkh = 0, eeprom_cfg_blkl = 0;
u16 build = 0, major = 0, patch = 0;
u32 etrack_id = 0;
err = pci_enable_device_mem(pdev);
if (err)
return err;
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (err) {
dev_err(&pdev->dev,
"No usable DMA configuration, aborting\n");
goto err_pci_disable_dev;
}
err = pci_request_selected_regions(pdev,
pci_select_bars(pdev, IORESOURCE_MEM),
txgbe_driver_name);
if (err) {
dev_err(&pdev->dev,
"pci_request_selected_regions failed 0x%x\n", err);
goto err_pci_disable_dev;
}
pci_set_master(pdev);
netdev = devm_alloc_etherdev_mqs(&pdev->dev,
sizeof(struct wx),
TXGBE_MAX_TX_QUEUES,
TXGBE_MAX_RX_QUEUES);
if (!netdev) {
err = -ENOMEM;
goto err_pci_release_regions;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
wx = netdev_priv(netdev);
wx->netdev = netdev;
wx->pdev = pdev;
wx->msg_enable = (1 << DEFAULT_DEBUG_LEVEL_SHIFT) - 1;
wx->hw_addr = devm_ioremap(&pdev->dev,
pci_resource_start(pdev, 0),
pci_resource_len(pdev, 0));
if (!wx->hw_addr) {
err = -EIO;
goto err_pci_release_regions;
}
/* The sapphire supports up to 63 VFs per pf, but physical
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/string.h`, `linux/etherdevice.h`, `linux/phylink.h`, `net/udp_tunnel.h`.
- Detected declarations: `function txgbe_check_minimum_link`, `function txgbe_enumerate_functions`, `function list_for_each_entry`, `function txgbe_module_detection_subtask`, `function txgbe_link_config_subtask`, `function txgbe_service_task`, `function txgbe_init_service`, `function txgbe_up_complete`, `function txgbe_reset`, `function txgbe_disable_device`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.