/* SPDX-License-Identifier: GPL-2.0 */ /* * 7990.h -- LANCE ethernet IC generic routines. * This is an attempt to separate out the bits of various ethernet * drivers that are common because they all use the AMD 7990 LANCE * (Local Area Network Controller for Ethernet) chip. * * Copyright (C) 05/1998 Peter Maydell <pmaydell@chiark.greenend.org.uk> * * Most of this stuff was obtained by looking at other LANCE drivers, * in particular a2065.[ch]. The AMD C-LANCE datasheet was also helpful.
*/
#ifndef _7990_H #define _7990_H
/* The lance only has two register locations. We communicate mostly via memory. */ #define LANCE_RDP 0 /* Register Data Port */ #define LANCE_RAP 2 /* Register Address Port */
/* Transmit/receive ring definitions. * We allow the specific drivers to override these defaults if they want to. * NB: according to lance.c, increasing the number of buffers is a waste * of space and reduces the chance that an upper layer will be able to * reorder queued Tx packets based on priority. [Clearly there is a minimum * limit too: too small and we drop rx packets and can't tx at full speed.] * 4+4 seems to be the usual setting; the atarilance driver uses 3 and 5.
*/
/* Blast! This won't work. The problem is that we can't specify a default * setting because that would cause the lance_init_block struct to be * too long (and overflow the RAM on shared-memory cards like the HP LANCE.
*/ #ifndef LANCE_LOG_TX_BUFFERS #define LANCE_LOG_TX_BUFFERS 1 #define LANCE_LOG_RX_BUFFERS 3 #endif
/* Each receive buffer is described by a receive message descriptor (RMD) */ struct lance_rx_desc { volatileunsignedshort rmd0; /* low address of packet */ volatileunsignedchar rmd1_bits; /* descriptor bits */ volatileunsignedchar rmd1_hadr; /* high address of packet */ volatileshort length; /* This length is 2s complement (negative)!
* Buffer length */ volatileunsignedshort mblength; /* Actual number of bytes received */
};
/* Ditto for TMD: */ struct lance_tx_desc { volatileunsignedshort tmd0; /* low address of packet */ volatileunsignedchar tmd1_bits; /* descriptor bits */ volatileunsignedchar tmd1_hadr; /* high address of packet */ volatileshort length; /* Length is 2s complement (negative)! */ volatileunsignedshort misc;
};
/* There are three memory structures accessed by the LANCE: * the initialization block, the receive and transmit descriptor rings, * and the data buffers themselves. In fact we might as well put the * init block,the Tx and Rx rings and the buffers together in memory:
*/ struct lance_init_block { volatileunsignedshort mode; /* Pre-set mode (reg. 15) */ volatileunsignedchar phys_addr[6]; /* Physical ethernet address */ volatileunsigned filter[2]; /* Multicast filter (64 bits) */
/* Receive and transmit ring base, along with extra bits. */ volatileunsignedshort rx_ptr; /* receive descriptor addr */ volatileunsignedshort rx_len; /* receive len and high addr */ volatileunsignedshort tx_ptr; /* transmit descriptor addr */ volatileunsignedshort tx_len; /* transmit len and high addr */
/* The Tx and Rx ring entries must be aligned on 8-byte boundaries. * This will be true if this whole struct is 8-byte aligned.
*/ volatilestruct lance_tx_desc btx_ring[TX_RING_SIZE]; volatilestruct lance_rx_desc brx_ring[RX_RING_SIZE];
volatilechar tx_buf[TX_RING_SIZE][TX_BUFF_SIZE]; volatilechar rx_buf[RX_RING_SIZE][RX_BUFF_SIZE]; /* we use this just to make the struct big enough that we can move its startaddr * in order to force alignment to an eight byte boundary.
*/
};
/* This is where we keep all the stuff the driver needs to know about. * I'm definitely unhappy about the mechanism for allowing specific * drivers to add things...
*/ struct lance_private { constchar *name; unsignedlong base; volatilestruct lance_init_block *init_block; /* CPU address of RAM */ volatilestruct lance_init_block *lance_init_block; /* LANCE address of RAM */
int rx_new, tx_new; int rx_old, tx_old;
int lance_log_rx_bufs, lance_log_tx_bufs; int rx_ring_mod_mask, tx_ring_mod_mask;
int tpe; /* TPE is selected */ int auto_select; /* cable-selection is by carrier */ unsignedshort busmaster_regval;
unsignedint irq; /* IRQ to register */
/* This is because the HP LANCE is disgusting and you have to check * a DIO-specific register every time you read/write the LANCE regs :-< * [could we get away with making these some sort of macro?]
*/ void (*writerap)(void *, unsignedshort); void (*writerdp)(void *, unsignedshort); unsignedshort (*readrdp)(void *);
spinlock_t devlock; char tx_full;
};
/* * Am7990 Control and Status Registers
*/ #define LE_CSR0 0x0000 /* LANCE Controller Status */ #define LE_CSR1 0x0001 /* IADR[15:0] (bit0==0 ie word aligned) */ #define LE_CSR2 0x0002 /* IADR[23:16] (high bits reserved) */ #define LE_CSR3 0x0003 /* Misc */
/* * Bit definitions for CSR0 (LANCE Controller Status)
*/ #define LE_C0_ERR 0x8000 /* Error = BABL | CERR | MISS | MERR */ #define LE_C0_BABL 0x4000 /* Babble: Transmitted too many bits */ #define LE_C0_CERR 0x2000 /* No Heartbeat (10BASE-T) */ #define LE_C0_MISS 0x1000 /* Missed Frame (no rx buffer to put it in) */ #define LE_C0_MERR 0x0800 /* Memory Error */ #define LE_C0_RINT 0x0400 /* Receive Interrupt */ #define LE_C0_TINT 0x0200 /* Transmit Interrupt */ #define LE_C0_IDON 0x0100 /* Initialization Done */ #define LE_C0_INTR 0x0080 /* Interrupt Flag
= BABL | MISS | MERR | RINT | TINT | IDON */ #define LE_C0_INEA 0x0040 /* Interrupt Enable */ #define LE_C0_RXON 0x0020 /* Receive On */ #define LE_C0_TXON 0x0010 /* Transmit On */ #define LE_C0_TDMD 0x0008 /* Transmit Demand */ #define LE_C0_STOP 0x0004 /* Stop */ #define LE_C0_STRT 0x0002 /* Start */ #define LE_C0_INIT 0x0001 /* Initialize */
/* * Bit definitions for CSR3
*/ #define LE_C3_BSWP 0x0004 /* Byte Swap (on for big endian byte order) */ #define LE_C3_ACON 0x0002 /* ALE Control (on for active low ALE) */ #define LE_C3_BCON 0x0001 /* Byte Control */
/* * Mode Flags
*/ #define LE_MO_PROM 0x8000 /* Promiscuous Mode */ /* these next ones 0x4000 -- 0x0080 are not available on the LANCE 7990, * but they are in NetBSD's am7990.h, presumably for backwards-compatible chips
*/ #define LE_MO_DRCVBC 0x4000 /* disable receive broadcast */ #define LE_MO_DRCVPA 0x2000 /* disable physical address detection */ #define LE_MO_DLNKTST 0x1000 /* disable link status */ #define LE_MO_DAPC 0x0800 /* disable automatic polarity correction */ #define LE_MO_MENDECL 0x0400 /* MENDEC loopback mode */ #define LE_MO_LRTTSEL 0x0200 /* lower RX threshold / TX mode selection */ #define LE_MO_PSEL1 0x0100 /* port selection bit1 */ #define LE_MO_PSEL0 0x0080 /* port selection bit0 */ /* and this one is from the C-LANCE data sheet... */ #define LE_MO_EMBA 0x0080 /* Enable Modified Backoff Algorithm
(C-LANCE, not original LANCE) */ #define LE_MO_INTL 0x0040 /* Internal Loopback */ #define LE_MO_DRTY 0x0020 /* Disable Retry */ #define LE_MO_FCOLL 0x0010 /* Force Collision */ #define LE_MO_DXMTFCS 0x0008 /* Disable Transmit CRC */ #define LE_MO_LOOP 0x0004 /* Loopback Enable */ #define LE_MO_DTX 0x0002 /* Disable Transmitter */ #define LE_MO_DRX 0x0001 /* Disable Receiver */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.