if_ep.c (121515) | if_ep.c (121588) |
---|---|
1/* 2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 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 --- 15 unchanged lines hidden (view full) --- 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 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 --- 15 unchanged lines hidden (view full) --- 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep.c 121515 2003-10-25 21:28:40Z imp $"); | 32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep.c 121588 2003-10-26 22:28:20Z imp $"); |
33 34/* 35 * Modified from the FreeBSD 1.1.5.1 version by: 36 * Andres Vega Garcia 37 * INRIA - Sophia Antipolis, France 38 * avega@sophia.inria.fr 39 */ 40 --- 15 unchanged lines hidden (view full) --- 56 */ 57 58/* 59 * MAINTAINER: Matthew N. Dodd <winter@jurai.net> 60 * <mdodd@FreeBSD.org> 61 */ 62 63#include <sys/cdefs.h> | 33 34/* 35 * Modified from the FreeBSD 1.1.5.1 version by: 36 * Andres Vega Garcia 37 * INRIA - Sophia Antipolis, France 38 * avega@sophia.inria.fr 39 */ 40 --- 15 unchanged lines hidden (view full) --- 56 */ 57 58/* 59 * MAINTAINER: Matthew N. Dodd <winter@jurai.net> 60 * <mdodd@FreeBSD.org> 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep.c 121515 2003-10-25 21:28:40Z imp $"); | 64__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep.c 121588 2003-10-26 22:28:20Z imp $"); |
65 66#include <sys/param.h> 67#include <sys/systm.h> 68#include <sys/mbuf.h> 69#include <sys/socket.h> 70#include <sys/sockio.h> 71#include <sys/bus.h> 72 --- 80 unchanged lines hidden (view full) --- 153{ 154 int i; 155 u_int16_t result; 156 int error; 157 u_int16_t *macaddr; 158 159 macaddr = (u_int16_t *) addr; 160 | 65 66#include <sys/param.h> 67#include <sys/systm.h> 68#include <sys/mbuf.h> 69#include <sys/socket.h> 70#include <sys/sockio.h> 71#include <sys/bus.h> 72 --- 80 unchanged lines hidden (view full) --- 153{ 154 int i; 155 u_int16_t result; 156 int error; 157 u_int16_t *macaddr; 158 159 macaddr = (u_int16_t *) addr; 160 |
161 GO_WINDOW(0); | 161 GO_WINDOW(sc, 0); |
162 for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) { 163 error = get_e(sc, i, &result); 164 if (error) 165 return (error); 166 macaddr[i] = htons(result); 167 } 168 169 return (0); --- 28 unchanged lines hidden (view full) --- 198 sc->stat = 0; /* 16 bit access */ 199 200 sc->bst = rman_get_bustag(sc->iobase); 201 sc->bsh = rman_get_bushandle(sc->iobase); 202 203 sc->ep_connectors = 0; 204 sc->ep_connector = 0; 205 | 162 for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) { 163 error = get_e(sc, i, &result); 164 if (error) 165 return (error); 166 macaddr[i] = htons(result); 167 } 168 169 return (0); --- 28 unchanged lines hidden (view full) --- 198 sc->stat = 0; /* 16 bit access */ 199 200 sc->bst = rman_get_bustag(sc->iobase); 201 sc->bsh = rman_get_bushandle(sc->iobase); 202 203 sc->ep_connectors = 0; 204 sc->ep_connector = 0; 205 |
206 GO_WINDOW(0); | 206 GO_WINDOW(sc, 0); |
207 sc->epb.cmd_off = 0; 208 209 error = get_e(sc, EEPROM_PROD_ID, &result); 210 if (error) 211 goto bad; 212 sc->epb.prod_id = result; 213 214 error = get_e(sc, EEPROM_RESOURCE_CFG, &result); --- 5 unchanged lines hidden (view full) --- 220 return (error); 221} 222 223void 224ep_get_media(struct ep_softc *sc) 225{ 226 u_int16_t config; 227 | 207 sc->epb.cmd_off = 0; 208 209 error = get_e(sc, EEPROM_PROD_ID, &result); 210 if (error) 211 goto bad; 212 sc->epb.prod_id = result; 213 214 error = get_e(sc, EEPROM_RESOURCE_CFG, &result); --- 5 unchanged lines hidden (view full) --- 220 return (error); 221} 222 223void 224ep_get_media(struct ep_softc *sc) 225{ 226 u_int16_t config; 227 |
228 GO_WINDOW(0); | 228 GO_WINDOW(sc, 0); |
229 config = CSR_READ_2(sc, EP_W0_CONFIG_CTRL); 230 if (config & IS_AUI) 231 sc->ep_connectors |= AUI; 232 if (config & IS_BNC) 233 sc->ep_connectors |= BNC; 234 if (config & IS_UTP) 235 sc->ep_connectors |= UTP; 236 --- 39 unchanged lines hidden (view full) --- 276 device_printf(sc->dev, "Unable to get Ethernet address!\n"); 277 EP_LOCK_DESTORY(sc); 278 return (ENXIO); 279 } 280 /* 281 * Setup the station address 282 */ 283 p = (u_short *)&sc->arpcom.ac_enaddr; | 229 config = CSR_READ_2(sc, EP_W0_CONFIG_CTRL); 230 if (config & IS_AUI) 231 sc->ep_connectors |= AUI; 232 if (config & IS_BNC) 233 sc->ep_connectors |= BNC; 234 if (config & IS_UTP) 235 sc->ep_connectors |= UTP; 236 --- 39 unchanged lines hidden (view full) --- 276 device_printf(sc->dev, "Unable to get Ethernet address!\n"); 277 EP_LOCK_DESTORY(sc); 278 return (ENXIO); 279 } 280 /* 281 * Setup the station address 282 */ 283 p = (u_short *)&sc->arpcom.ac_enaddr; |
284 GO_WINDOW(2); | 284 GO_WINDOW(sc, 2); |
285 for (i = 0; i < 3; i++) 286 CSR_WRITE_2(sc, EP_W2_ADDR_0 + (i * 2), ntohs(p[i])); 287 288 device_printf(sc->dev, "Ethernet address %6D\n", 289 sc->arpcom.ac_enaddr, ":"); 290 291 ifp = &sc->arpcom.ac_if; 292 attached = (ifp->if_softc != 0); --- 95 unchanged lines hidden (view full) --- 388 int i; 389 390 if (sc->gone) 391 return; 392 393 EP_ASSERT_LOCKED(sc); 394 EP_BUSY_WAIT(sc); 395 | 285 for (i = 0; i < 3; i++) 286 CSR_WRITE_2(sc, EP_W2_ADDR_0 + (i * 2), ntohs(p[i])); 287 288 device_printf(sc->dev, "Ethernet address %6D\n", 289 sc->arpcom.ac_enaddr, ":"); 290 291 ifp = &sc->arpcom.ac_if; 292 attached = (ifp->if_softc != 0); --- 95 unchanged lines hidden (view full) --- 388 int i; 389 390 if (sc->gone) 391 return; 392 393 EP_ASSERT_LOCKED(sc); 394 EP_BUSY_WAIT(sc); 395 |
396 GO_WINDOW(0); | 396 GO_WINDOW(sc, 0); |
397 CSR_WRITE_2(sc, EP_COMMAND, STOP_TRANSCEIVER); | 397 CSR_WRITE_2(sc, EP_COMMAND, STOP_TRANSCEIVER); |
398 GO_WINDOW(4); | 398 GO_WINDOW(sc, 4); |
399 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, DISABLE_UTP); | 399 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, DISABLE_UTP); |
400 GO_WINDOW(0); | 400 GO_WINDOW(sc, 0); |
401 402 /* Disable the card */ 403 CSR_WRITE_2(sc, EP_W0_CONFIG_CTRL, 0); 404 405 /* Enable the card */ 406 CSR_WRITE_2(sc, EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); 407 | 401 402 /* Disable the card */ 403 CSR_WRITE_2(sc, EP_W0_CONFIG_CTRL, 0); 404 405 /* Enable the card */ 406 CSR_WRITE_2(sc, EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); 407 |
408 GO_WINDOW(2); | 408 GO_WINDOW(sc, 2); |
409 410 /* Reload the ether_addr. */ 411 for (i = 0; i < 6; i++) 412 CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]); 413 414 CSR_WRITE_2(sc, EP_COMMAND, RX_RESET); 415 CSR_WRITE_2(sc, EP_COMMAND, TX_RESET); 416 EP_BUSY_WAIT(sc); 417 418 /* Window 1 is operating window */ | 409 410 /* Reload the ether_addr. */ 411 for (i = 0; i < 6; i++) 412 CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]); 413 414 CSR_WRITE_2(sc, EP_COMMAND, RX_RESET); 415 CSR_WRITE_2(sc, EP_COMMAND, TX_RESET); 416 EP_BUSY_WAIT(sc); 417 418 /* Window 1 is operating window */ |
419 GO_WINDOW(1); | 419 GO_WINDOW(sc, 1); |
420 for (i = 0; i < 31; i++) 421 CSR_READ_1(sc, EP_W1_TX_STATUS); 422 423 /* get rid of stray intr's */ 424 CSR_WRITE_2(sc, EP_COMMAND, ACK_INTR | 0xff); 425 426 CSR_WRITE_2(sc, EP_COMMAND, SET_RD_0_MASK | S_5_INTS); 427 --- 28 unchanged lines hidden (view full) --- 456 CSR_WRITE_2(sc, EP_COMMAND, SET_TX_START_THRESH | 16); 457 458 /* 459 * Store up a bunch of mbuf's for use later. (MAX_MBS). 460 * First we free up any that we had in case we're being 461 * called from intr or somewhere else. 462 */ 463 | 420 for (i = 0; i < 31; i++) 421 CSR_READ_1(sc, EP_W1_TX_STATUS); 422 423 /* get rid of stray intr's */ 424 CSR_WRITE_2(sc, EP_COMMAND, ACK_INTR | 0xff); 425 426 CSR_WRITE_2(sc, EP_COMMAND, SET_RD_0_MASK | S_5_INTS); 427 --- 28 unchanged lines hidden (view full) --- 456 CSR_WRITE_2(sc, EP_COMMAND, SET_TX_START_THRESH | 16); 457 458 /* 459 * Store up a bunch of mbuf's for use later. (MAX_MBS). 460 * First we free up any that we had in case we're being 461 * called from intr or somewhere else. 462 */ 463 |
464 GO_WINDOW(1); | 464 GO_WINDOW(sc, 1); |
465 epstart_locked(ifp); 466} 467 468static void 469epstart(struct ifnet *ifp) 470{ 471 struct ep_softc *sc; 472 sc = ifp->if_softc; --- 138 unchanged lines hidden (view full) --- 611 CSR_WRITE_2(sc, EP_COMMAND, ACK_INTR | (status & S_MASK)); 612 613 if (status & (S_RX_COMPLETE | S_RX_EARLY)) 614 epread(sc); 615 if (status & S_TX_AVAIL) { 616 /* we need ACK */ 617 ifp->if_timer = 0; 618 ifp->if_flags &= ~IFF_OACTIVE; | 465 epstart_locked(ifp); 466} 467 468static void 469epstart(struct ifnet *ifp) 470{ 471 struct ep_softc *sc; 472 sc = ifp->if_softc; --- 138 unchanged lines hidden (view full) --- 611 CSR_WRITE_2(sc, EP_COMMAND, ACK_INTR | (status & S_MASK)); 612 613 if (status & (S_RX_COMPLETE | S_RX_EARLY)) 614 epread(sc); 615 if (status & S_TX_AVAIL) { 616 /* we need ACK */ 617 ifp->if_timer = 0; 618 ifp->if_flags &= ~IFF_OACTIVE; |
619 GO_WINDOW(1); | 619 GO_WINDOW(sc, 1); |
620 CSR_READ_2(sc, EP_W1_FREE_TX); 621 epstart_locked(ifp); 622 } 623 if (status & S_CARD_FAILURE) { 624 ifp->if_timer = 0; 625#ifdef EP_LOCAL_STATS 626 printf("\nep%d:\n\tStatus: %x\n", sc->unit, status); | 620 CSR_READ_2(sc, EP_W1_FREE_TX); 621 epstart_locked(ifp); 622 } 623 if (status & S_CARD_FAILURE) { 624 ifp->if_timer = 0; 625#ifdef EP_LOCAL_STATS 626 printf("\nep%d:\n\tStatus: %x\n", sc->unit, status); |
627 GO_WINDOW(4); | 627 GO_WINDOW(sc, 4); |
628 printf("\tFIFO Diagnostic: %x\n", 629 CSR_READ_2(sc, EP_W4_FIFO_DIAG)); 630 printf("\tStat: %x\n", sc->stat); 631 printf("\tIpackets=%d, Opackets=%d\n", 632 ifp->if_ipackets, ifp->if_opackets); 633 printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n", 634 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf, 635 sc->rx_overrunl, sc->tx_underrun); --- 48 unchanged lines hidden (view full) --- 684 if (ifp->if_snd.ifq_head) 685 CSR_WRITE_2(sc, EP_COMMAND, 686 SET_TX_AVAIL_THRESH | 8); 687 } 688 /* pops up the next status */ 689 CSR_WRITE_1(sc, EP_W1_TX_STATUS, 0x0); 690 } /* while */ 691 ifp->if_flags &= ~IFF_OACTIVE; | 628 printf("\tFIFO Diagnostic: %x\n", 629 CSR_READ_2(sc, EP_W4_FIFO_DIAG)); 630 printf("\tStat: %x\n", sc->stat); 631 printf("\tIpackets=%d, Opackets=%d\n", 632 ifp->if_ipackets, ifp->if_opackets); 633 printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n", 634 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf, 635 sc->rx_overrunl, sc->tx_underrun); --- 48 unchanged lines hidden (view full) --- 684 if (ifp->if_snd.ifq_head) 685 CSR_WRITE_2(sc, EP_COMMAND, 686 SET_TX_AVAIL_THRESH | 8); 687 } 688 /* pops up the next status */ 689 CSR_WRITE_1(sc, EP_W1_TX_STATUS, 0x0); 690 } /* while */ 691 ifp->if_flags &= ~IFF_OACTIVE; |
692 GO_WINDOW(1); | 692 GO_WINDOW(sc, 1); |
693 CSR_READ_2(sc, EP_W1_FREE_TX); 694 epstart_locked(ifp); 695 } /* end TX_COMPLETE */ 696 } 697 698 CSR_WRITE_2(sc, EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */ 699 700 if ((status = CSR_READ_2(sc, EP_STATUS)) & S_5_INTS) --- 154 unchanged lines hidden (view full) --- 855} 856 857static int 858ep_ifmedia_upd(struct ifnet *ifp) 859{ 860 struct ep_softc *sc = ifp->if_softc; 861 int i = 0, j; 862 | 693 CSR_READ_2(sc, EP_W1_FREE_TX); 694 epstart_locked(ifp); 695 } /* end TX_COMPLETE */ 696 } 697 698 CSR_WRITE_2(sc, EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */ 699 700 if ((status = CSR_READ_2(sc, EP_STATUS)) & S_5_INTS) --- 154 unchanged lines hidden (view full) --- 855} 856 857static int 858ep_ifmedia_upd(struct ifnet *ifp) 859{ 860 struct ep_softc *sc = ifp->if_softc; 861 int i = 0, j; 862 |
863 GO_WINDOW(0); | 863 GO_WINDOW(sc, 0); |
864 CSR_WRITE_2(sc, EP_COMMAND, STOP_TRANSCEIVER); | 864 CSR_WRITE_2(sc, EP_COMMAND, STOP_TRANSCEIVER); |
865 GO_WINDOW(4); | 865 GO_WINDOW(sc, 4); |
866 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, DISABLE_UTP); | 866 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, DISABLE_UTP); |
867 GO_WINDOW(0); | 867 GO_WINDOW(sc, 0); |
868 869 switch (IFM_SUBTYPE(sc->ifmedia.ifm_media)) { 870 case IFM_10_T: 871 if (sc->ep_connectors & UTP) { 872 i = ACF_CONNECTOR_UTP; | 868 869 switch (IFM_SUBTYPE(sc->ifmedia.ifm_media)) { 870 case IFM_10_T: 871 if (sc->ep_connectors & UTP) { 872 i = ACF_CONNECTOR_UTP; |
873 GO_WINDOW(4); | 873 GO_WINDOW(sc, 4); |
874 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, ENABLE_UTP); 875 } 876 break; 877 case IFM_10_2: 878 if (sc->ep_connectors & BNC) { 879 i = ACF_CONNECTOR_BNC; 880 CSR_WRITE_2(sc, EP_COMMAND, START_TRANSCEIVER); 881 DELAY(DELAY_MULTIPLE * 1000); --- 4 unchanged lines hidden (view full) --- 886 i = ACF_CONNECTOR_AUI; 887 break; 888 default: 889 i = sc->ep_connector; 890 device_printf(sc->dev, 891 "strange connector type in EEPROM: assuming AUI\n"); 892 } 893 | 874 CSR_WRITE_2(sc, EP_W4_MEDIA_TYPE, ENABLE_UTP); 875 } 876 break; 877 case IFM_10_2: 878 if (sc->ep_connectors & BNC) { 879 i = ACF_CONNECTOR_BNC; 880 CSR_WRITE_2(sc, EP_COMMAND, START_TRANSCEIVER); 881 DELAY(DELAY_MULTIPLE * 1000); --- 4 unchanged lines hidden (view full) --- 886 i = ACF_CONNECTOR_AUI; 887 break; 888 default: 889 i = sc->ep_connector; 890 device_printf(sc->dev, 891 "strange connector type in EEPROM: assuming AUI\n"); 892 } 893 |
894 GO_WINDOW(0); | 894 GO_WINDOW(sc, 0); |
895 j = CSR_READ_2(sc, EP_W0_ADDRESS_CFG) & 0x3fff; 896 CSR_WRITE_2(sc, EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS)); 897 898 return (0); 899} 900 901static void 902ep_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) --- 91 unchanged lines hidden --- | 895 j = CSR_READ_2(sc, EP_W0_ADDRESS_CFG) & 0x3fff; 896 CSR_WRITE_2(sc, EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS)); 897 898 return (0); 899} 900 901static void 902ep_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) --- 91 unchanged lines hidden --- |