drivers/net/wan/farsync.c
Source file repositories/reference/linux-study-clean/drivers/net/wan/farsync.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wan/farsync.c- Extension
.c- Size
- 70620 bytes
- Lines
- 2593
- 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
linux/module.hlinux/kernel.hlinux/version.hlinux/pci.hlinux/sched.hlinux/slab.hlinux/ioport.hlinux/init.hlinux/interrupt.hlinux/delay.hlinux/if.hlinux/hdlc.hasm/io.hlinux/uaccess.hfarsync.h
Detected Declarations
struct txdescstruct rxdescstruct cirbuffstruct port_cfgstruct su_configstruct su_statusstruct fst_sharedstruct buf_windowstruct fst_port_infostruct fst_card_infofunction fst_q_work_itemfunction fst_process_tx_work_qfunction fst_process_int_work_qfunction fst_cpuresetfunction fst_cpureleasefunction fst_clear_intrfunction fst_enable_intrfunction fst_disable_intrfunction fst_process_rx_statusfunction fst_init_dmafunction fst_tx_dma_completefunction farsync_type_transfunction fst_rx_dma_completefunction fst_rx_dmafunction fst_tx_dmafunction fst_issue_cmdfunction fst_op_raisefunction fst_op_lowerfunction fst_rx_configfunction fst_tx_configfunction fst_intr_te1_alarmfunction fst_intr_ctlchgfunction fst_log_rx_errorfunction fst_recover_rx_errorfunction fst_intr_rxfunction do_bottom_half_txfunction do_bottom_half_rxfunction fst_intrfunction check_started_okfunction set_conf_from_infofunction gather_conf_infofunction fst_set_ifacefunction fst_get_ifacefunction fst_siocdevprivatefunction fst_ioctlfunction fst_openportfunction fst_closeportfunction fst_open
Annotated Snippet
static const struct net_device_ops fst_ops = {
.ndo_open = fst_open,
.ndo_stop = fst_close,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_siocwandev = fst_ioctl,
.ndo_siocdevprivate = fst_siocdevprivate,
.ndo_tx_timeout = fst_tx_timeout,
};
/* Initialise card when detected.
* Returns 0 to indicate success, or errno otherwise.
*/
static int
fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int no_of_cards_added;
struct fst_card_info *card;
int err = 0;
int i;
printk_once(KERN_INFO
pr_fmt("FarSync WAN driver " FST_USER_VERSION
" (c) 2001-2004 FarSite Communications Ltd.\n"));
#if FST_DEBUG
dbg(DBG_ASS, "The value of debug mask is %x\n", fst_debug_mask);
#endif
/* We are going to be clever and allow certain cards not to be
* configured. An exclude list can be provided in /etc/modules.conf
*/
if (fst_excluded_cards != 0) {
/* There are cards to exclude
*
*/
for (i = 0; i < fst_excluded_cards; i++) {
if (pdev->devfn >> 3 == fst_excluded_list[i]) {
pr_info("FarSync PCI device %d not assigned\n",
(pdev->devfn) >> 3);
return -EBUSY;
}
}
}
/* Allocate driver private data */
card = kzalloc_obj(struct fst_card_info);
if (!card)
return -ENOMEM;
/* Try to enable the device */
err = pci_enable_device(pdev);
if (err) {
pr_err("Failed to enable card. Err %d\n", -err);
goto enable_fail;
}
err = pci_request_regions(pdev, "FarSync");
if (err) {
pr_err("Failed to allocate regions. Err %d\n", -err);
goto regions_fail;
}
/* Get virtual addresses of memory regions */
card->pci_conf = pci_resource_start(pdev, 1);
card->phys_mem = pci_resource_start(pdev, 2);
card->phys_ctlmem = pci_resource_start(pdev, 3);
card->mem = ioremap(card->phys_mem, FST_MEMSIZE);
if (!card->mem) {
pr_err("Physical memory remap failed\n");
err = -ENODEV;
goto ioremap_physmem_fail;
}
card->ctlmem = ioremap(card->phys_ctlmem, 0x10);
if (!card->ctlmem) {
pr_err("Control memory remap failed\n");
err = -ENODEV;
goto ioremap_ctlmem_fail;
}
dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem);
/* Register the interrupt handler */
if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) {
pr_err("Unable to register interrupt %d\n", card->irq);
err = -ENODEV;
goto irq_fail;
}
/* Record info we need */
card->irq = pdev->irq;
card->type = ent->driver_data;
card->family = ((ent->driver_data == FST_TYPE_T2P) ||
(ent->driver_data == FST_TYPE_T4P))
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/version.h`, `linux/pci.h`, `linux/sched.h`, `linux/slab.h`, `linux/ioport.h`, `linux/init.h`.
- Detected declarations: `struct txdesc`, `struct rxdesc`, `struct cirbuff`, `struct port_cfg`, `struct su_config`, `struct su_status`, `struct fst_shared`, `struct buf_window`, `struct fst_port_info`, `struct fst_card_info`.
- 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.