if_devar.h revision 1.13
1/* $OpenBSD: if_devar.h,v 1.13 2001/07/18 19:32:01 mickey Exp $ */ 2/* $NetBSD: if_devar.h,v 1.13 1997/06/08 18:46:36 thorpej Exp $ */ 3 4/*- 5 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com) 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. The name of the author may not be used to endorse or promote products 14 * derived from this software withough specific prior written permission 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Id: if_devar.h,v 1.23 1997/06/03 18:51:16 thomas Exp 28 */ 29 30#if !defined(_DEVAR_H) 31#define _DEVAR_H 32 33#if defined(__OpenBSD__) 34#define __BROKEN_INDIRECT_CONFIG 35#endif 36 37#if defined(__NetBSD__) || defined(__OpenBSD__) 38 39typedef bus_addr_t tulip_csrptr_t; 40 41#define TULIP_CSR_READ(sc, csr) \ 42 bus_space_read_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr) 43#define TULIP_CSR_WRITE(sc, csr, val) \ 44 bus_space_write_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val)) 45 46#define TULIP_CSR_READBYTE(sc, csr) \ 47 bus_space_read_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr) 48#define TULIP_CSR_WRITEBYTE(sc, csr, val) \ 49 bus_space_write_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val)) 50#endif /* __NetBSD__ */ 51 52#ifdef TULIP_IOMAPPED 53#define TULIP_EISA_CSRSIZE 16 54#define TULIP_EISA_CSROFFSET 0 55#define TULIP_PCI_CSRSIZE 8 56#define TULIP_PCI_CSROFFSET 0 57 58#if !defined(__NetBSD__) && !defined(__OpenBSD__) 59typedef u_int16_t tulip_csrptr_t; 60 61#define TULIP_CSR_READ(sc, csr) (inl((sc)->tulip_csrs.csr)) 62#define TULIP_CSR_WRITE(sc, csr, val) outl((sc)->tulip_csrs.csr, val) 63 64#define TULIP_CSR_READBYTE(sc, csr) (inb((sc)->tulip_csrs.csr)) 65#define TULIP_CSR_WRITEBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val) 66#endif /* __NetBSD__ */ 67 68#else /* TULIP_IOMAPPED */ 69 70#define TULIP_PCI_CSRSIZE 8 71#define TULIP_PCI_CSROFFSET 0 72 73#if !defined(__NetBSD__) && !defined(__OpenBSD__) 74typedef volatile u_int32_t *tulip_csrptr_t; 75 76/* 77 * macros to read and write CSRs. Note that the "0 +" in 78 * READ_CSR is to prevent the macro from being an lvalue 79 * and WRITE_CSR shouldn't be assigned from. 80 */ 81#define TULIP_CSR_READ(sc, csr) (0 + *(sc)->tulip_csrs.csr) 82#define TULIP_CSR_WRITE(sc, csr, val) ((void)(*(sc)->tulip_csrs.csr = (val))) 83#endif /* __NetBSD__ */ 84 85#endif /* TULIP_IOMAPPED */ 86 87/* 88 * Swap macro to access certain data types. 89 */ 90#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN 91__inline__ static u_int32_t FILT_BO(u_int32_t); 92__inline__ static u_int32_t DESC_BO(u_int32_t); 93 94__inline__ static u_int32_t 95FILT_BO(x) 96 u_int32_t x; 97{ 98 u_int32_t s; 99 100 s = (x & 0xffff) << 16 | ((x & 0xff) << 8) | ((x & 0xff00) >> 8); 101 return s; 102} 103 104__inline__ static u_int32_t 105DESC_BO(x) 106 u_int32_t x; 107{ 108 u_int32_t s; 109 110 s = x; 111 x = (((s) >> 24) | (((s) >> 8) & 0xff00) | 112 ((s) << 24) | (((s) & 0xff00) << 8)); 113 return x; 114} 115 116#else 117#define FILT_BO(x) (x) 118#define DESC_BO(x) (x) 119#endif 120 121/* 122 * This structure contains "pointers" for the registers on 123 * the various 21x4x chips. CSR0 through CSR8 are common 124 * to all chips. After that, it gets messy... 125 */ 126typedef struct { 127 tulip_csrptr_t csr_busmode; /* CSR0 */ 128 tulip_csrptr_t csr_txpoll; /* CSR1 */ 129 tulip_csrptr_t csr_rxpoll; /* CSR2 */ 130 tulip_csrptr_t csr_rxlist; /* CSR3 */ 131 tulip_csrptr_t csr_txlist; /* CSR4 */ 132 tulip_csrptr_t csr_status; /* CSR5 */ 133 tulip_csrptr_t csr_command; /* CSR6 */ 134 tulip_csrptr_t csr_intr; /* CSR7 */ 135 tulip_csrptr_t csr_missed_frames; /* CSR8 */ 136 tulip_csrptr_t csr_9; /* CSR9 */ 137 tulip_csrptr_t csr_10; /* CSR10 */ 138 tulip_csrptr_t csr_11; /* CSR11 */ 139 tulip_csrptr_t csr_12; /* CSR12 */ 140 tulip_csrptr_t csr_13; /* CSR13 */ 141 tulip_csrptr_t csr_14; /* CSR14 */ 142 tulip_csrptr_t csr_15; /* CSR15 */ 143} tulip_regfile_t; 144 145#define csr_enetrom csr_9 /* 21040 */ 146#define csr_reserved csr_10 /* 21040 */ 147#define csr_full_duplex csr_11 /* 21040 */ 148#define csr_bootrom csr_10 /* 21041/21140A/?? */ 149#define csr_gp csr_12 /* 21140* */ 150#define csr_watchdog csr_15 /* 21140* */ 151#define csr_gp_timer csr_11 /* 21041/21140* */ 152#define csr_srom_mii csr_9 /* 21041/21140* */ 153#define csr_sia_status csr_12 /* 2104x */ 154#define csr_sia_connectivity csr_13 /* 2104x */ 155#define csr_sia_tx_rx csr_14 /* 2104x */ 156#define csr_sia_general csr_15 /* 2104x */ 157 158/* 159 * While 21x4x allows chaining of its descriptors, this driver 160 * doesn't take advantage of it. We keep the descriptors in a 161 * traditional FIFO ring. 162 */ 163typedef struct { 164 tulip_desc_t *ri_first; /* first entry in ring */ 165 tulip_desc_t *ri_last; /* one after last entry */ 166 tulip_desc_t *ri_nextin; /* next to processed by host */ 167 tulip_desc_t *ri_nextout; /* next to processed by adapter */ 168 int ri_max; 169 int ri_free; 170} tulip_ringinfo_t; 171 172/* 173 * The 21040 has a stupid restriction in that the receive 174 * buffers must be longword aligned. But since Ethernet 175 * headers are not a multiple of longwords in size this forces 176 * the data to non-longword aligned. Since IP requires the 177 * data to be longword aligned, we need to copy it after it has 178 * been DMA'ed in our memory. 179 * 180 * Since we have to copy it anyways, we might as well as allocate 181 * dedicated receive space for the input. This allows to use a 182 * small receive buffer size and more ring entries to be able to 183 * better keep with a flood of tiny Ethernet packets. 184 * 185 * The receive space MUST ALWAYS be a multiple of the page size. 186 * And the number of receive descriptors multiplied by the size 187 * of the receive buffers must equal the recevive space. This 188 * is so that we can manipulate the page tables so that even if a 189 * packet wraps around the end of the receive space, we can 190 * treat it as virtually contiguous. 191 * 192 * The above used to be true (the stupid restriction is still true) 193 * but we gone to directly DMA'ing into MBUFs (unless it's on an 194 * architecture which can't handle unaligned accesses) because with 195 * 100Mb/s cards the copying is just too much of a hit. 196 */ 197#if defined(__alpha__) || defined(__mips__) 198#define TULIP_COPY_RXDATA 1 199#endif 200 201#define TULIP_TXTIMER 4 202#define TULIP_RXDESCS 48 203#define TULIP_TXDESCS 128 204#define TULIP_RXQ_TARGET 32 205#if TULIP_RXQ_TARGET >= TULIP_RXDESCS 206#error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS 207#endif 208#define TULIP_RX_BUFLEN ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16) 209 210/* 211 * Forward reference to make C happy. 212 */ 213typedef struct _tulip_softc_t tulip_softc_t; 214 215/* 216 * The various controllers support. Technically the DE425 is just 217 * a 21040 on EISA. But since it remarkably difference from normal 218 * 21040s, we give it its own chip id. 219 */ 220 221typedef enum { 222 TULIP_21040, TULIP_DE425, 223 TULIP_21041, 224 TULIP_21140, TULIP_21140A, TULIP_21142, 225 TULIP_21143, 226 TULIP_CHIPID_UNKNOWN 227} tulip_chipid_t; 228 229/* 230 * Various physical media types supported. 231 * BNCAUI is BNC or AUI since on the 21040 you can't really tell 232 * which is in use. 233 */ 234typedef enum { 235 TULIP_MEDIA_UNKNOWN, 236 TULIP_MEDIA_10BASET, 237 TULIP_MEDIA_10BASET_FD, 238 TULIP_MEDIA_BNC, 239 TULIP_MEDIA_AUI, 240 TULIP_MEDIA_EXTSIA, 241 TULIP_MEDIA_AUIBNC, 242 TULIP_MEDIA_100BASETX, 243 TULIP_MEDIA_100BASETX_FD, 244 TULIP_MEDIA_100BASET4, 245 TULIP_MEDIA_100BASEFX, 246 TULIP_MEDIA_100BASEFX_FD, 247 TULIP_MEDIA_MAX 248} tulip_media_t; 249 250#define TULIP_BIT(b) (1L << ((int)(b))) 251#define TULIP_FDBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ## _FD)) 252#define TULIP_MBIT(m) (1L << ((int)TULIP_MEDIA_ ## m )) 253#define TULIP_IS_MEDIA_FD(m) (TULIP_BIT(m) & \ 254 (TULIP_FDBIT(10BASET) \ 255 |TULIP_FDBIT(100BASETX) \ 256 |TULIP_FDBIT(100BASEFX))) 257#define TULIP_CAN_MEDIA_FD(m) (TULIP_BIT(m) & \ 258 (TULIP_MBIT(10BASET) \ 259 |TULIP_MBIT(100BASETX) \ 260 |TULIP_MBIT(100BASEFX))) 261#define TULIP_FD_MEDIA_OF(m) ((tulip_media_t)((m) + 1)) 262#define TULIP_HD_MEDIA_OF(m) ((tulip_media_t)((m) - 1)) 263#define TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX) 264#define TULIP_IS_MEDIA_TP(m) ((TULIP_BIT(m) & \ 265 (TULIP_MBIT(BNC) \ 266 |TULIP_MBIT(AUI) \ 267 |TULIP_MBIT(AUIBNC) \ 268 |TULIP_MBIT(EXTSIA))) == 0) 269 270#define TULIP_SROM_ATTR_MII 0x0100 271#define TULIP_SROM_ATTR_NWAY 0x0200 272#define TULIP_SROM_ATTR_AUTOSENSE 0x0400 273#define TULIP_SROM_ATTR_POWERUP 0x0800 274#define TULIP_SROM_ATTR_NOLINKPASS 0x1000 275 276typedef struct { 277 enum { 278 TULIP_MEDIAINFO_NONE, 279 TULIP_MEDIAINFO_SIA, 280 TULIP_MEDIAINFO_GPR, 281 TULIP_MEDIAINFO_MII, 282 TULIP_MEDIAINFO_RESET, 283 TULIP_MEDIAINFO_SYM 284 } mi_type; 285 union { 286 struct { 287 u_int16_t sia_connectivity; 288 u_int16_t sia_tx_rx; 289 u_int16_t sia_general; 290 u_int32_t sia_gp_control; /* 21142/21143 */ 291 u_int32_t sia_gp_data; /* 21142/21143 */ 292 } un_sia; 293 struct { 294 u_int32_t gpr_cmdmode; 295 u_int32_t gpr_gpcontrol; /* 21142/21143 */ 296 u_int32_t gpr_gpdata; 297 u_int8_t gpr_actmask; 298 u_int8_t gpr_actdata; 299 u_int8_t gpr_default : 1; 300 } un_gpr; 301 struct { 302 u_int32_t mii_mediamask; 303 u_int16_t mii_capabilities; 304 u_int16_t mii_advertisement; 305 u_int16_t mii_full_duplex; 306 u_int16_t mii_tx_threshold; 307 u_int16_t mii_interrupt; /* 21142/21143 */ 308 u_int8_t mii_phyaddr; 309 u_int8_t mii_gpr_length; 310 u_int8_t mii_gpr_offset; 311 u_int8_t mii_reset_length; 312 u_int8_t mii_reset_offset; 313 u_int32_t mii_phyid; 314 } un_mii; 315 } mi_un; 316} tulip_media_info_t; 317 318#define mi_sia_connectivity mi_un.un_sia.sia_connectivity 319#define mi_sia_tx_rx mi_un.un_sia.sia_tx_rx 320#define mi_sia_general mi_un.un_sia.sia_general 321#define mi_sia_gp_control mi_un.un_sia.sia_gp_control 322#define mi_sia_gp_data mi_un.un_sia.sia_gp_data 323 324#define mi_gpcontrol mi_un.un_gpr.gpr_gpcontrol 325#define mi_gpdata mi_un.un_gpr.gpr_gpdata 326#define mi_actmask mi_un.un_gpr.gpr_actmask 327#define mi_actdata mi_un.un_gpr.gpr_actdata 328#define mi_default mi_un.un_gpr.gpr_default 329#define mi_cmdmode mi_un.un_gpr.gpr_cmdmode 330 331#define mi_phyaddr mi_un.un_mii.mii_phyaddr 332#define mi_gpr_length mi_un.un_mii.mii_gpr_length 333#define mi_gpr_offset mi_un.un_mii.mii_gpr_offset 334#define mi_reset_length mi_un.un_mii.mii_reset_length 335#define mi_reset_offset mi_un.un_mii.mii_reset_offset 336#define mi_capabilities mi_un.un_mii.mii_capabilities 337#define mi_advertisement mi_un.un_mii.mii_advertisement 338#define mi_full_duplex mi_un.un_mii.mii_full_duplex 339#define mi_tx_threshold mi_un.un_mii.mii_tx_threshold 340#define mi_mediamask mi_un.un_mii.mii_mediamask 341#define mi_mii_interrupt mi_un.un_mii.mii_interrupt 342#define mi_phyid mi_un.un_mii.mii_phyid 343 344#define TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \ 345 (mi)->mi_type = TULIP_MEDIAINFO_SIA; \ 346 sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \ 347 (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \ 348 (mi)->mi_sia_tx_rx = TULIP_ ## chipid ## _SIATXRX_ ## media; \ 349 (mi)->mi_sia_general = TULIP_ ## chipid ## _SIAGEN_ ## media; \ 350} while (0) 351 352#define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do { \ 353 if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL \ 354 && ((mi)->mi_capabilities & PHYSTS_ ## media)) { \ 355 (sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \ 356 (mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \ 357 } \ 358} while (0) 359 360#define TULIP_MII_NOPHY 32 361/* 362 * Some boards need to treated specially. The following enumeration 363 * identifies the cards with quirks (or those we just want to single 364 * out for special merit or scorn). 365 */ 366typedef enum { 367 TULIP_21040_GENERIC, /* Generic 21040 (works with most any board) */ 368 TULIP_21140_ISV, /* Digital Semicondutor 21140 ISV SROM Format */ 369 TULIP_21142_ISV, /* Digital Semicondutor 21142 ISV SROM Format */ 370 TULIP_21143_ISV, /* Digital Semicondutor 21143 ISV SROM Format */ 371 TULIP_21140_DEC_EB, /* Digital Semicondutor 21140 Evaluation Board */ 372 TULIP_21140_MII, /* 21140[A] with MII */ 373 TULIP_21140_DEC_DE500, /* Digital DE500-?? 10/100 */ 374 TULIP_21140_SMC_9332, /* SMC 9332 */ 375 TULIP_21140_COGENT_EM100, /* Cogent EM100 100 only */ 376 TULIP_21140_ZNYX_ZX34X, /* ZNYX ZX342 10/100 */ 377 TULIP_21140_ASANTE, /* AsanteFast 10/100 */ 378 TULIP_21140_EN1207, /* Accton EN2107 10/100 BNC */ 379 TULIP_21041_GENERIC /* Generic 21041 card */ 380} tulip_board_t; 381 382typedef enum { 383 TULIP_MEDIAPOLL_TIMER, /* 100ms timer fired */ 384 TULIP_MEDIAPOLL_FASTTIMER, /* <100ms timer fired */ 385 TULIP_MEDIAPOLL_LINKFAIL, /* called from interrupt routine */ 386 TULIP_MEDIAPOLL_LINKPASS, /* called from interrupt routine */ 387 TULIP_MEDIAPOLL_START, /* start a media probe (called from reset) */ 388 TULIP_MEDIAPOLL_TXPROBE_OK, /* txprobe succeeded */ 389 TULIP_MEDIAPOLL_TXPROBE_FAILED, /* txprobe failed */ 390 TULIP_MEDIAPOLL_MAX 391} tulip_mediapoll_event_t; 392 393typedef enum { 394 TULIP_LINK_DOWN, /* Link is down */ 395 TULIP_LINK_UP, /* link is ok */ 396 TULIP_LINK_UNKNOWN /* we can't tell either way */ 397} tulip_link_status_t; 398 399 400/* 401 * This data structure is used to abstract out the quirks. 402 * media_probe = tries to determine the media type. 403 * media_select = enables the current media (or autosenses) 404 * media_poll = autosenses media 405 * media_preset = 21140, etal requires bit to set before the 406 * the software reset; hence pre-set. Should be 407 * pre-reset but that's ugly. 408 */ 409 410typedef struct { 411 tulip_board_t bd_type; 412 void (*bd_media_probe)(tulip_softc_t * const sc); 413 void (*bd_media_select)(tulip_softc_t * const sc); 414 void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event); 415 void (*bd_media_preset)(tulip_softc_t * const sc); 416#if defined(__bsdi__) && _BSDI_VERSION >= 199701 417 struct ifmedia_entry *bd_media_list; 418 int bd_media_cnt; 419 int bd_media_options_mask; 420#endif 421} tulip_boardsw_t; 422 423/* 424 * The next few declarations are for MII/PHY based board. 425 * 426 * The first enumeration identifies a superset of various datums 427 * that can be obtained from various PHY chips. Not all PHYs will 428 * support all datums. 429 * The modedata structure indicates what register contains 430 * a datum, what mask is applied the register contents, and what the 431 * result should be. 432 * The attr structure records information about a supported PHY. 433 * The phy structure records information about a PHY instance. 434 */ 435 436typedef enum { 437 PHY_MODE_10T, 438 PHY_MODE_100TX, 439 PHY_MODE_100T4, 440 PHY_MODE_FULLDUPLEX, 441 PHY_MODE_MAX 442} tulip_phy_mode_t; 443 444typedef struct { 445 u_int16_t pm_regno; 446 u_int16_t pm_mask; 447 u_int16_t pm_value; 448} tulip_phy_modedata_t; 449 450typedef struct { 451 u_int32_t attr_id; 452 u_int16_t attr_flags; 453#define PHY_NEED_HARD_RESET 0x0001 454#define PHY_DUAL_CYCLE_TA 0x0002 455 tulip_phy_modedata_t attr_modes[PHY_MODE_MAX]; 456#ifdef TULIP_DEBUG 457 const char *attr_name; 458#endif 459} tulip_phy_attr_t; 460 461/* 462 * Various probe states used when trying to autosense the media. 463 */ 464 465typedef enum { 466 TULIP_PROBE_INACTIVE, 467 TULIP_PROBE_PHYRESET, 468 TULIP_PROBE_PHYAUTONEG, 469 TULIP_PROBE_GPRTEST, 470 TULIP_PROBE_MEDIATEST, 471 TULIP_PROBE_FAILED 472} tulip_probe_state_t; 473 474typedef struct { 475 /* 476 * Transmit Statistics 477 */ 478 u_int32_t dot3StatsSingleCollisionFrames; 479 u_int32_t dot3StatsMultipleCollisionFrames; 480 u_int32_t dot3StatsSQETestErrors; 481 u_int32_t dot3StatsDeferredTransmissions; 482 u_int32_t dot3StatsLateCollisions; 483 u_int32_t dot3StatsExcessiveCollisions; 484 u_int32_t dot3StatsCarrierSenseErrors; 485 u_int32_t dot3StatsInternalMacTransmitErrors; 486 u_int32_t dot3StatsInternalTransmitUnderflows; /* not in rfc1650! */ 487 u_int32_t dot3StatsInternalTransmitBabbles; /* not in rfc1650! */ 488 /* 489 * Receive Statistics 490 */ 491 u_int32_t dot3StatsMissedFrames; /* not in rfc1650! */ 492 u_int32_t dot3StatsAlignmentErrors; 493 u_int32_t dot3StatsFCSErrors; 494 u_int32_t dot3StatsFrameTooLongs; 495 u_int32_t dot3StatsInternalMacReceiveErrors; 496} tulip_dot3_stats_t; 497 498/* 499 * Now to important stuff. This is softc structure (where does softc 500 * come from??? No idea) for the tulip device. 501 * 502 */ 503struct _tulip_softc_t { 504#if defined(__bsdi__) 505 struct device tulip_dev; /* base device */ 506 struct isadev tulip_id; /* ISA device */ 507 struct intrhand tulip_ih; /* intrrupt vectoring */ 508 struct atshutdown tulip_ats; /* shutdown hook */ 509#if _BSDI_VERSION < 199401 510 caddr_t tulip_bpf; /* for BPF */ 511#else 512 prf_t tulip_pf; /* printf function */ 513#if _BSDI_VERSION >= 199701 514 struct mii_data tulip_mii; /* Generic MII and media data */ 515#define tulip_ifmedia tulip_mii.mii_media 516#endif /* _BSDI_VERSION >= 199701 */ 517#endif /* _BSDI_VERSION < 199401 */ 518#endif /* __bsdi__ */ 519#if defined(__NetBSD__) || defined(__OpenBSD__) 520 struct device tulip_dev; /* base device */ 521 void *tulip_ih; /* intrrupt vectoring */ 522 void *tulip_ats; /* shutdown hook */ 523 524 bus_space_tag_t tulip_bustag; /* tag of CSR region being used */ 525 bus_space_handle_t tulip_bushandle; /* handle for CSR region being used */ 526 pci_chipset_tag_t tulip_pc; 527#if !defined(__OpenBSD__) 528 struct ethercom tulip_ec; 529#endif 530 u_int8_t tulip_enaddr[ETHER_ADDR_LEN]; 531#endif 532#if !defined(tulip_ifmedia) && defined(IFM_ETHER) 533 struct ifmedia tulip_ifmedia; 534#endif 535#if !defined(__NetBSD__) 536 struct arpcom tulip_ac; 537 struct timeout tulip_ftmo, tulip_stmo; 538#endif 539 tulip_regfile_t tulip_csrs; 540 u_int32_t tulip_flags; 541#define TULIP_WANTSETUP 0x00000001 542#define TULIP_WANTHASHPERFECT 0x00000002 543#define TULIP_WANTHASHONLY 0x00000004 544#define TULIP_DOINGSETUP 0x00000008 545#define TULIP_PRINTMEDIA 0x00000010 546#define TULIP_TXPROBE_ACTIVE 0x00000020 547#define TULIP_ALLMULTI 0x00000040 548#define TULIP_WANTRXACT 0x00000080 549#define TULIP_RXACT 0x00000100 550#define TULIP_INRESET 0x00000200 551#define TULIP_NEEDRESET 0x00000400 552#define TULIP_SQETEST 0x00000800 553#define TULIP_xxxxxx0 0x00001000 554#define TULIP_xxxxxx1 0x00002000 555#define TULIP_WANTTXSTART 0x00004000 556#define TULIP_NEWTXTHRESH 0x00008000 557#define TULIP_NOAUTOSENSE 0x00010000 558#define TULIP_PRINTLINKUP 0x00020000 559#define TULIP_LINKUP 0x00040000 560#define TULIP_RXBUFSLOW 0x00080000 561#define TULIP_NOMESSAGES 0x00100000 562#define TULIP_SYSTEMERROR 0x00200000 563#define TULIP_TIMEOUTPENDING 0x00400000 564#define TULIP_xxxxxx2 0x00800000 565#define TULIP_TRYNWAY 0x01000000 566#define TULIP_DIDNWAY 0x02000000 567#define TULIP_RXIGNORE 0x04000000 568#define TULIP_PROBE1STPASS 0x08000000 569#define TULIP_DEVICEPROBE 0x10000000 570#define TULIP_PROMISC 0x20000000 571#define TULIP_HASHONLY 0x40000000 572#define TULIP_xxxxxx3 0x80000000 573 /* only 4 bits left! */ 574 u_int32_t tulip_features; /* static bits indicating features of chip */ 575#define TULIP_HAVE_GPR 0x00000001 /* have gp register (140[A]) */ 576#define TULIP_HAVE_RXBADOVRFLW 0x00000002 /* RX corrupts on overflow */ 577#define TULIP_HAVE_POWERMGMT 0x00000004 /* Snooze/sleep modes */ 578#define TULIP_HAVE_MII 0x00000008 /* Some medium on MII */ 579#define TULIP_HAVE_SIANWAY 0x00000010 /* SIA does NWAY */ 580#define TULIP_HAVE_DUALSENSE 0x00000020 /* SIA senses both AUI & TP */ 581#define TULIP_HAVE_SIAGP 0x00000040 /* SIA has a GP port */ 582#define TULIP_HAVE_BROKEN_HASH 0x00000080 /* Broken Multicast Hash */ 583#define TULIP_HAVE_ISVSROM 0x00000100 /* uses ISV SROM Format */ 584#define TULIP_HAVE_BASEROM 0x00000200 /* Board ROM can be cloned */ 585#define TULIP_HAVE_SLAVEDROM 0x00000400 /* Board ROM cloned */ 586#define TULIP_HAVE_SLAVEDINTR 0x00000800 /* Board slaved interrupt */ 587#define TULIP_HAVE_SHAREDINTR 0x00001000 /* Board shares interrupts */ 588#define TULIP_HAVE_OKROM 0x00002000 /* ROM was recognized */ 589#define TULIP_HAVE_NOMEDIA 0x00004000 /* did not detect any media */ 590#define TULIP_HAVE_STOREFWD 0x00008000 /* have CMD_STOREFWD */ 591#define TULIP_HAVE_SIA100 0x00010000 /* has LS100 in SIA status */ 592#define TULIP_HAVE_OKSROM 0x00020000 /* SROM CRC is OK */ 593 u_int32_t tulip_intrmask; /* our copy of csr_intr */ 594 u_int32_t tulip_cmdmode; /* our copy of csr_cmdmode */ 595 u_int32_t tulip_last_system_error : 3; /* last system error (only value is TULIP_SYSTEMERROR is also set) */ 596 u_int32_t tulip_txtimer : 2; /* transmission timer */ 597 u_int32_t tulip_system_errors; /* number of system errors encountered */ 598 u_int32_t tulip_statusbits; /* status bits from CSR5 that may need to be printed */ 599 600 tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX]; /* indexes into mediainfo */ 601 tulip_media_t tulip_media; /* current media type */ 602 u_int32_t tulip_abilities; /* remote system's abiltities (as defined in IEEE 802.3u) */ 603 604 u_int8_t tulip_revinfo; /* revision of chip */ 605 u_int8_t tulip_phyaddr; /* 0..31 -- address of current phy */ 606 u_int8_t tulip_gpinit; /* active pins on 21140 */ 607 u_int8_t tulip_gpdata; /* default gpdata for 21140 */ 608 609 struct { 610 u_int8_t probe_count; /* count of probe operations */ 611 int32_t probe_timeout; /* time in ms of probe timeout */ 612 tulip_probe_state_t probe_state; /* current media probe state */ 613 tulip_media_t probe_media; /* current media being probed */ 614 u_int32_t probe_mediamask; /* medias checked */ 615 u_int32_t probe_passes; /* times autosense failed */ 616 u_int32_t probe_txprobes; /* txprobes attempted */ 617 } tulip_probe; 618#define tulip_probe_count tulip_probe.probe_count 619#define tulip_probe_timeout tulip_probe.probe_timeout 620#define tulip_probe_state tulip_probe.probe_state 621#define tulip_probe_media tulip_probe.probe_media 622#define tulip_probe_mediamask tulip_probe.probe_mediamask 623#define tulip_probe_passes tulip_probe.probe_passes 624 625 tulip_chipid_t tulip_chipid; /* type of chip we are using */ 626 const tulip_boardsw_t *tulip_boardsw; /* board/chip characteristics */ 627 tulip_softc_t *tulip_slaves; /* slaved devices (ZX3xx) */ 628#if defined(TULIP_DEBUG) 629 /* 630 * Debugging/Statistical information 631 */ 632 struct { 633 tulip_media_t dbg_last_media; 634 u_int32_t dbg_intrs; 635 u_int32_t dbg_media_probes; 636 u_int32_t dbg_txprobe_nocarr; 637 u_int32_t dbg_txprobe_exccoll; 638 u_int32_t dbg_link_downed; 639 u_int32_t dbg_link_suspected; 640 u_int32_t dbg_link_intrs; 641 u_int32_t dbg_link_pollintrs; 642 u_int32_t dbg_link_failures; 643 u_int32_t dbg_nway_starts; 644 u_int32_t dbg_nway_failures; 645 u_int16_t dbg_phyregs[32][4]; 646 u_int32_t dbg_rxlowbufs; 647 u_int32_t dbg_rxintrs; 648 u_int32_t dbg_last_rxintrs; 649 u_int32_t dbg_high_rxintrs_hz; 650 u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX]; 651 u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX]; 652 u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX]; 653 u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS]; 654 } tulip_dbg; 655#endif 656#if defined(TULIP_PERFSTATS) 657#define TULIP_PERF_CURRENT 0 658#define TULIP_PERF_PREVIOUS 1 659#define TULIP_PERF_TOTAL 2 660#define TULIP_PERF_MAX 3 661 struct tulip_perfstats { 662 u_quad_t perf_intr_cycles; 663 u_quad_t perf_ifstart_cycles; 664 u_quad_t perf_ifstart_one_cycles; 665 u_quad_t perf_ifioctl_cycles; 666 u_quad_t perf_ifwatchdog_cycles; 667 u_quad_t perf_timeout_cycles; 668 u_quad_t perf_txput_cycles; 669 u_quad_t perf_txintr_cycles; 670 u_quad_t perf_rxintr_cycles; 671 u_quad_t perf_rxget_cycles; 672 unsigned perf_intr; 673 unsigned perf_ifstart; 674 unsigned perf_ifstart_one; 675 unsigned perf_ifioctl; 676 unsigned perf_ifwatchdog; 677 unsigned perf_timeout; 678 unsigned perf_txput; 679 unsigned perf_txintr; 680 unsigned perf_rxintr; 681 unsigned perf_rxget; 682 } tulip_perfstats[TULIP_PERF_MAX]; 683#define tulip_curperfstats tulip_perfstats[TULIP_PERF_CURRENT] 684#endif 685 struct ifqueue tulip_txq; 686 struct ifqueue tulip_rxq; 687 tulip_dot3_stats_t tulip_dot3stats; 688 tulip_ringinfo_t tulip_rxinfo; 689 tulip_ringinfo_t tulip_txinfo; 690 tulip_media_info_t tulip_mediainfo[10]; 691 /* 692 * The setup buffers for sending the setup frame to the chip. 693 * one is the one being sent while the other is the one being 694 * filled. 695 */ 696 u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)]; 697 u_int32_t tulip_setupdata[192/sizeof(u_int32_t)]; 698 char tulip_boardid[16]; /* buffer for board ID */ 699 u_int8_t tulip_rombuf[128]; 700#if defined(__NetBSD__) 701 struct device *tulip_pci_busno; /* needed for multiport boards */ 702#else 703 u_int8_t tulip_pci_busno; /* needed for multiport boards */ 704#endif 705 u_int8_t tulip_pci_devno; /* needed for multiport boards */ 706 u_int8_t tulip_connidx; 707 tulip_srom_connection_t tulip_conntype; 708 tulip_desc_t tulip_rxdescs[TULIP_RXDESCS]; 709 tulip_desc_t tulip_txdescs[TULIP_TXDESCS]; 710#if defined(__NetBSD__) && NRND > 0 711 rndsource_element_t tulip_rndsource; 712#endif 713}; 714 715#if defined(IFM_ETHER) 716#define TULIP_DO_AUTOSENSE(sc) (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO) 717#else 718#define TULIP_DO_AUTOSENSE(sc) (((sc)->tulip_flags & TULIP_NOAUTOSENSE) == 0) 719#endif 720 721 722#if defined(TULIP_HDR_DATA) 723static const char * const tulip_chipdescs[] = { 724 "21040 [10Mb/s]", 725#if defined(TULIP_EISA) 726 "DE425 [10Mb/s]", 727#else 728 NULL, 729#endif 730 "21041 [10Mb/s]", 731 "21140 [10-100Mb/s]", 732 "21140A [10-100Mb/s]", 733 "21142 [10-100Mb/s]", 734 "21143 [10-100Mb/s]", 735 "82C168 [10-100Mb/s]", 736}; 737 738static const char * const tulip_mediums[] = { 739 "unknown", /* TULIP_MEDIA_UNKNOWN */ 740 "10baseT", /* TULIP_MEDIA_10BASET */ 741 "Full Duplex 10baseT", /* TULIP_MEDIA_10BASET_FD */ 742 "BNC", /* TULIP_MEDIA_BNC */ 743 "AUI", /* TULIP_MEDIA_AUI */ 744 "External SIA", /* TULIP_MEDIA_EXTSIA */ 745 "AUI/BNC", /* TULIP_MEDIA_AUIBNC */ 746 "100baseTX", /* TULIP_MEDIA_100BASET */ 747 "Full Duplex 100baseTX", /* TULIP_MEDIA_100BASET_FD */ 748 "100baseT4", /* TULIP_MEDIA_100BASET4 */ 749 "100baseFX", /* TULIP_MEDIA_100BASEFX */ 750 "Full Duplex 100baseFX", /* TULIP_MEDIA_100BASEFX_FD */ 751}; 752 753#if defined(IFM_ETHER) 754static const int tulip_media_to_ifmedia[] = { 755 IFM_ETHER | IFM_NONE, /* TULIP_MEDIA_UNKNOWN */ 756 IFM_ETHER | IFM_10_T, /* TULIP_MEDIA_10BASET */ 757 IFM_ETHER | IFM_10_T | IFM_FDX, /* TULIP_MEDIA_10BASET_FD */ 758 IFM_ETHER | IFM_10_2, /* TULIP_MEDIA_BNC */ 759 IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUI */ 760 IFM_ETHER | IFM_MANUAL, /* TULIP_MEDIA_EXTSIA */ 761 IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUIBNC */ 762 IFM_ETHER | IFM_100_TX, /* TULIP_MEDIA_100BASET */ 763 IFM_ETHER | IFM_100_TX | IFM_FDX, /* TULIP_MEDIA_100BASET_FD */ 764 IFM_ETHER | IFM_100_T4, /* TULIP_MEDIA_100BASET4 */ 765 IFM_ETHER | IFM_100_FX, /* TULIP_MEDIA_100BASEFX */ 766 IFM_ETHER | IFM_100_FX | IFM_FDX, /* TULIP_MEDIA_100BASEFX_FD */ 767}; 768#endif /* defined(IFM_ETHER) */ 769 770static const char * const tulip_system_errors[] = { 771 "parity error", 772 "master abort", 773 "target abort", 774 "reserved #3", 775 "reserved #4", 776 "reserved #5", 777 "reserved #6", 778 "reserved #7", 779}; 780 781static const char * const tulip_status_bits[] = { 782 NULL, 783 "transmit process stopped", 784 NULL, 785 "transmit jabber timeout", 786 787 NULL, 788 "transmit underflow", 789 NULL, 790 "receive underflow", 791 792 "receive process stopped", 793 "receive watchdog timeout", 794 NULL, 795 NULL, 796 797 "link failure", 798 NULL, 799 NULL, 800}; 801 802static const struct { 803 tulip_srom_connection_t sc_type; 804 tulip_media_t sc_media; 805 u_int32_t sc_attrs; 806} tulip_srom_conninfo[] = { 807 { TULIP_SROM_CONNTYPE_10BASET, TULIP_MEDIA_10BASET }, 808 { TULIP_SROM_CONNTYPE_BNC, TULIP_MEDIA_BNC }, 809 { TULIP_SROM_CONNTYPE_AUI, TULIP_MEDIA_AUI }, 810 { TULIP_SROM_CONNTYPE_100BASETX, TULIP_MEDIA_100BASETX }, 811 { TULIP_SROM_CONNTYPE_100BASET4, TULIP_MEDIA_100BASET4 }, 812 { TULIP_SROM_CONNTYPE_100BASEFX, TULIP_MEDIA_100BASEFX }, 813 { TULIP_SROM_CONNTYPE_MII_10BASET, TULIP_MEDIA_10BASET, 814 TULIP_SROM_ATTR_MII }, 815 { TULIP_SROM_CONNTYPE_MII_100BASETX, TULIP_MEDIA_100BASETX, 816 TULIP_SROM_ATTR_MII }, 817 { TULIP_SROM_CONNTYPE_MII_100BASET4, TULIP_MEDIA_100BASET4, 818 TULIP_SROM_ATTR_MII }, 819 { TULIP_SROM_CONNTYPE_MII_100BASEFX, TULIP_MEDIA_100BASEFX, 820 TULIP_SROM_ATTR_MII }, 821 { TULIP_SROM_CONNTYPE_10BASET_NWAY, TULIP_MEDIA_10BASET, 822 TULIP_SROM_ATTR_NWAY }, 823 { TULIP_SROM_CONNTYPE_10BASET_FD, TULIP_MEDIA_10BASET_FD }, 824 { TULIP_SROM_CONNTYPE_MII_10BASET_FD, TULIP_MEDIA_10BASET_FD, 825 TULIP_SROM_ATTR_MII }, 826 { TULIP_SROM_CONNTYPE_100BASETX_FD, TULIP_MEDIA_100BASETX_FD }, 827 { TULIP_SROM_CONNTYPE_MII_100BASETX_FD, TULIP_MEDIA_100BASETX_FD, 828 TULIP_SROM_ATTR_MII }, 829 { TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS, TULIP_MEDIA_10BASET, 830 TULIP_SROM_ATTR_NOLINKPASS }, 831 { TULIP_SROM_CONNTYPE_AUTOSENSE, TULIP_MEDIA_UNKNOWN, 832 TULIP_SROM_ATTR_AUTOSENSE }, 833 { TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP, TULIP_MEDIA_UNKNOWN, 834 TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP }, 835 { TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY, TULIP_MEDIA_UNKNOWN, 836 TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY }, 837 { TULIP_SROM_CONNTYPE_NOT_USED, TULIP_MEDIA_UNKNOWN } 838}; 839#define TULIP_SROM_LASTCONNIDX \ 840 (sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1) 841 842static const struct { 843 tulip_media_t sm_type; 844 tulip_srom_media_t sm_srom_type; 845} tulip_srom_mediums[] = { 846 { TULIP_MEDIA_100BASEFX_FD, TULIP_SROM_MEDIA_100BASEFX_FD }, 847 { TULIP_MEDIA_100BASEFX, TULIP_SROM_MEDIA_100BASEFX }, 848 { TULIP_MEDIA_100BASET4, TULIP_SROM_MEDIA_100BASET4 }, 849 { TULIP_MEDIA_100BASETX_FD, TULIP_SROM_MEDIA_100BASETX_FD }, 850 { TULIP_MEDIA_100BASETX, TULIP_SROM_MEDIA_100BASETX }, 851 { TULIP_MEDIA_10BASET_FD, TULIP_SROM_MEDIA_10BASET_FD }, 852 { TULIP_MEDIA_AUI, TULIP_SROM_MEDIA_AUI }, 853 { TULIP_MEDIA_BNC, TULIP_SROM_MEDIA_BNC }, 854 { TULIP_MEDIA_10BASET, TULIP_SROM_MEDIA_10BASET }, 855 { TULIP_MEDIA_UNKNOWN } 856}; 857#endif /* TULIP_HDR_DATA */ 858 859/* 860 * This driver supports a maximum of 32 tulip boards. 861 * This should be enough for the forseeable future. 862 */ 863#define TULIP_MAX_DEVICES 32 864 865#if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA) 866static u_int32_t tulip_softintr_mask; 867static int tulip_softintr_last_unit; 868static int tulip_softintr_max_unit; 869static void tulip_softintr(void); 870#endif 871 872#ifdef notyet 873#define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */ 874#define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */ 875#endif 876 877#if defined(__FreeBSD__) 878typedef void ifnet_ret_t; 879typedef int ioctl_cmd_t; 880#if defined(TULIP_HDR_DATA) 881static tulip_softc_t *tulips[TULIP_MAX_DEVICES]; 882#endif 883#if BSD >= 199506 884#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc)) 885#if NBPFILTER > 0 886#define TULIP_BPF_MTAP(sc, m) bpf_mtap(&(sc)->tulip_if, m) 887#define TULIP_BPF_TAP(sc, p, l) bpf_tap(&(sc)->tulip_if, p, l) 888#define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header)) 889#endif 890#define tulip_intrfunc_t void 891#define TULIP_VOID_INTRFUNC 892#define IFF_NOTRAILERS 0 893#if 0 894#define TULIP_KVATOPHYS(sc, va) kvtop(va) 895#endif 896#define TULIP_EADDR_FMT "%6D" 897#define TULIP_EADDR_ARGS(addr) addr, ":" 898#else 899extern int bootverbose; 900#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit)) 901#include <sys/devconf.h> 902#define TULIP_DEVCONF 903#endif 904#if defined(TULIP_USE_SOFTINTR) 905NETISR_SET(NETISR_DE, tulip_softintr); 906#endif 907#define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit]) 908#define TULIP_BURSTSIZE(unit) pci_max_burst_len 909#define loudprintf if (bootverbose) printf 910#endif 911 912#if defined(__bsdi__) 913typedef int ifnet_ret_t; 914typedef u_long ioctl_cmd_t; 915extern struct cfdriver decd; 916#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit]) 917#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit)) 918#define TULIP_ETHER_IFATTACH(sc) ether_attach(&(sc)->tulip_if) 919#if _BSDI_VERSION >= 199510 920#if 0 921#define TULIP_BURSTSIZE(unit) log2_burst_size 922#endif 923#define loudprintf aprint_verbose 924#define printf (*sc->tulip_pf) 925#define MCNT(x) (sizeof(x) / sizeof(struct ifmedia_entry)) 926#elif _BSDI_VERSION <= 199401 927#define DRQNONE 0 928#define loudprintf printf 929static void 930arp_ifinit( 931 struct arpcom *ac, 932 struct ifaddr *ifa) 933{ 934 ac->ac_ipaddr = IA_SIN(ifa)->sin_addr; 935 arpwhohas(ac, &ac->ac_ipaddr); 936} 937#endif 938#endif /* __bsdi__ */ 939 940#if defined(__NetBSD__) || defined(__OpenBSD__) 941typedef void ifnet_ret_t; 942typedef u_long ioctl_cmd_t; 943extern struct cfattach de_ca; 944extern struct cfdriver de_cd; 945#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit]) 946#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc)) 947#define tulip_unit tulip_dev.dv_unit 948#if defined(__OpenBSD__) 949#define tulip_xname tulip_dev.dv_cfdata->cf_driver->cd_name 950#else 951#define tulip_xname tulip_if.if_xname 952#endif 953 954#if NBPFILTER > 0 955#define TULIP_BPF_MTAP(sc, m) bpf_mtap((sc)->tulip_if.if_bpf, m) 956#define TULIP_BPF_TAP(sc, p, l) bpf_tap((sc)->tulip_if.if_bpf, p, l) 957#define TULIP_BPF_ATTACH(sc) 958#endif 959#define TULIP_RAISESPL() splnet() 960#define TULIP_RAISESOFTSPL() splsoftnet() 961#define TULIP_RESTORESPL(s) splx(s) 962#define loudprintf printf 963 964#if !defined(__OpenBSD__) 965#define tulip_if tulip_ec.ec_if 966#define tulip_enaddr tulip_enaddr 967#define tulip_multicnt tulip_ec.ec_multicnt 968#define TULIP_ETHERCOM(sc) (&(sc)->tulip_ec) 969#define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->tulip_if, (ifa)) 970#define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if, (sc)->tulip_enaddr) 971#define TULIP_PRINTF_FMT "%s" 972#define TULIP_PRINTF_ARGS sc->tulip_xname 973#else 974#define TULIP_PRINTF_FMT "%s%d" 975#define TULIP_PRINTF_ARGS sc->tulip_xname, sc->tulip_unit 976#endif 977#endif /* __NetBSD__ */ 978 979#if defined(__alpha__) 980/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */ 981#define TULIP_KVATOPHYS(sc, va) alpha_XXX_dmamap((vm_offset_t)(va)) 982#endif 983 984#ifndef TULIP_PRINTF_FMT 985#define TULIP_PRINTF_FMT "%s%d" 986#endif 987#ifndef TULIP_PRINTF_ARGS 988#define TULIP_PRINTF_ARGS sc->tulip_name, sc->tulip_unit 989#endif 990 991#ifndef TULIP_BURSTSIZE 992#define TULIP_BURSTSIZE(unit) 3 993#endif 994 995#ifndef tulip_if 996#define tulip_if tulip_ac.ac_if 997#endif 998#ifndef tulip_unit 999#define tulip_unit tulip_if.if_unit 1000#endif 1001#define tulip_name tulip_if.if_name 1002#ifndef tulip_enaddr 1003#define tulip_enaddr tulip_ac.ac_enaddr 1004#endif 1005#ifndef tulip_multicnt 1006#define tulip_multicnt tulip_ac.ac_multicnt 1007#endif 1008 1009#if !defined(TULIP_ETHERCOM) 1010#define TULIP_ETHERCOM(sc) (&(sc)->tulip_ac) 1011#endif 1012 1013#if !defined(TULIP_ARP_IFINIT) 1014#define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(TULIP_ETHERCOM(sc), (ifa)) 1015#endif 1016 1017#if !defined(TULIP_ETHER_IFATTACH) 1018#define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if) 1019#endif 1020 1021#if !defined(tulip_bpf) && (!defined(__bsdi__) || _BSDI_VERSION >= 199401) 1022#define tulip_bpf tulip_if.if_bpf 1023#endif 1024 1025#if !defined(tulip_intrfunc_t) 1026#define tulip_intrfunc_t int 1027#endif 1028 1029#if !defined(TULIP_KVATOPHYS) 1030#define TULIP_KVATOPHYS(sc, va) vtophys((vaddr_t)va) 1031#endif 1032 1033#ifndef TULIP_RAISESPL 1034#define TULIP_RAISESPL() splimp() 1035#endif 1036#ifndef TULIP_RAISESOFTSPL 1037#define TULIP_RAISESOFTSPL() splnet() 1038#endif 1039#ifndef TULUP_RESTORESPL 1040#define TULIP_RESTORESPL(s) splx(s) 1041#endif 1042 1043/* 1044 * While I think FreeBSD's 2.2 change to the bpf is a nice simplification, 1045 * it does add yet more conditional code to this driver. Sigh. 1046 */ 1047#if !defined(TULIP_BPF_MTAP) && NBPFILTER > 0 1048#define TULIP_BPF_MTAP(sc, m) bpf_mtap((sc)->tulip_bpf, m) 1049#define TULIP_BPF_TAP(sc, p, l) bpf_tap((sc)->tulip_bpf, p, l) 1050#define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_bpf, &(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header)) 1051#endif 1052 1053#if defined(TULIP_PERFSTATS) 1054#define TULIP_PERFMERGE(sc, member) \ 1055 do { (sc)->tulip_perfstats[TULIP_PERF_TOTAL].member \ 1056 += (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \ 1057 (sc)->tulip_perfstats[TULIP_PERF_PREVIOUS].member \ 1058 = (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \ 1059 (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member = 0; } while (0) 1060#define TULIP_PERFSTART(name) const tulip_cycle_t perfstart_ ## name = TULIP_PERFREAD(); 1061#define TULIP_PERFEND(name) do { \ 1062 (sc)->tulip_curperfstats.perf_ ## name ## _cycles += TULIP_PERFDIFF(perfstart_ ## name, TULIP_PERFREAD()); \ 1063 (sc)->tulip_curperfstats.perf_ ## name ++; \ 1064 } while (0) 1065#if defined(__i386__) 1066typedef u_quad_t tulip_cycle_t; 1067static __inline__ tulip_cycle_t 1068TULIP_PERFREAD( 1069 void) 1070{ 1071 tulip_cycle_t x; 1072 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); 1073 return x; 1074} 1075#define TULIP_PERFDIFF(s, f) ((f) - (s)) 1076#elif defined(__alpha__) 1077typedef unsigned long tulip_cycle_t; 1078static __inline__ tulip_cycle_t 1079TULIP_PERFREAD( 1080 void) 1081{ 1082 tulip_cycle_t x; 1083 __asm__ volatile ("rpcc %0" : "=r" (x)); 1084 return x; 1085} 1086#define TULIP_PERFDIFF(s, f) ((unsigned int) ((f) - (s))) 1087#endif 1088#else 1089#define TULIP_PERFSTART(name) 1090#define TULIP_PERFEND(name) do { } while (0) 1091#define TULIP_PERFMERGE(s,n) do { } while (0) 1092#endif /* TULIP_PERFSTATS */ 1093 1094/* 1095 * However, this change to FreeBSD I am much less enamored with. 1096 */ 1097#if !defined(TULIP_EADDR_FMT) 1098#define TULIP_EADDR_FMT "%s" 1099#define TULIP_EADDR_ARGS(addr) ether_sprintf(addr) 1100#endif 1101 1102#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */ 1103#define TULIP_MAX_TXSEG 30 1104 1105#define TULIP_ADDREQUAL(a1, a2) \ 1106 (((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \ 1107 && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \ 1108 && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2]) 1109#define TULIP_ADDRBRDCST(a1) \ 1110 (((u_int16_t *)a1)[0] == 0xFFFFU \ 1111 && ((u_int16_t *)a1)[1] == 0xFFFFU \ 1112 && ((u_int16_t *)a1)[2] == 0xFFFFU) 1113 1114typedef int tulip_spl_t; 1115 1116#endif /* !defined(_DEVAR_H) */ 1117