drivers/net/ethernet/3com/typhoon.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/3com/typhoon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/3com/typhoon.c- Extension
.c- Size
- 73445 bytes
- Lines
- 2610
- 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/kernel.hlinux/sched.hlinux/string.hlinux/timer.hlinux/errno.hlinux/ioport.hlinux/interrupt.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/mm.hlinux/init.hlinux/delay.hlinux/ethtool.hlinux/if_vlan.hlinux/crc32.hlinux/bitops.hasm/processor.hasm/io.hlinux/uaccess.hlinux/in6.hlinux/dma-mapping.hlinux/firmware.htyphoon.hnet/vxlan.h
Detected Declarations
struct typhoon_card_infostruct typhoon_sharedstruct rxbuff_entstruct typhoonenum typhoon_cardsenum completion_wait_valuesenum state_valuesfunction typhoon_inc_indexfunction typhoon_inc_cmd_indexfunction typhoon_inc_resp_indexfunction typhoon_inc_rxfree_indexfunction typhoon_inc_tx_indexfunction typhoon_inc_rx_indexfunction typhoon_resetfunction typhoon_wait_statusfunction typhoon_media_statusfunction typhoon_hellofunction typhoon_process_responsefunction typhoon_num_freefunction typhoon_num_free_cmdfunction typhoon_num_free_respfunction typhoon_num_free_txfunction typhoon_issue_commandfunction typhoon_tso_fillfunction typhoon_start_txfunction typhoon_set_rx_modefunction netdev_for_each_mc_addrfunction typhoon_do_get_statsfunction typhoon_get_statsfunction typhoon_get_drvinfofunction typhoon_get_link_ksettingsfunction typhoon_set_link_ksettingsfunction typhoon_get_wolfunction typhoon_set_wolfunction typhoon_get_ringparamfunction typhoon_wait_interruptfunction typhoon_init_interfacefunction typhoon_init_ringsfunction typhoon_request_firmwarefunction typhoon_download_firmwarefunction typhoon_boot_3XPfunction typhoon_clean_txfunction typhoon_tx_completefunction typhoon_recycle_rx_skbfunction typhoon_alloc_rx_skbfunction typhoon_rxfunction typhoon_fill_free_ringfunction typhoon_poll
Annotated Snippet
static const struct net_device_ops typhoon_netdev_ops = {
.ndo_open = typhoon_open,
.ndo_stop = typhoon_close,
#if MAX_SKB_FRAGS > 32
.ndo_features_check = typhoon_features_check,
#endif
.ndo_start_xmit = typhoon_start_tx,
.ndo_set_rx_mode = typhoon_set_rx_mode,
.ndo_tx_timeout = typhoon_tx_timeout,
.ndo_get_stats = typhoon_get_stats,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static int
typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct typhoon *tp;
int card_id = (int) ent->driver_data;
u8 addr[ETH_ALEN] __aligned(4);
void __iomem *ioaddr;
void *shared;
dma_addr_t shared_dma;
struct cmd_desc xp_cmd;
struct resp_desc xp_resp[3];
int err = 0;
const char *err_msg;
dev = alloc_etherdev(sizeof(*tp));
if (dev == NULL) {
err_msg = "unable to alloc new net device";
err = -ENOMEM;
goto error_out;
}
SET_NETDEV_DEV(dev, &pdev->dev);
err = pci_enable_device(pdev);
if (err < 0) {
err_msg = "unable to enable device";
goto error_out_dev;
}
err = pci_set_mwi(pdev);
if (err < 0) {
err_msg = "unable to set MWI";
goto error_out_disable;
}
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err < 0) {
err_msg = "No usable DMA configuration";
goto error_out_mwi;
}
/* sanity checks on IO and MMIO BARs
*/
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) {
err_msg = "region #1 not a PCI IO resource, aborting";
err = -ENODEV;
goto error_out_mwi;
}
if (pci_resource_len(pdev, 0) < 128) {
err_msg = "Invalid PCI IO region size, aborting";
err = -ENODEV;
goto error_out_mwi;
}
if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
err_msg = "region #1 not a PCI MMIO resource, aborting";
err = -ENODEV;
goto error_out_mwi;
}
if (pci_resource_len(pdev, 1) < 128) {
err_msg = "Invalid PCI MMIO region size, aborting";
err = -ENODEV;
goto error_out_mwi;
}
err = pci_request_regions(pdev, KBUILD_MODNAME);
if (err < 0) {
err_msg = "could not request regions";
goto error_out_mwi;
}
/* map our registers
*/
if (use_mmio != 0 && use_mmio != 1)
use_mmio = typhoon_test_mmio(pdev);
ioaddr = pci_iomap(pdev, use_mmio, 128);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/string.h`, `linux/timer.h`, `linux/errno.h`, `linux/ioport.h`, `linux/interrupt.h`.
- Detected declarations: `struct typhoon_card_info`, `struct typhoon_shared`, `struct rxbuff_ent`, `struct typhoon`, `enum typhoon_cards`, `enum completion_wait_values`, `enum state_values`, `function typhoon_inc_index`, `function typhoon_inc_cmd_index`, `function typhoon_inc_resp_index`.
- 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.