drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c- Extension
.c- Size
- 95342 bytes
- Lines
- 3446
- 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/module.hlinux/moduleparam.hlinux/init.hlinux/pci.hlinux/dma-mapping.hlinux/netdevice.hlinux/etherdevice.hlinux/debugfs.hlinux/ethtool.hlinux/mdio.ht4vf_common.ht4vf_defs.h../cxgb4/t4_regs.h../cxgb4/t4_msg.h../cxgb4/t4_pci_id_tbl.h
Detected Declarations
struct queue_port_statsstruct cxgb4vf_debugfs_entryfunction t4vf_os_link_changedfunction t4vf_os_portmod_changedfunction cxgb4vf_set_addr_hashfunction cxgb4vf_change_macfunction list_for_each_entryfunction link_startfunction name_msix_vecsfunction request_msix_queue_irqsfunction free_msix_queue_irqsfunction qenablefunction enable_rxfunction quiesce_rxfunction fwevtq_handlerfunction setup_sge_queuesfunction Scalingfunction for_each_portfunction adapter_upfunction adapter_downfunction cxgb4vf_openfunction cxgb4vf_stopfunction cxgb4vf_mac_syncfunction cxgb4vf_mac_unsyncfunction set_rxmodefunction cxgb4vf_set_rxmodefunction closest_timerfunction closest_thresfunction qtimer_valfunction set_rxq_intr_paramsfunction mk_adap_versfunction cxgb4vf_do_ioctlfunction cxgb4vf_change_mtufunction cxgb4vf_fix_featuresfunction cxgb4vf_set_featuresfunction cxgb4vf_set_mac_addrfunction cxgb4vf_poll_controllerfunction from_fw_port_mod_typefunction fw_caps_to_lmmfunction cxgb4vf_get_link_ksettingsfunction fwcap_to_eth_fecfunction cc_to_eth_fecfunction cxgb4vf_get_fecparamfunction cxgb4vf_get_drvinfofunction cxgb4vf_get_msglevelfunction cxgb4vf_set_msglevelfunction cxgb4vf_get_ringparamfunction cxgb4vf_set_ringparam
Annotated Snippet
const struct file_operations *fops;
};
static struct cxgb4vf_debugfs_entry debugfs_files[] = {
{ "mboxlog", 0444, &mboxlog_fops },
{ "sge_qinfo", 0444, &sge_qinfo_fops },
{ "sge_qstats", 0444, &sge_qstats_fops },
{ "resources", 0444, &resources_fops },
{ "interfaces", 0444, &interfaces_fops },
};
/*
* Module and device initialization and cleanup code.
* ==================================================
*/
/*
* Set up out /sys/kernel/debug/cxgb4vf sub-nodes. We assume that the
* directory (debugfs_root) has already been set up.
*/
static int setup_debugfs(struct adapter *adapter)
{
int i;
BUG_ON(IS_ERR_OR_NULL(adapter->debugfs_root));
/*
* Debugfs support is best effort.
*/
for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
debugfs_create_file(debugfs_files[i].name,
debugfs_files[i].mode,
adapter->debugfs_root, adapter,
debugfs_files[i].fops);
return 0;
}
/*
* Tear down the /sys/kernel/debug/cxgb4vf sub-nodes created above. We leave
* it to our caller to tear down the directory (debugfs_root).
*/
static void cleanup_debugfs(struct adapter *adapter)
{
BUG_ON(IS_ERR_OR_NULL(adapter->debugfs_root));
/*
* Unlike our sister routine cleanup_proc(), we don't need to remove
* individual entries because a call will be made to
* debugfs_remove_recursive(). We just need to clean up any ancillary
* persistent state.
*/
/* nothing to do */
}
/* Figure out how many Ports and Queue Sets we can support. This depends on
* knowing our Virtual Function Resources and may be called a second time if
* we fall back from MSI-X to MSI Interrupt Mode.
*/
static void size_nports_qsets(struct adapter *adapter)
{
struct vf_resources *vfres = &adapter->params.vfres;
unsigned int ethqsets, pmask_nports;
/* The number of "ports" which we support is equal to the number of
* Virtual Interfaces with which we've been provisioned.
*/
adapter->params.nports = vfres->nvi;
if (adapter->params.nports > MAX_NPORTS) {
dev_warn(adapter->pdev_dev, "only using %d of %d maximum"
" allowed virtual interfaces\n", MAX_NPORTS,
adapter->params.nports);
adapter->params.nports = MAX_NPORTS;
}
/* We may have been provisioned with more VIs than the number of
* ports we're allowed to access (our Port Access Rights Mask).
* This is obviously a configuration conflict but we don't want to
* crash the kernel or anything silly just because of that.
*/
pmask_nports = hweight32(adapter->params.vfres.pmask);
if (pmask_nports < adapter->params.nports) {
dev_warn(adapter->pdev_dev, "only using %d of %d provisioned"
" virtual interfaces; limited by Port Access Rights"
" mask %#x\n", pmask_nports, adapter->params.nports,
adapter->params.vfres.pmask);
adapter->params.nports = pmask_nports;
}
/* We need to reserve an Ingress Queue for the Asynchronous Firmware
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/pci.h`, `linux/dma-mapping.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/debugfs.h`.
- Detected declarations: `struct queue_port_stats`, `struct cxgb4vf_debugfs_entry`, `function t4vf_os_link_changed`, `function t4vf_os_portmod_changed`, `function cxgb4vf_set_addr_hash`, `function cxgb4vf_change_mac`, `function list_for_each_entry`, `function link_start`, `function name_msix_vecs`, `function request_msix_queue_irqs`.
- 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.