drivers/net/ethernet/tehuti/tehuti.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/tehuti/tehuti.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/tehuti/tehuti.c- Extension
.c- Size
- 67078 bytes
- Lines
- 2458
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
tehuti.h
Detected Declarations
function print_hw_idfunction print_fw_idfunction print_eth_idfunction bdx_fifo_initfunction bdx_fifo_freefunction bdx_link_changedfunction bdx_isr_extrafunction bdx_isr_napifunction bdx_pollfunction NICfunction bdx_restore_macfunction bdx_hw_startfunction bdx_hw_stopfunction bdx_hw_reset_directfunction bdx_hw_resetfunction bdx_sw_resetfunction bdx_resetfunction bdx_closefunction systemfunction bdx_range_checkfunction bdx_siocdevprivatefunction __bdx_vlan_rx_vidfunction bdx_vlan_rx_add_vidfunction bdx_vlan_rx_kill_vidfunction bdx_change_mtufunction bdx_setmultifunction netdev_for_each_mc_addrfunction bdx_set_macfunction bdx_read_macfunction bdx_read_l2statfunction bdx_update_statsfunction bdx_rxdb_destroyfunction bdx_rxdb_alloc_elemfunction bdx_rxdb_availablefunction bdx_rxdb_free_elemfunction bdx_rx_initfunction bdx_rx_free_skbsfunction bdx_rx_freefunction bdx_rx_alloc_skbsfunction NETIF_RX_MUXfunction bdx_recycle_skbfunction bdx_rx_receivefunction print_rxddfunction print_rxfdfunction __bdx_tx_db_ptr_nextfunction bdx_tx_db_inc_rptrfunction bdx_tx_db_inc_wptrfunction bdx_tx_db_init
Annotated Snippet
static const struct net_device_ops bdx_netdev_ops = {
.ndo_open = bdx_open,
.ndo_stop = bdx_close,
.ndo_start_xmit = bdx_tx_transmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_siocdevprivate = bdx_siocdevprivate,
.ndo_set_rx_mode = bdx_setmulti,
.ndo_change_mtu = bdx_change_mtu,
.ndo_set_mac_address = bdx_set_mac,
.ndo_vlan_rx_add_vid = bdx_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = bdx_vlan_rx_kill_vid,
};
/**
* bdx_probe - Device Initialization Routine
* @pdev: PCI device information struct
* @ent: entry in bdx_pci_tbl
*
* Returns 0 on success, negative on failure
*
* bdx_probe initializes an adapter identified by a pci_dev structure.
* The OS initialization, configuring of the adapter private structure,
* and a hardware reset occur.
*
* functions and their order used as explained in
* /usr/src/linux/Documentation/DMA-{API,mapping}.txt
*
*/
/* TBD: netif_msg should be checked and implemented. I disable it for now */
static int
bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *ndev;
struct bdx_priv *priv;
unsigned long pciaddr;
u32 regionSize;
struct pci_nic *nic;
int err, port;
ENTER;
nic = vmalloc(sizeof(*nic));
if (!nic)
RET(-ENOMEM);
/************** pci *****************/
err = pci_enable_device(pdev);
if (err) /* it triggers interrupt, dunno why. */
goto err_pci; /* it's not a problem though */
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (err) {
pr_err("No usable DMA configuration, aborting\n");
goto err_dma;
}
err = pci_request_regions(pdev, BDX_DRV_NAME);
if (err)
goto err_dma;
pci_set_master(pdev);
pciaddr = pci_resource_start(pdev, 0);
if (!pciaddr) {
err = -EIO;
pr_err("no MMIO resource\n");
goto err_out_res;
}
regionSize = pci_resource_len(pdev, 0);
if (regionSize < BDX_REGS_SIZE) {
err = -EIO;
pr_err("MMIO resource (%x) too small\n", regionSize);
goto err_out_res;
}
nic->regs = ioremap(pciaddr, regionSize);
if (!nic->regs) {
err = -EIO;
pr_err("ioremap failed\n");
goto err_out_res;
}
if (pdev->irq < 2) {
err = -EIO;
pr_err("invalid irq (%d)\n", pdev->irq);
goto err_out_iomap;
}
pci_set_drvdata(pdev, nic);
Annotation
- Immediate include surface: `tehuti.h`.
- Detected declarations: `function print_hw_id`, `function print_fw_id`, `function print_eth_id`, `function bdx_fifo_init`, `function bdx_fifo_free`, `function bdx_link_changed`, `function bdx_isr_extra`, `function bdx_isr_napi`, `function bdx_poll`, `function NIC`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.