1*56819Sralph /*- 2*56819Sralph * Copyright (c) 1992 The Regents of the University of California. 352130Smckusick * All rights reserved. 452130Smckusick * 552130Smckusick * This code is derived from software contributed to Berkeley by 6*56819Sralph * Ralph Campbell and Rick Macklem. 752130Smckusick * 852130Smckusick * %sccs.include.redist.c% 952130Smckusick * 10*56819Sralph * @(#)if_lereg.h 7.3 (Berkeley) 11/15/92 1152130Smckusick */ 1252130Smckusick 1352130Smckusick #define LEMTU 1518 14*56819Sralph #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. 35*56819Sralph * Currently 32 * 1520 receive plus 8 * 1520 transmit buffers plus 3652130Smckusick * buffer descriptor rings. 37*56819Sralph * There are two variants of the structure, one for the Pmax/3min/maxine 38*56819Sralph * with 2 byte pads between entries and one for the 3max and turbochannel 39*56819Sralph * option densely packed. 4052130Smckusick */ 41*56819Sralph struct lermd { /* +0x0020 */ 42*56819Sralph u_short rmd0; 43*56819Sralph u_short rmd1; 44*56819Sralph short rmd2; 45*56819Sralph u_short rmd3; 46*56819Sralph }; 47*56819Sralph 48*56819Sralph struct letmd { /* +0x0058 */ 49*56819Sralph u_short tmd0; 50*56819Sralph u_short tmd1; 51*56819Sralph short tmd2; 52*56819Sralph u_short tmd3; 53*56819Sralph }; 54*56819Sralph 55*56819Sralph struct lermdpad { /* +0x0020 */ 56*56819Sralph u_short rmd0; 57*56819Sralph short pad0; 58*56819Sralph u_short rmd1; 59*56819Sralph short pad1; 60*56819Sralph short rmd2; 61*56819Sralph short pad2; 62*56819Sralph u_short rmd3; 63*56819Sralph short pad3; 64*56819Sralph }; 65*56819Sralph 66*56819Sralph struct letmdpad { /* +0x0058 */ 67*56819Sralph u_short tmd0; 68*56819Sralph short pad0; 69*56819Sralph u_short tmd1; 70*56819Sralph short pad1; 71*56819Sralph short tmd2; 72*56819Sralph short pad2; 73*56819Sralph u_short tmd3; 74*56819Sralph short pad3; 75*56819Sralph }; 76*56819Sralph 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 */ 91*56819Sralph short pad0[4]; /* Pad to 16 shorts */ 9252130Smckusick /* receive message descriptors */ 93*56819Sralph struct lermd ler2_rmd[LERBUF]; 9452130Smckusick /* transmit message descriptors */ 95*56819Sralph struct letmd ler2_tmd[LETBUF]; 96*56819Sralph char ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */ 97*56819Sralph char ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */ 9852130Smckusick }; 9952130Smckusick 100*56819Sralph struct lereg2pad { 101*56819Sralph /* init block */ /* CHIP address */ 102*56819Sralph u_short ler2_mode; /* +0x0000 */ 103*56819Sralph short pad0; 104*56819Sralph u_short ler2_padr0; /* +0x0002 */ 105*56819Sralph short pad1; 106*56819Sralph u_short ler2_padr1; /* +0x0004 */ 107*56819Sralph short pad2; 108*56819Sralph u_short ler2_padr2; /* +0x0006 */ 109*56819Sralph short pad3; 110*56819Sralph u_short ler2_ladrf0; /* +0x0008 */ 111*56819Sralph short pad4; 112*56819Sralph u_short ler2_ladrf1; /* +0x000A */ 113*56819Sralph short pad5; 114*56819Sralph u_short ler2_ladrf2; /* +0x000C */ 115*56819Sralph short pad6; 116*56819Sralph u_short ler2_ladrf3; /* +0x000E */ 117*56819Sralph short pad7; 118*56819Sralph u_short ler2_rdra; /* +0x0010 */ 119*56819Sralph short pad8; 120*56819Sralph u_short ler2_rlen; /* +0x0012 */ 121*56819Sralph short pad9; 122*56819Sralph u_short ler2_tdra; /* +0x0014 */ 123*56819Sralph short pad10; 124*56819Sralph u_short ler2_tlen; /* +0x0016 */ 125*56819Sralph short pad11[9]; /* Pad to 32 shorts */ 126*56819Sralph /* receive message descriptors */ 127*56819Sralph struct lermdpad ler2_rmd[LERBUF]; 128*56819Sralph /* transmit message descriptors */ 129*56819Sralph struct letmdpad ler2_tmd[LETBUF]; 130*56819Sralph short ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */ 131*56819Sralph short ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */ 132*56819Sralph }; 133*56819Sralph 13452130Smckusick /* 135*56819Sralph * Now for some truly ugly macros to access the structure fields 136*56819Sralph * padded/non-padded at runtime. (For once, a Pascal like record variant 137*56819Sralph * would be nice to have.) 138*56819Sralph */ 139*56819Sralph #define LER2_RMDADDR(p, i) \ 140*56819Sralph (le->sc_ler2pad ? \ 141*56819Sralph (volatile void *)&(((struct lereg2pad *)(p))->ler2_rmd[(i)]) : \ 142*56819Sralph (volatile void *)&(((struct lereg2 *)(p))->ler2_rmd[(i)])) 143*56819Sralph 144*56819Sralph #define LER2_TMDADDR(p, i) \ 145*56819Sralph ((le->sc_ler2pad ? \ 146*56819Sralph (volatile void *)&(((struct lereg2pad *)(p))->ler2_tmd[(i)]) : \ 147*56819Sralph (volatile void *)&(((struct lereg2 *)(p))->ler2_tmd[(i)]))) 148*56819Sralph 149*56819Sralph #define LER2_RBUFADDR(p, i) \ 150*56819Sralph ((le->sc_ler2pad ? \ 151*56819Sralph (volatile void *)(((struct lereg2pad *)(p))->ler2_rbuf[(i)]) : \ 152*56819Sralph (volatile void *)(((struct lereg2 *)(p))->ler2_rbuf[(i)]))) 153*56819Sralph 154*56819Sralph #define LER2_TBUFADDR(p, i) \ 155*56819Sralph ((le->sc_ler2pad ? \ 156*56819Sralph (volatile void *)(((struct lereg2pad *)(p))->ler2_tbuf[(i)]) : \ 157*56819Sralph (volatile void *)(((struct lereg2 *)(p))->ler2_tbuf[(i)]))) 158*56819Sralph 159*56819Sralph #define LER2_mode(p, v) \ 160*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_mode = (v)) : \ 161*56819Sralph (((volatile struct lereg2 *)(p))->ler2_mode = (v))) 162*56819Sralph #define LER2V_mode(p) \ 163*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_mode : \ 164*56819Sralph ((volatile struct lereg2 *)(p))->ler2_mode) 165*56819Sralph 166*56819Sralph #define LER2_padr0(p, v) \ 167*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr0 = (v)) : \ 168*56819Sralph (((volatile struct lereg2 *)(p))->ler2_padr0 = (v))) 169*56819Sralph #define LER2V_padr0(p) \ 170*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr0 : \ 171*56819Sralph ((volatile struct lereg2 *)(p))->ler2_padr0) 172*56819Sralph 173*56819Sralph #define LER2_padr1(p, v) \ 174*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr1 = (v)) : \ 175*56819Sralph (((volatile struct lereg2 *)(p))->ler2_padr1 = (v))) 176*56819Sralph #define LER2V_padr1(p) \ 177*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr1 : \ 178*56819Sralph ((volatile struct lereg2 *)(p))->ler2_padr1) 179*56819Sralph 180*56819Sralph #define LER2_padr2(p, v) \ 181*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr2 = (v)) : \ 182*56819Sralph (((volatile struct lereg2 *)(p))->ler2_padr2 = (v))) 183*56819Sralph #define LER2V_padr2(p) \ 184*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr2 : \ 185*56819Sralph ((volatile struct lereg2 *)(p))->ler2_padr2) 186*56819Sralph 187*56819Sralph #define LER2_ladrf0(p, v) \ 188*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf0 = (v)) : \ 189*56819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf0 = (v))) 190*56819Sralph #define LER2V_ladrf0(p) \ 191*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf0 : \ 192*56819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf0) 193*56819Sralph 194*56819Sralph #define LER2_ladrf1(p, v) \ 195*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf1 = (v)) : \ 196*56819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf1 = (v))) 197*56819Sralph #define LER2V_ladrf1(p) \ 198*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf1 : \ 199*56819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf1) 200*56819Sralph 201*56819Sralph #define LER2_ladrf2(p, v) \ 202*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf2 = (v)) : \ 203*56819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf2 = (v))) 204*56819Sralph #define LER2V_ladrf2(p) \ 205*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf2 : \ 206*56819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf2) 207*56819Sralph 208*56819Sralph #define LER2_ladrf3(p, v) \ 209*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf3 = (v)) : \ 210*56819Sralph (((volatile struct lereg2 *)(p))->ler2_ladrf3 = (v))) 211*56819Sralph #define LER2V_ladrf3(p) \ 212*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf3 : \ 213*56819Sralph ((volatile struct lereg2 *)(p))->ler2_ladrf3) 214*56819Sralph 215*56819Sralph #define LER2_rdra(p, v) \ 216*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rdra = (v)) : \ 217*56819Sralph (((volatile struct lereg2 *)(p))->ler2_rdra = (v))) 218*56819Sralph #define LER2V_rdra(p) \ 219*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rdra : \ 220*56819Sralph ((volatile struct lereg2 *)(p))->ler2_rdra) 221*56819Sralph 222*56819Sralph #define LER2_rlen(p, v) \ 223*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rlen = (v)) : \ 224*56819Sralph (((volatile struct lereg2 *)(p))->ler2_rlen = (v))) 225*56819Sralph #define LER2V_rlen(p) \ 226*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rlen : \ 227*56819Sralph ((volatile struct lereg2 *)(p))->ler2_rlen) 228*56819Sralph 229*56819Sralph #define LER2_tdra(p, v) \ 230*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tdra = (v)) : \ 231*56819Sralph (((volatile struct lereg2 *)(p))->ler2_tdra = (v))) 232*56819Sralph #define LER2V_tdra(p) \ 233*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tdra : \ 234*56819Sralph ((volatile struct lereg2 *)(p))->ler2_tdra) 235*56819Sralph 236*56819Sralph #define LER2_tlen(p, v) \ 237*56819Sralph (le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tlen = (v)) : \ 238*56819Sralph (((volatile struct lereg2 *)(p))->ler2_tlen = (v))) 239*56819Sralph #define LER2V_tlen(p) \ 240*56819Sralph (le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tlen : \ 241*56819Sralph ((volatile struct lereg2 *)(p))->ler2_tlen) 242*56819Sralph 243*56819Sralph #define LER2_rmd0(p, v) \ 244*56819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd0 = (v)) : \ 245*56819Sralph ((((volatile struct lermd *)(p))->rmd0 = (v)))) 246*56819Sralph #define LER2V_rmd0(p) \ 247*56819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd0 : \ 248*56819Sralph ((volatile struct lermd *)(p))->rmd0) 249*56819Sralph 250*56819Sralph #define LER2_rmd1(p, v) \ 251*56819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd1 = (v)) : \ 252*56819Sralph (((volatile struct lermd *)(p))->rmd1 = (v))) 253*56819Sralph #define LER2V_rmd1(p) \ 254*56819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd1 : \ 255*56819Sralph ((volatile struct lermd *)(p))->rmd1) 256*56819Sralph 257*56819Sralph #define LER2_rmd2(p, v) \ 258*56819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd2 = (v)) : \ 259*56819Sralph (((volatile struct lermd *)(p))->rmd2 = (v))) 260*56819Sralph #define LER2V_rmd2(p) \ 261*56819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd2 : \ 262*56819Sralph ((volatile struct lermd *)(p))->rmd2) 263*56819Sralph 264*56819Sralph #define LER2_rmd3(p, v) \ 265*56819Sralph (le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd3 = (v)) : \ 266*56819Sralph (((volatile struct lermd *)(p))->rmd3 = (v))) 267*56819Sralph #define LER2V_rmd3(p) \ 268*56819Sralph (le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd3 : \ 269*56819Sralph ((volatile struct lermd *)(p))->rmd3) 270*56819Sralph 271*56819Sralph #define LER2_tmd0(p, v) \ 272*56819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd0 = (v)) : \ 273*56819Sralph (((volatile struct letmd *)(p))->tmd0 = (v))) 274*56819Sralph #define LER2V_tmd0(p) \ 275*56819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd0 : \ 276*56819Sralph ((volatile struct letmd *)(p))->tmd0) 277*56819Sralph 278*56819Sralph #define LER2_tmd1(p, v) \ 279*56819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd1 = (v)) : \ 280*56819Sralph (((volatile struct letmd *)(p))->tmd1 = (v))) 281*56819Sralph #define LER2V_tmd1(p) \ 282*56819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd1 : \ 283*56819Sralph ((volatile struct letmd *)(p))->tmd1) 284*56819Sralph 285*56819Sralph #define LER2_tmd2(p, v) \ 286*56819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd2 = (v)) : \ 287*56819Sralph (((volatile struct letmd *)(p))->tmd2 = (v))) 288*56819Sralph #define LER2V_tmd2(p) \ 289*56819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd2 : \ 290*56819Sralph ((volatile struct letmd *)(p))->tmd2) 291*56819Sralph 292*56819Sralph #define LER2_tmd3(p, v) \ 293*56819Sralph (le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd3 = (v)) : \ 294*56819Sralph (((volatile struct letmd *)(p))->tmd3 = (v))) 295*56819Sralph #define LER2V_tmd3(p) \ 296*56819Sralph (le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd3 : \ 297*56819Sralph ((volatile struct letmd *)(p))->tmd3) 298*56819Sralph 299*56819Sralph /* 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