if_de.c revision 4796
1/*- 2 * Copyright (c) 1994 Matt Thomas (thomas@lkg.dec.com) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. The name of the author may not be used to endorse or promote products 11 * derived from this software withough specific prior written permission 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * 24 * $Id: if_de.c,v 1.7 1994/11/22 09:47:31 davidg Exp $ 25 * 26 */ 27 28/* 29 * DEC DC21040 PCI Ethernet Controller 30 * 31 * Written by Matt Thomas 32 * BPF support code stolen directly from if_ec.c 33 * 34 * This driver supports the DEC DE435 or any other PCI 35 * board which support DC21040. 36 */ 37 38#include "de.h" 39#if NDE > 0 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/mbuf.h> 44#include <sys/protosw.h> 45#include <sys/socket.h> 46#include <sys/ioctl.h> 47#include <sys/errno.h> 48#include <sys/malloc.h> 49 50#include <net/if.h> 51#include <net/if_types.h> 52#include <net/if_dl.h> 53#include <net/route.h> 54 55#include "bpfilter.h" 56#if NBPFILTER > 0 57#include <net/bpf.h> 58#include <net/bpfdesc.h> 59#endif 60 61#ifdef INET 62#include <netinet/in.h> 63#include <netinet/in_systm.h> 64#include <netinet/in_var.h> 65#include <netinet/ip.h> 66#include <netinet/if_ether.h> 67#endif 68 69#ifdef NS 70#include <netns/ns.h> 71#include <netns/ns_if.h> 72#endif 73 74#include <vm/vm.h> 75#include <vm/vm_kern.h> 76#include <vm/vm_param.h> 77 78 79#include <pci.h> 80#if NPCI > 0 81#include <i386/pci/pcireg.h> 82#endif 83#include <i386/isa/icu.h> 84#include <i386/pci/dc21040.h> 85 86/* 87 * This module supports the DEC DC21040 PCI Ethernet Controller. 88 */ 89 90typedef struct { 91 unsigned long addr; 92 unsigned long length; 93} tulip_addrvec_t; 94 95typedef struct { 96 tulip_desc_t *ri_first; 97 tulip_desc_t *ri_last; 98 tulip_desc_t *ri_nextin; 99 tulip_desc_t *ri_nextout; 100 int ri_max; 101 int ri_free; 102} tulip_ringinfo_t; 103 104typedef struct { 105 volatile tulip_uint32_t *csr_busmode; /* CSR0 */ 106 volatile tulip_uint32_t *csr_txpoll; /* CSR1 */ 107 volatile tulip_uint32_t *csr_rxpoll; /* CSR2 */ 108 volatile tulip_uint32_t *csr_rxlist; /* CSR3 */ 109 volatile tulip_uint32_t *csr_txlist; /* CSR4 */ 110 volatile tulip_uint32_t *csr_status; /* CSR5 */ 111 volatile tulip_uint32_t *csr_command; /* CSR6 */ 112 volatile tulip_uint32_t *csr_intr; /* CSR7 */ 113 volatile tulip_uint32_t *csr_missed_frame; /* CSR8 */ 114 volatile tulip_sint32_t *csr_enetrom; /* CSR9 */ 115 volatile tulip_uint32_t *csr_reserved; /* CSR10 */ 116 volatile tulip_uint32_t *csr_full_duplex; /* CSR11 */ 117 volatile tulip_uint32_t *csr_sia_status; /* CSR12 */ 118 volatile tulip_uint32_t *csr_sia_connectivity; /* CSR13 */ 119 volatile tulip_uint32_t *csr_sia_tx_rx; /* CSR14 */ 120 volatile tulip_uint32_t *csr_sia_general; /* CSR15 */ 121} tulip_regfile_t; 122 123/* 124 * The DC21040 has a stupid restriction in that the receive 125 * buffers must be longword aligned. But since Ethernet 126 * headers are not a multiple of longwords in size this forces 127 * the data to non-longword aligned. Since IP requires the 128 * data to be longword aligned, we need to copy it after it has 129 * been DMA'ed in our memory. 130 * 131 * Since we have to copy it anyways, we might as well as allocate 132 * dedicated receive space for the input. This allows to use a 133 * small receive buffer size and more ring entries to be able to 134 * better keep with a flood of tiny Ethernet packets. 135 * 136 * The receive space MUST ALWAYS be a multiple of the page size. 137 * And the number of receive descriptors multiplied by the size 138 * of the receive buffers must equal the recevive space. This 139 * is so that we can manipulate the page tables so that even if a 140 * packet wraps around the end of the receive space, we can 141 * treat it as virtually contiguous. 142 */ 143#define TULIP_RXBUFSIZE 512 144#define TULIP_RXDESCS 128 145#define TULIP_RXSPACE (TULIP_RXBUFSIZE * TULIP_RXDESCS) 146#define TULIP_TXDESCS 128 147 148typedef struct { 149 struct arpcom tulip_ac; 150 tulip_regfile_t tulip_csrs; 151 vm_offset_t tulip_rxspace; 152 unsigned tulip_flags; 153#define TULIP_WANTSETUP 0x01 154#define TULIP_WANTHASH 0x02 155#define TULIP_DOINGSETUP 0x04 156#define TULIP_ALTPHYS 0x08 /* use AUI */ 157 unsigned char tulip_rombuf[32]; 158 tulip_uint32_t tulip_setupbuf[192/sizeof(tulip_uint32_t)]; 159 tulip_uint32_t tulip_setupdata[192/sizeof(tulip_uint32_t)]; 160 tulip_uint32_t tulip_intrmask; 161 tulip_uint32_t tulip_cmdmode; 162 tulip_uint32_t tulip_revinfo; 163#if NBPFILTER > 0 164 caddr_t tulip_bpf; /* BPF context */ 165#endif 166 struct ifqueue tulip_txq; 167 tulip_ringinfo_t tulip_rxinfo; 168 tulip_ringinfo_t tulip_txinfo; 169} tulip_softc_t; 170 171#ifndef IFF_ALTPHYS 172#define IFF_ALTPHYS IFF_LINK0 /* In case it isn't defined */ 173#endif 174typedef enum { TULIP_DC21040, TULIP_DC21140 } tulip_chipid_t; 175const char *tulip_chipdescs[] = { 176 "DC21040 [10Mb/s]", 177 "DC21140 [100Mb/s]", 178}; 179 180tulip_softc_t *tulips[NDE]; 181tulip_chipid_t tulip_chipids[NDE]; 182 183#define tulip_if tulip_ac.ac_if 184#define tulip_unit tulip_ac.ac_if.if_unit 185#define tulip_name tulip_ac.ac_if.if_name 186#define tulip_hwaddr tulip_ac.ac_enaddr 187 188#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */ 189#define TULIP_CHECK_RXCRC 0 190#define TULIP_MAX_TXSEG 30 191 192#define TULIP_ADDREQUAL(a1, a2) \ 193 (((u_short *)a1)[0] == ((u_short *)a2)[0] \ 194 && ((u_short *)a1)[1] == ((u_short *)a2)[1] \ 195 && ((u_short *)a1)[2] == ((u_short *)a2)[2]) 196#define TULIP_ADDRBRDCST(a1) \ 197 (((u_short *)a1)[0] == 0xFFFFU \ 198 && ((u_short *)a1)[1] == 0xFFFFU \ 199 && ((u_short *)a1)[2] == 0xFFFFU) 200 201static void tulip_start(struct ifnet *ifp); 202static void tulip_addr_filter(tulip_softc_t *sc); 203 204#if __FreeBSD__ > 1 205#define TULIP_IFRESET_ARGS int unit 206#define TULIP_RESET(sc) tulip_reset((sc)->tulip_unit) 207#else 208#define TULIP_IFRESET_ARGS int unit, int uban 209#define TULIP_RESET(sc) tulip_reset((sc)->tulip_unit, 0) 210#endif 211 212static void 213tulip_reset( 214 TULIP_IFRESET_ARGS) 215{ 216 tulip_softc_t *sc = tulips[unit]; 217 tulip_ringinfo_t *ri; 218 tulip_desc_t *di; 219 vm_offset_t vmoff; 220 221 *sc->tulip_csrs.csr_busmode = TULIP_BUSMODE_SWRESET; 222 DELAY(10); /* Wait 10 microsends (actually 50 PCI cycles but at 223 33MHz that comes to two microseconds but wait a 224 bit longer anyways) */ 225 226 /* 227 * Use the 228 */ 229 *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_RESET; 230 if (sc->tulip_if.if_flags & IFF_ALTPHYS) { 231 if ((sc->tulip_flags & TULIP_ALTPHYS) == 0) 232 printf("%s%d: enabling Thinwire/AUI port\n", 233 sc->tulip_if.if_name, sc->tulip_if.if_unit); 234 *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_AUI; 235 sc->tulip_flags |= TULIP_ALTPHYS; 236 } else { 237 if (sc->tulip_flags & TULIP_ALTPHYS) 238 printf("%s%d: enabling 10baseT/UTP port\n", 239 sc->tulip_if.if_name, sc->tulip_if.if_unit); 240 *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_10BASET; 241 sc->tulip_flags &= ~TULIP_ALTPHYS; 242 } 243 *sc->tulip_csrs.csr_txlist = vtophys(&sc->tulip_txinfo.ri_first[0]); 244 *sc->tulip_csrs.csr_rxlist = vtophys(&sc->tulip_rxinfo.ri_first[0]); 245 *sc->tulip_csrs.csr_intr = 0; 246 *sc->tulip_csrs.csr_busmode = 0x4800; 247 248 sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS; 249 /* 250 * Free all the mbufs that were on the transmit ring. 251 */ 252 for (;;) { 253 struct mbuf *m; 254 IF_DEQUEUE(&sc->tulip_txq, m); 255 if (m == NULL) 256 break; 257 m_freem(m); 258 } 259 260 ri = &sc->tulip_txinfo; 261 ri->ri_nextin = ri->ri_nextout = ri->ri_first; 262 ri->ri_free = ri->ri_max; 263 for (di = ri->ri_first; di < ri->ri_last; di++) 264 di->d_status = 0; 265 266 /* 267 * We need to collect all the mbufs were on the 268 * receive ring before we reinit it either to put 269 * them back on or to know if we have to allocate 270 * more. 271 */ 272 ri = &sc->tulip_rxinfo; 273 ri->ri_nextin = ri->ri_nextout = ri->ri_first; 274 ri->ri_free = ri->ri_max; 275 for (vmoff = vtophys(sc->tulip_rxspace), di = ri->ri_first; 276 di < ri->ri_last; di++, vmoff += TULIP_RXBUFSIZE) { 277 di->d_status |= TULIP_DSTS_OWNER; 278 di->d_length1 = TULIP_RXBUFSIZE; di->d_addr1 = vmoff; 279 di->d_length2 = 0; di->d_addr2 = 0; 280 } 281 282 sc->tulip_intrmask = TULIP_STS_NORMALINTR|TULIP_STS_RXINTR|TULIP_STS_TXINTR 283 |TULIP_STS_ABNRMLINTR|TULIP_STS_SYSERROR|TULIP_STS_TXSTOPPED 284 |TULIP_STS_TXBABBLE|TULIP_STS_LINKFAIL|TULIP_STS_RXSTOPPED; 285 sc->tulip_flags &= ~(TULIP_DOINGSETUP|TULIP_WANTSETUP); 286 tulip_addr_filter(sc); 287} 288 289static void 290tulip_init( 291 int unit) 292{ 293 tulip_softc_t *sc = tulips[unit]; 294 295 if (sc->tulip_if.if_flags & IFF_UP) { 296 sc->tulip_if.if_flags |= IFF_RUNNING; 297 if (sc->tulip_if.if_flags & IFF_PROMISC) { 298 sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS; 299 } else { 300 sc->tulip_cmdmode &= ~TULIP_CMD_PROMISCUOUS; 301 if (sc->tulip_if.if_flags & IFF_ALLMULTI) { 302 sc->tulip_cmdmode |= TULIP_CMD_ALLMULTI; 303 } else { 304 sc->tulip_cmdmode &= ~TULIP_CMD_ALLMULTI; 305 } 306 } 307 sc->tulip_cmdmode |= TULIP_CMD_TXRUN; 308 if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) { 309 sc->tulip_cmdmode |= TULIP_CMD_RXRUN; 310 sc->tulip_intrmask |= TULIP_STS_RXSTOPPED; 311 } else { 312 sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED; 313 tulip_start(&sc->tulip_if); 314 } 315 sc->tulip_cmdmode |= TULIP_CMD_THRSHLD160; 316 *sc->tulip_csrs.csr_intr = sc->tulip_intrmask; 317 *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; 318 } else { 319 TULIP_RESET(sc); 320 sc->tulip_if.if_flags &= ~IFF_RUNNING; 321 } 322} 323 324 325#if TULIP_CHECK_RXCRC 326static unsigned 327tulip_crc32( 328 u_char *addr, 329 int len) 330{ 331 unsigned int crc = 0xFFFFFFFF; 332 static unsigned int crctbl[256]; 333 int idx; 334 static int done; 335 /* 336 * initialize the multicast address CRC table 337 */ 338 for (idx = 0; !done && idx < 256; idx++) { 339 unsigned int tmp = idx; 340 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 341 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 342 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 343 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 344 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 345 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 346 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 347 tmp = (tmp >> 1) ^ (tmp & 1 ? TULIP_CRC32_POLY : 0); /* XOR */ 348 crctbl[idx] = tmp; 349 } 350 done = 1; 351 352 while (len-- > 0) 353 crc = (crc >> 8) ^ crctbl[*addr++] ^ crctbl[crc & 0xFF]; 354 355 return crc; 356} 357#endif 358 359static void 360tulip_rx_intr( 361 tulip_softc_t *sc) 362{ 363 tulip_ringinfo_t *ri = &sc->tulip_rxinfo; 364 struct ifnet *ifp = &sc->tulip_if; 365 366 for (;;) { 367 tulip_desc_t *eop; 368 int total_len, ndescs; 369 caddr_t bufaddr = (caddr_t) sc->tulip_rxspace; 370 371 for (ndescs = 1, eop = ri->ri_nextin;; ndescs++) { 372 if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER) 373 return; 374 375 if (eop->d_status & TULIP_DSTS_RxLASTDESC) 376 break; 377 if (++eop == ri->ri_last) 378 eop = ri->ri_first; 379 } 380 381 bufaddr += TULIP_RXBUFSIZE * (ri->ri_nextin - ri->ri_first); 382 total_len = ((eop->d_status >> 16) & 0x7FF) - 4; 383 384 if ((eop->d_status & TULIP_DSTS_ERRSUM) == 0) { 385 struct ether_header eh; 386 struct mbuf *m; 387 388#if TULIP_CHECK_RXCRC 389 unsigned crc = tulip_crc32(bufaddr, total_len); 390 if (~crc != *((unsigned *) &bufaddr[total_len])) { 391 printf("de0: bad rx crc: %08x [rx] != %08x\n", 392 *((unsigned *) &bufaddr[total_len]), ~crc); 393 goto next; 394 } 395#endif 396 eh = *(struct ether_header *) bufaddr; 397#if NBPFILTER > 0 398 if (sc->tulip_bpf != NULL) { 399 bpf_tap(sc->tulip_bpf, bufaddr, total_len); 400 if (eh.ether_type != ETHERTYPE_IP && eh.ether_type != ETHERTYPE_ARP) 401 goto next; 402 if ((eh.ether_dhost[0] & 1) == 0 && 403 !TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_ac.ac_enaddr)) 404 goto next; 405 } else if (!TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_ac.ac_enaddr) 406 && !TULIP_ADDRBRDCST(eh.ether_dhost)) { 407 goto next; 408 } 409#endif 410 MGETHDR(m, M_DONTWAIT, MT_DATA); 411 if (m != NULL) { 412 m->m_pkthdr.rcvif = ifp; 413 total_len -= sizeof(eh); 414 if (total_len > MHLEN) { 415 MCLGET(m, M_DONTWAIT); 416 if ((m->m_flags & M_EXT) == 0) { 417 m_freem(m); 418 ifp->if_ierrors++; 419 goto next; 420 } 421 } 422 bcopy(bufaddr + sizeof(eh), mtod(m, caddr_t), total_len); 423 m->m_len = m->m_pkthdr.len = total_len; 424 ether_input(ifp, &eh, m); 425 } else { 426 ifp->if_ierrors++; 427 } 428 } else { 429 ifp->if_ierrors++; 430 } 431next: 432 ifp->if_ipackets++; 433 while (ndescs-- > 0) { 434 ri->ri_nextin->d_status |= TULIP_DSTS_OWNER; 435 if (++ri->ri_nextin == ri->ri_last) 436 ri->ri_nextin = ri->ri_first; 437 } 438 } 439} 440 441static int 442tulip_tx_intr( 443 tulip_softc_t *sc) 444{ 445 tulip_ringinfo_t *ri = &sc->tulip_txinfo; 446 struct mbuf *m; 447 int xmits = 0; 448 449 while (ri->ri_free < ri->ri_max) { 450 if (((volatile tulip_desc_t *) ri->ri_nextin)->d_status & TULIP_DSTS_OWNER) 451 break; 452 453 if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxLASTSEG) { 454 if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxSETUPPKT) { 455 /* 456 * We've just finished processing a setup packet. 457 * Mark that we can finished it. If there's not 458 * another pending, startup the TULIP receiver. 459 * Make sure we ack the RXSTOPPED so we won't get 460 * an abormal interrupt indication. 461 */ 462 sc->tulip_flags &= ~TULIP_DOINGSETUP; 463 if ((sc->tulip_flags & TULIP_WANTSETUP) == 0) { 464 sc->tulip_cmdmode |= TULIP_CMD_RXRUN; 465 sc->tulip_intrmask |= TULIP_STS_RXSTOPPED; 466 *sc->tulip_csrs.csr_status = TULIP_STS_RXSTOPPED; 467 *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; 468 *sc->tulip_csrs.csr_intr = sc->tulip_intrmask; 469 } 470 } else { 471 IF_DEQUEUE(&sc->tulip_txq, m); 472 m_freem(m); 473 sc->tulip_if.if_collisions += 474 (ri->ri_nextin->d_status & TULIP_DSTS_TxCOLLMASK) 475 >> TULIP_DSTS_V_TxCOLLCNT; 476 if (ri->ri_nextin->d_status & TULIP_DSTS_ERRSUM) 477 sc->tulip_if.if_oerrors++; 478 xmits++; 479 } 480 } 481 482 if (++ri->ri_nextin == ri->ri_last) 483 ri->ri_nextin = ri->ri_first; 484 ri->ri_free++; 485 sc->tulip_if.if_flags &= ~IFF_OACTIVE; 486 } 487 sc->tulip_if.if_opackets += xmits; 488 return xmits; 489} 490 491static int 492tulip_txsegment( 493 tulip_softc_t *sc, 494 struct mbuf *m, 495 tulip_addrvec_t *avp, 496 size_t maxseg) 497{ 498 int segcnt; 499 500 for (segcnt = 0; m; m = m->m_next) { 501 int len = m->m_len; 502 caddr_t addr = mtod(m, caddr_t); 503 unsigned clsize = CLBYTES - (((u_long) addr) & (CLBYTES-1)); 504 505 while (len > 0) { 506 unsigned slen = min(len, clsize); 507 if (segcnt < maxseg) { 508 avp->addr = vtophys(addr); 509 avp->length = slen; 510 } 511 len -= slen; 512 addr += slen; 513 clsize = CLBYTES; 514 avp++; 515 segcnt++; 516 } 517 } 518 if (segcnt >= maxseg) { 519 printf("%s%d: tulip_txsegment: extremely fragmented packet encountered (%d segments)\n", 520 sc->tulip_name, sc->tulip_unit, segcnt); 521 return -1; 522 } 523 avp->addr = 0; 524 avp->length = 0; 525 return segcnt; 526} 527 528static void 529tulip_start( 530 struct ifnet *ifp) 531{ 532 tulip_softc_t *sc = (tulip_softc_t *) ifp; 533 struct ifqueue *ifq = &ifp->if_snd; 534 tulip_ringinfo_t *ri = &sc->tulip_txinfo; 535 tulip_desc_t *sop, *eop; 536 struct mbuf *m; 537 tulip_addrvec_t addrvec[TULIP_MAX_TXSEG+1], *avp; 538 int segcnt; 539 tulip_uint32_t d_status; 540 541 if ((ifp->if_flags & IFF_RUNNING) == 0) 542 return; 543 544 for (;;) { 545 if (sc->tulip_flags & TULIP_WANTSETUP) { 546 if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) { 547 ifp->if_flags |= IFF_OACTIVE; 548 return; 549 } 550 bcopy(sc->tulip_setupdata, sc->tulip_setupbuf, 551 sizeof(sc->tulip_setupbuf)); 552 sc->tulip_flags &= ~TULIP_WANTSETUP; 553 sc->tulip_flags |= TULIP_DOINGSETUP; 554 ri->ri_free--; 555 ri->ri_nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN; 556 ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG 557 |TULIP_DFLAG_TxSETUPPKT|TULIP_DFLAG_TxWANTINTR; 558 if (sc->tulip_flags & TULIP_WANTHASH) 559 ri->ri_nextout->d_flag |= TULIP_DFLAG_TxHASHFILT; 560 ri->ri_nextout->d_length1 = sizeof(sc->tulip_setupbuf); 561 ri->ri_nextout->d_addr1 = vtophys(sc->tulip_setupbuf); 562 ri->ri_nextout->d_length2 = 0; 563 ri->ri_nextout->d_addr2 = 0; 564 ri->ri_nextout->d_status = TULIP_DSTS_OWNER; 565 *sc->tulip_csrs.csr_txpoll = 1; 566 /* 567 * Advance the ring for the next transmit packet. 568 */ 569 if (++ri->ri_nextout == ri->ri_last) 570 ri->ri_nextout = ri->ri_first; 571 } 572 573 IF_DEQUEUE(ifq, m); 574 if (m == NULL) 575 break; 576 577 /* 578 * First find out how many and which different pages 579 * the mbuf data occupies. Then check to see if we 580 * have enough descriptor space in our transmit ring 581 * to actually send it. 582 */ 583 segcnt = tulip_txsegment(sc, m, addrvec, 584 min(ri->ri_max - 1, TULIP_MAX_TXSEG)); 585 if (segcnt < 0) { 586 struct mbuf *m0; 587 MGETHDR(m0, M_DONTWAIT, MT_DATA); 588 if (m0 != NULL) { 589 if (m->m_pkthdr.len > MHLEN) { 590 MCLGET(m0, M_DONTWAIT); 591 if ((m0->m_flags & M_EXT) == 0) { 592 m_freem(m); 593 continue; 594 } 595 } 596 m_copydata(m, 0, m0->m_pkthdr.len, mtod(m0, caddr_t)); 597 m0->m_pkthdr.len = m0->m_len = m->m_pkthdr.len; 598 m_freem(m); 599 IF_PREPEND(ifq, m0); 600 continue; 601 } else { 602 m_freem(m); 603 continue; 604 } 605 } 606 if (ri->ri_free - 2 <= (segcnt + 1) >> 1) 607 break; 608 609 ri->ri_free -= (segcnt + 1) >> 1; 610 /* 611 * Now we fill in our transmit descriptors. This is 612 * a bit reminiscent of going on the Ark two by two 613 * since each descriptor for the TULIP can describe 614 * two buffers. So we advance through the address 615 * vector two entries at a time to to fill each 616 * descriptor. Clear the first and last segment bits 617 * in each descriptor (actually just clear everything 618 * but the end-of-ring or chain bits) to make sure 619 * we don't get messed up by previously sent packets. 620 */ 621 sop = ri->ri_nextout; 622 d_status = 0; 623 avp = addrvec; 624 do { 625 eop = ri->ri_nextout; 626 eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN; 627 eop->d_status = d_status; 628 eop->d_addr1 = avp->addr; eop->d_length1 = avp->length; avp++; 629 eop->d_addr2 = avp->addr; eop->d_length2 = avp->length; avp++; 630 d_status = TULIP_DSTS_OWNER; 631 if (++ri->ri_nextout == ri->ri_last) 632 ri->ri_nextout = ri->ri_first; 633 } while ((segcnt -= 2) > 0); 634#if NBPFILTER > 0 635 if (sc->tulip_bpf != NULL) 636 bpf_mtap(sc->tulip_bpf, m); 637#endif 638 /* 639 * The descriptors have been filled in. Mark the first 640 * and last segments, indicate we want a transmit complete 641 * interrupt, give the descriptors to the TULIP, and tell 642 * it to transmit! 643 */ 644 645 IF_ENQUEUE(&sc->tulip_txq, m); 646 eop->d_flag |= TULIP_DFLAG_TxLASTSEG|TULIP_DFLAG_TxWANTINTR; 647 sop->d_flag |= TULIP_DFLAG_TxFIRSTSEG; 648 sop->d_status = TULIP_DSTS_OWNER; 649 650 *sc->tulip_csrs.csr_txpoll = 1; 651 } 652 if (m != NULL) { 653 ifp->if_flags |= IFF_OACTIVE; 654 IF_PREPEND(ifq, m); 655 } 656} 657 658static int 659tulip_intr( 660 tulip_softc_t *sc) 661{ 662 tulip_uint32_t csr; 663 664 while ((csr = *sc->tulip_csrs.csr_status) & (TULIP_STS_NORMALINTR|TULIP_STS_ABNRMLINTR)) { 665 *sc->tulip_csrs.csr_status = csr & sc->tulip_intrmask; 666 667 if (csr & TULIP_STS_SYSERROR) { 668 if ((csr & TULIP_STS_ERRORMASK) == TULIP_STS_ERR_PARITY) { 669 TULIP_RESET(sc); 670 tulip_init(sc->tulip_unit); 671 return 1; 672 } 673 } 674 if (csr & TULIP_STS_ABNRMLINTR) { 675 printf("%s%d: abnormal interrupt: 0x%05x [0x%05x]\n", 676 sc->tulip_name, sc->tulip_unit, csr, csr & sc->tulip_intrmask); 677 *sc->tulip_csrs.csr_command = sc->tulip_cmdmode; 678 } 679 if (csr & TULIP_STS_RXINTR) 680 tulip_rx_intr(sc); 681 if (sc->tulip_txinfo.ri_free < sc->tulip_txinfo.ri_max) { 682 tulip_tx_intr(sc); 683 tulip_start(&sc->tulip_if); 684 } 685 } 686 return 1; 687} 688 689/* 690 * This is the standard method of reading the DEC Address ROMS. 691 */ 692static int 693tulip_read_macaddr( 694 tulip_softc_t *sc) 695{ 696 int cksum, rom_cksum, idx; 697 tulip_sint32_t csr; 698 unsigned char tmpbuf[8]; 699 static u_char testpat[] = { 0xFF, 0, 0x55, 0xAA, 0xFF, 0, 0x55, 0xAA }; 700 701 *sc->tulip_csrs.csr_enetrom = 1; 702 for (idx = 0; idx < 32; idx++) { 703 int cnt = 0; 704 while ((csr = *sc->tulip_csrs.csr_enetrom) < 0 && cnt < 10000) 705 cnt++; 706 sc->tulip_rombuf[idx] = csr & 0xFF; 707 } 708 709 if (bcmp(&sc->tulip_rombuf[0], &sc->tulip_rombuf[16], 8) != 0) { 710 /* 711 * Some folks don't use the standard ethernet rom format 712 * but instead just put the address in the first 6 bytes 713 * of the rom and let the rest be all 0xffs. (Can we say 714 * ZNYX???) 715 */ 716 for (idx = 6; idx < 32; idx++) { 717 if (sc->tulip_rombuf[idx] != 0xFF) 718 return -4; 719 } 720 /* 721 * Make sure the address is not multicast or locally assigned 722 * that the OUI is not 00-00-00. 723 */ 724 if ((sc->tulip_rombuf[0] & 3) != 0) 725 return -4; 726 if (sc->tulip_rombuf[0] == 0 && sc->tulip_rombuf[1] == 0 727 && sc->tulip_rombuf[2] == 0) 728 return -4; 729 bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6); 730 return 0; 731 } 732 if (bcmp(&sc->tulip_rombuf[24], testpat, 8) != 0) 733 return -3; 734 735 tmpbuf[0] = sc->tulip_rombuf[15]; tmpbuf[1] = sc->tulip_rombuf[14]; 736 tmpbuf[2] = sc->tulip_rombuf[13]; tmpbuf[3] = sc->tulip_rombuf[12]; 737 tmpbuf[4] = sc->tulip_rombuf[11]; tmpbuf[5] = sc->tulip_rombuf[10]; 738 tmpbuf[6] = sc->tulip_rombuf[9]; tmpbuf[7] = sc->tulip_rombuf[8]; 739 if (bcmp(&sc->tulip_rombuf[0], tmpbuf, 8) != 0) 740 return -2; 741 742 bcopy(sc->tulip_rombuf, sc->tulip_hwaddr, 6); 743 744 cksum = *(u_short *) &sc->tulip_hwaddr[0]; 745 cksum *= 2; 746 if (cksum > 65535) cksum -= 65535; 747 cksum += *(u_short *) &sc->tulip_hwaddr[2]; 748 if (cksum > 65535) cksum -= 65535; 749 cksum *= 2; 750 if (cksum > 65535) cksum -= 65535; 751 cksum += *(u_short *) &sc->tulip_hwaddr[4]; 752 if (cksum >= 65535) cksum -= 65535; 753 754 rom_cksum = *(u_short *) &sc->tulip_rombuf[6]; 755 756 if (cksum != rom_cksum) 757 return -1; 758 return 0; 759} 760 761static unsigned 762tulip_mchash( 763 unsigned char *mca) 764{ 765 u_int idx, bit, data, crc = 0xFFFFFFFFUL; 766 767#ifdef __alpha 768 for (data = *(__unaligned u_long *) mca, bit = 0; bit < 48; bit++, data >>= 7691) 770 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0); 771#else 772 for (idx = 0; idx < 6; idx++) 773 for (data = *mca++, bit = 0; bit < 8; bit++, data >>= 1) 774 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0); 775#endif 776 return crc & 0x1FF; 777} 778 779static void 780tulip_addr_filter( 781 tulip_softc_t *sc) 782{ 783 tulip_uint32_t *sp = sc->tulip_setupdata; 784 struct ether_multistep step; 785 struct ether_multi *enm; 786 int i; 787 788 sc->tulip_flags &= ~TULIP_WANTHASH; 789 sc->tulip_flags |= TULIP_WANTSETUP; 790 sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN; 791 sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED; 792 if (sc->tulip_ac.ac_multicnt > 14) { 793 unsigned hash; 794 /* 795 * If we have more than 14 multicasts, we have 796 * go into hash perfect mode (512 bit multicast 797 * hash and one perfect hardware). 798 */ 799 800 bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata)); 801 hash = tulip_mchash(etherbroadcastaddr); 802 sp[hash >> 4] |= 1 << (hash & 0xF); 803 ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); 804 while (enm != NULL) { 805 hash = tulip_mchash(enm->enm_addrlo); 806 sp[hash >> 4] |= 1 << (hash & 0xF); 807 ETHER_NEXT_MULTI(step, enm); 808 } 809 sc->tulip_cmdmode |= TULIP_WANTHASH; 810 sp[40] = ((u_short *) sc->tulip_ac.ac_enaddr)[0]; 811 sp[41] = ((u_short *) sc->tulip_ac.ac_enaddr)[1]; 812 sp[42] = ((u_short *) sc->tulip_ac.ac_enaddr)[2]; 813 } else { 814 /* 815 * Else can get perfect filtering for 16 addresses. 816 */ 817 i = 0; 818 ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); 819 for (; enm != NULL; i++) { 820 *sp++ = ((u_short *) enm->enm_addrlo)[0]; 821 *sp++ = ((u_short *) enm->enm_addrlo)[1]; 822 *sp++ = ((u_short *) enm->enm_addrlo)[2]; 823 ETHER_NEXT_MULTI(step, enm); 824 } 825 /* 826 * If an IP address is enabled, turn on broadcast 827 */ 828 if (sc->tulip_ac.ac_ipaddr.s_addr != 0) { 829 i++; 830 *sp++ = 0xFFFF; 831 *sp++ = 0xFFFF; 832 *sp++ = 0xFFFF; 833 } 834 /* 835 * Pad the rest with our hardware address 836 */ 837 for (; i < 16; i++) { 838 *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[0]; 839 *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[1]; 840 *sp++ = ((u_short *) sc->tulip_ac.ac_enaddr)[2]; 841 } 842 } 843} 844 845static int 846tulip_ioctl( 847 struct ifnet *ifp, 848 int cmd, 849 caddr_t data) 850{ 851 tulip_softc_t *sc = tulips[ifp->if_unit]; 852 struct ifaddr *ifa = (struct ifaddr *)data; 853 struct ifreq *ifr = (struct ifreq *) data; 854 int s, error = 0; 855 856 s = splimp(); 857 858 switch (cmd) { 859 case SIOCSIFADDR: { 860 861 ifp->if_flags |= IFF_UP; 862 switch(ifa->ifa_addr->sa_family) { 863#ifdef INET 864 case AF_INET: { 865 ((struct arpcom *)ifp)->ac_ipaddr = IA_SIN(ifa)->sin_addr; 866 tulip_addr_filter(sc); /* reset multicast filtering */ 867 (*ifp->if_init)(ifp->if_unit); 868 arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr); 869 break; 870 } 871#endif /* INET */ 872 873#ifdef NS 874 /* This magic copied from if_is.c; I don't use XNS, 875 * so I have no way of telling if this actually 876 * works or not. 877 */ 878 case AF_NS: { 879 struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); 880 if (ns_nullhost(*ina)) { 881 ina->x_host = *(union ns_host *)(sc->tulip_ac.ac_enaddr); 882 } else { 883 ifp->if_flags &= ~IFF_RUNNING; 884 bcopy((caddr_t)ina->x_host.c_host, 885 (caddr_t)sc->tulip_ac.ac_enaddr, 886 sizeof sc->tulip_ac.ac_enaddr); 887 } 888 889 (*ifp->if_init)(ifp->if_unit); 890 break; 891 } 892#endif /* NS */ 893 894 default: { 895 (*ifp->if_init)(ifp->if_unit); 896 break; 897 } 898 } 899 break; 900 } 901 902 case SIOCSIFFLAGS: { 903 /* 904 * Changing the connection forces a reset. 905 */ 906 if (sc->tulip_flags & TULIP_ALTPHYS) { 907 if ((ifp->if_flags & IFF_ALTPHYS) == 0) 908 TULIP_RESET(sc); 909 } else { 910 if (ifp->if_flags & IFF_ALTPHYS) 911 TULIP_RESET(sc); 912 } 913 (*ifp->if_init)(ifp->if_unit); 914 break; 915 } 916 917 case SIOCADDMULTI: 918 case SIOCDELMULTI: { 919 /* 920 * Update multicast listeners 921 */ 922 if (cmd == SIOCADDMULTI) 923 error = ether_addmulti(ifr, &sc->tulip_ac); 924 else 925 error = ether_delmulti(ifr, &sc->tulip_ac); 926 927 if (error == ENETRESET) { 928 tulip_addr_filter(sc); /* reset multicast filtering */ 929 (*ifp->if_init)(ifp->if_unit); 930 error = 0; 931 } 932 break; 933 } 934 case SIOCSIFMTU: 935 /* 936 * Set the interface MTU. 937 */ 938 if (ifr->ifr_mtu > ETHERMTU) { 939 error = EINVAL; 940 } else { 941 ifp->if_mtu = ifr->ifr_mtu; 942 } 943 break; 944 945 default: { 946 error = EINVAL; 947 break; 948 } 949 } 950 951 splx(s); 952 return error; 953} 954 955static void 956tulip_attach( 957 tulip_softc_t *sc) 958{ 959 struct ifnet *ifp = &sc->tulip_if; 960 int cnt; 961 962 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST; 963 964 *sc->tulip_csrs.csr_sia_connectivity = 0; 965 *sc->tulip_csrs.csr_sia_connectivity = TULIP_SIACONN_10BASET; 966 for (cnt = 0; cnt < 240000; cnt++) { 967 if ((*sc->tulip_csrs.csr_sia_status & TULIP_SIASTS_LINKFAIL) == 0) 968 break; 969 DELAY(10); 970 } 971 if (*sc->tulip_csrs.csr_sia_status & TULIP_SIASTS_LINKFAIL) { 972 ifp->if_flags |= IFF_ALTPHYS; 973 } else { 974 sc->tulip_flags |= TULIP_ALTPHYS; 975 } 976 TULIP_RESET(sc); 977 978 ifp->if_init = tulip_init; 979 ifp->if_ioctl = tulip_ioctl; 980 ifp->if_output = ether_output; 981 ifp->if_reset = tulip_reset; 982 ifp->if_start = tulip_start; 983 984 printf("%s%d: %s pass %d.%d ethernet address %s\n", 985 sc->tulip_name, sc->tulip_unit, 986 tulip_chipdescs[tulip_chipids[sc->tulip_unit]], 987 (sc->tulip_revinfo & 0xF0) >> 4, 988 sc->tulip_revinfo & 0x0F, 989 ether_sprintf(sc->tulip_hwaddr)); 990 991 if_attach(ifp); 992 993#if NBPFILTER > 0 994 bpfattach(&sc->tulip_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header)); 995#endif 996} 997 998static void 999tulip_initcsrs( 1000 tulip_softc_t *sc, 1001 volatile tulip_uint32_t *va_csrs, 1002 size_t csr_size) 1003{ 1004 sc->tulip_csrs.csr_busmode = va_csrs + 0 * csr_size; 1005 sc->tulip_csrs.csr_txpoll = va_csrs + 1 * csr_size; 1006 sc->tulip_csrs.csr_rxpoll = va_csrs + 2 * csr_size; 1007 sc->tulip_csrs.csr_rxlist = va_csrs + 3 * csr_size; 1008 sc->tulip_csrs.csr_txlist = va_csrs + 4 * csr_size; 1009 sc->tulip_csrs.csr_status = va_csrs + 5 * csr_size; 1010 sc->tulip_csrs.csr_command = va_csrs + 6 * csr_size; 1011 sc->tulip_csrs.csr_intr = va_csrs + 7 * csr_size; 1012 sc->tulip_csrs.csr_missed_frame = va_csrs + 8 * csr_size; 1013 sc->tulip_csrs.csr_enetrom = va_csrs + 9 * csr_size; 1014 sc->tulip_csrs.csr_reserved = va_csrs + 10 * csr_size; 1015 sc->tulip_csrs.csr_full_duplex = va_csrs + 11 * csr_size; 1016 sc->tulip_csrs.csr_sia_status = va_csrs + 12 * csr_size; 1017 sc->tulip_csrs.csr_sia_connectivity = va_csrs + 13 * csr_size; 1018 sc->tulip_csrs.csr_sia_tx_rx = va_csrs + 14 * csr_size; 1019 sc->tulip_csrs.csr_sia_general = va_csrs + 15 * csr_size; 1020} 1021 1022static void 1023tulip_initring( 1024 tulip_softc_t *sc, 1025 tulip_ringinfo_t *ri, 1026 tulip_desc_t *descs, 1027 int ndescs) 1028{ 1029 ri->ri_max = ndescs; 1030 ri->ri_first = descs; 1031 ri->ri_last = ri->ri_first + ri->ri_max; 1032 bzero((caddr_t) ri->ri_first, sizeof(ri->ri_first[0]) * ri->ri_max); 1033 ri->ri_last[-1].d_flag = TULIP_DFLAG_ENDRING; 1034} 1035 1036#if NPCI > 0 1037/* 1038 * This is the PCI configuration support. Since the DC21040 is available 1039 * on both EISA and PCI boards, one must be careful in how defines the 1040 * DC21040 in the config file. 1041 */ 1042static char* tulip_pci_probe (pcici_t config_id, pcidi_t device_id); 1043static void tulip_pci_attach(pcici_t config_id, int unit); 1044static u_long tulip_count; 1045 1046struct pci_driver dedevice = { 1047 tulip_pci_probe, 1048 tulip_pci_attach, 1049 &tulip_count, 1050}; 1051 1052#define PCI_CFID 0x00 /* Configuration ID */ 1053#define PCI_CFCS 0x04 /* Configurtion Command/Status */ 1054#define PCI_CFRV 0x08 /* Configuration Revision */ 1055#define PCI_CFLT 0x0c /* Configuration Latency Timer */ 1056#define PCI_CBIO 0x10 /* Configuration Base IO Address */ 1057#define PCI_CBMA 0x14 /* Configuration Base Memory Address */ 1058#define PCI_CFIT 0x3c /* Configuration Interrupt */ 1059#define PCI_CFDA 0x40 /* Configuration Driver Area */ 1060 1061#define TULIP_PCI_CSRSIZE (8 / sizeof(tulip_uint32_t)) 1062static char* 1063tulip_pci_probe( 1064 pcici_t config_id, 1065 pcidi_t device_id) 1066{ 1067 int idx; 1068 for (idx = 0; idx < NDE; idx++) { 1069 if (tulips[idx] == NULL) { 1070 if (device_id == 0x00021011ul) { 1071 tulip_chipids[idx] = TULIP_DC21040; 1072 return "Digital DC21040 Ethernet"; 1073 } 1074 if (device_id == 0x00091011ul) { 1075 tulip_chipids[idx] = TULIP_DC21140; 1076 return "Digital DC21140 Fast Ethernet"; 1077 } 1078 return NULL; 1079 } 1080 } 1081 return NULL; 1082} 1083 1084static void 1085tulip_pci_attach( 1086 pcici_t config_id, 1087 int unit) 1088{ 1089 tulip_softc_t *sc; 1090 int retval, idx; 1091 vm_offset_t va_csrs, pa_csrs; 1092 tulip_desc_t *rxdescs, *txdescs; 1093 1094 sc = (tulip_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); 1095 if (sc == NULL) 1096 return; 1097 1098 rxdescs = (tulip_desc_t *) 1099 malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT); 1100 if (rxdescs == NULL) { 1101 free((caddr_t) sc, M_DEVBUF); 1102 return; 1103 } 1104 1105 txdescs = (tulip_desc_t *) 1106 malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT); 1107 if (txdescs == NULL) { 1108 free((caddr_t) rxdescs, M_DEVBUF); 1109 free((caddr_t) sc, M_DEVBUF); 1110 return; 1111 } 1112 1113 bzero(sc, sizeof(sc)); /* Zero out the softc*/ 1114 sc->tulip_rxspace = kmem_alloc(kernel_map, TULIP_RXSPACE + NBPG); 1115 /* 1116 * We've allocated an extra page of receive space so we can double map 1117 * the first page of the receive space into the page after the last page 1118 * of the receive space. This means that even if a receive wraps around 1119 * the end of the receive space, it will still virtually contiguous and 1120 * that greatly simplifies the recevie logic. 1121 */ 1122 pmap_enter(pmap_kernel(), sc->tulip_rxspace + TULIP_RXSPACE, 1123 vtophys(sc->tulip_rxspace), VM_PROT_READ, TRUE); 1124 1125 sc->tulip_unit = unit; 1126 sc->tulip_name = "de"; 1127 retval = pci_map_mem(config_id, PCI_CBMA, &va_csrs, &pa_csrs); 1128 if (!retval) { 1129 kmem_free(kernel_map, sc->tulip_rxspace, TULIP_RXSPACE + NBPG); 1130 free((caddr_t) txdescs, M_DEVBUF); 1131 free((caddr_t) rxdescs, M_DEVBUF); 1132 free((caddr_t) sc, M_DEVBUF); 1133 return; 1134 } 1135 tulips[unit] = sc; 1136 tulip_initcsrs(sc, (volatile tulip_uint32_t *) va_csrs, TULIP_PCI_CSRSIZE); 1137 tulip_initring(sc, &sc->tulip_rxinfo, rxdescs, TULIP_RXDESCS); 1138 tulip_initring(sc, &sc->tulip_txinfo, txdescs, TULIP_TXDESCS); 1139 sc->tulip_revinfo = pci_conf_read(config_id, PCI_CFRV); 1140 if ((retval = tulip_read_macaddr(sc)) < 0) { 1141 printf("de%d: can't read ENET ROM (why=%d) (", sc->tulip_unit, retval); 1142 for (idx = 0; idx < 32; idx++) 1143 printf("%02x", sc->tulip_rombuf[idx]); 1144 printf("\n"); 1145 printf("%s%d: %s pass %d.%d ethernet address %s\n", 1146 sc->tulip_name, sc->tulip_unit, 1147 tulip_chipdescs[tulip_chipids[sc->tulip_unit]], 1148 (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F, 1149 "unknown"); 1150 } else { 1151 TULIP_RESET(sc); 1152 tulip_attach(sc); 1153 pci_map_int (config_id, tulip_intr, (void*) sc, &net_imask); 1154 } 1155} 1156#endif /* NPCI > 0 */ 1157#endif /* NDE > 0 */ 1158