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