/* 82596.c: A generic 82596 ethernet driver for linux. */
/*
Based on Apricot.c
Written 1994 by Mark Evans.
This driver is for the Apricot 82596 bus-master interface
Modularised 12/94 Mark Evans
Modified to support the 82596 ethernet chips on 680x0 VME boards.
by Richard Hirst <richard@sleepie.demon.co.uk>
Renamed to be 82596.c
980825: Changed to receive directly in to sk_buffs which are
allocated at open() time. Eliminates copy on incoming frames
(small ones are still copied). Shared data now held in a
non-cached page, so we can run on 68060 in copyback mode.
TBD:
* look at deferring rx frames rather than discarding (as per tulip)
* handle tx ring full as per tulip
* performace test to tune rx_copybreak
Most of my modifications relate to the braindead big-endian
implementation by Intel. When the i596 is operating in
'big-endian' mode, it thinks a 32 bit value of 0x12345678
should be stored as 0x56781234. This is a real pain, when
you have linked lists which are shared by the 680x0 and the
i596.
Driver skeleton
Written 1993 by Donald Becker.
Copyright 1993 United States Government as represented by the Director,
National Security Agency. This software may only be used and distributed
according to the terms of the GNU General Public License as modified by SRC,
incorporated herein by reference.
The author may be reached as becker@scyld.com, or C/O
Scyld Computing Corporation, 410 Severn Ave., Suite 210, Annapolis MD 21403
*/
#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/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/pgtable.h>
#include <asm/cacheflush.h>
static char version[] __initdata =
"82596.c $Revision: 1.5 $\n";
#define DRV_NAME "82596"
/* DEBUG flags
*/
#define DEB_INIT 0x0001
#define DEB_PROBE 0x0002
#define DEB_SERIOUS 0x0004
#define DEB_ERRORS 0x0008
#define DEB_MULTI 0x0010
#define DEB_TDR 0x0020
#define DEB_OPEN 0x0040
#define DEB_RESET 0x0080
#define DEB_ADDCMD 0x0100
#define DEB_STATUS 0x0200
#define DEB_STARTTX 0x0400
#define DEB_RXADDR 0x0800
#define DEB_TXADDR 0x1000
#define DEB_RXFRAME 0x2000
#define DEB_INTS 0x4000
#define DEB_STRUCT 0x8000
#define DEB_ANY 0xffff
#define DEB(x,y) if (i596_debug & (x)) y
#if defined(CONFIG_MVME16x_NET) || defined(CONFIG_MVME16x_NET_MODULE)
#define ENABLE_MVME16x_NET
#endif
#if defined(CONFIG_BVME6000_NET) || defined(CONFIG_BVME6000_NET_MODULE)
#define ENABLE_BVME6000_NET
#endif
#if defined(CONFIG_APRICOT) || defined(CONFIG_APRICOT_MODULE)
#define ENABLE_APRICOT
#endif
#ifdef ENABLE_MVME16x_NET
#include <asm/mvme16xhw.h>
#endif
#ifdef ENABLE_BVME6000_NET
#include <asm/bvme6000hw.h>
#endif
/*
* Define various macros for Channel Attention, word swapping etc., dependent
* on architecture. MVME and BVME are 680x0 based, otherwise it is Intel.
*/
#ifdef __mc68000__
#define WSWAPrfd(x) ((struct i596_rfd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPrbd(x) ((struct i596_rbd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPiscp(x) ((struct i596_iscp *)(((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPscb(x) ((struct i596_scb *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPcmd(x) ((struct i596_cmd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPtbd(x) ((struct i596_tbd *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define WSWAPchar(x) ((char *) (((u32)(x)<<16) | ((((u32)(x)))>>16)))
#define ISCP_BUSY 0x00010000
#define MACH_IS_APRICOT 0
#else
#define WSWAPrfd(x) ((struct i596_rfd *)(x))
#define WSWAPrbd(x) ((struct i596_rbd *)(x))
#define WSWAPiscp(x) ((struct i596_iscp *)(x))
#define WSWAPscb(x) ((struct i596_scb *)(x))
#define WSWAPcmd(x) ((struct i596_cmd *)(x))
#define WSWAPtbd(x) ((struct i596_tbd *)(x))
#define WSWAPchar(x) ((char *)(x))
#define ISCP_BUSY 0x0001
#define MACH_IS_APRICOT 1
#endif
/*
* The MPU_PORT command allows direct access to the 82596. With PORT access
* the following commands are available (p5-18). The 32-bit port command
* must be word-swapped with the most significant word written first.
* This only applies to VME boards.
*/
#define PORT_RESET 0x00 /* reset 82596 */
#define PORT_SELFTEST 0x01 /* selftest */
#define PORT_ALTSCP 0x02 /* alternate SCB address */
#define PORT_ALTDUMP 0x03 /* Alternate DUMP address */
static int i596_debug = (DEB_SERIOUS|DEB_PROBE);
MODULE_AUTHOR("Richard Hirst");
MODULE_DESCRIPTION("i82596 driver");
MODULE_LICENSE("GPL");
module_param(i596_debug, int, 0);
MODULE_PARM_DESC(i596_debug, "i8
|