Home | History | Annotate | Line # | Download | only in dev
if_ecreg.h revision 1.2
      1 /*	$NetBSD: if_ecreg.h,v 1.2 2001/08/14 03:57:16 fredette Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Matthew Fredette.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * 3Com Ethernet controller registers.
     41  */
     42 
     43 #define	EC_BUF_SZ	2048
     44 
     45 #if __for_reference_only__
     46 struct ec_regs {
     47 	u_int16_t	ec_csr;		/* control/status register */
     48 	u_int16_t	ec_backoff;	/* backoff seed */
     49 	u_int8_t	ec_pad1[0x400 - (2 * sizeof(u_int16_t))];
     50 	struct		ether_addr ec_arom;	/* address ROM */
     51 	u_int8_t	ec_pad2[0x200 - sizeof(struct ether_addr)];
     52 	struct		ether_addr ec_aram;	/* address RAM */
     53 	u_int8_t	ec_pad3[0x200 - sizeof(struct ether_addr)];
     54 	u_int8_t	ec_tbuf[EC_BUF_SZ];	/* transmit buffer */
     55 	u_int8_t	ec_abuf[EC_BUF_SZ];	/* receive buffer A */
     56 	u_int8_t	ec_bbuf[EC_BUF_SZ];	/* receive buffer B */
     57 };
     58 #endif
     59 
     60 /* Register offsets. */
     61 #define	ECREG_CSR	(0)
     62 #define	ECREG_BACKOFF	(2)
     63 #define	ECREG_AROM	(1024)
     64 #define	ECREG_ARAM	(1536)
     65 #define	ECREG_TBUF	(2048)
     66 #define ECREG_ABUF	(ECREG_TBUF + EC_BUF_SZ)
     67 #define ECREG_BBUF	(ECREG_ABUF + EC_BUF_SZ)
     68 #define	ECREG_BANK_SZ	(ECREG_BBUF + EC_BUF_SZ)
     69 
     70 /*
     71  * Control/status register bits
     72  */
     73 #define	EC_CSR_BBSW	0x8000		/* B buffer empty (belongs to card) */
     74 #define	EC_CSR_ABSW	0x4000		/* A buffer empty (belongs to card) */
     75 #define	EC_CSR_TBSW	0x2000		/* T buffer full (belongs to card) */
     76 #define	EC_CSR_JAM	0x1000		/* Ethernet jammed (collision) */
     77 #define	EC_CSR_AMSW	0x0800		/* address RAM belongs to ether */
     78 #define	EC_CSR_RBBA	0x0400		/* B buffer received before A */
     79 #define	EC_CSR_RESET	0x0100		/* reset the card */
     80 #define	EC_CSR_BINT	0x0080		/* B buffer interrupt enable */
     81 #define	EC_CSR_AINT	0x0040		/* A buffer interrupt enable */
     82 #define	EC_CSR_TINT	0x0020		/* T buffer interrupt enable */
     83 #define	EC_CSR_JINT	0x0010		/* jam interrupt enable */
     84 #define	EC_CSR_INTPA	0x00ff		/* mask for interrupt and PA fields */
     85 #define	EC_CSR_PAMASK	0x000f		/* PA field */
     86 
     87 #define	EC_CSR_PA	0x0007		/* receive mine+broadcast-errors */
     88 #define EC_CSR_PROMISC	0x0001		/* receive all-errors */
     89 
     90 /*
     91  * Turns an EC_CSR_xINT value into an ECREG_xBUF value.
     92  * NB: does not work with EC_CSR_TINT.
     93  */
     94 #define EC_CSR_INT_BUF(x) (((x) << 5) + 2048)
     95 
     96 /*
     97  * Turns an EC_CSR_xINT value into an ECREG_xBSW value.
     98  */
     99 #define EC_CSR_INT_BSW(x) ((x) << 8)
    100 
    101 /*
    102  * Receive status bits.  The first 16 bits of a receive
    103  * buffer are a status word.
    104  */
    105 #define	EC_PKT_FCSERR		0x8000		/* FCS error */
    106 #define	EC_PKT_BROADCAST	0x4000		/* packet was broadcast */
    107 #define	EC_PKT_RGERR		0x2000		/* range error */
    108 #define	EC_PKT_ADDRMATCH	0x1000		/* address match */
    109 #define	EC_PKT_FRERR		0x0800		/* framing error */
    110 #define	EC_PKT_DOFF		0x07ff		/* first free byte */
    111 
    112 #define	EC_PKT_MAXTDOFF	(EC_BUF_SZ - (ETHER_MIN_LEN - ETHER_CRC_LEN))	/* max xmit doff (min size) */
    113 #define	EC_PKT_RDOFF	2			/* packet offset in buffer */
    114 #define	EC_PKT_MINRDOFF	(EC_PKT_RDOFF + (ETHER_MIN_LEN - ETHER_CRC_LEN))	/* min packet doff (min size) */
    115 #define	EC_PKT_MAXRDOFF	(EC_PKT_RDOFF + (ETHER_MAX_LEN - ETHER_CRC_LEN))	/* max packet doff (max size) */
    116