drivers/net/wan/wanxl.c

Source file repositories/reference/linux-study-clean/drivers/net/wan/wanxl.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wan/wanxl.c
Extension
.c
Size
20647 bytes
Lines
842
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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct net_device_ops wanxl_ops = {
	.ndo_open       = wanxl_open,
	.ndo_stop       = wanxl_close,
	.ndo_start_xmit = hdlc_start_xmit,
	.ndo_siocwandev = wanxl_ioctl,
	.ndo_get_stats  = wanxl_get_stats,
};

static int wanxl_pci_init_one(struct pci_dev *pdev,
			      const struct pci_device_id *ent)
{
	struct card *card;
	u32 ramsize, stat;
	unsigned long timeout;
	u32 plx_phy;		/* PLX PCI base address */
	u32 mem_phy;		/* memory PCI base addr */
	u8 __iomem *mem;	/* memory virtual base addr */
	int i, ports;

#ifndef MODULE
	pr_info_once("%s\n", version);
#endif

	i = pci_enable_device(pdev);
	if (i)
		return i;

	/* QUICC can only access first 256 MB of host RAM directly,
	 * but PLX9060 DMA does 32-bits for actual packet data transfers
	 */

	/* FIXME when PCI/DMA subsystems are fixed.
	 * We set both dma_mask and consistent_dma_mask to 28 bits
	 * and pray pci_alloc_consistent() will use this info. It should
	 * work on most platforms
	 */
	if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(28)) ||
	    dma_set_mask(&pdev->dev, DMA_BIT_MASK(28))) {
		pr_err("No usable DMA configuration\n");
		pci_disable_device(pdev);
		return -EIO;
	}

	i = pci_request_regions(pdev, "wanXL");
	if (i) {
		pci_disable_device(pdev);
		return i;
	}

	switch (pdev->device) {
	case PCI_DEVICE_ID_SBE_WANXL100:
		ports = 1;
		break;
	case PCI_DEVICE_ID_SBE_WANXL200:
		ports = 2;
		break;
	default:
		ports = 4;
	}

	card = kzalloc_flex(*card, ports, ports);
	if (!card) {
		pci_release_regions(pdev);
		pci_disable_device(pdev);
		return -ENOBUFS;
	}

	pci_set_drvdata(pdev, card);
	card->pdev = pdev;

	card->status = dma_alloc_coherent(&pdev->dev,
					  sizeof(struct card_status),
					  &card->status_address, GFP_KERNEL);
	if (!card->status) {
		wanxl_pci_remove_one(pdev);
		return -ENOBUFS;
	}

#ifdef DEBUG_PCI
	printk(KERN_DEBUG "wanXL %s: pci_alloc_consistent() returned memory"
	       " at 0x%LX\n", pci_name(pdev),
	       (unsigned long long)card->status_address);
#endif

	/* FIXME when PCI/DMA subsystems are fixed.
	 * We set both dma_mask and consistent_dma_mask back to 32 bits
	 * to indicate the card can do 32-bit DMA addressing
	 */
	if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)) ||
	    dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {

Annotation

Implementation Notes