/*
* 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 reference.
*
*
* $Id: xircom_cb.c,v 1.33 2001/03/19 14:02:07 arjanv Exp $
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/ethtool.h>
#include <linux/bitops.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#ifdef CONFIG_NET_POLL_CONTROLLER
#include <asm/irq.h>
#endif
#ifdef DEBUG
#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
#define leave(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
#else
#define enter(x) do {} while (0)
#define leave(x) do {} while (0)
#endif
MODULE_DESCRIPTION("Xircom Cardbus ethernet driver");
MODULE_AUTHOR("Arjan van de Ven <arjanv@redhat.com>");
MODULE_LICENSE("GPL");
/* 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] = {128,2048,4096,6144};
struct xircom_private {
/* Send and receive buffers, kernel-addressable and dma addressable forms */
unsigned int *rx_buffer;
unsigned int *tx_buffer;
dma_addr_t rx_dma_handle;
dma_addr_t tx_dma_handle;
struct sk_buff *tx_skb[4];
unsigned long io_port;
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;
struct net_device_stats stats;
};
/* 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, struct pt_regs *regs);
static int 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);
static struct net_device_stats *xircom_get_stats(struct net_device *dev);
#ifdef CONFIG_NET_POLL_CONTROLLER
static void xircom_poll_controller(struct net_device *dev);
#endif
static void investigate_read_descriptor(struct net_device *