From nobody Sat Aug 1 21:31:01 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 491D03BBA0E for ; Sat, 1 Aug 2026 18:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785609235; cv=none; b=ly0UDTdgbQWQ12uUI0CNEejUy2FJGbdy8syyfjuzw+twRhGDVo/iWic/0+cpE6LWR+rsuNRt+uDK1ceHfzUGIIqmD0lqK31Q+q7/qMgRQEDem5C7EGOE3/n9n8mCXr+XXwUvggvSbyYwkcwWxjTGvuqpPOeUoc2sKvSOnCsw9Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785609235; c=relaxed/simple; bh=i2QzpTT4FFhKiXkMvjQ6+jO1A4Stau1j/2/zRsgsbnY=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=hS8ZadIS9G5ccihxUU5zvErJ6Bj6Sv8FCzTr2loakAyTpqSwUFskhudb3zP6Zw6i17DZhVih1p2zv9IfJE6wb5ScVKkPshbGoBQwNllWKDh/YQQpxtsSjaJqb7CX0u3tXoLd/bC4KKTUnoxwaNMNr1/8bah1XtNglXp2WQUiar0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FzgNH8Ct; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FzgNH8Ct" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493f6de72faso5217125e9.0 for ; Sat, 01 Aug 2026 11:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785609230; x=1786214030; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:content-type :mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0Iugm45e0TbpBPfcmBDQPECgq2mumVa5U3h25sbeick=; b=FzgNH8CtfyREbGnjumtRUz4zA2ixSx/A3HtVnY9LkcnI79KYEBb7yJ/nSDihYvaLlP 9bvX0jy5mNWWQBhjiFy6ZDzx0qmFsZ0sHeFNiNuMhL+lHvFk1lQX9sfoKFux+6mPQ5F4 X+zb3s/e8NiSNM3XoGj6Q3QkSjGGLizV2eksJsjkfva6yjMIY9ZUMeFbMp+8GXpkvulU iKdWHUjyg93RI8QhL7Y1kW6TPudk2PNDVSadQo4SGnnhVZVWrRHQbFKuclO+dPwd+3qI ZUTq3YYU8ZFWGCDr0d6py+FTDeda88/RjEjoSVfAEyN8KGWstoThgMkVfD97UQ7ejIfm UTZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785609230; x=1786214030; h=content-transfer-encoding:content-disposition:content-type :mime-version:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0Iugm45e0TbpBPfcmBDQPECgq2mumVa5U3h25sbeick=; b=VEsEme56Cri4z5Tg345xmRRxuwu/eO1E6+FjpF2DlXhpljQh86T09YZV1aJ6sQR9Rn jFNqOV/DMs90j/FVya7YQYc9DfBsuh0wIajmU2iRruFa4x0aPI0HRCZpOGYetQaAEiX+ i9ftAzNAnhMmRWmTN4XxLcNL8mdLOWAhKqNiVitH/ALJRo1ROrV3wNN//tjHET+FrdMm IKBKt6fyj/GaUjDo8Zyj4qeCz3ytHSSBt0vvtooY11C2IOSyliyTmpvDnuqTDh7cDTCS vtI9+ex6jFp1Y0DkiWbKsi/lBCXut8jVauVVnd0QDrhW03evF/mAYLnCojpMKwHSy2VE 0Cww== X-Forwarded-Encrypted: i=1; AHgh+RqieIXVhi1GHZo8lakhX8yhWEqeuc0SLFob49O56okv7rEKuEdTeZtkFQIqqDCpCbnrH7hZOPnp8LLGP3U=@vger.kernel.org X-Gm-Message-State: AOJu0YyS2YTSyp1/AIi5DWTQbvmlUlZrpl3hLixgrOjj3RRlc7eA/qcL XQITsV4gsYUsTLZby9ycK7ypzt2HgTotqnUq7t5YqkzMFuCz1a6E/+kh X-Gm-Gg: AR+sD12q8R11RTSrarrEA3w9haE5Fg0Dg2hQdgV3eEVkFg2Idi1ZlhznPtMasNdpCjC EOFNCyMiJAYYSxXG+v+Jo3J60q3AGx1+Z1EVydQkQaGmGzbL8p3QdkjP3XL1VSf0fBz3zibGez4 vQNSkIeGuSIXyzW29N+XO/MUtyIRRD4hEdihxtbOL5mTua+UJ7VGktTf1uv7UzA/01X/ZVH/4tx DrYw6QpXTQ/5srHplGG1DVdxOVX1YqVQGf1b5Kw59dtUIqsjsKBaVKvt8BpliWsRY35H+/LL3F6 XiFytyUzwE4km1eUMU6MoIvr9FHelcW4vkXGdsolIdP4ldQdgZzXZolot4uvTm3rcsyCH5pHaw1 sbstKmdeFR/v1MH4F871F0IgMntggAQmybopVbI6UMfApzhEFvgXH/+lNi0wjsCHcBZfqeogj5U fzkbOmK2ZPdGrYEj8t8nV1ep3W2VqAqzeAgu+Oqu64kD8q/iz/c2jSTcw0HUXnESxiA/ZVWMpEv aXlAyojbJo4cicsQWqGhH+MzEw/QC8lhLttvtQtaeRo/NKH8FvcLIDfl6aqiLzC0KfUHBBOpAnx U9Q= X-Received: by 2002:a05:600c:4708:b0:495:5d6d:9cc1 with SMTP id 5b1f17b1804b1-4980eb4e95dmr50977775e9.0.1785609230259; Sat, 01 Aug 2026 11:33:50 -0700 (PDT) Received: from ThinkPad-P15 (67.85-86-63.dynamic.clientes.euskaltel.es. [85.86.63.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807b5b4a2sm81317005e9.1.2026.08.01.11.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 11:33:49 -0700 (PDT) Date: Sat, 1 Aug 2026 20:33:49 +0200 From: Pablo =?iso-8859-1?Q?Vallesp=EDn?= Aranguren To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , open list , "open list:TULIP NETWORK DRIVERS" , "open list:TULIP NETWORK DRIVERS" Cc: Greg KH Subject: [PATCH] net: tulip: remove xircom_cb driver Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A possible bug was found in investigate_read_descriptor() and a fix was proposed. Since this is an orphan driver for hardware that is old, removing the driver was suggested instead. This patch removes the driver. Link: https://lore.kernel.org/netdev/2026080158-next-diligent-b4ce@gregkh Signed-off-by: Pablo Vallesp=C3=ADn Aranguren --- drivers/net/ethernet/dec/tulip/Kconfig | 12 - drivers/net/ethernet/dec/tulip/Makefile | 1 - drivers/net/ethernet/dec/tulip/xircom_cb.c | 1172 -------------------- 3 files changed, 1185 deletions(-) delete mode 100644 drivers/net/ethernet/dec/tulip/xircom_cb.c diff --git a/drivers/net/ethernet/dec/tulip/Kconfig b/drivers/net/ethernet/= dec/tulip/Kconfig index 078a12f07e96..b7ff76ff51e4 100644 --- a/drivers/net/ethernet/dec/tulip/Kconfig +++ b/drivers/net/ethernet/dec/tulip/Kconfig @@ -139,16 +139,4 @@ config ULI526X To compile this driver as a module, choose M here. The module will be called uli526x. =20 -config PCMCIA_XIRCOM - tristate "Xircom CardBus support" - depends on CARDBUS - help - This driver is for the Digital "Tulip" Ethernet CardBus adapters. - It should work with most DEC 21*4*-based chips/ethercards, as well - as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and - ASIX. - - To compile this driver as a module, choose M here. The module will - be called xircom_cb. If unsure, say N. - endif # NET_TULIP diff --git a/drivers/net/ethernet/dec/tulip/Makefile b/drivers/net/ethernet= /dec/tulip/Makefile index d4f1d21d29a0..5d999d72840f 100644 --- a/drivers/net/ethernet/dec/tulip/Makefile +++ b/drivers/net/ethernet/dec/tulip/Makefile @@ -5,7 +5,6 @@ =20 ccflags-$(CONFIG_NET_TULIP) :=3D -DDEBUG =20 -obj-$(CONFIG_PCMCIA_XIRCOM) +=3D xircom_cb.o obj-$(CONFIG_DM9102) +=3D dmfe.o obj-$(CONFIG_WINBOND_840) +=3D winbond-840.o obj-$(CONFIG_DE2104X) +=3D de2104x.o diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ether= net/dec/tulip/xircom_cb.c deleted file mode 100644 index e5d2ede13845..000000000000 --- a/drivers/net/ethernet/dec/tulip/xircom_cb.c +++ /dev/null @@ -1,1172 +0,0 @@ -/* - * xircom_cb: A driver for the (tulip-like) Xircom Cardbus ethernet cards - * - * This software is (C) by the respective authors, and licensed under the = GPL - * License. - * - * Written by Arjan van de Ven for Red Hat, Inc. - * Based on work by Jeff Garzik, Doug Ledford and Donald Becker - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by referenc= e. - * - * - * $Id: xircom_cb.c,v 1.33 2001/03/19 14:02:07 arjanv Exp $ - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#ifdef CONFIG_NET_POLL_CONTROLLER -#include -#endif - -MODULE_DESCRIPTION("Xircom Cardbus ethernet driver"); -MODULE_AUTHOR("Arjan van de Ven "); -MODULE_LICENSE("GPL"); - -#define xw32(reg, val) iowrite32(val, ioaddr + (reg)) -#define xr32(reg) ioread32(ioaddr + (reg)) -#define xr8(reg) ioread8(ioaddr + (reg)) - -/* IO registers on the card, offsets */ -#define CSR0 0x00 -#define CSR1 0x08 -#define CSR2 0x10 -#define CSR3 0x18 -#define CSR4 0x20 -#define CSR5 0x28 -#define CSR6 0x30 -#define CSR7 0x38 -#define CSR8 0x40 -#define CSR9 0x48 -#define CSR10 0x50 -#define CSR11 0x58 -#define CSR12 0x60 -#define CSR13 0x68 -#define CSR14 0x70 -#define CSR15 0x78 -#define CSR16 0x80 - -/* PCI registers */ -#define PCI_POWERMGMT 0x40 - -/* Offsets of the buffers within the descriptor pages, in bytes */ - -#define NUMDESCRIPTORS 4 - -static int bufferoffsets[NUMDESCRIPTORS] =3D {128,2048,4096,6144}; - - -struct xircom_private { - /* Send and receive buffers, kernel-addressable and dma addressable forms= */ - - __le32 *rx_buffer; - __le32 *tx_buffer; - - dma_addr_t rx_dma_handle; - dma_addr_t tx_dma_handle; - - struct sk_buff *tx_skb[4]; - - void __iomem *ioaddr; - int open; - - /* transmit_used is the rotating counter that indicates which transmit - descriptor has to be used next */ - int transmit_used; - - /* Spinlock to serialize register operations. - It must be helt while manipulating the following registers: - CSR0, CSR6, CSR7, CSR9, CSR10, CSR15 - */ - spinlock_t lock; - - struct pci_dev *pdev; - struct net_device *dev; -}; - - -/* Function prototypes */ -static int xircom_probe(struct pci_dev *pdev, const struct pci_device_id *= id); -static void xircom_remove(struct pci_dev *pdev); -static irqreturn_t xircom_interrupt(int irq, void *dev_instance); -static netdev_tx_t xircom_start_xmit(struct sk_buff *skb, - struct net_device *dev); -static int xircom_open(struct net_device *dev); -static int xircom_close(struct net_device *dev); -static void xircom_up(struct xircom_private *card); -#ifdef CONFIG_NET_POLL_CONTROLLER -static void xircom_poll_controller(struct net_device *dev); -#endif - -static void investigate_read_descriptor(struct net_device *dev,struct xirc= om_private *card, int descnr, unsigned int bufferoffset); -static void investigate_write_descriptor(struct net_device *dev, struct xi= rcom_private *card, int descnr, unsigned int bufferoffset); -static void read_mac_address(struct xircom_private *card); -static void transceiver_voodoo(struct xircom_private *card); -static void initialize_card(struct xircom_private *card); -static void trigger_transmit(struct xircom_private *card); -static void trigger_receive(struct xircom_private *card); -static void setup_descriptors(struct xircom_private *card); -static void remove_descriptors(struct xircom_private *card); -static int link_status_changed(struct xircom_private *card); -static void activate_receiver(struct xircom_private *card); -static void deactivate_receiver(struct xircom_private *card); -static void activate_transmitter(struct xircom_private *card); -static void deactivate_transmitter(struct xircom_private *card); -static void enable_transmit_interrupt(struct xircom_private *card); -static void enable_receive_interrupt(struct xircom_private *card); -static void enable_link_interrupt(struct xircom_private *card); -static void disable_all_interrupts(struct xircom_private *card); -static int link_status(struct xircom_private *card); - - - -static const struct pci_device_id xircom_pci_table[] =3D { - { PCI_VDEVICE(XIRCOM, 0x0003), }, - {0,}, -}; -MODULE_DEVICE_TABLE(pci, xircom_pci_table); - -static struct pci_driver xircom_driver =3D { - .name =3D "xircom_cb", - .id_table =3D xircom_pci_table, - .probe =3D xircom_probe, - .remove =3D xircom_remove, -}; - - -#if defined DEBUG && DEBUG > 1 -static void print_binary(unsigned int number) -{ - int i,i2; - char buffer[64]; - memset(buffer,0,64); - i2=3D0; - for (i=3D31;i>=3D0;i--) { - if (number & (1<dev; - struct net_device *dev =3D NULL; - struct xircom_private *private; - unsigned long flags; - unsigned short tmp16; - int rc; - - /* First do the PCI initialisation */ - - rc =3D pci_enable_device(pdev); - if (rc < 0) - goto out; - - /* disable all powermanagement */ - pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000); - - pci_set_master(pdev); /* Why isn't this done by pci_enable_device ?*/ - - /* clear PCI status, if any */ - pci_read_config_word (pdev,PCI_STATUS, &tmp16); - pci_write_config_word (pdev, PCI_STATUS,tmp16); - - rc =3D pci_request_regions(pdev, "xircom_cb"); - if (rc < 0) { - pr_err("%s: failed to allocate io-region\n", __func__); - goto err_disable; - } - - rc =3D -ENOMEM; - /* - Before changing the hardware, allocate the memory. - This way, we can fail gracefully if not enough memory - is available. - */ - dev =3D alloc_etherdev(sizeof(struct xircom_private)); - if (!dev) - goto err_release; - - private =3D netdev_priv(dev); - - /* Allocate the send/receive buffers */ - private->rx_buffer =3D dma_alloc_coherent(d, 8192, - &private->rx_dma_handle, - GFP_KERNEL); - if (private->rx_buffer =3D=3D NULL) - goto rx_buf_fail; - - private->tx_buffer =3D dma_alloc_coherent(d, 8192, - &private->tx_dma_handle, - GFP_KERNEL); - if (private->tx_buffer =3D=3D NULL) - goto tx_buf_fail; - - SET_NETDEV_DEV(dev, &pdev->dev); - - - private->dev =3D dev; - private->pdev =3D pdev; - - /* IO range. */ - private->ioaddr =3D pci_iomap(pdev, 0, 0); - if (!private->ioaddr) - goto reg_fail; - - spin_lock_init(&private->lock); - - initialize_card(private); - read_mac_address(private); - setup_descriptors(private); - - dev->netdev_ops =3D &netdev_ops; - pci_set_drvdata(pdev, dev); - - rc =3D register_netdev(dev); - if (rc < 0) { - pr_err("%s: netdevice registration failed\n", __func__); - goto err_unmap; - } - - netdev_info(dev, "Xircom cardbus revision %i at irq %i\n", - pdev->revision, pdev->irq); - /* start the transmitter to get a heartbeat */ - /* TODO: send 2 dummy packets here */ - transceiver_voodoo(private); - - spin_lock_irqsave(&private->lock,flags); - activate_transmitter(private); - activate_receiver(private); - spin_unlock_irqrestore(&private->lock,flags); - - trigger_receive(private); -out: - return rc; - -err_unmap: - pci_iounmap(pdev, private->ioaddr); -reg_fail: - dma_free_coherent(d, 8192, private->tx_buffer, private->tx_dma_handle); -tx_buf_fail: - dma_free_coherent(d, 8192, private->rx_buffer, private->rx_dma_handle); -rx_buf_fail: - free_netdev(dev); -err_release: - pci_release_regions(pdev); -err_disable: - pci_disable_device(pdev); - goto out; -} - - -/* - xircom_remove is called on module-unload or on device-eject. - it unregisters the irq, io-region and network device. - Interrupts and such are already stopped in the "ifconfig ethX down" - code. - */ -static void xircom_remove(struct pci_dev *pdev) -{ - struct net_device *dev =3D pci_get_drvdata(pdev); - struct xircom_private *card =3D netdev_priv(dev); - struct device *d =3D &pdev->dev; - - unregister_netdev(dev); - pci_iounmap(pdev, card->ioaddr); - dma_free_coherent(d, 8192, card->tx_buffer, card->tx_dma_handle); - dma_free_coherent(d, 8192, card->rx_buffer, card->rx_dma_handle); - free_netdev(dev); - pci_release_regions(pdev); - pci_disable_device(pdev); -} - -static irqreturn_t xircom_interrupt(int irq, void *dev_instance) -{ - struct net_device *dev =3D (struct net_device *) dev_instance; - struct xircom_private *card =3D netdev_priv(dev); - void __iomem *ioaddr =3D card->ioaddr; - unsigned int status; - int i; - - spin_lock(&card->lock); - status =3D xr32(CSR5); - -#if defined DEBUG && DEBUG > 1 - print_binary(status); - pr_debug("tx status 0x%08x 0x%08x\n", - card->tx_buffer[0], card->tx_buffer[4]); - pr_debug("rx status 0x%08x 0x%08x\n", - card->rx_buffer[0], card->rx_buffer[4]); -#endif - /* Handle shared irq and hotplug */ - if (status =3D=3D 0 || status =3D=3D 0xffffffff) { - spin_unlock(&card->lock); - return IRQ_NONE; - } - - if (link_status_changed(card)) { - int newlink; - netdev_dbg(dev, "Link status has changed\n"); - newlink =3D link_status(card); - netdev_info(dev, "Link is %d mbit\n", newlink); - if (newlink) - netif_carrier_on(dev); - else - netif_carrier_off(dev); - - } - - /* Clear all remaining interrupts */ - status |=3D 0xffffffff; /* FIXME: make this clear only the - real existing bits */ - xw32(CSR5, status); - - - for (i=3D0;ilock); - return IRQ_HANDLED; -} - -static netdev_tx_t xircom_start_xmit(struct sk_buff *skb, - struct net_device *dev) -{ - struct xircom_private *card; - unsigned long flags; - int nextdescriptor; - int desc; - - card =3D netdev_priv(dev); - spin_lock_irqsave(&card->lock,flags); - - /* First see if we can free some descriptors */ - for (desc=3D0;desctransmit_used +1) % (NUMDESCRIPTORS); - desc =3D card->transmit_used; - - /* only send the packet if the descriptor is free */ - if (card->tx_buffer[4*desc]=3D=3D0) { - /* Copy the packet data; zero the memory first as the card - sometimes sends more than you ask it to. */ - - memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536); - skb_copy_from_linear_data(skb, - &(card->tx_buffer[bufferoffsets[desc] / 4]), - skb->len); - /* FIXME: The specification tells us that the length we send HAS to be = a multiple of - 4 bytes. */ - - card->tx_buffer[4*desc+1] =3D cpu_to_le32(skb->len); - if (desc =3D=3D NUMDESCRIPTORS - 1) /* bit 25: last descriptor of the r= ing */ - card->tx_buffer[4*desc+1] |=3D cpu_to_le32(1<<25); =20 - - card->tx_buffer[4*desc+1] |=3D cpu_to_le32(0xF0000000); - /* 0xF0... means want interrupts*/ - card->tx_skb[desc] =3D skb; - - wmb(); - /* This gives the descriptor to the card */ - card->tx_buffer[4*desc] =3D cpu_to_le32(0x80000000); - trigger_transmit(card); - if (card->tx_buffer[nextdescriptor*4] & cpu_to_le32(0x8000000)) { - /* next descriptor is occupied... */ - netif_stop_queue(dev); - } - card->transmit_used =3D nextdescriptor; - spin_unlock_irqrestore(&card->lock,flags); - return NETDEV_TX_OK; - } - - /* Uh oh... no free descriptor... drop the packet */ - netif_stop_queue(dev); - spin_unlock_irqrestore(&card->lock,flags); - trigger_transmit(card); - - return NETDEV_TX_BUSY; -} - - - - -static int xircom_open(struct net_device *dev) -{ - struct xircom_private *xp =3D netdev_priv(dev); - const int irq =3D xp->pdev->irq; - int retval; - - netdev_info(dev, "xircom cardbus adaptor found, using irq %i\n", irq); - retval =3D request_irq(irq, xircom_interrupt, IRQF_SHARED, dev->name, dev= ); - if (retval) - return retval; - - xircom_up(xp); - xp->open =3D 1; - - return 0; -} - -static int xircom_close(struct net_device *dev) -{ - struct xircom_private *card; - unsigned long flags; - - card =3D netdev_priv(dev); - netif_stop_queue(dev); /* we don't want new packets */ - - - spin_lock_irqsave(&card->lock,flags); - - disable_all_interrupts(card); -#if 0 - /* We can enable this again once we send dummy packets on ifconfig ethX u= p */ - deactivate_receiver(card); - deactivate_transmitter(card); -#endif - remove_descriptors(card); - - spin_unlock_irqrestore(&card->lock,flags); - - card->open =3D 0; - free_irq(card->pdev->irq, dev); - - return 0; - -} - - -#ifdef CONFIG_NET_POLL_CONTROLLER -static void xircom_poll_controller(struct net_device *dev) -{ - struct xircom_private *xp =3D netdev_priv(dev); - const int irq =3D xp->pdev->irq; - - disable_irq(irq); - xircom_interrupt(irq, dev); - enable_irq(irq); -} -#endif - - -static void initialize_card(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned long flags; - u32 val; - - spin_lock_irqsave(&card->lock, flags); - - /* First: reset the card */ - val =3D xr32(CSR0); - val |=3D 0x01; /* Software reset */ - xw32(CSR0, val); - - udelay(100); /* give the card some time to reset */ - - val =3D xr32(CSR0); - val &=3D ~0x01; /* disable Software reset */ - xw32(CSR0, val); - - - val =3D 0; /* Value 0x00 is a safe and conservative value - for the PCI configuration settings */ - xw32(CSR0, val); - - - disable_all_interrupts(card); - deactivate_receiver(card); - deactivate_transmitter(card); - - spin_unlock_irqrestore(&card->lock, flags); -} - -/* -trigger_transmit causes the card to check for frames to be transmitted. -This is accomplished by writing to the CSR1 port. The documentation -claims that the act of writing is sufficient and that the value is -ignored; I chose zero. -*/ -static void trigger_transmit(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - - xw32(CSR1, 0); -} - -/* -trigger_receive causes the card to check for empty frames in the -descriptor list in which packets can be received. -This is accomplished by writing to the CSR2 port. The documentation -claims that the act of writing is sufficient and that the value is -ignored; I chose zero. -*/ -static void trigger_receive(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - - xw32(CSR2, 0); -} - -/* -setup_descriptors initializes the send and receive buffers to be valid -descriptors and programs the addresses into the card. -*/ -static void setup_descriptors(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - u32 address; - int i; - - BUG_ON(card->rx_buffer =3D=3D NULL); - BUG_ON(card->tx_buffer =3D=3D NULL); - - /* Receive descriptors */ - memset(card->rx_buffer, 0, 128); /* clear the descriptors */ - for (i=3D0;i 0x80000000 */ - card->rx_buffer[i*4 + 0] =3D cpu_to_le32(0x80000000); - /* Rx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */ - card->rx_buffer[i*4 + 1] =3D cpu_to_le32(1536); - if (i =3D=3D NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */ - card->rx_buffer[i*4 + 1] |=3D cpu_to_le32(1 << 25); - - /* Rx Descr2: address of the buffer - we store the buffer at the 2nd half of the page */ - - address =3D card->rx_dma_handle; - card->rx_buffer[i*4 + 2] =3D cpu_to_le32(address + bufferoffsets[i]); - /* Rx Desc3: address of 2nd buffer -> 0 */ - card->rx_buffer[i*4 + 3] =3D 0; - } - - wmb(); - /* Write the receive descriptor ring address to the card */ - address =3D card->rx_dma_handle; - xw32(CSR3, address); /* Receive descr list address */ - - - /* transmit descriptors */ - memset(card->tx_buffer, 0, 128); /* clear the descriptors */ - - for (i=3D0;i 0x00000000 */ - card->tx_buffer[i*4 + 0] =3D 0x00000000; - /* Tx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */ - card->tx_buffer[i*4 + 1] =3D cpu_to_le32(1536); - if (i =3D=3D NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */ - card->tx_buffer[i*4 + 1] |=3D cpu_to_le32(1 << 25); - - /* Tx Descr2: address of the buffer - we store the buffer at the 2nd half of the page */ - address =3D card->tx_dma_handle; - card->tx_buffer[i*4 + 2] =3D cpu_to_le32(address + bufferoffsets[i]); - /* Tx Desc3: address of 2nd buffer -> 0 */ - card->tx_buffer[i*4 + 3] =3D 0; - } - - wmb(); - /* wite the transmit descriptor ring to the card */ - address =3D card->tx_dma_handle; - xw32(CSR4, address); /* xmit descr list address */ -} - -/* -remove_descriptors informs the card the descriptors are no longer -valid by setting the address in the card to 0x00. -*/ -static void remove_descriptors(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D 0; - xw32(CSR3, val); /* Receive descriptor address */ - xw32(CSR4, val); /* Send descriptor address */ -} - -/* -link_status_changed returns 1 if the card has indicated that -the link status has changed. The new link status has to be read from CSR12. - -This function also clears the status-bit. -*/ -static int link_status_changed(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR5); /* Status register */ - if (!(val & (1 << 27))) /* no change */ - return 0; - - /* clear the event by writing a 1 to the bit in the - status register. */ - val =3D (1 << 27); - xw32(CSR5, val); - - return 1; -} - - -/* -transmit_active returns 1 if the transmitter on the card is -in a non-stopped state. -*/ -static int transmit_active(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - - if (!(xr32(CSR5) & (7 << 20))) /* transmitter disabled */ - return 0; - - return 1; -} - -/* -receive_active returns 1 if the receiver on the card is -in a non-stopped state. -*/ -static int receive_active(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - - if (!(xr32(CSR5) & (7 << 17))) /* receiver disabled */ - return 0; - - return 1; -} - -/* -activate_receiver enables the receiver on the card. -Before being allowed to active the receiver, the receiver -must be completely de-activated. To achieve this, -this code actually disables the receiver first; then it waits for the -receiver to become inactive, then it activates the receiver and then -it waits for the receiver to be active. - -must be called with the lock held and interrupts disabled. -*/ -static void activate_receiver(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - int counter; - - val =3D xr32(CSR6); /* Operation mode */ - - /* If the "active" bit is set and the receiver is already - active, no need to do the expensive thing */ - if ((val&2) && (receive_active(card))) - return; - - - val =3D val & ~2; /* disable the receiver */ - xw32(CSR6, val); - - counter =3D 10; - while (counter > 0) { - if (!receive_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, "Receiver failed to deactivate\n"); - } - - /* enable the receiver */ - val =3D xr32(CSR6); /* Operation mode */ - val =3D val | 2; /* enable the receiver */ - xw32(CSR6, val); - - /* now wait for the card to activate again */ - counter =3D 10; - while (counter > 0) { - if (receive_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, - "Receiver failed to re-activate\n"); - } -} - -/* -deactivate_receiver disables the receiver on the card. -To achieve this this code disables the receiver first; -then it waits for the receiver to become inactive. - -must be called with the lock held and interrupts disabled. -*/ -static void deactivate_receiver(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - int counter; - - val =3D xr32(CSR6); /* Operation mode */ - val =3D val & ~2; /* disable the receiver */ - xw32(CSR6, val); - - counter =3D 10; - while (counter > 0) { - if (!receive_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, "Receiver failed to deactivate\n"); - } -} - - -/* -activate_transmitter enables the transmitter on the card. -Before being allowed to active the transmitter, the transmitter -must be completely de-activated. To achieve this, -this code actually disables the transmitter first; then it waits for the -transmitter to become inactive, then it activates the transmitter and then -it waits for the transmitter to be active again. - -must be called with the lock held and interrupts disabled. -*/ -static void activate_transmitter(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - int counter; - - val =3D xr32(CSR6); /* Operation mode */ - - /* If the "active" bit is set and the receiver is already - active, no need to do the expensive thing */ - if ((val&(1<<13)) && (transmit_active(card))) - return; - - val =3D val & ~(1 << 13); /* disable the transmitter */ - xw32(CSR6, val); - - counter =3D 10; - while (counter > 0) { - if (!transmit_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, - "Transmitter failed to deactivate\n"); - } - - /* enable the transmitter */ - val =3D xr32(CSR6); /* Operation mode */ - val =3D val | (1 << 13); /* enable the transmitter */ - xw32(CSR6, val); - - /* now wait for the card to activate again */ - counter =3D 10; - while (counter > 0) { - if (transmit_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, - "Transmitter failed to re-activate\n"); - } -} - -/* -deactivate_transmitter disables the transmitter on the card. -To achieve this this code disables the transmitter first; -then it waits for the transmitter to become inactive. - -must be called with the lock held and interrupts disabled. -*/ -static void deactivate_transmitter(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - int counter; - - val =3D xr32(CSR6); /* Operation mode */ - val =3D val & ~2; /* disable the transmitter */ - xw32(CSR6, val); - - counter =3D 20; - while (counter > 0) { - if (!transmit_active(card)) - break; - /* wait a while */ - udelay(50); - counter--; - if (counter <=3D 0) - netdev_err(card->dev, - "Transmitter failed to deactivate\n"); - } -} - - -/* -enable_transmit_interrupt enables the transmit interrupt - -must be called with the lock held and interrupts disabled. -*/ -static void enable_transmit_interrupt(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR7); /* Interrupt enable register */ - val |=3D 1; /* enable the transmit interrupt */ - xw32(CSR7, val); -} - - -/* -enable_receive_interrupt enables the receive interrupt - -must be called with the lock held and interrupts disabled. -*/ -static void enable_receive_interrupt(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR7); /* Interrupt enable register */ - val =3D val | (1 << 6); /* enable the receive interrupt */ - xw32(CSR7, val); -} - -/* -enable_link_interrupt enables the link status change interrupt - -must be called with the lock held and interrupts disabled. -*/ -static void enable_link_interrupt(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR7); /* Interrupt enable register */ - val =3D val | (1 << 27); /* enable the link status chage interrupt */ - xw32(CSR7, val); -} - - - -/* -disable_all_interrupts disables all interrupts - -must be called with the lock held and interrupts disabled. -*/ -static void disable_all_interrupts(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - - xw32(CSR7, 0); -} - -/* -enable_common_interrupts enables several weird interrupts - -must be called with the lock held and interrupts disabled. -*/ -static void enable_common_interrupts(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR7); /* Interrupt enable register */ - val |=3D (1<<16); /* Normal Interrupt Summary */ - val |=3D (1<<15); /* Abnormal Interrupt Summary */ - val |=3D (1<<13); /* Fatal bus error */ - val |=3D (1<<8); /* Receive Process Stopped */ - val |=3D (1<<7); /* Receive Buffer Unavailable */ - val |=3D (1<<5); /* Transmit Underflow */ - val |=3D (1<<2); /* Transmit Buffer Unavailable */ - val |=3D (1<<1); /* Transmit Process Stopped */ - xw32(CSR7, val); -} - -/* -enable_promisc starts promisc mode - -must be called with the lock held and interrupts disabled. -*/ -static int enable_promisc(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned int val; - - val =3D xr32(CSR6); - val =3D val | (1 << 6); - xw32(CSR6, val); - - return 1; -} - - - - -/* -link_status() checks the links status and will return 0 for no link, 10 fo= r 10mbit link and 100 for.. guess what. - -Must be called in locked state with interrupts disabled -*/ -static int link_status(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - u8 val; - - val =3D xr8(CSR12); - - /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */ - if (!(val & (1 << 2))) - return 10; - /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */ - if (!(val & (1 << 1))) - return 100; - - /* If we get here -> no link at all */ - - return 0; -} - - - - - -/* - read_mac_address() reads the MAC address from the NIC and stores it in t= he "dev" structure. - - This function will take the spinlock itself and can, as a result, not be= called with the lock helt. - */ -static void read_mac_address(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned long flags; - u8 link; - int i; - - spin_lock_irqsave(&card->lock, flags); - - xw32(CSR9, 1 << 12); /* enable boot rom access */ - for (i =3D 0x100; i < 0x1f7; i +=3D link + 2) { - u8 tuple, data_id, data_count; - - xw32(CSR10, i); - tuple =3D xr32(CSR9); - xw32(CSR10, i + 1); - link =3D xr32(CSR9); - xw32(CSR10, i + 2); - data_id =3D xr32(CSR9); - xw32(CSR10, i + 3); - data_count =3D xr32(CSR9); - if ((tuple =3D=3D 0x22) && (data_id =3D=3D 0x04) && (data_count =3D=3D 0= x06)) { - u8 addr[ETH_ALEN]; - int j; - - for (j =3D 0; j < 6; j++) { - xw32(CSR10, i + j + 4); - addr[j] =3D xr32(CSR9) & 0xff; - } - eth_hw_addr_set(card->dev, addr); - break; - } else if (link =3D=3D 0) { - break; - } - } - spin_unlock_irqrestore(&card->lock, flags); - pr_debug(" %pM\n", card->dev->dev_addr); -} - - -/* - transceiver_voodoo() enables the external UTP plug thingy. - it's called voodoo as I stole this code and cannot cross-reference - it with the specification. - */ -static void transceiver_voodoo(struct xircom_private *card) -{ - void __iomem *ioaddr =3D card->ioaddr; - unsigned long flags; - - /* disable all powermanagement */ - pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); - - setup_descriptors(card); - - spin_lock_irqsave(&card->lock, flags); - - xw32(CSR15, 0x0008); - udelay(25); - xw32(CSR15, 0xa8050000); - udelay(25); - xw32(CSR15, 0xa00f0000); - udelay(25); - - spin_unlock_irqrestore(&card->lock, flags); - - netif_start_queue(card->dev); -} - - -static void xircom_up(struct xircom_private *card) -{ - unsigned long flags; - int i; - - /* disable all powermanagement */ - pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); - - setup_descriptors(card); - - spin_lock_irqsave(&card->lock, flags); - - - enable_link_interrupt(card); - enable_transmit_interrupt(card); - enable_receive_interrupt(card); - enable_common_interrupts(card); - enable_promisc(card); - - /* The card can have received packets already, read them away now */ - for (i=3D0;idev,card,i,bufferoffsets[i]); - - - spin_unlock_irqrestore(&card->lock, flags); - trigger_receive(card); - trigger_transmit(card); - netif_start_queue(card->dev); -} - -/* Bufferoffset is in BYTES */ -static void -investigate_read_descriptor(struct net_device *dev, struct xircom_private = *card, - int descnr, unsigned int bufferoffset) -{ - int status; - - status =3D le32_to_cpu(card->rx_buffer[4*descnr]); - - if (status > 0) { /* packet received */ - - /* TODO: discard error packets */ - - short pkt_len =3D ((status >> 16) & 0x7ff) - 4; - /* minus 4, we don't want the CRC */ - struct sk_buff *skb; - - if (pkt_len > 1518) { - netdev_err(dev, "Packet length %i is bogus\n", pkt_len); - pkt_len =3D 1518; - } - - skb =3D netdev_alloc_skb(dev, pkt_len + 2); - if (skb =3D=3D NULL) { - dev->stats.rx_dropped++; - goto out; - } - skb_reserve(skb, 2); - skb_copy_to_linear_data(skb, - &card->rx_buffer[bufferoffset / 4], - pkt_len); - skb_put(skb, pkt_len); - skb->protocol =3D eth_type_trans(skb, dev); - netif_rx(skb); - dev->stats.rx_packets++; - dev->stats.rx_bytes +=3D pkt_len; - -out: - /* give the buffer back to the card */ - card->rx_buffer[4*descnr] =3D cpu_to_le32(0x80000000); - trigger_receive(card); - } -} - - -/* Bufferoffset is in BYTES */ -static void -investigate_write_descriptor(struct net_device *dev, - struct xircom_private *card, - int descnr, unsigned int bufferoffset) -{ - int status; - - status =3D le32_to_cpu(card->tx_buffer[4*descnr]); -#if 0 - if (status & 0x8000) { /* Major error */ - pr_err("Major transmit error status %x\n", status); - card->tx_buffer[4*descnr] =3D 0; - netif_wake_queue (dev); - } -#endif - if (status > 0) { /* bit 31 is 0 when done */ - if (card->tx_skb[descnr]!=3DNULL) { - dev->stats.tx_bytes +=3D card->tx_skb[descnr]->len; - dev_kfree_skb_irq(card->tx_skb[descnr]); - } - card->tx_skb[descnr] =3D NULL; - /* Bit 8 in the status field is 1 if there was a collision */ - if (status & (1 << 8)) - dev->stats.collisions++; - card->tx_buffer[4*descnr] =3D 0; /* descriptor is free again */ - netif_wake_queue (dev); - dev->stats.tx_packets++; - } -} - -module_pci_driver(xircom_driver); --=20 2.43.0