drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c- Extension
.c- Size
- 23292 bytes
- Lines
- 926
- 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.
- 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.hnet/ip.hlinux/phy.hlinux/if_vlan.h../libwx/wx_type.h../libwx/wx_hw.h../libwx/wx_lib.h../libwx/wx_ptp.h../libwx/wx_mbx.h../libwx/wx_sriov.hngbe_type.hngbe_mdio.hngbe_hw.hngbe_ethtool.h
Detected Declarations
function ngbe_init_type_codefunction ngbe_sw_initfunction ngbe_service_taskfunction ngbe_init_servicefunction ngbe_irq_enablefunction ngbe_intrfunction __ngbe_msix_miscfunction ngbe_msix_miscfunction ngbe_misc_and_queuefunction ngbe_request_msix_irqsfunction ngbe_request_irqfunction ngbe_disable_devicefunction ngbe_resetfunction ngbe_downfunction ngbe_upfunction systemfunction ngbe_closefunction ngbe_dev_shutdownfunction ngbe_shutdownfunction ngbe_setup_tcfunction ngbe_probefunction ngbe_removefunction ngbe_suspendfunction ngbe_resume
Annotated Snippet
static const struct net_device_ops ngbe_netdev_ops = {
.ndo_open = ngbe_open,
.ndo_stop = ngbe_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,
};
/**
* ngbe_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in ngbe_pci_tbl
*
* Returns 0 on success, negative on failure
*
* ngbe_probe initializes an wx identified by a pci_dev structure.
* The OS initialization, configuring of the wx private structure,
* and a hardware reset occur.
**/
static int ngbe_probe(struct pci_dev *pdev,
const struct pci_device_id __always_unused *ent)
{
struct net_device *netdev;
u32 e2rom_cksum_cap = 0;
struct wx *wx = NULL;
static int func_nums;
u16 e2rom_ver = 0;
u32 etrack_id = 0;
u32 saved_ver = 0;
int err;
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),
ngbe_driver_name);
if (err) {
dev_err(&pdev->dev,
"pci_request_selected_regions failed %d\n", err);
goto err_pci_disable_dev;
}
pci_set_master(pdev);
netdev = devm_alloc_etherdev_mqs(&pdev->dev,
sizeof(struct wx),
NGBE_MAX_TX_QUEUES,
NGBE_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 = BIT(3) - 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 emerald supports up to 8 VFs per pf, but physical
* function also need one pool for basic networking.
*/
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/string.h`, `linux/etherdevice.h`, `net/ip.h`, `linux/phy.h`.
- Detected declarations: `function ngbe_init_type_code`, `function ngbe_sw_init`, `function ngbe_service_task`, `function ngbe_init_service`, `function ngbe_irq_enable`, `function ngbe_intr`, `function __ngbe_msix_misc`, `function ngbe_msix_misc`, `function ngbe_misc_and_queue`, `function ngbe_request_msix_irqs`.
- 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.