| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_ti.c,v 1.117 2020/03/05 15:33:13 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_ti.c,v 1.118 2020/03/05 15:36:39 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997, 1998, 1999 | | 4 | * Copyright (c) 1997, 1998, 1999 |
5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | | 5 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -71,27 +71,27 @@ | | | @@ -71,27 +71,27 @@ |
71 | * compiling it requires a GNU toolchain targeted for mips-sgi-irix5.3. | | 71 | * compiling it requires a GNU toolchain targeted for mips-sgi-irix5.3. |
72 | * | | 72 | * |
73 | * The following people deserve special thanks: | | 73 | * The following people deserve special thanks: |
74 | * - Terry Murphy of 3Com, for providing a 3c985 Tigon 1 board | | 74 | * - Terry Murphy of 3Com, for providing a 3c985 Tigon 1 board |
75 | * for testing | | 75 | * for testing |
76 | * - Raymond Lee of Netgear, for providing a pair of Netgear | | 76 | * - Raymond Lee of Netgear, for providing a pair of Netgear |
77 | * GA620 Tigon 2 boards for testing | | 77 | * GA620 Tigon 2 boards for testing |
78 | * - Ulf Zimmermann, for bringing the GA620 to my attention and | | 78 | * - Ulf Zimmermann, for bringing the GA620 to my attention and |
79 | * convincing me to write this driver. | | 79 | * convincing me to write this driver. |
80 | * - Andrew Gallatin for providing FreeBSD/Alpha support. | | 80 | * - Andrew Gallatin for providing FreeBSD/Alpha support. |
81 | */ | | 81 | */ |
82 | | | 82 | |
83 | #include <sys/cdefs.h> | | 83 | #include <sys/cdefs.h> |
84 | __KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.117 2020/03/05 15:33:13 msaitoh Exp $"); | | 84 | __KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.118 2020/03/05 15:36:39 msaitoh Exp $"); |
85 | | | 85 | |
86 | #include "opt_inet.h" | | 86 | #include "opt_inet.h" |
87 | | | 87 | |
88 | #include <sys/param.h> | | 88 | #include <sys/param.h> |
89 | #include <sys/systm.h> | | 89 | #include <sys/systm.h> |
90 | #include <sys/sockio.h> | | 90 | #include <sys/sockio.h> |
91 | #include <sys/mbuf.h> | | 91 | #include <sys/mbuf.h> |
92 | #include <sys/malloc.h> | | 92 | #include <sys/malloc.h> |
93 | #include <sys/kernel.h> | | 93 | #include <sys/kernel.h> |
94 | #include <sys/socket.h> | | 94 | #include <sys/socket.h> |
95 | #include <sys/queue.h> | | 95 | #include <sys/queue.h> |
96 | #include <sys/device.h> | | 96 | #include <sys/device.h> |
97 | #include <sys/reboot.h> | | 97 | #include <sys/reboot.h> |
| @@ -216,27 +216,27 @@ CFATTACH_DECL_NEW(ti, sizeof(struct ti_s | | | @@ -216,27 +216,27 @@ CFATTACH_DECL_NEW(ti, sizeof(struct ti_s |
216 | * Send an instruction or address to the EEPROM, check for ACK. | | 216 | * Send an instruction or address to the EEPROM, check for ACK. |
217 | */ | | 217 | */ |
218 | static uint32_t | | 218 | static uint32_t |
219 | ti_eeprom_putbyte(struct ti_softc *sc, int byte) | | 219 | ti_eeprom_putbyte(struct ti_softc *sc, int byte) |
220 | { | | 220 | { |
221 | int i, ack = 0; | | 221 | int i, ack = 0; |
222 | | | 222 | |
223 | /* | | 223 | /* |
224 | * Make sure we're in TX mode. | | 224 | * Make sure we're in TX mode. |
225 | */ | | 225 | */ |
226 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); | | 226 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); |
227 | | | 227 | |
228 | /* | | 228 | /* |
229 | * Feed in each bit and stobe the clock. | | 229 | * Feed in each bit and strobe the clock. |
230 | */ | | 230 | */ |
231 | for (i = 0x80; i; i >>= 1) { | | 231 | for (i = 0x80; i; i >>= 1) { |
232 | if (byte & i) { | | 232 | if (byte & i) { |
233 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); | | 233 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); |
234 | } else { | | 234 | } else { |
235 | TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); | | 235 | TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); |
236 | } | | 236 | } |
237 | DELAY(1); | | 237 | DELAY(1); |
238 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); | | 238 | TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); |
239 | DELAY(1); | | 239 | DELAY(1); |
240 | TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); | | 240 | TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); |
241 | } | | 241 | } |
242 | | | 242 | |
| @@ -2198,27 +2198,27 @@ ti_stats_update(struct ti_softc *sc) | | | @@ -2198,27 +2198,27 @@ ti_stats_update(struct ti_softc *sc) |
2198 | | | 2198 | |
2199 | uint64_t collisions = | | 2199 | uint64_t collisions = |
2200 | (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames + | | 2200 | (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames + |
2201 | sc->ti_rdata->ti_info.ti_stats.dot3StatsMultipleCollisionFrames + | | 2201 | sc->ti_rdata->ti_info.ti_stats.dot3StatsMultipleCollisionFrames + |
2202 | sc->ti_rdata->ti_info.ti_stats.dot3StatsExcessiveCollisions + | | 2202 | sc->ti_rdata->ti_info.ti_stats.dot3StatsExcessiveCollisions + |
2203 | sc->ti_rdata->ti_info.ti_stats.dot3StatsLateCollisions); | | 2203 | sc->ti_rdata->ti_info.ti_stats.dot3StatsLateCollisions); |
2204 | if_statadd(ifp, if_collisions, collisions - sc->ti_if_collisions); | | 2204 | if_statadd(ifp, if_collisions, collisions - sc->ti_if_collisions); |
2205 | sc->ti_if_collisions = collisions; | | 2205 | sc->ti_if_collisions = collisions; |
2206 | | | 2206 | |
2207 | TI_CDSTATSSYNC(sc, BUS_DMASYNC_PREREAD); | | 2207 | TI_CDSTATSSYNC(sc, BUS_DMASYNC_PREREAD); |
2208 | } | | 2208 | } |
2209 | | | 2209 | |
2210 | /* | | 2210 | /* |
2211 | * Encapsulate an mbuf chain in the tx ring by coupling the mbuf data | | 2211 | * Encapsulate an mbuf chain in the tx ring by coupling the mbuf data |
2212 | * pointers to descriptors. | | 2212 | * pointers to descriptors. |
2213 | */ | | 2213 | */ |
2214 | static int | | 2214 | static int |
2215 | ti_encap_tigon1(struct ti_softc *sc, struct mbuf *m_head, uint32_t *txidx) | | 2215 | ti_encap_tigon1(struct ti_softc *sc, struct mbuf *m_head, uint32_t *txidx) |
2216 | { | | 2216 | { |
2217 | struct ti_tx_desc *f = NULL; | | 2217 | struct ti_tx_desc *f = NULL; |
2218 | uint32_t frag, cur, cnt = 0; | | 2218 | uint32_t frag, cur, cnt = 0; |
2219 | struct txdmamap_pool_entry *dma; | | 2219 | struct txdmamap_pool_entry *dma; |
2220 | bus_dmamap_t dmamap; | | 2220 | bus_dmamap_t dmamap; |
2221 | int error, i; | | 2221 | int error, i; |
2222 | uint16_t csum_flags = 0; | | 2222 | uint16_t csum_flags = 0; |
2223 | | | 2223 | |
2224 | dma = SIMPLEQ_FIRST(&sc->txdma_list); | | 2224 | dma = SIMPLEQ_FIRST(&sc->txdma_list); |
| @@ -2677,27 +2677,27 @@ ti_ifmedia_sts(struct ifnet *ifp, struct | | | @@ -2677,27 +2677,27 @@ ti_ifmedia_sts(struct ifnet *ifp, struct |
2677 | if (media & TI_LNK_FULL_DUPLEX) | | 2677 | if (media & TI_LNK_FULL_DUPLEX) |
2678 | ifmr->ifm_active |= IFM_FDX; | | 2678 | ifmr->ifm_active |= IFM_FDX; |
2679 | if (media & TI_LNK_HALF_DUPLEX) | | 2679 | if (media & TI_LNK_HALF_DUPLEX) |
2680 | ifmr->ifm_active |= IFM_HDX; | | 2680 | ifmr->ifm_active |= IFM_HDX; |
2681 | } | | 2681 | } |
2682 | | | 2682 | |
2683 | sc->ethercom.ec_if.if_baudrate = | | 2683 | sc->ethercom.ec_if.if_baudrate = |
2684 | ifmedia_baudrate(sc->ifmedia.ifm_media); | | 2684 | ifmedia_baudrate(sc->ifmedia.ifm_media); |
2685 | } | | 2685 | } |
2686 | | | 2686 | |
2687 | static int | | 2687 | static int |
2688 | ti_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) | | 2688 | ti_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) |
2689 | { | | 2689 | { |
2690 | struct ifaddr *ifa = (struct ifaddr *) data; | | 2690 | struct ifaddr *ifa = (struct ifaddr *)data; |
2691 | struct ti_softc *sc = ifp->if_softc; | | 2691 | struct ti_softc *sc = ifp->if_softc; |
2692 | | | 2692 | |
2693 | if ((ifp->if_flags & IFF_UP) == 0) { | | 2693 | if ((ifp->if_flags & IFF_UP) == 0) { |
2694 | ifp->if_flags |= IFF_UP; | | 2694 | ifp->if_flags |= IFF_UP; |
2695 | ti_init(sc); | | 2695 | ti_init(sc); |
2696 | } | | 2696 | } |
2697 | | | 2697 | |
2698 | switch (cmd) { | | 2698 | switch (cmd) { |
2699 | case SIOCINITIFADDR: | | 2699 | case SIOCINITIFADDR: |
2700 | | | 2700 | |
2701 | switch (ifa->ifa_addr->sa_family) { | | 2701 | switch (ifa->ifa_addr->sa_family) { |
2702 | #ifdef INET | | 2702 | #ifdef INET |
2703 | case AF_INET: | | 2703 | case AF_INET: |
| @@ -2710,27 +2710,27 @@ ti_ether_ioctl(struct ifnet *ifp, u_long | | | @@ -2710,27 +2710,27 @@ ti_ether_ioctl(struct ifnet *ifp, u_long |
2710 | break; | | 2710 | break; |
2711 | | | 2711 | |
2712 | default: | | 2712 | default: |
2713 | return (EINVAL); | | 2713 | return (EINVAL); |
2714 | } | | 2714 | } |
2715 | | | 2715 | |
2716 | return (0); | | 2716 | return (0); |
2717 | } | | 2717 | } |
2718 | | | 2718 | |
2719 | static int | | 2719 | static int |
2720 | ti_ioctl(struct ifnet *ifp, u_long command, void *data) | | 2720 | ti_ioctl(struct ifnet *ifp, u_long command, void *data) |
2721 | { | | 2721 | { |
2722 | struct ti_softc *sc = ifp->if_softc; | | 2722 | struct ti_softc *sc = ifp->if_softc; |
2723 | struct ifreq *ifr = (struct ifreq *) data; | | 2723 | struct ifreq *ifr = (struct ifreq *)data; |
2724 | int s, error = 0; | | 2724 | int s, error = 0; |
2725 | struct ti_cmd_desc cmd; | | 2725 | struct ti_cmd_desc cmd; |
2726 | | | 2726 | |
2727 | s = splnet(); | | 2727 | s = splnet(); |
2728 | | | 2728 | |
2729 | switch (command) { | | 2729 | switch (command) { |
2730 | case SIOCINITIFADDR: | | 2730 | case SIOCINITIFADDR: |
2731 | error = ti_ether_ioctl(ifp, command, data); | | 2731 | error = ti_ether_ioctl(ifp, command, data); |
2732 | break; | | 2732 | break; |
2733 | case SIOCSIFMTU: | | 2733 | case SIOCSIFMTU: |
2734 | if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU_JUMBO) | | 2734 | if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU_JUMBO) |
2735 | error = EINVAL; | | 2735 | error = EINVAL; |
2736 | else if ((error = ifioctl_common(ifp, command, data)) | | 2736 | else if ((error = ifioctl_common(ifp, command, data)) |