Commit a866edc8 authored by Jeff Garzik's avatar Jeff Garzik

Merge new sun3 82586 net driver from 2.4.x.

parent d56ec794
......@@ -154,6 +154,7 @@ obj-$(CONFIG_DE600) += de600.o
obj-$(CONFIG_DE620) += de620.o
obj-$(CONFIG_AT1500) += lance.o
obj-$(CONFIG_LANCE) += lance.o
obj-$(CONFIG_SUN3_82586) += sun3_82586.o
obj-$(CONFIG_SUN3LANCE) += sun3lance.o
obj-$(CONFIG_DEFXX) += defxx.o
obj-$(CONFIG_SGISEEQ) += sgiseeq.o
......
......@@ -88,6 +88,7 @@ extern int smc_init( struct net_device * );
extern int sgiseeq_probe(struct net_device *);
extern int atarilance_probe(struct net_device *);
extern int sun3lance_probe(struct net_device *);
extern int sun3_82586_probe(struct net_device *);
extern int apne_probe(struct net_device *);
extern int bionet_probe(struct net_device *);
extern int pamsnet_probe(struct net_device *);
......@@ -334,6 +335,9 @@ static struct devprobe m68k_probes[] __initdata = {
#ifdef CONFIG_SUN3LANCE /* sun3 onboard Lance chip */
{sun3lance_probe, 0},
#endif
#ifdef CONFIG_SUN3_82586 /* sun3 onboard Intel 82586 chip */
{sun3_82586_probe, 0},
#endif
#ifdef CONFIG_APNE /* A1200 PCMCIA NE2000 */
{apne_probe, 0},
#endif
......
/*
* Sun3 i82586 Ethernet driver
*
* Cloned from ni52.c for the Sun3 by Sam Creasey (sammy@sammy.net)
*
* Original copyright follows:
* --------------------------
*
* net-3-driver for the NI5210 card (i82586 Ethernet chip)
*
* This is an extension to the Linux operating system, and is covered by the
* same Gnu Public License that covers that work.
*
* Alphacode 0.82 (96/09/29) for Linux 2.0.0 (or later)
* Copyrights (c) 1994,1995,1996 by M.Hipp (hippm@informatik.uni-tuebingen.de)
* --------------------------
*
* Consult ni52.c for further notes from the original driver.
*
* This incarnation currently supports the OBIO version of the i82586 chip
* used in certain sun3 models. It should be fairly doable to expand this
* to support VME if I should every acquire such a board.
*
*/
static int debuglevel = 0; /* debug-printk 0: off 1: a few 2: more */
static int automatic_resume = 0; /* experimental .. better should be zero */
static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
static int fifo=0x8; /* don't change */
/* #define REALLY_SLOW_IO */
#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/init.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/idprom.h>
#include <asm/machines.h>
#include <asm/sun3mmu.h>
#include <asm/dvma.h>
#include <asm/byteorder.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include "sun3_82586.h"
#define DEBUG /* debug on */
#define SYSBUSVAL 0 /* 16 Bit */
#define sun3_attn586() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_ATTEN; *(volatile unsigned char *)(dev->base_addr) &= ~IEOB_ATTEN;}
#define sun3_reset586() {*(volatile unsigned char *)(dev->base_addr) = 0; udelay(100); *(volatile unsigned char *)(dev->base_addr) = IEOB_NORSET;}
#define sun3_disint() {*(volatile unsigned char *)(dev->base_addr) &= ~IEOB_IENAB;}
#define sun3_enaint() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_IENAB;}
#define sun3_active() {*(volatile unsigned char *)(dev->base_addr) |= (IEOB_IENAB|IEOB_ONAIR|IEOB_NORSET);}
#define make32(ptr16) (p->memtop + (swab16((unsigned short) (ptr16))) )
#define make24(ptr32) (char *)swab32(( ((unsigned long) (ptr32)) - p->base))
#define make16(ptr32) (swab16((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )))
/******************* how to calculate the buffers *****************************
* IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
* --------------- in a different (more stable?) mode. Only in this mode it's
* possible to configure the driver with 'NO_NOPCOMMANDS'
sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
sizeof(rfd) = 24; sizeof(rbd) = 12;
sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
sizeof(nop_cmd) = 8;
* if you don't know the driver, better do not change these values: */
#define RECV_BUFF_SIZE 1536 /* slightly oversized */
#define XMIT_BUFF_SIZE 1536 /* slightly oversized */
#define NUM_XMIT_BUFFS 1 /* config for 32K shmem */
#define NUM_RECV_BUFFS_8 4 /* config for 32K shared mem */
#define NUM_RECV_BUFFS_16 9 /* config for 32K shared mem */
#define NUM_RECV_BUFFS_32 16 /* config for 32K shared mem */
#define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
/**************************************************************************/
/* different DELAYs */
#define DELAY(x) mdelay(32 * x);
#define DELAY_16(); { udelay(16); }
#define DELAY_18(); { udelay(4); }
/* wait for command with timeout: */
#define WAIT_4_SCB_CMD() \
{ int i; \
for(i=0;i<16384;i++) { \
if(!p->scb->cmd_cuc) break; \
DELAY_18(); \
if(i == 16383) { \
printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
#define WAIT_4_SCB_CMD_RUC() { int i; \
for(i=0;i<16384;i++) { \
if(!p->scb->cmd_ruc) break; \
DELAY_18(); \
if(i == 16383) { \
printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
#define WAIT_4_STAT_COMPL(addr) { int i; \
for(i=0;i<32767;i++) { \
if(swab16((addr)->cmd_status) & STAT_COMPL) break; \
DELAY_16(); DELAY_16(); } }
static int sun3_82586_probe1(struct net_device *dev,int ioaddr);
static void sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr);
static int sun3_82586_open(struct net_device *dev);
static int sun3_82586_close(struct net_device *dev);
static int sun3_82586_send_packet(struct sk_buff *,struct net_device *);
static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev);
static void set_multicast_list(struct net_device *dev);
static void sun3_82586_timeout(struct net_device *dev);
#if 0
static void sun3_82586_dump(struct net_device *,void *);
#endif
/* helper-functions */
static int init586(struct net_device *dev);
static int check586(struct net_device *dev,char *where,unsigned size);
static void alloc586(struct net_device *dev);
static void startrecv586(struct net_device *dev);
static void *alloc_rfa(struct net_device *dev,void *ptr);
static void sun3_82586_rcv_int(struct net_device *dev);
static void sun3_82586_xmt_int(struct net_device *dev);
static void sun3_82586_rnr_int(struct net_device *dev);
struct priv
{
struct net_device_stats stats;
unsigned long base;
char *memtop;
long int lock;
int reseted;
volatile struct rfd_struct *rfd_last,*rfd_top,*rfd_first;
volatile struct scp_struct *scp; /* volatile is important */
volatile struct iscp_struct *iscp; /* volatile is important */
volatile struct scb_struct *scb; /* volatile is important */
volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
#if (NUM_XMIT_BUFFS == 1)
volatile struct nop_cmd_struct *nop_cmds[2];
#else
volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
#endif
volatile int nop_point,num_recv_buffs;
volatile char *xmit_cbuffs[NUM_XMIT_BUFFS];
volatile int xmit_count,xmit_last;
};
/**********************************************
* close device
*/
static int sun3_82586_close(struct net_device *dev)
{
free_irq(dev->irq, dev);
sun3_reset586(); /* the hard way to stop the receiver */
netif_stop_queue(dev);
return 0;
}
/**********************************************
* open device
*/
static int sun3_82586_open(struct net_device *dev)
{
int ret;
sun3_disint();
alloc586(dev);
init586(dev);
startrecv586(dev);
sun3_enaint();
ret = request_irq(dev->irq, &sun3_82586_interrupt,0,dev->name,dev);
if (ret)
{
sun3_reset586();
return ret;
}
netif_start_queue(dev);
return 0; /* most done by init */
}
/**********************************************
* Check to see if there's an 82586 out there.
*/
static int check586(struct net_device *dev,char *where,unsigned size)
{
struct priv pb;
struct priv *p = /* (struct priv *) dev->priv*/ &pb;
char *iscp_addr;
int i;
p->base = (unsigned long) dvma_btov(0);
p->memtop = (char *)dvma_btov((unsigned long)where);
p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
memset((char *)p->scp,0, sizeof(struct scp_struct));
for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
if(((char *)p->scp)[i])
return 0;
p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */
if(p->scp->sysbus != SYSBUSVAL)
return 0;
iscp_addr = (char *)dvma_btov((unsigned long)where);
p->iscp = (struct iscp_struct *) iscp_addr;
memset((char *)p->iscp,0, sizeof(struct iscp_struct));
p->scp->iscp = make24(p->iscp);
p->iscp->busy = 1;
sun3_reset586();
sun3_attn586();
DELAY(1); /* wait a while... */
if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
return 0;
return 1;
}
/******************************************************************
* set iscp at the right place, called by sun3_82586_probe1 and open586.
*/
static void alloc586(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
sun3_reset586();
DELAY(1);
p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
p->iscp = (struct iscp_struct *) dvma_btov(dev->mem_start);
p->scb = (struct scb_struct *) ((char *)p->iscp + sizeof(struct iscp_struct));
memset((char *) p->iscp,0,sizeof(struct iscp_struct));
memset((char *) p->scp ,0,sizeof(struct scp_struct));
p->scp->iscp = make24(p->iscp);
p->scp->sysbus = SYSBUSVAL;
p->iscp->scb_offset = make16(p->scb);
p->iscp->scb_base = make24(dvma_btov(dev->mem_start));
p->iscp->busy = 1;
sun3_reset586();
sun3_attn586();
DELAY(1);
if(p->iscp->busy)
printk("%s: Init-Problems (alloc).\n",dev->name);
p->reseted = 0;
memset((char *)p->scb,0,sizeof(struct scb_struct));
}
int __init sun3_82586_probe(struct net_device *dev)
{
unsigned long ioaddr, iopte;
static int found = 0;
/* check that this machine has an onboard lance */
switch(idprom->id_machtype) {
case SM_SUN3|SM_3_160:
case SM_SUN3|SM_3_260:
/* these machines have lance */
break;
default:
return(-ENODEV);
}
if(found)
return -ENODEV;
for(ioaddr = 0xfe00000; ioaddr < (0xfe00000 +
SUN3_PMEG_SIZE); ioaddr += SUN3_PTE_SIZE) {
iopte = sun3_get_pte(ioaddr);
if(!(iopte & SUN3_PAGE_TYPE_IO)) /* this an io page? */
continue;
if(((iopte & SUN3_PAGE_PGNUM_MASK) << PAGE_SHIFT) ==
IE_OBIO) {
found = 1;
break;
}
}
if(!found)
return 0;
SET_MODULE_OWNER(dev);
dev->irq = IE_IRQ;
dev->base_addr = ioaddr;
if(sun3_82586_probe1(dev, ioaddr) == 0)
return 0;
return -ENODEV;
}
static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
{
int i, size, retval;
// if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, dev->name))
// return -EBUSY;
/* copy in the ethernet address from the prom */
for(i = 0; i < 6 ; i++)
dev->dev_addr[i] = idprom->id_ethaddr[i];
printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
/*
* check (or search) IO-Memory, 32K
*/
size = 0x8000;
dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
dev->mem_end = dev->mem_start + size;
if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->name,size);
retval = -ENODEV;
goto out;
}
if(!check586(dev,(char *) dev->mem_start,size)) {
printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
retval = -ENODEV;
goto out;
}
dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL);
if(dev->priv == NULL) {
printk("%s: Ooops .. can't allocate private driver memory.\n",dev->name);
retval = -ENOMEM;
goto out;
}
/* warning: we don't free it on errors */
memset((char *) dev->priv,0,sizeof(struct priv));
((struct priv *) (dev->priv))->memtop = (char *)dvma_btov(dev->mem_start);
((struct priv *) (dev->priv))->base = (unsigned long) dvma_btov(0);
alloc586(dev);
/* set number of receive-buffs according to memsize */
if(size == 0x2000)
((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
else if(size == 0x4000)
((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;
else
((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_32;
printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
dev->open = sun3_82586_open;
dev->stop = sun3_82586_close;
dev->get_stats = sun3_82586_get_stats;
dev->tx_timeout = sun3_82586_timeout;
dev->watchdog_timeo = HZ/20;
dev->hard_start_xmit = sun3_82586_send_packet;
dev->set_multicast_list = set_multicast_list;
dev->if_port = 0;
ether_setup(dev);
return 0;
out:
return retval;
}
static int init586(struct net_device *dev)
{
void *ptr;
int i,result=0;
struct priv *p = (struct priv *) dev->priv;
volatile struct configure_cmd_struct *cfg_cmd;
volatile struct iasetup_cmd_struct *ias_cmd;
volatile struct tdr_cmd_struct *tdr_cmd;
volatile struct mcsetup_cmd_struct *mc_cmd;
struct dev_mc_list *dmi=dev->mc_list;
int num_addrs=dev->mc_count;
ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
cfg_cmd->cmd_status = 0;
cfg_cmd->cmd_cmd = swab16(CMD_CONFIGURE | CMD_LAST);
cfg_cmd->cmd_link = 0xffff;
cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */
cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */
cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */
cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
cfg_cmd->priority = 0x00;
cfg_cmd->ifs = 0x60;
cfg_cmd->time_low = 0x00;
cfg_cmd->time_high = 0xf2;
cfg_cmd->promisc = 0;
if(dev->flags & IFF_ALLMULTI) {
int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
if(num_addrs > len) {
printk("%s: switching to promisc. mode\n",dev->name);
dev->flags|=IFF_PROMISC;
}
}
if(dev->flags&IFF_PROMISC)
{
cfg_cmd->promisc=1;
dev->flags|=IFF_PROMISC;
}
cfg_cmd->carr_coll = 0x00;
p->scb->cbl_offset = make16(cfg_cmd);
p->scb->cmd_ruc = 0;
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
sun3_attn586();
WAIT_4_STAT_COMPL(cfg_cmd);
if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
{
printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status));
return 1;
}
/*
* individual address setup
*/
ias_cmd = (struct iasetup_cmd_struct *)ptr;
ias_cmd->cmd_status = 0;
ias_cmd->cmd_cmd = swab16(CMD_IASETUP | CMD_LAST);
ias_cmd->cmd_link = 0xffff;
memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
p->scb->cbl_offset = make16(ias_cmd);
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
sun3_attn586();
WAIT_4_STAT_COMPL(ias_cmd);
if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status));
return 1;
}
/*
* TDR, wire check .. e.g. no resistor e.t.c
*/
tdr_cmd = (struct tdr_cmd_struct *)ptr;
tdr_cmd->cmd_status = 0;
tdr_cmd->cmd_cmd = swab16(CMD_TDR | CMD_LAST);
tdr_cmd->cmd_link = 0xffff;
tdr_cmd->status = 0;
p->scb->cbl_offset = make16(tdr_cmd);
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
sun3_attn586();
WAIT_4_STAT_COMPL(tdr_cmd);
if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL))
{
printk("%s: Problems while running the TDR.\n",dev->name);
}
else
{
DELAY_16(); /* wait for result */
result = swab16(tdr_cmd->status);
p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
sun3_attn586(); /* ack the interrupts */
if(result & TDR_LNK_OK)
;
else if(result & TDR_XCVR_PRB)
printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
else if(result & TDR_ET_OPN)
printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
else if(result & TDR_ET_SRT)
{
if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
}
else
printk("%s: TDR: Unknown status %04x\n",dev->name,result);
}
/*
* Multicast setup
*/
if(num_addrs && !(dev->flags & IFF_PROMISC) )
{
mc_cmd = (struct mcsetup_cmd_struct *) ptr;
mc_cmd->cmd_status = 0;
mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST);
mc_cmd->cmd_link = 0xffff;
mc_cmd->mc_cnt = swab16(num_addrs * 6);
for(i=0;i<num_addrs;i++,dmi=dmi->next)
memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6);
p->scb->cbl_offset = make16(mc_cmd);
p->scb->cmd_cuc = CUC_START;
sun3_attn586();
WAIT_4_STAT_COMPL(mc_cmd);
if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
printk("%s: Can't apply multicast-address-list.\n",dev->name);
}
/*
* alloc nop/xmit-cmds
*/
#if (NUM_XMIT_BUFFS == 1)
for(i=0;i<2;i++)
{
p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
p->nop_cmds[i]->cmd_status = 0;
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
}
#else
for(i=0;i<NUM_XMIT_BUFFS;i++)
{
p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
p->nop_cmds[i]->cmd_status = 0;
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
}
#endif
ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */
/*
* alloc xmit-buffs / init xmit_cmds
*/
for(i=0;i<NUM_XMIT_BUFFS;i++)
{
p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
ptr = (char *) ptr + XMIT_BUFF_SIZE;
p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
ptr = (char *) ptr + sizeof(struct tbd_struct);
if((void *)ptr > (void *)dev->mem_end)
{
printk("%s: not enough shared-mem for your configuration!\n",dev->name);
return 1;
}
memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL);
p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
p->xmit_buffs[i]->next = 0xffff;
p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
}
p->xmit_count = 0;
p->xmit_last = 0;
#ifndef NO_NOPCOMMANDS
p->nop_point = 0;
#endif
/*
* 'start transmitter'
*/
#ifndef NO_NOPCOMMANDS
p->scb->cbl_offset = make16(p->nop_cmds[0]);
p->scb->cmd_cuc = CUC_START;
sun3_attn586();
WAIT_4_SCB_CMD();
#else
p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
p->xmit_cmds[0]->cmd_cmd = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT);
#endif
/*
* ack. interrupts
*/
p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
sun3_attn586();
DELAY_16();
sun3_enaint();
sun3_active();
return 0;
}
/******************************************************
* This is a helper routine for sun3_82586_rnr_int() and init586().
* It sets up the Receive Frame Area (RFA).
*/
static void *alloc_rfa(struct net_device *dev,void *ptr)
{
volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
volatile struct rbd_struct *rbd;
int i;
struct priv *p = (struct priv *) dev->priv;
memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
p->rfd_first = rfd;
for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
rfd[i].rbd_offset = 0xffff;
}
rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP; /* RU suspend */
ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
rbd = (struct rbd_struct *) ptr;
ptr = (void *) (rbd + p->num_recv_buffs);
/* clr descriptors */
memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
for(i=0;i<p->num_recv_buffs;i++)
{
rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
rbd[i].size = swab16(RECV_BUFF_SIZE);
rbd[i].buffer = make24(ptr);
ptr = (char *) ptr + RECV_BUFF_SIZE;
}
p->rfd_top = p->rfd_first;
p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
p->scb->rfa_offset = make16(p->rfd_first);
p->rfd_first->rbd_offset = make16(rbd);
return ptr;
}
/**************************************************
* Interrupt Handler ...
*/
static void sun3_82586_interrupt(int irq,void *dev_id,struct pt_regs *reg_ptr)
{
struct net_device *dev = dev_id;
unsigned short stat;
int cnt=0;
struct priv *p;
if (!dev) {
printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
return;
}
p = (struct priv *) dev->priv;
if(debuglevel > 1)
printk("I");
WAIT_4_SCB_CMD(); /* wait for last command */
while((stat=p->scb->cus & STAT_MASK))
{
p->scb->cmd_cuc = stat;
sun3_attn586();
if(stat & STAT_FR) /* received a frame */
sun3_82586_rcv_int(dev);
if(stat & STAT_RNR) /* RU went 'not ready' */
{
printk("(R)");
if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
{
WAIT_4_SCB_CMD();
p->scb->cmd_ruc = RUC_RESUME;
sun3_attn586();
WAIT_4_SCB_CMD_RUC();
}
else
{
printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
sun3_82586_rnr_int(dev);
}
}
if(stat & STAT_CX) /* command with I-bit set complete */
sun3_82586_xmt_int(dev);
#ifndef NO_NOPCOMMANDS
if(stat & STAT_CNA) /* CU went 'not ready' */
{
if(netif_running(dev))
printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
}
#endif
if(debuglevel > 1)
printk("%d",cnt++);
WAIT_4_SCB_CMD(); /* wait for ack. (sun3_82586_xmt_int can be faster than ack!!) */
if(p->scb->cmd_cuc) /* timed out? */
{
printk("%s: Acknowledge timed out.\n",dev->name);
sun3_disint();
break;
}
}
if(debuglevel > 1)
printk("i");
}
/*******************************************************
* receive-interrupt
*/
static void sun3_82586_rcv_int(struct net_device *dev)
{
int status,cnt=0;
unsigned short totlen;
struct sk_buff *skb;
struct rbd_struct *rbd;
struct priv *p = (struct priv *) dev->priv;
if(debuglevel > 0)
printk("R");
for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
{
rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
if(status & RFD_OK) /* frame received without error? */
{
if( (totlen = swab16(rbd->status)) & RBD_LAST) /* the first and the last buffer? */
{
totlen &= RBD_MASK; /* length of this frame */
rbd->status = 0;
skb = (struct sk_buff *) dev_alloc_skb(totlen+2);
if(skb != NULL)
{
skb->dev = dev;
skb_reserve(skb,2);
skb_put(skb,totlen);
eth_copy_and_sum(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen,0);
skb->protocol=eth_type_trans(skb,dev);
netif_rx(skb);
p->stats.rx_packets++;
}
else
p->stats.rx_dropped++;
}
else
{
int rstat;
/* free all RBD's until RBD_LAST is set */
totlen = 0;
while(!((rstat=swab16(rbd->status)) & RBD_LAST))
{
totlen += rstat & RBD_MASK;
if(!rstat)
{
printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
break;
}
rbd->status = 0;
rbd = (struct rbd_struct *) make32(rbd->next);
}
totlen += rstat & RBD_MASK;
rbd->status = 0;
printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
p->stats.rx_dropped++;
}
}
else /* frame !(ok), only with 'save-bad-frames' */
{
printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
p->stats.rx_errors++;
}
p->rfd_top->stat_high = 0;
p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
p->rfd_top->rbd_offset = 0xffff;
p->rfd_last->last = 0; /* delete RFD_SUSP */
p->rfd_last = p->rfd_top;
p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
p->scb->rfa_offset = make16(p->rfd_top);
if(debuglevel > 0)
printk("%d",cnt++);
}
if(automatic_resume)
{
WAIT_4_SCB_CMD();
p->scb->cmd_ruc = RUC_RESUME;
sun3_attn586();
WAIT_4_SCB_CMD_RUC();
}
#ifdef WAIT_4_BUSY
{
int i;
for(i=0;i<1024;i++)
{
if(p->rfd_top->status)
break;
DELAY_16();
if(i == 1023)
printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
}
}
#endif
#if 0
if(!at_least_one)
{
int i;
volatile struct rfd_struct *rfds=p->rfd_top;
volatile struct rbd_struct *rbds;
printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
for(i=0;i< (p->num_recv_buffs+4);i++)
{
rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
printk("%04x:%04x ",rfds->status,rbds->status);
rfds = (struct rfd_struct *) make32(rfds->next);
}
printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
}
old_at_least = at_least_one;
#endif
if(debuglevel > 0)
printk("r");
}
/**********************************************************
* handle 'Receiver went not ready'.
*/
static void sun3_82586_rnr_int(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
p->stats.rx_errors++;
WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */
p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
sun3_attn586();
WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */
alloc_rfa(dev,(char *)p->rfd_first);
/* maybe add a check here, before restarting the RU */
startrecv586(dev); /* restart RU */
printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
}
/**********************************************************
* handle xmit - interrupt
*/
static void sun3_82586_xmt_int(struct net_device *dev)
{
int status;
struct priv *p = (struct priv *) dev->priv;
if(debuglevel > 0)
printk("X");
status = swab16(p->xmit_cmds[p->xmit_last]->cmd_status);
if(!(status & STAT_COMPL))
printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
if(status & STAT_OK)
{
p->stats.tx_packets++;
p->stats.collisions += (status & TCMD_MAXCOLLMASK);
}
else
{
p->stats.tx_errors++;
if(status & TCMD_LATECOLL) {
printk("%s: late collision detected.\n",dev->name);
p->stats.collisions++;
}
else if(status & TCMD_NOCARRIER) {
p->stats.tx_carrier_errors++;
printk("%s: no carrier detected.\n",dev->name);
}
else if(status & TCMD_LOSTCTS)
printk("%s: loss of CTS detected.\n",dev->name);
else if(status & TCMD_UNDERRUN) {
p->stats.tx_fifo_errors++;
printk("%s: DMA underrun detected.\n",dev->name);
}
else if(status & TCMD_MAXCOLL) {
printk("%s: Max. collisions exceeded.\n",dev->name);
p->stats.collisions += 16;
}
}
#if (NUM_XMIT_BUFFS > 1)
if( (++p->xmit_last) == NUM_XMIT_BUFFS)
p->xmit_last = 0;
#endif
netif_wake_queue(dev);
}
/***********************************************************
* (re)start the receiver
*/
static void startrecv586(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
WAIT_4_SCB_CMD();
WAIT_4_SCB_CMD_RUC();
p->scb->rfa_offset = make16(p->rfd_first);
p->scb->cmd_ruc = RUC_START;
sun3_attn586(); /* start cmd. */
WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. (no timeout!!) */
}
static void sun3_82586_timeout(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
#ifndef NO_NOPCOMMANDS
if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
{
netif_wake_queue(dev);
#ifdef DEBUG
printk("%s: strange ... timeout with CU active?!?\n",dev->name);
printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)swab16(p->xmit_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[1]->cmd_status),(int)p->nop_point);
#endif
p->scb->cmd_cuc = CUC_ABORT;
sun3_attn586();
WAIT_4_SCB_CMD();
p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
p->scb->cmd_cuc = CUC_START;
sun3_attn586();
WAIT_4_SCB_CMD();
dev->trans_start = jiffies;
return 0;
}
#endif
{
#ifdef DEBUG
printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
printk("%s: check, whether you set the right interrupt number!\n",dev->name);
#endif
sun3_82586_close(dev);
sun3_82586_open(dev);
}
dev->trans_start = jiffies;
}
/******************************************************
* send frame
*/
static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
{
int len,i;
#ifndef NO_NOPCOMMANDS
int next_nop;
#endif
struct priv *p = (struct priv *) dev->priv;
if(skb->len > XMIT_BUFF_SIZE)
{
printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
return 0;
}
netif_stop_queue(dev);
#if(NUM_XMIT_BUFFS > 1)
if(test_and_set_bit(0,(void *) &p->lock)) {
printk("%s: Queue was locked\n",dev->name);
return 1;
}
else
#endif
{
memcpy((char *)p->xmit_cbuffs[p->xmit_count],(char *)(skb->data),skb->len);
len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
#if (NUM_XMIT_BUFFS == 1)
# ifdef NO_NOPCOMMANDS
#ifdef DEBUG
if(p->scb->cus & CU_ACTIVE)
{
printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,swab16(p->xmit_cmds[0]->cmd_status));
}
#endif
p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
for(i=0;i<16;i++)
{
p->xmit_cmds[0]->cmd_status = 0;
WAIT_4_SCB_CMD();
if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
p->scb->cmd_cuc = CUC_RESUME;
else
{
p->scb->cbl_offset = make16(p->xmit_cmds[0]);
p->scb->cmd_cuc = CUC_START;
}
sun3_attn586();
dev->trans_start = jiffies;
if(!i)
dev_kfree_skb(skb);
WAIT_4_SCB_CMD();
if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
break;
if(p->xmit_cmds[0]->cmd_status)
break;
if(i==15)
printk("%s: Can't start transmit-command.\n",dev->name);
}
# else
next_nop = (p->nop_point + 1) & 0x1;
p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
= make16((p->nop_cmds[next_nop]));
p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
dev->trans_start = jiffies;
p->nop_point = next_nop;
dev_kfree_skb(skb);
# endif
#else
p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
next_nop = 0;
p->xmit_cmds[p->xmit_count]->cmd_status = 0;
/* linkpointer of xmit-command already points to next nop cmd */
p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
p->nop_cmds[next_nop]->cmd_status = 0;
p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
dev->trans_start = jiffies;
p->xmit_count = next_nop;
{
unsigned long flags;
save_flags(flags);
cli();
if(p->xmit_count != p->xmit_last)
netif_wake_queue(dev);
p->lock = 0;
restore_flags(flags);
}
dev_kfree_skb(skb);
#endif
}
return 0;
}
/*******************************************
* Someone wanna have the statistics
*/
static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
unsigned short crc,aln,rsc,ovrn;
crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
p->scb->crc_errs = 0;
aln = swab16(p->scb->aln_errs);
p->scb->aln_errs = 0;
rsc = swab16(p->scb->rsc_errs);
p->scb->rsc_errs = 0;
ovrn = swab16(p->scb->ovrn_errs);
p->scb->ovrn_errs = 0;
p->stats.rx_crc_errors += crc;
p->stats.rx_fifo_errors += ovrn;
p->stats.rx_frame_errors += aln;
p->stats.rx_dropped += rsc;
return &p->stats;
}
/********************************************************
* Set MC list ..
*/
static void set_multicast_list(struct net_device *dev)
{
netif_stop_queue(dev);
sun3_disint();
alloc586(dev);
init586(dev);
startrecv586(dev);
sun3_enaint();
netif_wake_queue(dev);
}
#ifdef MODULE
#error This code is not currently supported as a module
static struct net_device dev_sun3_82586;
int init_module(void)
{
dev_sun3_82586.init = sun3_82586_probe;
if (register_netdev(&dev_sun3_82586) != 0)
return -EIO;
return 0;
}
void cleanup_module(void)
{
unregister_netdev(&dev_sun3_82586);
kfree(dev_sun3_82586.priv);
dev_sun3_82586.priv = NULL;
}
#endif /* MODULE */
#if 0
/*
* DUMP .. we expect a not running CMD unit and enough space
*/
void sun3_82586_dump(struct net_device *dev,void *ptr)
{
struct priv *p = (struct priv *) dev->priv;
struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
int i;
p->scb->cmd_cuc = CUC_ABORT;
sun3_attn586();
WAIT_4_SCB_CMD();
WAIT_4_SCB_CMD_RUC();
dump_cmd->cmd_status = 0;
dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
dump_cmd->dump_offset = make16((dump_cmd + 1));
dump_cmd->cmd_link = 0xffff;
p->scb->cbl_offset = make16(dump_cmd);
p->scb->cmd_cuc = CUC_START;
sun3_attn586();
WAIT_4_STAT_COMPL(dump_cmd);
if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
printk("%s: Can't get dump information.\n",dev->name);
for(i=0;i<170;i++) {
printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
if(i % 24 == 23)
printk("\n");
}
printk("\n");
}
#endif
MODULE_LICENSE("GPL");
/*
* Intel i82586 Ethernet definitions
*
* This is an extension to the Linux operating system, and is covered by the
* same Gnu Public License that covers that work.
*
* copyrights (c) 1994 by Michael Hipp (hippm@informatik.uni-tuebingen.de)
*
* I have done a look in the following sources:
* crynwr-packet-driver by Russ Nelson
* Garret A. Wollman's i82586-driver for BSD
*/
/*
* Cloned from ni52.h, copyright as above.
*
* Modified for Sun3 OBIO i82586 by Sam Creasey (sammy@sammy.net)
*/
/* defines for the obio chip (not vme) */
#define IEOB_NORSET 0x80 /* don't reset the board */
#define IEOB_ONAIR 0x40 /* put us on the air */
#define IEOB_ATTEN 0x20 /* attention! */
#define IEOB_IENAB 0x10 /* interrupt enable */
#define IEOB_XXXXX 0x08 /* free bit */
#define IEOB_XCVRL2 0x04 /* level 2 transceiver? */
#define IEOB_BUSERR 0x02 /* bus error */
#define IEOB_INT 0x01 /* interrupt */
/* where the obio one lives */
#define IE_OBIO 0xc0000
#define IE_IRQ 3
/*
* where to find the System Configuration Pointer (SCP)
*/
#define SCP_DEFAULT_ADDRESS 0xfffff4
/*
* System Configuration Pointer Struct
*/
struct scp_struct
{
unsigned short zero_dum0; /* has to be zero */
unsigned char sysbus; /* 0=16Bit,1=8Bit */
unsigned char zero_dum1; /* has to be zero for 586 */
unsigned short zero_dum2;
unsigned short zero_dum3;
char *iscp; /* pointer to the iscp-block */
};
/*
* Intermediate System Configuration Pointer (ISCP)
*/
struct iscp_struct
{
unsigned char busy; /* 586 clears after successful init */
unsigned char zero_dummy; /* has to be zero */
unsigned short scb_offset; /* pointeroffset to the scb_base */
char *scb_base; /* base-address of all 16-bit offsets */
};
/*
* System Control Block (SCB)
*/
struct scb_struct
{
unsigned char rus;
unsigned char cus;
unsigned char cmd_ruc; /* command word: RU part */
unsigned char cmd_cuc; /* command word: CU part & ACK */
unsigned short cbl_offset; /* pointeroffset, command block list */
unsigned short rfa_offset; /* pointeroffset, receive frame area */
unsigned short crc_errs; /* CRC-Error counter */
unsigned short aln_errs; /* allignmenterror counter */
unsigned short rsc_errs; /* Resourceerror counter */
unsigned short ovrn_errs; /* OVerrunerror counter */
};
/*
* possible command values for the command word
*/
#define RUC_MASK 0x0070 /* mask for RU commands */
#define RUC_NOP 0x0000 /* NOP-command */
#define RUC_START 0x0010 /* start RU */
#define RUC_RESUME 0x0020 /* resume RU after suspend */
#define RUC_SUSPEND 0x0030 /* suspend RU */
#define RUC_ABORT 0x0040 /* abort receiver operation immediately */
#define CUC_MASK 0x07 /* mask for CU command */
#define CUC_NOP 0x00 /* NOP-command */
#define CUC_START 0x01 /* start execution of 1. cmd on the CBL */
#define CUC_RESUME 0x02 /* resume after suspend */
#define CUC_SUSPEND 0x03 /* Suspend CU */
#define CUC_ABORT 0x04 /* abort command operation immediately */
#define ACK_MASK 0xf0 /* mask for ACK command */
#define ACK_CX 0x80 /* acknowledges STAT_CX */
#define ACK_FR 0x40 /* ack. STAT_FR */
#define ACK_CNA 0x20 /* ack. STAT_CNA */
#define ACK_RNR 0x10 /* ack. STAT_RNR */
/*
* possible status values for the status word
*/
#define STAT_MASK 0xf0 /* mask for cause of interrupt */
#define STAT_CX 0x80 /* CU finished cmd with its I bit set */
#define STAT_FR 0x40 /* RU finished receiving a frame */
#define STAT_CNA 0x20 /* CU left active state */
#define STAT_RNR 0x10 /* RU left ready state */
#define CU_STATUS 0x7 /* CU status, 0=idle */
#define CU_SUSPEND 0x1 /* CU is suspended */
#define CU_ACTIVE 0x2 /* CU is active */
#define RU_STATUS 0x70 /* RU status, 0=idle */
#define RU_SUSPEND 0x10 /* RU suspended */
#define RU_NOSPACE 0x20 /* RU no resources */
#define RU_READY 0x40 /* RU is ready */
/*
* Receive Frame Descriptor (RFD)
*/
struct rfd_struct
{
unsigned char stat_low; /* status word */
unsigned char stat_high; /* status word */
unsigned char rfd_sf; /* 82596 mode only */
unsigned char last; /* Bit15,Last Frame on List / Bit14,suspend */
unsigned short next; /* linkoffset to next RFD */
unsigned short rbd_offset; /* pointeroffset to RBD-buffer */
unsigned char dest[6]; /* ethernet-address, destination */
unsigned char source[6]; /* ethernet-address, source */
unsigned short length; /* 802.3 frame-length */
unsigned short zero_dummy; /* dummy */
};
#define RFD_LAST 0x80 /* last: last rfd in the list */
#define RFD_SUSP 0x40 /* last: suspend RU after */
#define RFD_COMPL 0x80
#define RFD_OK 0x20
#define RFD_BUSY 0x40
#define RFD_ERR_LEN 0x10 /* Length error (if enabled length-checking */
#define RFD_ERR_CRC 0x08 /* CRC error */
#define RFD_ERR_ALGN 0x04 /* Alignment error */
#define RFD_ERR_RNR 0x02 /* status: receiver out of resources */
#define RFD_ERR_OVR 0x01 /* DMA Overrun! */
#define RFD_ERR_FTS 0x0080 /* Frame to short */
#define RFD_ERR_NEOP 0x0040 /* No EOP flag (for bitstuffing only) */
#define RFD_ERR_TRUN 0x0020 /* (82596 only/SF mode) indicates truncated frame */
#define RFD_MATCHADD 0x0002 /* status: Destinationaddress !matches IA (only 82596) */
#define RFD_COLLDET 0x0001 /* Detected collision during reception */
/*
* Receive Buffer Descriptor (RBD)
*/
struct rbd_struct
{
unsigned short status; /* status word,number of used bytes in buff */
unsigned short next; /* pointeroffset to next RBD */
char *buffer; /* receive buffer address pointer */
unsigned short size; /* size of this buffer */
unsigned short zero_dummy; /* dummy */
};
#define RBD_LAST 0x8000 /* last buffer */
#define RBD_USED 0x4000 /* this buffer has data */
#define RBD_MASK 0x3fff /* size-mask for length */
/*
* Statusvalues for Commands/RFD
*/
#define STAT_COMPL 0x8000 /* status: frame/command is complete */
#define STAT_BUSY 0x4000 /* status: frame/command is busy */
#define STAT_OK 0x2000 /* status: frame/command is ok */
/*
* Action-Commands
*/
#define CMD_NOP 0x0000 /* NOP */
#define CMD_IASETUP 0x0001 /* initial address setup command */
#define CMD_CONFIGURE 0x0002 /* configure command */
#define CMD_MCSETUP 0x0003 /* MC setup command */
#define CMD_XMIT 0x0004 /* transmit command */
#define CMD_TDR 0x0005 /* time domain reflectometer (TDR) command */
#define CMD_DUMP 0x0006 /* dump command */
#define CMD_DIAGNOSE 0x0007 /* diagnose command */
/*
* Action command bits
*/
#define CMD_LAST 0x8000 /* indicates last command in the CBL */
#define CMD_SUSPEND 0x4000 /* suspend CU after this CB */
#define CMD_INT 0x2000 /* generate interrupt after execution */
/*
* NOP - command
*/
struct nop_cmd_struct
{
unsigned short cmd_status; /* status of this command */
unsigned short cmd_cmd; /* the command itself (+bits) */
unsigned short cmd_link; /* offsetpointer to next command */
};
/*
* IA Setup command
*/
struct iasetup_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned char iaddr[6];
};
/*
* Configure command
*/
struct configure_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned char byte_cnt; /* size of the config-cmd */
unsigned char fifo; /* fifo/recv monitor */
unsigned char sav_bf; /* save bad frames (bit7=1)*/
unsigned char adr_len; /* adr_len(0-2),al_loc(3),pream(4-5),loopbak(6-7)*/
unsigned char priority; /* lin_prio(0-2),exp_prio(4-6),bof_metd(7) */
unsigned char ifs; /* inter frame spacing */
unsigned char time_low; /* slot time low */
unsigned char time_high; /* slot time high(0-2) and max. retries(4-7) */
unsigned char promisc; /* promisc-mode(0) , et al (1-7) */
unsigned char carr_coll; /* carrier(0-3)/collision(4-7) stuff */
unsigned char fram_len; /* minimal frame len */
unsigned char dummy; /* dummy */
};
/*
* Multicast Setup command
*/
struct mcsetup_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned short mc_cnt; /* number of bytes in the MC-List */
unsigned char mc_list[0][6]; /* pointer to 6 bytes entries */
};
/*
* DUMP command
*/
struct dump_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned short dump_offset; /* pointeroffset to DUMP space */
};
/*
* transmit command
*/
struct transmit_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned short tbd_offset; /* pointeroffset to TBD */
unsigned char dest[6]; /* destination address of the frame */
unsigned short length; /* user defined: 802.3 length / Ether type */
};
#define TCMD_ERRMASK 0x0fa0
#define TCMD_MAXCOLLMASK 0x000f
#define TCMD_MAXCOLL 0x0020
#define TCMD_HEARTBEAT 0x0040
#define TCMD_DEFERRED 0x0080
#define TCMD_UNDERRUN 0x0100
#define TCMD_LOSTCTS 0x0200
#define TCMD_NOCARRIER 0x0400
#define TCMD_LATECOLL 0x0800
struct tdr_cmd_struct
{
unsigned short cmd_status;
unsigned short cmd_cmd;
unsigned short cmd_link;
unsigned short status;
};
#define TDR_LNK_OK 0x8000 /* No link problem identified */
#define TDR_XCVR_PRB 0x4000 /* indicates a transceiver problem */
#define TDR_ET_OPN 0x2000 /* open, no correct termination */
#define TDR_ET_SRT 0x1000 /* TDR detected a short circuit */
#define TDR_TIMEMASK 0x07ff /* mask for the time field */
/*
* Transmit Buffer Descriptor (TBD)
*/
struct tbd_struct
{
unsigned short size; /* size + EOF-Flag(15) */
unsigned short next; /* pointeroffset to next TBD */
char *buffer; /* pointer to buffer */
};
#define TBD_LAST 0x8000 /* EOF-Flag, indicates last buffer in list */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment