if_tx.c (105966) | if_tx.c (106937) |
---|---|
1/*- 2 * Copyright (c) 1997 Semen Ustimenko (semenu@FreeBSD.org) 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 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1997 Semen Ustimenko (semenu@FreeBSD.org) 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 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/tx/if_tx.c 105966 2002-10-25 22:06:03Z sam $ | 26 * $FreeBSD: head/sys/dev/tx/if_tx.c 106937 2002-11-14 23:54:55Z sam $ |
27 */ 28 29/* 30 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 31 * 32 * These cards are based on SMC83c17x (EPIC) chip and one of the various 33 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 34 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- --- 293 unchanged lines hidden (view full) --- 328 printf("%c", (u_int8_t)tmp); 329 tmp >>= 8; 330 if (' ' == (u_int8_t)tmp) break; 331 printf("%c", (u_int8_t)tmp); 332 } 333 printf("\n"); 334 335 /* Attach to OS's managers */ | 27 */ 28 29/* 30 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 31 * 32 * These cards are based on SMC83c17x (EPIC) chip and one of the various 33 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 34 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- --- 293 unchanged lines hidden (view full) --- 328 printf("%c", (u_int8_t)tmp); 329 tmp >>= 8; 330 if (' ' == (u_int8_t)tmp) break; 331 printf("%c", (u_int8_t)tmp); 332 } 333 printf("\n"); 334 335 /* Attach to OS's managers */ |
336 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 336 ether_ifattach(ifp, sc->sc_macaddr); |
337 ifp->if_hdrlen = sizeof(struct ether_vlan_header); | 337 ifp->if_hdrlen = sizeof(struct ether_vlan_header); |
338 ifp->if_capabilities |= IFCAP_VLAN_MTU; |
|
338 callout_handle_init(&sc->stat_ch); 339 340fail: 341 splx(s); 342 343 return(error); 344} 345 --- 8 unchanged lines hidden (view full) --- 354 epic_softc_t *sc; 355 int s; 356 357 s = splimp(); 358 359 sc = device_get_softc(dev); 360 ifp = &sc->arpcom.ac_if; 361 | 339 callout_handle_init(&sc->stat_ch); 340 341fail: 342 splx(s); 343 344 return(error); 345} 346 --- 8 unchanged lines hidden (view full) --- 355 epic_softc_t *sc; 356 int s; 357 358 s = splimp(); 359 360 sc = device_get_softc(dev); 361 ifp = &sc->arpcom.ac_if; 362 |
362 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); | 363 ether_ifdetach(ifp); |
363 364 epic_stop(sc); 365 366 bus_generic_detach(dev); 367 device_delete_child(dev, sc->miibus); 368 369 bus_teardown_intr(dev, sc->irq, sc->sc_ih); 370 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); --- 40 unchanged lines hidden (view full) --- 411 epic_softc_t *sc = ifp->if_softc; 412 struct mii_data *mii; 413 struct ifreq *ifr = (struct ifreq *) data; 414 int x, error = 0; 415 416 x = splimp(); 417 418 switch (command) { | 364 365 epic_stop(sc); 366 367 bus_generic_detach(dev); 368 device_delete_child(dev, sc->miibus); 369 370 bus_teardown_intr(dev, sc->irq, sc->sc_ih); 371 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); --- 40 unchanged lines hidden (view full) --- 412 epic_softc_t *sc = ifp->if_softc; 413 struct mii_data *mii; 414 struct ifreq *ifr = (struct ifreq *) data; 415 int x, error = 0; 416 417 x = splimp(); 418 419 switch (command) { |
419 case SIOCSIFADDR: 420 case SIOCGIFADDR: 421 error = ether_ioctl(ifp, command, data); 422 break; | |
423 case SIOCSIFMTU: 424 if (ifp->if_mtu == ifr->ifr_mtu) 425 break; 426 427 /* XXX Though the datasheet doesn't imply any 428 * limitations on RX and TX sizes beside max 64Kb 429 * DMA transfer, seems we can't send more then 1600 430 * data bytes per ethernet packet. (Transmitter hangs --- 39 unchanged lines hidden (view full) --- 470 471 case SIOCSIFMEDIA: 472 case SIOCGIFMEDIA: 473 mii = device_get_softc(sc->miibus); 474 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 475 break; 476 477 default: | 420 case SIOCSIFMTU: 421 if (ifp->if_mtu == ifr->ifr_mtu) 422 break; 423 424 /* XXX Though the datasheet doesn't imply any 425 * limitations on RX and TX sizes beside max 64Kb 426 * DMA transfer, seems we can't send more then 1600 427 * data bytes per ethernet packet. (Transmitter hangs --- 39 unchanged lines hidden (view full) --- 467 468 case SIOCSIFMEDIA: 469 case SIOCGIFMEDIA: 470 mii = device_get_softc(sc->miibus); 471 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); 472 break; 473 474 default: |
478 error = EINVAL; | 475 error = ether_ioctl(ifp, command, data); 476 break; |
479 } 480 splx(x); 481 482 return error; 483} 484 485/* 486 * OS-independed part of attach process. allocate memory for descriptors --- 117 unchanged lines hidden (view full) --- 604 desc->txlength = 605 max(m0->m_pkthdr.len,ETHER_MIN_LEN-ETHER_CRC_LEN); 606 desc->status = 0x8000; 607 CSR_WRITE_4(sc, COMMAND, COMMAND_TXQUEUED); 608 609 /* Set watchdog timer */ 610 ifp->if_timer = 8; 611 | 477 } 478 splx(x); 479 480 return error; 481} 482 483/* 484 * OS-independed part of attach process. allocate memory for descriptors --- 117 unchanged lines hidden (view full) --- 602 desc->txlength = 603 max(m0->m_pkthdr.len,ETHER_MIN_LEN-ETHER_CRC_LEN); 604 desc->status = 0x8000; 605 CSR_WRITE_4(sc, COMMAND, COMMAND_TXQUEUED); 606 607 /* Set watchdog timer */ 608 ifp->if_timer = 8; 609 |
612 if (ifp->if_bpf) 613 bpf_mtap(ifp, m0); | 610 BPF_MTAP(ifp, m0); |
614 } 615 616 ifp->if_flags |= IFF_OACTIVE; 617 618 return; 619 620} 621 --- 4 unchanged lines hidden (view full) --- 626epic_rx_done(sc) 627 epic_softc_t *sc; 628{ 629 struct ifnet *ifp = &sc->sc_if; 630 u_int16_t len; 631 struct epic_rx_buffer *buf; 632 struct epic_rx_desc *desc; 633 struct mbuf *m; | 611 } 612 613 ifp->if_flags |= IFF_OACTIVE; 614 615 return; 616 617} 618 --- 4 unchanged lines hidden (view full) --- 623epic_rx_done(sc) 624 epic_softc_t *sc; 625{ 626 struct ifnet *ifp = &sc->sc_if; 627 u_int16_t len; 628 struct epic_rx_buffer *buf; 629 struct epic_rx_desc *desc; 630 struct mbuf *m; |
634 struct ether_header *eh; | |
635 636 while ((sc->rx_desc[sc->cur_rx].status & 0x8000) == 0) { 637 buf = sc->rx_buffer + sc->cur_rx; 638 desc = sc->rx_desc + sc->cur_rx; 639 640 /* Switch to next descriptor */ 641 sc->cur_rx = (sc->cur_rx+1) & RX_RING_MASK; 642 --- 23 unchanged lines hidden (view full) --- 666 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES; 667 m_adj(buf->mbuf, ETHER_ALIGN); 668 669 /* Point to new mbuf, and give descriptor to chip */ 670 desc->bufaddr = vtophys(mtod(buf->mbuf, caddr_t)); 671 desc->status = 0x8000; 672 673 /* First mbuf in packet holds the ethernet and packet headers */ | 631 632 while ((sc->rx_desc[sc->cur_rx].status & 0x8000) == 0) { 633 buf = sc->rx_buffer + sc->cur_rx; 634 desc = sc->rx_desc + sc->cur_rx; 635 636 /* Switch to next descriptor */ 637 sc->cur_rx = (sc->cur_rx+1) & RX_RING_MASK; 638 --- 23 unchanged lines hidden (view full) --- 662 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES; 663 m_adj(buf->mbuf, ETHER_ALIGN); 664 665 /* Point to new mbuf, and give descriptor to chip */ 666 desc->bufaddr = vtophys(mtod(buf->mbuf, caddr_t)); 667 desc->status = 0x8000; 668 669 /* First mbuf in packet holds the ethernet and packet headers */ |
674 eh = mtod(m, struct ether_header *); 675 m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); 676 m->m_data += sizeof(struct ether_header); | |
677 m->m_pkthdr.rcvif = ifp; | 670 m->m_pkthdr.rcvif = ifp; |
671 m->m_pkthdr.len = m->m_len = len; |
|
678 679 /* Give mbuf to OS */ | 672 673 /* Give mbuf to OS */ |
680 ether_input(ifp, eh, m); | 674 (*ifp->if_input)(ifp, m); |
681 682 /* Successfuly received frame */ 683 ifp->if_ipackets++; 684 } 685 686 return; 687} 688 --- 1069 unchanged lines hidden --- | 675 676 /* Successfuly received frame */ 677 ifp->if_ipackets++; 678 } 679 680 return; 681} 682 --- 1069 unchanged lines hidden --- |