drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c- Extension
.c- Size
- 8520 bytes
- Lines
- 332
- 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.
- 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.h../libwx/wx_type.h../libwx/wx_hw.h../libwx/wx_lib.h../libwx/wx_mbx.h../libwx/wx_vf.h../libwx/wx_vf_common.h../libwx/wx_ethtool.htxgbevf_type.h
Detected Declarations
function txgbevf_set_num_queuesfunction txgbevf_init_type_codefunction txgbevf_sw_initfunction txgbevf_probefunction txgbevf_remove
Annotated Snippet
static const struct net_device_ops txgbevf_netdev_ops = {
.ndo_open = wxvf_open,
.ndo_stop = wxvf_close,
.ndo_start_xmit = wx_xmit_frame,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = wx_set_mac_vf,
};
static void txgbevf_set_num_queues(struct wx *wx)
{
u32 def_q = 0, num_tcs = 0;
u16 rss, queue;
int ret = 0;
/* Start with base case */
wx->num_rx_queues = 1;
wx->num_tx_queues = 1;
spin_lock_bh(&wx->mbx.mbx_lock);
/* fetch queue configuration from the PF */
ret = wx_get_queues_vf(wx, &num_tcs, &def_q);
spin_unlock_bh(&wx->mbx.mbx_lock);
if (ret)
return;
/* we need as many queues as traffic classes */
if (num_tcs > 1) {
wx->num_rx_queues = num_tcs;
} else {
rss = min_t(u16, num_online_cpus(), TXGBEVF_MAX_RSS_NUM);
queue = min_t(u16, wx->mac.max_rx_queues, wx->mac.max_tx_queues);
rss = min_t(u16, queue, rss);
if (wx->vfinfo->vf_api >= wx_mbox_api_13) {
wx->num_rx_queues = rss;
wx->num_tx_queues = rss;
}
}
}
static void txgbevf_init_type_code(struct wx *wx)
{
switch (wx->device_id) {
case TXGBEVF_DEV_ID_SP1000:
case TXGBEVF_DEV_ID_WX1820:
wx->mac.type = wx_mac_sp;
break;
case TXGBEVF_DEV_ID_AML500F:
case TXGBEVF_DEV_ID_AML510F:
case TXGBEVF_DEV_ID_AML5024:
case TXGBEVF_DEV_ID_AML5124:
case TXGBEVF_DEV_ID_AML503F:
case TXGBEVF_DEV_ID_AML513F:
wx->mac.type = wx_mac_aml;
break;
default:
wx->mac.type = wx_mac_unknown;
break;
}
}
static int txgbevf_sw_init(struct wx *wx)
{
struct net_device *netdev = wx->netdev;
struct pci_dev *pdev = wx->pdev;
int err;
/* Initialize pcie info and common capability flags */
err = wx_sw_init(wx);
if (err < 0)
goto err_wx_sw_init;
/* Initialize the mailbox */
err = wx_init_mbx_params_vf(wx);
if (err)
goto err_init_mbx_params;
/* max q_vectors */
wx->mac.max_msix_vectors = TXGBEVF_MAX_MSIX_VECTORS;
/* Initialize the device type */
txgbevf_init_type_code(wx);
/* lock to protect mailbox accesses */
spin_lock_init(&wx->mbx.mbx_lock);
err = wx_reset_hw_vf(wx);
if (err) {
wx_err(wx, "PF still in reset state. Is the PF interface up?\n");
goto err_reset_hw;
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/string.h`, `linux/etherdevice.h`, `../libwx/wx_type.h`, `../libwx/wx_hw.h`.
- Detected declarations: `function txgbevf_set_num_queues`, `function txgbevf_init_type_code`, `function txgbevf_sw_init`, `function txgbevf_probe`, `function txgbevf_remove`.
- 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.