156819Sralph /*- 2*63206Sbostic * Copyright (c) 1992, 1993 3*63206Sbostic * The Regents of the University of California. All rights reserved. 452130Smckusick * 552130Smckusick * This code is derived from software contributed to Berkeley by 656819Sralph * Ralph Campbell and Rick Macklem. 752130Smckusick * 852130Smckusick * %sccs.include.redist.c% 952130Smckusick * 10*63206Sbostic * @(#)if_lereg.h 8.1 (Berkeley) 06/10/93 1152130Smckusick */ 1252130Smckusick 1352130Smckusick #define LEMTU 1518 1456819Sralph #define LEBLEN 1520 /* LEMTU up to a multiple of 16 */ 1552130Smckusick #define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ 1652130Smckusick #define LERBUF 32 1752130Smckusick #define LERBUFLOG2 5 1852130Smckusick #define LE_RLEN (LERBUFLOG2 << 13) 1952130Smckusick #define LETBUF 8 2052130Smckusick #define LETBUFLOG2 3 2152130Smckusick #define LE_TLEN (LETBUFLOG2 << 13) 2252130Smckusick 2352130Smckusick /* 2452130Smckusick * LANCE registers. 2552130Smckusick */ 2652130Smckusick struct lereg1 { 2752130Smckusick u_short ler1_rdp; /* data port */ 2852130Smckusick short pad0; 2952130Smckusick u_short ler1_rap; /* register select port */ 3052130Smckusick short pad1; 3152130Smckusick }; 3252130Smckusick 3352130Smckusick /* 3452696Sralph * This structure is overlayed on the network dual-port RAM. 3556819Sralph * Currently 32 * 1520 receive plus 8 * 1520 transmit buffers plus 3652130Smckusick * buffer descriptor rings. 3756819Sralph * There are two variants of the structure, one for the Pmax/3min/maxine 3856819Sralph * with 2 byte pads between entries and one for the 3max and turbochannel 3956819Sralph * option densely packed. 4052130Smckusick */ 4156819Sralph struct lermd { /* +0x0020 */ 4256819Sralph u_short rmd0; 4356819Sralph u_short rmd1; 4456819Sralph short rmd2; 4556819Sralph u_short rmd3; 4656819Sralph }; 4756819Sralph 4856819Sralph struct letmd { /* +0x0058 */ 4956819Sralph u_short tmd0; 5056819Sralph u_short tmd1; 5156819Sralph short tmd2; 5256819Sralph u_short tmd3; 5356819Sralph }; 5456819Sralph 5556819Sralph struct lermdpad { /* +0x0020 */ 5656819Sralph u_short rmd0; 5756819Sralph short pad0; 5856819Sralph u_short rmd1; 5956819Sralph short pad1; 6056819Sralph short rmd2; 6156819Sralph short pad2; 6256819Sralph u_short rmd3; 6356819Sralph short pad3; 6456819Sralph }; 6556819Sralph 6656819Sralph struct letmdpad { /* +0x0058 */ 6756819Sralph u_short tmd0; 6856819Sralph short pad0; 6956819Sralph u_short tmd1; 7056819Sralph short pad1; 7156819Sralph short tmd2; 7256819Sralph short pad2; 7356819Sralph u_short tmd3; 7456819Sralph short pad3; 7556819Sralph }; 7656819Sralph 7752130Smckusick struct lereg2 { 7852130Smckusick /* init block */ /* CHIP address */ 7952130Smckusick u_short ler2_mode; /* +0x0000 */ 8052130Smckusick u_short ler2_padr0; /* +0x0002 */ 8152130Smckusick u_short ler2_padr1; /* +0x0004 */ 8252130Smckusick u_short ler2_padr2; /* +0x0006 */ 8352130Smckusick u_short ler2_ladrf0; /* +0x0008 */ 8452130Smckusick u_short ler2_ladrf1; /* +0x000A */ 8552130Smckusick u_short ler2_ladrf2; /* +0x000C */ 8652130Smckusick u_short ler2_ladrf3; /* +0x000E */ 8752130Smckusick u_short ler2_rdra; /* +0x0010 */ 8852130Smckusick u_short ler2_rlen; /* +0x0012 */ 8952130Smckusick u_short ler2_tdra; /* +0x0014 */ 9052130Smckusick u_short ler2_tlen; /* +0x0016 */ 9156819Sralph short pad0[4]; /* Pad to 16 shorts */ 9252130Smckusick /* receive message descriptors */ 9356819Sralph struct lermd ler2_rmd[LERBUF]; 9452130Smckusick /* transmit message descriptors */ 9556819Sralph struct letmd ler2_tmd[LETBUF]; 9656819Sralph char ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */ 9756819Sralph char ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */ 9852130Smckusick }; 9952130Smckusick 10056819Sralph struct lereg2pad { 10156819Sralph /* init block */ /* CHIP address */ 10256819Sralph u_short ler2_mode; /* +0x0000 */ 10356819Sralph short pad0; 10456819Sralph u_short ler2_padr0; /* +0x0002 */ 10556819Sralph short pad1; 10656819Sralph u_short ler2_padr1; /* +0x0004 */ 10756819Sralph short pad2; 10856819Sralph u_short ler2_padr2; /* +0x0006 */ 10956819Sralph short pad3; 11056819Sralph u_short ler2_ladrf0; /* +0x0008 */ 11156819Sralph short pad4; 11256819Sralph u_short ler2_ladrf1; /* +0x000A */ 11356819Sralph short pad5; 11456819Sralph u_short ler2_ladrf2; /* +0x000C */ 11556819Sralph short pad6; 11656819Sralph u_short ler2_ladrf3; /* +0x000E */ 11756819Sralph short pad7; 11856819Sralph u_short ler2_rdra; /* +0x0010 */ 11956819Sralph short pad8; 12056819Sralph u_short ler2_rlen; /* +0x0012 */ 12156819Sralph short pad9; 12256819Sralph u_short ler2_tdra; /* +0x0014 */ 12356819Sralph short pad10; 12456819Sralph u_short ler2_tlen; /* +0x0016 */ 12556819Sralph short pad11[9]; /* Pad to 32 shorts */ 12656819Sralph /* receive message descriptors */ 12756819Sralph struct lermdpad ler2_rmd[LERBUF]; 12856819Sralph /* transmit message descriptors */ 12956819Sralph struct letmdpad ler2_tmd[LETBUF]; 13056819Sralph short ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */ 13156819Sralph short ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */ 13256819Sralph }; 13356819Sralph 13452130Smckusick /* 13556819Sralph * Now for some truly ugly macros to access the structure fields 13656819Sralph * padded/non-padded at runtime. (For once, a Pascal like record variant 13756819Sralph * would be nice to have.) 13856819Sralph */ 13956819Sralph #define LER2_RMDADDR(p, i) \ 14056819Sralph (le->sc_ler2pad ? \ 14156819Sralph (volatile void *)&(((struct lereg2pad *)(p))->ler2_rmd[(i)]) : \ 14256819Sralph (volatile void *)&(((struct lereg2 *)(p))->ler2_rmd[(i)])) 14356819Sralph 14456819Sralph #define LER2_TMDADDR(p, i) \ 14556819Sralph ((le->sc_ler2pad ? \ 14656819Sralph (volatile void *)&(((struct lereg2pad *)(p))->ler2_tmd[(i)]) : \ 14756819Sralph (volatile void *)&(((struct lereg2 *)(p))->ler2_tmd[(i)]))) 14856819Sralph 14956819Sralph #define LER2_RBUFADDR(p, i) \ 15056819Sralph ((le->sc_ler2pad ? \ 15156819Sralph (volatile void *)(((struct lereg2pad *)(p))->ler2_rbuf[(i)]) : \ 15256819Sralph (volatile void *)(((struct lereg2 *)(p))->ler2_rbuf[(i)]))) 15356819Sralph 15456819Sralph #define LER2_TBUFADDR(p, i) \ 15556819Sralph ((le->sc_ler2pad ? \ 15656819Sralph (volatile void *)(((struct lereg2pad *)(p))->ler2_tbuf[(i)]) : \ 15756819Sralph (volatile void *)(((struct lereg2 *)(p))->ler2_tbuf[(i)]))) 15856819Sralph 15956819Sralph #define LER2_mode(p, v) \ 16056819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_mode = (v)) : \ 16156819Sralph (((volatile struct lereg2 *)(p))->ler2_mode = (v))) 16256819Sralph #define LER2V_mode(p) \ 16356819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_mode : \ 16456819Sralph ((volatile struct lereg2 *)(p))->ler2_mode) 16556819Sralph 16656819Sralph #define LER2_padr0(p, v) \ 16756819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr0 = (v)) : \ 16856819Sralph (((volatile struct lereg2 *)(p))->ler2_padr0 = (v))) 16956819Sralph #define LER2V_padr0(p) \ 17056819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr0 : \ 17156819Sralph ((volatile struct lereg2 *)(p))->ler2_padr0) 17256819Sralph 17356819Sralph #define LER2_padr1(p, v) \ 17456819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr1 = (v)) : \ 17556819Sralph (((volatile struct lereg2 *)(p))->ler2_padr1 = (v))) 17656819Sralph #define LER2V_padr1(p) \ 17756819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr1 : \ 17856819Sralph ((volatile struct lereg2 *)(p))->ler2_padr1) 17956819Sralph 18056819Sralph #define LER2_padr2(p, v) \ 18156819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr2 = (v)) : \ 18256819Sralph (((volatile struct lereg2 *)(p))->ler2_padr2 = (v))) 18356819Sralph #define LER2V_padr2(p) \ 18456819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr2 : \ 18556819Sralph ((volatile struct lereg2 *)(p))->ler2_padr2) 18656819Sralph 18756819Sralph #define LER2_ladrf0(p, v) \ 18856819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf0 = (v)) : \ 18956819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf0 = (v))) 19056819Sralph #define LER2V_ladrf0(p) \ 19156819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf0 : \ 19256819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf0) 19356819Sralph 19456819Sralph #define LER2_ladrf1(p, v) \ 19556819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf1 = (v)) : \ 19656819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf1 = (v))) 19756819Sralph #define LER2V_ladrf1(p) \ 19856819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf1 : \ 19956819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf1) 20056819Sralph 20156819Sralph #define LER2_ladrf2(p, v) \ 20256819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf2 = (v)) : \ 20356819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf2 = (v))) 20456819Sralph #define LER2V_ladrf2(p) \ 20556819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf2 : \ 20656819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf2) 20756819Sralph 20856819Sralph #define LER2_ladrf3(p, v) \ 20956819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf3 = (v)) : \ 21056819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf3 = (v))) 21156819Sralph #define LER2V_ladrf3(p) \ 21256819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf3 : \ 21356819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf3) 21456819Sralph 21556819Sralph #define LER2_rdra(p, v) \ 21656819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rdra = (v)) : \ 21756819Sralph (((volatile struct lereg2 *)(p))->ler2_rdra = (v))) 21856819Sralph #define LER2V_rdra(p) \ 21956819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rdra : \ 22056819Sralph ((volatile struct lereg2 *)(p))->ler2_rdra) 22156819Sralph 22256819Sralph #define LER2_rlen(p, v) \ 22356819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rlen = (v)) : \ 22456819Sralph (((volatile struct lereg2 *)(p))->ler2_rlen = (v))) 22556819Sralph #define LER2V_rlen(p) \ 22656819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rlen : \ 22756819Sralph ((volatile struct lereg2 *)(p))->ler2_rlen) 22856819Sralph 22956819Sralph #define LER2_tdra(p, v) \ 23056819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tdra = (v)) : \ 23156819Sralph (((volatile struct lereg2 *)(p))->ler2_tdra = (v))) 23256819Sralph #define LER2V_tdra(p) \ 23356819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tdra : \ 23456819Sralph ((volatile struct lereg2 *)(p))->ler2_tdra) 23556819Sralph 23656819Sralph #define LER2_tlen(p, v) \ 23756819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tlen = (v)) : \ 23856819Sralph (((volatile struct lereg2 *)(p))->ler2_tlen = (v))) 23956819Sralph #define LER2V_tlen(p) \ 24056819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tlen : \ 24156819Sralph ((volatile struct lereg2 *)(p))->ler2_tlen) 24256819Sralph 24356819Sralph #define LER2_rmd0(p, v) \ 24456819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd0 = (v)) : \ 24556819Sralph ((((volatile struct lermd *)(p))->rmd0 = (v)))) 24656819Sralph #define LER2V_rmd0(p) \ 24756819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd0 : \ 24856819Sralph ((volatile struct lermd *)(p))->rmd0) 24956819Sralph 25056819Sralph #define LER2_rmd1(p, v) \ 25156819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd1 = (v)) : \ 25256819Sralph (((volatile struct lermd *)(p))->rmd1 = (v))) 25356819Sralph #define LER2V_rmd1(p) \ 25456819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd1 : \ 25556819Sralph ((volatile struct lermd *)(p))->rmd1) 25656819Sralph 25756819Sralph #define LER2_rmd2(p, v) \ 25856819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd2 = (v)) : \ 25956819Sralph (((volatile struct lermd *)(p))->rmd2 = (v))) 26056819Sralph #define LER2V_rmd2(p) \ 26156819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd2 : \ 26256819Sralph ((volatile struct lermd *)(p))->rmd2) 26356819Sralph 26456819Sralph #define LER2_rmd3(p, v) \ 26556819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd3 = (v)) : \ 26656819Sralph (((volatile struct lermd *)(p))->rmd3 = (v))) 26756819Sralph #define LER2V_rmd3(p) \ 26856819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd3 : \ 26956819Sralph ((volatile struct lermd *)(p))->rmd3) 27056819Sralph 27156819Sralph #define LER2_tmd0(p, v) \ 27256819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd0 = (v)) : \ 27356819Sralph (((volatile struct letmd *)(p))->tmd0 = (v))) 27456819Sralph #define LER2V_tmd0(p) \ 27556819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd0 : \ 27656819Sralph ((volatile struct letmd *)(p))->tmd0) 27756819Sralph 27856819Sralph #define LER2_tmd1(p, v) \ 27956819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd1 = (v)) : \ 28056819Sralph (((volatile struct letmd *)(p))->tmd1 = (v))) 28156819Sralph #define LER2V_tmd1(p) \ 28256819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd1 : \ 28356819Sralph ((volatile struct letmd *)(p))->tmd1) 28456819Sralph 28556819Sralph #define LER2_tmd2(p, v) \ 28656819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd2 = (v)) : \ 28756819Sralph (((volatile struct letmd *)(p))->tmd2 = (v))) 28856819Sralph #define LER2V_tmd2(p) \ 28956819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd2 : \ 29056819Sralph ((volatile struct letmd *)(p))->tmd2) 29156819Sralph 29256819Sralph #define LER2_tmd3(p, v) \ 29356819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd3 = (v)) : \ 29456819Sralph (((volatile struct letmd *)(p))->tmd3 = (v))) 29556819Sralph #define LER2V_tmd3(p) \ 29656819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd3 : \ 29756819Sralph ((volatile struct letmd *)(p))->tmd3) 29856819Sralph 29956819Sralph /* 30052130Smckusick * Control and status bits -- lereg0 30152130Smckusick */ 30252130Smckusick #define LE_IE 0x80 /* interrupt enable */ 30352130Smckusick #define LE_IR 0x40 /* interrupt requested */ 30452130Smckusick #define LE_LOCK 0x08 /* lock status register */ 30552130Smckusick #define LE_ACK 0x04 /* ack of lock */ 30652130Smckusick #define LE_JAB 0x02 /* loss of tx clock (???) */ 30752130Smckusick #define LE_IPL(x) ((((x) >> 4) & 0x3) + 3) 30852130Smckusick 30952130Smckusick /* 31052130Smckusick * Control and status bits -- lereg1 31152130Smckusick */ 31252130Smckusick #define LE_CSR0 0 31352130Smckusick #define LE_CSR1 1 31452130Smckusick #define LE_CSR2 2 31552130Smckusick #define LE_CSR3 3 31652130Smckusick 31752130Smckusick #define LE_SERR 0x8000 31852130Smckusick #define LE_BABL 0x4000 31952130Smckusick #define LE_CERR 0x2000 32052130Smckusick #define LE_MISS 0x1000 32152130Smckusick #define LE_MERR 0x0800 32252130Smckusick #define LE_RINT 0x0400 32352130Smckusick #define LE_TINT 0x0200 32452130Smckusick #define LE_IDON 0x0100 32552130Smckusick #define LE_INTR 0x0080 32652130Smckusick #define LE_INEA 0x0040 32752130Smckusick #define LE_RXON 0x0020 32852130Smckusick #define LE_TXON 0x0010 32952130Smckusick #define LE_TDMD 0x0008 33052130Smckusick #define LE_STOP 0x0004 33152130Smckusick #define LE_STRT 0x0002 33252130Smckusick #define LE_INIT 0x0001 33352130Smckusick 33452130Smckusick #define LE_BSWP 0x4 33552130Smckusick #define LE_MODE 0x0 33652130Smckusick 33752130Smckusick /* 33852130Smckusick * Control and status bits -- lereg2 33952130Smckusick */ 34052130Smckusick #define LE_OWN 0x8000 34152130Smckusick #define LE_ERR 0x4000 34252130Smckusick #define LE_STP 0x0200 34352130Smckusick #define LE_ENP 0x0100 34452130Smckusick 34552130Smckusick #define LE_FRAM 0x2000 34652130Smckusick #define LE_OFLO 0x1000 34752130Smckusick #define LE_CRC 0x0800 34852130Smckusick #define LE_RBUFF 0x0400 34952130Smckusick 35052130Smckusick #define LE_MORE 0x1000 35152130Smckusick #define LE_ONE 0x0800 35252130Smckusick #define LE_DEF 0x0400 35352130Smckusick 35452130Smckusick #define LE_TBUFF 0x8000 35552130Smckusick #define LE_UFLO 0x4000 35652130Smckusick #define LE_LCOL 0x1000 35752130Smckusick #define LE_LCAR 0x0800 35852130Smckusick #define LE_RTRY 0x0400 359