drivers/net/ethernet/chelsio/cxgb/cxgb2.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb/cxgb2.c- Extension
.c- Size
- 36669 bytes
- Lines
- 1331
- 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
common.hlinux/module.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/if_vlan.hlinux/mii.hlinux/sockios.hlinux/dma-mapping.hlinux/uaccess.hcpl5_cmd.hregs.hgmac.hcphy.hsge.htp.hespi.helmer0.hlinux/workqueue.h
Detected Declarations
function Copyrightfunction cancel_mac_stats_updatefunction t1_set_rxmodefunction link_reportfunction t1_link_negotiatedfunction link_startfunction enable_hw_csumfunction cxgb_upfunction cxgb_downfunction cxgb_openfunction cxgb_closefunction get_msglevelfunction set_msglevelfunction get_regs_lenfunction get_drvinfofunction get_sset_countfunction get_stringsfunction get_statsfunction reg_block_dumpfunction get_regsfunction get_link_ksettingsfunction speed_duplex_to_capsfunction set_link_ksettingsfunction get_pauseparamfunction set_pauseparamfunction get_sge_paramfunction set_sge_paramfunction set_coalescefunction get_coalescefunction get_eeprom_lenfunction get_eepromfunction t1_ioctlfunction t1_change_mtufunction t1_set_mac_addrfunction t1_fix_featuresfunction t1_set_featuresfunction t1_netpollfunction mac_stats_taskfunction for_each_portfunction init_onefunction bit_bangfunction t1_clockfunction t1_sw_resetfunction remove_onefunction for_each_port
Annotated Snippet
static const struct net_device_ops cxgb_netdev_ops = {
.ndo_open = cxgb_open,
.ndo_stop = cxgb_close,
.ndo_start_xmit = t1_start_xmit,
.ndo_get_stats = t1_get_stats,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = t1_set_rxmode,
.ndo_eth_ioctl = t1_ioctl,
.ndo_change_mtu = t1_change_mtu,
.ndo_set_mac_address = t1_set_mac_addr,
.ndo_fix_features = t1_fix_features,
.ndo_set_features = t1_set_features,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = t1_netpoll,
#endif
};
static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned long mmio_start, mmio_len;
const struct board_info *bi;
struct adapter *adapter = NULL;
struct port_info *pi;
int i, err;
err = pci_enable_device(pdev);
if (err)
return err;
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
pr_err("%s: cannot find PCI device memory base address\n",
pci_name(pdev));
err = -ENODEV;
goto out_disable_pdev;
}
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (err) {
pr_err("%s: no usable DMA configuration\n", pci_name(pdev));
goto out_disable_pdev;
}
err = pci_request_regions(pdev, DRV_NAME);
if (err) {
pr_err("%s: cannot obtain PCI resources\n", pci_name(pdev));
goto out_disable_pdev;
}
pci_set_master(pdev);
mmio_start = pci_resource_start(pdev, 0);
mmio_len = pci_resource_len(pdev, 0);
bi = t1_get_board_info(ent->driver_data);
for (i = 0; i < bi->port_number; ++i) {
struct net_device *netdev;
netdev = alloc_etherdev(adapter ? 0 : sizeof(*adapter));
if (!netdev) {
err = -ENOMEM;
goto out_free_dev;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
if (!adapter) {
adapter = netdev_priv(netdev);
adapter->pdev = pdev;
adapter->port[0].dev = netdev; /* so we don't leak it */
adapter->regs = ioremap(mmio_start, mmio_len);
if (!adapter->regs) {
pr_err("%s: cannot map device registers\n",
pci_name(pdev));
err = -ENOMEM;
goto out_free_dev;
}
if (t1_get_board_rev(adapter, bi, &adapter->params)) {
err = -ENODEV; /* Can't handle this chip rev */
goto out_free_dev;
}
adapter->name = pci_name(pdev);
adapter->msg_enable = dflt_msg_enable;
adapter->mmio_len = mmio_len;
spin_lock_init(&adapter->tpi_lock);
spin_lock_init(&adapter->work_lock);
spin_lock_init(&adapter->async_lock);
Annotation
- Immediate include surface: `common.h`, `linux/module.h`, `linux/pci.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/mii.h`, `linux/sockios.h`.
- Detected declarations: `function Copyright`, `function cancel_mac_stats_update`, `function t1_set_rxmode`, `function link_report`, `function t1_link_negotiated`, `function link_start`, `function enable_hw_csum`, `function cxgb_up`, `function cxgb_down`, `function cxgb_open`.
- 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.