if_wb.c (98995) | if_wb.c (102336) |
---|---|
1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/pci/if_wb.c 98995 2002-06-28 23:48:23Z alfred $ | 32 * $FreeBSD: head/sys/pci/if_wb.c 102336 2002-08-24 00:02:03Z alfred $ |
33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = | 33 */ 34 35/* 36 * Winbond fast ethernet PCI NIC driver 37 * 38 * Supports various cheap network adapters based on the Winbond W89C840F 39 * fast ethernet controller chip. This includes adapters manufactured by 40 * Winbond itself and some made by Linksys. --- 82 unchanged lines hidden (view full) --- 123#define WB_USEIOSPACE 124 125#include <pci/if_wbreg.h> 126 127MODULE_DEPEND(wb, miibus, 1, 1, 1); 128 129#ifndef lint 130static const char rcsid[] = |
131 "$FreeBSD: head/sys/pci/if_wb.c 98995 2002-06-28 23:48:23Z alfred $"; | 131 "$FreeBSD: head/sys/pci/if_wb.c 102336 2002-08-24 00:02:03Z alfred $"; |
132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 99 unchanged lines hidden (view full) --- 239 240#define SIO_CLR(x) \ 241 CSR_WRITE_4(sc, WB_SIO, \ 242 CSR_READ_4(sc, WB_SIO) & ~x) 243 244/* 245 * Send a read command and address to the EEPROM, check for ACK. 246 */ | 132#endif 133 134/* 135 * Various supported device vendors/types and their names. 136 */ 137static struct wb_type wb_devs[] = { 138 { WB_VENDORID, WB_DEVICEID_840F, 139 "Winbond W89C840F 10/100BaseTX" }, --- 99 unchanged lines hidden (view full) --- 239 240#define SIO_CLR(x) \ 241 CSR_WRITE_4(sc, WB_SIO, \ 242 CSR_READ_4(sc, WB_SIO) & ~x) 243 244/* 245 * Send a read command and address to the EEPROM, check for ACK. 246 */ |
247static void wb_eeprom_putbyte(sc, addr) | 247static void 248wb_eeprom_putbyte(sc, addr) |
248 struct wb_softc *sc; 249 int addr; 250{ 251 register int d, i; 252 253 d = addr | WB_EECMD_READ; 254 255 /* --- 13 unchanged lines hidden (view full) --- 269 } 270 271 return; 272} 273 274/* 275 * Read a word of data stored in the EEPROM at address 'addr.' 276 */ | 249 struct wb_softc *sc; 250 int addr; 251{ 252 register int d, i; 253 254 d = addr | WB_EECMD_READ; 255 256 /* --- 13 unchanged lines hidden (view full) --- 270 } 271 272 return; 273} 274 275/* 276 * Read a word of data stored in the EEPROM at address 'addr.' 277 */ |
277static void wb_eeprom_getword(sc, addr, dest) | 278static void 279wb_eeprom_getword(sc, addr, dest) |
278 struct wb_softc *sc; 279 int addr; 280 u_int16_t *dest; 281{ 282 register int i; 283 u_int16_t word = 0; 284 285 /* Enter EEPROM access mode. */ --- 24 unchanged lines hidden (view full) --- 310 *dest = word; 311 312 return; 313} 314 315/* 316 * Read a sequence of words from the EEPROM. 317 */ | 280 struct wb_softc *sc; 281 int addr; 282 u_int16_t *dest; 283{ 284 register int i; 285 u_int16_t word = 0; 286 287 /* Enter EEPROM access mode. */ --- 24 unchanged lines hidden (view full) --- 312 *dest = word; 313 314 return; 315} 316 317/* 318 * Read a sequence of words from the EEPROM. 319 */ |
318static void wb_read_eeprom(sc, dest, off, cnt, swap) | 320static void 321wb_read_eeprom(sc, dest, off, cnt, swap) |
319 struct wb_softc *sc; 320 caddr_t dest; 321 int off; 322 int cnt; 323 int swap; 324{ 325 int i; 326 u_int16_t word = 0, *ptr; --- 8 unchanged lines hidden (view full) --- 335 } 336 337 return; 338} 339 340/* 341 * Sync the PHYs by setting data bit and strobing the clock 32 times. 342 */ | 322 struct wb_softc *sc; 323 caddr_t dest; 324 int off; 325 int cnt; 326 int swap; 327{ 328 int i; 329 u_int16_t word = 0, *ptr; --- 8 unchanged lines hidden (view full) --- 338 } 339 340 return; 341} 342 343/* 344 * Sync the PHYs by setting data bit and strobing the clock 32 times. 345 */ |
343static void wb_mii_sync(sc) | 346static void 347wb_mii_sync(sc) |
344 struct wb_softc *sc; 345{ 346 register int i; 347 348 SIO_SET(WB_SIO_MII_DIR|WB_SIO_MII_DATAIN); 349 350 for (i = 0; i < 32; i++) { 351 SIO_SET(WB_SIO_MII_CLK); 352 DELAY(1); 353 SIO_CLR(WB_SIO_MII_CLK); 354 DELAY(1); 355 } 356 357 return; 358} 359 360/* 361 * Clock a series of bits through the MII. 362 */ | 348 struct wb_softc *sc; 349{ 350 register int i; 351 352 SIO_SET(WB_SIO_MII_DIR|WB_SIO_MII_DATAIN); 353 354 for (i = 0; i < 32; i++) { 355 SIO_SET(WB_SIO_MII_CLK); 356 DELAY(1); 357 SIO_CLR(WB_SIO_MII_CLK); 358 DELAY(1); 359 } 360 361 return; 362} 363 364/* 365 * Clock a series of bits through the MII. 366 */ |
363static void wb_mii_send(sc, bits, cnt) | 367static void 368wb_mii_send(sc, bits, cnt) |
364 struct wb_softc *sc; 365 u_int32_t bits; 366 int cnt; 367{ 368 int i; 369 370 SIO_CLR(WB_SIO_MII_CLK); 371 --- 8 unchanged lines hidden (view full) --- 380 DELAY(1); 381 SIO_SET(WB_SIO_MII_CLK); 382 } 383} 384 385/* 386 * Read an PHY register through the MII. 387 */ | 369 struct wb_softc *sc; 370 u_int32_t bits; 371 int cnt; 372{ 373 int i; 374 375 SIO_CLR(WB_SIO_MII_CLK); 376 --- 8 unchanged lines hidden (view full) --- 385 DELAY(1); 386 SIO_SET(WB_SIO_MII_CLK); 387 } 388} 389 390/* 391 * Read an PHY register through the MII. 392 */ |
388static int wb_mii_readreg(sc, frame) | 393static int 394wb_mii_readreg(sc, frame) |
389 struct wb_softc *sc; 390 struct wb_mii_frame *frame; 391 392{ 393 int i, ack; 394 395 WB_LOCK(sc); 396 --- 79 unchanged lines hidden (view full) --- 476 if (ack) 477 return(1); 478 return(0); 479} 480 481/* 482 * Write to a PHY register through the MII. 483 */ | 395 struct wb_softc *sc; 396 struct wb_mii_frame *frame; 397 398{ 399 int i, ack; 400 401 WB_LOCK(sc); 402 --- 79 unchanged lines hidden (view full) --- 482 if (ack) 483 return(1); 484 return(0); 485} 486 487/* 488 * Write to a PHY register through the MII. 489 */ |
484static int wb_mii_writereg(sc, frame) | 490static int 491wb_mii_writereg(sc, frame) |
485 struct wb_softc *sc; 486 struct wb_mii_frame *frame; 487 488{ 489 WB_LOCK(sc); 490 491 /* 492 * Set up frame for TX. --- 28 unchanged lines hidden (view full) --- 521 */ 522 SIO_CLR(WB_SIO_MII_DIR); 523 524 WB_UNLOCK(sc); 525 526 return(0); 527} 528 | 492 struct wb_softc *sc; 493 struct wb_mii_frame *frame; 494 495{ 496 WB_LOCK(sc); 497 498 /* 499 * Set up frame for TX. --- 28 unchanged lines hidden (view full) --- 528 */ 529 SIO_CLR(WB_SIO_MII_DIR); 530 531 WB_UNLOCK(sc); 532 533 return(0); 534} 535 |
529static int wb_miibus_readreg(dev, phy, reg) | 536static int 537wb_miibus_readreg(dev, phy, reg) |
530 device_t dev; 531 int phy, reg; 532{ 533 struct wb_softc *sc; 534 struct wb_mii_frame frame; 535 536 sc = device_get_softc(dev); 537 538 bzero((char *)&frame, sizeof(frame)); 539 540 frame.mii_phyaddr = phy; 541 frame.mii_regaddr = reg; 542 wb_mii_readreg(sc, &frame); 543 544 return(frame.mii_data); 545} 546 | 538 device_t dev; 539 int phy, reg; 540{ 541 struct wb_softc *sc; 542 struct wb_mii_frame frame; 543 544 sc = device_get_softc(dev); 545 546 bzero((char *)&frame, sizeof(frame)); 547 548 frame.mii_phyaddr = phy; 549 frame.mii_regaddr = reg; 550 wb_mii_readreg(sc, &frame); 551 552 return(frame.mii_data); 553} 554 |
547static int wb_miibus_writereg(dev, phy, reg, data) | 555static int 556wb_miibus_writereg(dev, phy, reg, data) |
548 device_t dev; 549 int phy, reg, data; 550{ 551 struct wb_softc *sc; 552 struct wb_mii_frame frame; 553 554 sc = device_get_softc(dev); 555 556 bzero((char *)&frame, sizeof(frame)); 557 558 frame.mii_phyaddr = phy; 559 frame.mii_regaddr = reg; 560 frame.mii_data = data; 561 562 wb_mii_writereg(sc, &frame); 563 564 return(0); 565} 566 | 557 device_t dev; 558 int phy, reg, data; 559{ 560 struct wb_softc *sc; 561 struct wb_mii_frame frame; 562 563 sc = device_get_softc(dev); 564 565 bzero((char *)&frame, sizeof(frame)); 566 567 frame.mii_phyaddr = phy; 568 frame.mii_regaddr = reg; 569 frame.mii_data = data; 570 571 wb_mii_writereg(sc, &frame); 572 573 return(0); 574} 575 |
567static void wb_miibus_statchg(dev) | 576static void 577wb_miibus_statchg(dev) |
568 device_t dev; 569{ 570 struct wb_softc *sc; 571 struct mii_data *mii; 572 573 sc = device_get_softc(dev); 574 WB_LOCK(sc); 575 mii = device_get_softc(sc->wb_miibus); --- 32 unchanged lines hidden (view full) --- 608 * I could come up with that works. 609 */ 610 return(~(crc >> 26) & 0x0000003F); 611} 612 613/* 614 * Program the 64-bit multicast hash filter. 615 */ | 578 device_t dev; 579{ 580 struct wb_softc *sc; 581 struct mii_data *mii; 582 583 sc = device_get_softc(dev); 584 WB_LOCK(sc); 585 mii = device_get_softc(sc->wb_miibus); --- 32 unchanged lines hidden (view full) --- 618 * I could come up with that works. 619 */ 620 return(~(crc >> 26) & 0x0000003F); 621} 622 623/* 624 * Program the 64-bit multicast hash filter. 625 */ |
616static void wb_setmulti(sc) | 626static void 627wb_setmulti(sc) |
617 struct wb_softc *sc; 618{ 619 struct ifnet *ifp; 620 int h = 0; 621 u_int32_t hashes[2] = { 0, 0 }; 622 struct ifmultiaddr *ifma; 623 u_int32_t rxfilt; 624 int mcnt = 0; --- 38 unchanged lines hidden (view full) --- 663 return; 664} 665 666/* 667 * The Winbond manual states that in order to fiddle with the 668 * 'full-duplex' and '100Mbps' bits in the netconfig register, we 669 * first have to put the transmit and/or receive logic in the idle state. 670 */ | 628 struct wb_softc *sc; 629{ 630 struct ifnet *ifp; 631 int h = 0; 632 u_int32_t hashes[2] = { 0, 0 }; 633 struct ifmultiaddr *ifma; 634 u_int32_t rxfilt; 635 int mcnt = 0; --- 38 unchanged lines hidden (view full) --- 674 return; 675} 676 677/* 678 * The Winbond manual states that in order to fiddle with the 679 * 'full-duplex' and '100Mbps' bits in the netconfig register, we 680 * first have to put the transmit and/or receive logic in the idle state. 681 */ |
671static void wb_setcfg(sc, media) | 682static void 683wb_setcfg(sc, media) |
672 struct wb_softc *sc; 673 u_int32_t media; 674{ 675 int i, restart = 0; 676 677 if (CSR_READ_4(sc, WB_NETCFG) & (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON)) { 678 restart = 1; 679 WB_CLRBIT(sc, WB_NETCFG, (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON)); --- 21 unchanged lines hidden (view full) --- 701 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_FULLDUPLEX); 702 703 if (restart) 704 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_TX_ON|WB_NETCFG_RX_ON); 705 706 return; 707} 708 | 684 struct wb_softc *sc; 685 u_int32_t media; 686{ 687 int i, restart = 0; 688 689 if (CSR_READ_4(sc, WB_NETCFG) & (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON)) { 690 restart = 1; 691 WB_CLRBIT(sc, WB_NETCFG, (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON)); --- 21 unchanged lines hidden (view full) --- 713 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_FULLDUPLEX); 714 715 if (restart) 716 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_TX_ON|WB_NETCFG_RX_ON); 717 718 return; 719} 720 |
709static void wb_reset(sc) | 721static void 722wb_reset(sc) |
710 struct wb_softc *sc; 711{ 712 register int i; 713 struct mii_data *mii; 714 715 CSR_WRITE_4(sc, WB_NETCFG, 0); 716 CSR_WRITE_4(sc, WB_BUSCTL, 0); 717 CSR_WRITE_4(sc, WB_TXADDR, 0); --- 24 unchanged lines hidden (view full) --- 742 struct mii_softc *miisc; 743 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) 744 mii_phy_reset(miisc); 745 } 746 747 return; 748} 749 | 723 struct wb_softc *sc; 724{ 725 register int i; 726 struct mii_data *mii; 727 728 CSR_WRITE_4(sc, WB_NETCFG, 0); 729 CSR_WRITE_4(sc, WB_BUSCTL, 0); 730 CSR_WRITE_4(sc, WB_TXADDR, 0); --- 24 unchanged lines hidden (view full) --- 755 struct mii_softc *miisc; 756 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) 757 mii_phy_reset(miisc); 758 } 759 760 return; 761} 762 |
750static void wb_fixmedia(sc) | 763static void 764wb_fixmedia(sc) |
751 struct wb_softc *sc; 752{ 753 struct mii_data *mii = NULL; 754 struct ifnet *ifp; 755 u_int32_t media; 756 757 if (sc->wb_miibus == NULL) 758 return; --- 15 unchanged lines hidden (view full) --- 774 775 return; 776} 777 778/* 779 * Probe for a Winbond chip. Check the PCI vendor and device 780 * IDs against our list and return a device name if we find a match. 781 */ | 765 struct wb_softc *sc; 766{ 767 struct mii_data *mii = NULL; 768 struct ifnet *ifp; 769 u_int32_t media; 770 771 if (sc->wb_miibus == NULL) 772 return; --- 15 unchanged lines hidden (view full) --- 788 789 return; 790} 791 792/* 793 * Probe for a Winbond chip. Check the PCI vendor and device 794 * IDs against our list and return a device name if we find a match. 795 */ |
782static int wb_probe(dev) | 796static int 797wb_probe(dev) |
783 device_t dev; 784{ 785 struct wb_type *t; 786 787 t = wb_devs; 788 789 while(t->wb_name != NULL) { 790 if ((pci_get_vendor(dev) == t->wb_vid) && --- 6 unchanged lines hidden (view full) --- 797 798 return(ENXIO); 799} 800 801/* 802 * Attach the interface. Allocate softc structures, do ifmedia 803 * setup and ethernet/BPF attach. 804 */ | 798 device_t dev; 799{ 800 struct wb_type *t; 801 802 t = wb_devs; 803 804 while(t->wb_name != NULL) { 805 if ((pci_get_vendor(dev) == t->wb_vid) && --- 6 unchanged lines hidden (view full) --- 812 813 return(ENXIO); 814} 815 816/* 817 * Attach the interface. Allocate softc structures, do ifmedia 818 * setup and ethernet/BPF attach. 819 */ |
805static int wb_attach(dev) | 820static int 821wb_attach(dev) |
806 device_t dev; 807{ 808 u_char eaddr[ETHER_ADDR_LEN]; 809 u_int32_t command; 810 struct wb_softc *sc; 811 struct ifnet *ifp; 812 int unit, error = 0, rid; 813 --- 156 unchanged lines hidden (view full) --- 970 if (error) 971 device_delete_child(dev, sc->wb_miibus); 972 WB_UNLOCK(sc); 973 mtx_destroy(&sc->wb_mtx); 974 975 return(error); 976} 977 | 822 device_t dev; 823{ 824 u_char eaddr[ETHER_ADDR_LEN]; 825 u_int32_t command; 826 struct wb_softc *sc; 827 struct ifnet *ifp; 828 int unit, error = 0, rid; 829 --- 156 unchanged lines hidden (view full) --- 986 if (error) 987 device_delete_child(dev, sc->wb_miibus); 988 WB_UNLOCK(sc); 989 mtx_destroy(&sc->wb_mtx); 990 991 return(error); 992} 993 |
978static int wb_detach(dev) | 994static int 995wb_detach(dev) |
979 device_t dev; 980{ 981 struct wb_softc *sc; 982 struct ifnet *ifp; 983 984 sc = device_get_softc(dev); 985 WB_LOCK(sc); 986 ifp = &sc->arpcom.ac_if; --- 15 unchanged lines hidden (view full) --- 1002 mtx_destroy(&sc->wb_mtx); 1003 1004 return(0); 1005} 1006 1007/* 1008 * Initialize the transmit descriptors. 1009 */ | 996 device_t dev; 997{ 998 struct wb_softc *sc; 999 struct ifnet *ifp; 1000 1001 sc = device_get_softc(dev); 1002 WB_LOCK(sc); 1003 ifp = &sc->arpcom.ac_if; --- 15 unchanged lines hidden (view full) --- 1019 mtx_destroy(&sc->wb_mtx); 1020 1021 return(0); 1022} 1023 1024/* 1025 * Initialize the transmit descriptors. 1026 */ |
1010static int wb_list_tx_init(sc) | 1027static int 1028wb_list_tx_init(sc) |
1011 struct wb_softc *sc; 1012{ 1013 struct wb_chain_data *cd; 1014 struct wb_list_data *ld; 1015 int i; 1016 1017 cd = &sc->wb_cdata; 1018 ld = sc->wb_ldata; --- 16 unchanged lines hidden (view full) --- 1035} 1036 1037 1038/* 1039 * Initialize the RX descriptors and allocate mbufs for them. Note that 1040 * we arrange the descriptors in a closed ring, so that the last descriptor 1041 * points back to the first. 1042 */ | 1029 struct wb_softc *sc; 1030{ 1031 struct wb_chain_data *cd; 1032 struct wb_list_data *ld; 1033 int i; 1034 1035 cd = &sc->wb_cdata; 1036 ld = sc->wb_ldata; --- 16 unchanged lines hidden (view full) --- 1053} 1054 1055 1056/* 1057 * Initialize the RX descriptors and allocate mbufs for them. Note that 1058 * we arrange the descriptors in a closed ring, so that the last descriptor 1059 * points back to the first. 1060 */ |
1043static int wb_list_rx_init(sc) | 1061static int 1062wb_list_rx_init(sc) |
1044 struct wb_softc *sc; 1045{ 1046 struct wb_chain_data *cd; 1047 struct wb_list_data *ld; 1048 int i; 1049 1050 cd = &sc->wb_cdata; 1051 ld = sc->wb_ldata; --- 16 unchanged lines hidden (view full) --- 1068 } 1069 } 1070 1071 cd->wb_rx_head = &cd->wb_rx_chain[0]; 1072 1073 return(0); 1074} 1075 | 1063 struct wb_softc *sc; 1064{ 1065 struct wb_chain_data *cd; 1066 struct wb_list_data *ld; 1067 int i; 1068 1069 cd = &sc->wb_cdata; 1070 ld = sc->wb_ldata; --- 16 unchanged lines hidden (view full) --- 1087 } 1088 } 1089 1090 cd->wb_rx_head = &cd->wb_rx_chain[0]; 1091 1092 return(0); 1093} 1094 |
1076static void wb_bfree(buf, args) | 1095static void 1096wb_bfree(buf, args) |
1077 void *buf; 1078 void *args; 1079{ 1080 return; 1081} 1082 1083/* 1084 * Initialize an RX descriptor and attach an MBUF cluster. 1085 */ | 1097 void *buf; 1098 void *args; 1099{ 1100 return; 1101} 1102 1103/* 1104 * Initialize an RX descriptor and attach an MBUF cluster. 1105 */ |
1086static int wb_newbuf(sc, c, m) | 1106static int 1107wb_newbuf(sc, c, m) |
1087 struct wb_softc *sc; 1088 struct wb_chain_onefrag *c; 1089 struct mbuf *m; 1090{ 1091 struct mbuf *m_new = NULL; 1092 1093 if (m == NULL) { 1094 MGETHDR(m_new, M_DONTWAIT, MT_DATA); --- 18 unchanged lines hidden (view full) --- 1113 1114 return(0); 1115} 1116 1117/* 1118 * A frame has been uploaded: pass the resulting mbuf chain up to 1119 * the higher level protocols. 1120 */ | 1108 struct wb_softc *sc; 1109 struct wb_chain_onefrag *c; 1110 struct mbuf *m; 1111{ 1112 struct mbuf *m_new = NULL; 1113 1114 if (m == NULL) { 1115 MGETHDR(m_new, M_DONTWAIT, MT_DATA); --- 18 unchanged lines hidden (view full) --- 1134 1135 return(0); 1136} 1137 1138/* 1139 * A frame has been uploaded: pass the resulting mbuf chain up to 1140 * the higher level protocols. 1141 */ |
1121static void wb_rxeof(sc) | 1142static void 1143wb_rxeof(sc) |
1122 struct wb_softc *sc; 1123{ 1124 struct ether_header *eh; 1125 struct mbuf *m = NULL; 1126 struct ifnet *ifp; 1127 struct wb_chain_onefrag *cur_rx; 1128 int total_len = 0; 1129 u_int32_t rxstat; --- 55 unchanged lines hidden (view full) --- 1185 eh = mtod(m, struct ether_header *); 1186 1187 /* Remove header from mbuf and pass it on. */ 1188 m_adj(m, sizeof(struct ether_header)); 1189 ether_input(ifp, eh, m); 1190 } 1191} 1192 | 1144 struct wb_softc *sc; 1145{ 1146 struct ether_header *eh; 1147 struct mbuf *m = NULL; 1148 struct ifnet *ifp; 1149 struct wb_chain_onefrag *cur_rx; 1150 int total_len = 0; 1151 u_int32_t rxstat; --- 55 unchanged lines hidden (view full) --- 1207 eh = mtod(m, struct ether_header *); 1208 1209 /* Remove header from mbuf and pass it on. */ 1210 m_adj(m, sizeof(struct ether_header)); 1211 ether_input(ifp, eh, m); 1212 } 1213} 1214 |
1193void wb_rxeoc(sc) | 1215void 1216wb_rxeoc(sc) |
1194 struct wb_softc *sc; 1195{ 1196 wb_rxeof(sc); 1197 1198 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_RX_ON); 1199 CSR_WRITE_4(sc, WB_RXADDR, vtophys(&sc->wb_ldata->wb_rx_list[0])); 1200 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_RX_ON); 1201 if (CSR_READ_4(sc, WB_ISR) & WB_RXSTATE_SUSPEND) 1202 CSR_WRITE_4(sc, WB_RXSTART, 0xFFFFFFFF); 1203 1204 return; 1205} 1206 1207/* 1208 * A frame was downloaded to the chip. It's safe for us to clean up 1209 * the list buffers. 1210 */ | 1217 struct wb_softc *sc; 1218{ 1219 wb_rxeof(sc); 1220 1221 WB_CLRBIT(sc, WB_NETCFG, WB_NETCFG_RX_ON); 1222 CSR_WRITE_4(sc, WB_RXADDR, vtophys(&sc->wb_ldata->wb_rx_list[0])); 1223 WB_SETBIT(sc, WB_NETCFG, WB_NETCFG_RX_ON); 1224 if (CSR_READ_4(sc, WB_ISR) & WB_RXSTATE_SUSPEND) 1225 CSR_WRITE_4(sc, WB_RXSTART, 0xFFFFFFFF); 1226 1227 return; 1228} 1229 1230/* 1231 * A frame was downloaded to the chip. It's safe for us to clean up 1232 * the list buffers. 1233 */ |
1211static void wb_txeof(sc) | 1234static void 1235wb_txeof(sc) |
1212 struct wb_softc *sc; 1213{ 1214 struct wb_chain *cur_tx; 1215 struct ifnet *ifp; 1216 1217 ifp = &sc->arpcom.ac_if; 1218 1219 /* Clear the timeout timer. */ --- 39 unchanged lines hidden (view full) --- 1259 } 1260 1261 return; 1262} 1263 1264/* 1265 * TX 'end of channel' interrupt handler. 1266 */ | 1236 struct wb_softc *sc; 1237{ 1238 struct wb_chain *cur_tx; 1239 struct ifnet *ifp; 1240 1241 ifp = &sc->arpcom.ac_if; 1242 1243 /* Clear the timeout timer. */ --- 39 unchanged lines hidden (view full) --- 1283 } 1284 1285 return; 1286} 1287 1288/* 1289 * TX 'end of channel' interrupt handler. 1290 */ |
1267static void wb_txeoc(sc) | 1291static void 1292wb_txeoc(sc) |
1268 struct wb_softc *sc; 1269{ 1270 struct ifnet *ifp; 1271 1272 ifp = &sc->arpcom.ac_if; 1273 1274 ifp->if_timer = 0; 1275 --- 6 unchanged lines hidden (view full) --- 1282 ifp->if_timer = 5; 1283 CSR_WRITE_4(sc, WB_TXSTART, 0xFFFFFFFF); 1284 } 1285 } 1286 1287 return; 1288} 1289 | 1293 struct wb_softc *sc; 1294{ 1295 struct ifnet *ifp; 1296 1297 ifp = &sc->arpcom.ac_if; 1298 1299 ifp->if_timer = 0; 1300 --- 6 unchanged lines hidden (view full) --- 1307 ifp->if_timer = 5; 1308 CSR_WRITE_4(sc, WB_TXSTART, 0xFFFFFFFF); 1309 } 1310 } 1311 1312 return; 1313} 1314 |
1290static void wb_intr(arg) | 1315static void 1316wb_intr(arg) |
1291 void *arg; 1292{ 1293 struct wb_softc *sc; 1294 struct ifnet *ifp; 1295 u_int32_t status; 1296 1297 sc = arg; 1298 WB_LOCK(sc); --- 70 unchanged lines hidden (view full) --- 1369 wb_start(ifp); 1370 } 1371 1372 WB_UNLOCK(sc); 1373 1374 return; 1375} 1376 | 1317 void *arg; 1318{ 1319 struct wb_softc *sc; 1320 struct ifnet *ifp; 1321 u_int32_t status; 1322 1323 sc = arg; 1324 WB_LOCK(sc); --- 70 unchanged lines hidden (view full) --- 1395 wb_start(ifp); 1396 } 1397 1398 WB_UNLOCK(sc); 1399 1400 return; 1401} 1402 |
1377static void wb_tick(xsc) | 1403static void 1404wb_tick(xsc) |
1378 void *xsc; 1379{ 1380 struct wb_softc *sc; 1381 struct mii_data *mii; 1382 1383 sc = xsc; 1384 WB_LOCK(sc); 1385 mii = device_get_softc(sc->wb_miibus); --- 6 unchanged lines hidden (view full) --- 1392 1393 return; 1394} 1395 1396/* 1397 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data 1398 * pointers to the fragment pointers. 1399 */ | 1405 void *xsc; 1406{ 1407 struct wb_softc *sc; 1408 struct mii_data *mii; 1409 1410 sc = xsc; 1411 WB_LOCK(sc); 1412 mii = device_get_softc(sc->wb_miibus); --- 6 unchanged lines hidden (view full) --- 1419 1420 return; 1421} 1422 1423/* 1424 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data 1425 * pointers to the fragment pointers. 1426 */ |
1400static int wb_encap(sc, c, m_head) | 1427static int 1428wb_encap(sc, c, m_head) |
1401 struct wb_softc *sc; 1402 struct wb_chain *c; 1403 struct mbuf *m_head; 1404{ 1405 int frag = 0; 1406 struct wb_desc *f = NULL; 1407 int total_len; 1408 struct mbuf *m; --- 77 unchanged lines hidden (view full) --- 1486 1487/* 1488 * Main transmit routine. To avoid having to do mbuf copies, we put pointers 1489 * to the mbuf data regions directly in the transmit lists. We also save a 1490 * copy of the pointers since the transmit list fragment pointers are 1491 * physical addresses. 1492 */ 1493 | 1429 struct wb_softc *sc; 1430 struct wb_chain *c; 1431 struct mbuf *m_head; 1432{ 1433 int frag = 0; 1434 struct wb_desc *f = NULL; 1435 int total_len; 1436 struct mbuf *m; --- 77 unchanged lines hidden (view full) --- 1514 1515/* 1516 * Main transmit routine. To avoid having to do mbuf copies, we put pointers 1517 * to the mbuf data regions directly in the transmit lists. We also save a 1518 * copy of the pointers since the transmit list fragment pointers are 1519 * physical addresses. 1520 */ 1521 |
1494static void wb_start(ifp) | 1522static void 1523wb_start(ifp) |
1495 struct ifnet *ifp; 1496{ 1497 struct wb_softc *sc; 1498 struct mbuf *m_head = NULL; 1499 struct wb_chain *cur_tx = NULL, *start_tx; 1500 1501 sc = ifp->if_softc; 1502 WB_LOCK(sc); --- 76 unchanged lines hidden (view full) --- 1579 * Set a timeout in case the chip goes out to lunch. 1580 */ 1581 ifp->if_timer = 5; 1582 WB_UNLOCK(sc); 1583 1584 return; 1585} 1586 | 1524 struct ifnet *ifp; 1525{ 1526 struct wb_softc *sc; 1527 struct mbuf *m_head = NULL; 1528 struct wb_chain *cur_tx = NULL, *start_tx; 1529 1530 sc = ifp->if_softc; 1531 WB_LOCK(sc); --- 76 unchanged lines hidden (view full) --- 1608 * Set a timeout in case the chip goes out to lunch. 1609 */ 1610 ifp->if_timer = 5; 1611 WB_UNLOCK(sc); 1612 1613 return; 1614} 1615 |
1587static void wb_init(xsc) | 1616static void 1617wb_init(xsc) |
1588 void *xsc; 1589{ 1590 struct wb_softc *sc = xsc; 1591 struct ifnet *ifp = &sc->arpcom.ac_if; 1592 int i; 1593 struct mii_data *mii; 1594 1595 WB_LOCK(sc); --- 104 unchanged lines hidden (view full) --- 1700 WB_UNLOCK(sc); 1701 1702 return; 1703} 1704 1705/* 1706 * Set media options. 1707 */ | 1618 void *xsc; 1619{ 1620 struct wb_softc *sc = xsc; 1621 struct ifnet *ifp = &sc->arpcom.ac_if; 1622 int i; 1623 struct mii_data *mii; 1624 1625 WB_LOCK(sc); --- 104 unchanged lines hidden (view full) --- 1730 WB_UNLOCK(sc); 1731 1732 return; 1733} 1734 1735/* 1736 * Set media options. 1737 */ |
1708static int wb_ifmedia_upd(ifp) | 1738static int 1739wb_ifmedia_upd(ifp) |
1709 struct ifnet *ifp; 1710{ 1711 struct wb_softc *sc; 1712 1713 sc = ifp->if_softc; 1714 1715 if (ifp->if_flags & IFF_UP) 1716 wb_init(sc); 1717 1718 return(0); 1719} 1720 1721/* 1722 * Report current media status. 1723 */ | 1740 struct ifnet *ifp; 1741{ 1742 struct wb_softc *sc; 1743 1744 sc = ifp->if_softc; 1745 1746 if (ifp->if_flags & IFF_UP) 1747 wb_init(sc); 1748 1749 return(0); 1750} 1751 1752/* 1753 * Report current media status. 1754 */ |
1724static void wb_ifmedia_sts(ifp, ifmr) | 1755static void 1756wb_ifmedia_sts(ifp, ifmr) |
1725 struct ifnet *ifp; 1726 struct ifmediareq *ifmr; 1727{ 1728 struct wb_softc *sc; 1729 struct mii_data *mii; 1730 1731 sc = ifp->if_softc; 1732 1733 mii = device_get_softc(sc->wb_miibus); 1734 1735 mii_pollstat(mii); 1736 ifmr->ifm_active = mii->mii_media_active; 1737 ifmr->ifm_status = mii->mii_media_status; 1738 1739 return; 1740} 1741 | 1757 struct ifnet *ifp; 1758 struct ifmediareq *ifmr; 1759{ 1760 struct wb_softc *sc; 1761 struct mii_data *mii; 1762 1763 sc = ifp->if_softc; 1764 1765 mii = device_get_softc(sc->wb_miibus); 1766 1767 mii_pollstat(mii); 1768 ifmr->ifm_active = mii->mii_media_active; 1769 ifmr->ifm_status = mii->mii_media_status; 1770 1771 return; 1772} 1773 |
1742static int wb_ioctl(ifp, command, data) | 1774static int 1775wb_ioctl(ifp, command, data) |
1743 struct ifnet *ifp; 1744 u_long command; 1745 caddr_t data; 1746{ 1747 struct wb_softc *sc = ifp->if_softc; 1748 struct mii_data *mii; 1749 struct ifreq *ifr = (struct ifreq *) data; 1750 int error = 0; --- 30 unchanged lines hidden (view full) --- 1781 break; 1782 } 1783 1784 WB_UNLOCK(sc); 1785 1786 return(error); 1787} 1788 | 1776 struct ifnet *ifp; 1777 u_long command; 1778 caddr_t data; 1779{ 1780 struct wb_softc *sc = ifp->if_softc; 1781 struct mii_data *mii; 1782 struct ifreq *ifr = (struct ifreq *) data; 1783 int error = 0; --- 30 unchanged lines hidden (view full) --- 1814 break; 1815 } 1816 1817 WB_UNLOCK(sc); 1818 1819 return(error); 1820} 1821 |
1789static void wb_watchdog(ifp) | 1822static void 1823wb_watchdog(ifp) |
1790 struct ifnet *ifp; 1791{ 1792 struct wb_softc *sc; 1793 1794 sc = ifp->if_softc; 1795 1796 WB_LOCK(sc); 1797 ifp->if_oerrors++; --- 13 unchanged lines hidden (view full) --- 1811 1812 return; 1813} 1814 1815/* 1816 * Stop the adapter and free any mbufs allocated to the 1817 * RX and TX lists. 1818 */ | 1824 struct ifnet *ifp; 1825{ 1826 struct wb_softc *sc; 1827 1828 sc = ifp->if_softc; 1829 1830 WB_LOCK(sc); 1831 ifp->if_oerrors++; --- 13 unchanged lines hidden (view full) --- 1845 1846 return; 1847} 1848 1849/* 1850 * Stop the adapter and free any mbufs allocated to the 1851 * RX and TX lists. 1852 */ |
1819static void wb_stop(sc) | 1853static void 1854wb_stop(sc) |
1820 struct wb_softc *sc; 1821{ 1822 register int i; 1823 struct ifnet *ifp; 1824 1825 WB_LOCK(sc); 1826 ifp = &sc->arpcom.ac_if; 1827 ifp->if_timer = 0; --- 35 unchanged lines hidden (view full) --- 1863 1864 return; 1865} 1866 1867/* 1868 * Stop all chip I/O so that the kernel's probe routines don't 1869 * get confused by errant DMAs when rebooting. 1870 */ | 1855 struct wb_softc *sc; 1856{ 1857 register int i; 1858 struct ifnet *ifp; 1859 1860 WB_LOCK(sc); 1861 ifp = &sc->arpcom.ac_if; 1862 ifp->if_timer = 0; --- 35 unchanged lines hidden (view full) --- 1898 1899 return; 1900} 1901 1902/* 1903 * Stop all chip I/O so that the kernel's probe routines don't 1904 * get confused by errant DMAs when rebooting. 1905 */ |
1871static void wb_shutdown(dev) | 1906static void 1907wb_shutdown(dev) |
1872 device_t dev; 1873{ 1874 struct wb_softc *sc; 1875 1876 sc = device_get_softc(dev); 1877 wb_stop(sc); 1878 1879 return; 1880} | 1908 device_t dev; 1909{ 1910 struct wb_softc *sc; 1911 1912 sc = device_get_softc(dev); 1913 wb_stop(sc); 1914 1915 return; 1916} |