| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_ti.c,v 1.118 2020/03/05 15:36:39 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_ti.c,v 1.119 2020/03/05 15:40:06 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.118 2020/03/05 15:36:39 msaitoh Exp $"); | | 84 | __KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.119 2020/03/05 15:40:06 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> |
| @@ -896,27 +896,27 @@ ti_newbuf_jumbo(struct ti_softc *sc, int | | | @@ -896,27 +896,27 @@ ti_newbuf_jumbo(struct ti_softc *sc, int |
896 | * that's 1MB or memory, which is a lot. For now, we fill only the first | | 896 | * that's 1MB or memory, which is a lot. For now, we fill only the first |
897 | * 256 ring entries and hope that our CPU is fast enough to keep up with | | 897 | * 256 ring entries and hope that our CPU is fast enough to keep up with |
898 | * the NIC. | | 898 | * the NIC. |
899 | */ | | 899 | */ |
900 | static int | | 900 | static int |
901 | ti_init_rx_ring_std(struct ti_softc *sc) | | 901 | ti_init_rx_ring_std(struct ti_softc *sc) |
902 | { | | 902 | { |
903 | int i; | | 903 | int i; |
904 | struct ti_cmd_desc cmd; | | 904 | struct ti_cmd_desc cmd; |
905 | | | 905 | |
906 | for (i = 0; i < TI_SSLOTS; i++) { | | 906 | for (i = 0; i < TI_SSLOTS; i++) { |
907 | if (ti_newbuf_std(sc, i, NULL, 0) == ENOBUFS) | | 907 | if (ti_newbuf_std(sc, i, NULL, 0) == ENOBUFS) |
908 | return (ENOBUFS); | | 908 | return (ENOBUFS); |
909 | }; | | 909 | } |
910 | | | 910 | |
911 | TI_UPDATE_STDPROD(sc, i - 1); | | 911 | TI_UPDATE_STDPROD(sc, i - 1); |
912 | sc->ti_std = i - 1; | | 912 | sc->ti_std = i - 1; |
913 | | | 913 | |
914 | return (0); | | 914 | return (0); |
915 | } | | 915 | } |
916 | | | 916 | |
917 | static void | | 917 | static void |
918 | ti_free_rx_ring_std(struct ti_softc *sc) | | 918 | ti_free_rx_ring_std(struct ti_softc *sc) |
919 | { | | 919 | { |
920 | int i; | | 920 | int i; |
921 | | | 921 | |
922 | for (i = 0; i < TI_STD_RX_RING_CNT; i++) { | | 922 | for (i = 0; i < TI_STD_RX_RING_CNT; i++) { |
| @@ -934,27 +934,27 @@ ti_free_rx_ring_std(struct ti_softc *sc) | | | @@ -934,27 +934,27 @@ ti_free_rx_ring_std(struct ti_softc *sc) |
934 | | | 934 | |
935 | return; | | 935 | return; |
936 | } | | 936 | } |
937 | | | 937 | |
938 | static int | | 938 | static int |
939 | ti_init_rx_ring_jumbo(struct ti_softc *sc) | | 939 | ti_init_rx_ring_jumbo(struct ti_softc *sc) |
940 | { | | 940 | { |
941 | int i; | | 941 | int i; |
942 | struct ti_cmd_desc cmd; | | 942 | struct ti_cmd_desc cmd; |
943 | | | 943 | |
944 | for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) { | | 944 | for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) { |
945 | if (ti_newbuf_jumbo(sc, i, NULL) == ENOBUFS) | | 945 | if (ti_newbuf_jumbo(sc, i, NULL) == ENOBUFS) |
946 | return (ENOBUFS); | | 946 | return (ENOBUFS); |
947 | }; | | 947 | } |
948 | | | 948 | |
949 | TI_UPDATE_JUMBOPROD(sc, i - 1); | | 949 | TI_UPDATE_JUMBOPROD(sc, i - 1); |
950 | sc->ti_jumbo = i - 1; | | 950 | sc->ti_jumbo = i - 1; |
951 | | | 951 | |
952 | return (0); | | 952 | return (0); |
953 | } | | 953 | } |
954 | | | 954 | |
955 | static void | | 955 | static void |
956 | ti_free_rx_ring_jumbo(struct ti_softc *sc) | | 956 | ti_free_rx_ring_jumbo(struct ti_softc *sc) |
957 | { | | 957 | { |
958 | int i; | | 958 | int i; |
959 | | | 959 | |
960 | for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) { | | 960 | for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) { |
| @@ -967,27 +967,27 @@ ti_free_rx_ring_jumbo(struct ti_softc *s | | | @@ -967,27 +967,27 @@ ti_free_rx_ring_jumbo(struct ti_softc *s |
967 | } | | 967 | } |
968 | | | 968 | |
969 | return; | | 969 | return; |
970 | } | | 970 | } |
971 | | | 971 | |
972 | static int | | 972 | static int |
973 | ti_init_rx_ring_mini(struct ti_softc *sc) | | 973 | ti_init_rx_ring_mini(struct ti_softc *sc) |
974 | { | | 974 | { |
975 | int i; | | 975 | int i; |
976 | | | 976 | |
977 | for (i = 0; i < TI_MSLOTS; i++) { | | 977 | for (i = 0; i < TI_MSLOTS; i++) { |
978 | if (ti_newbuf_mini(sc, i, NULL, 0) == ENOBUFS) | | 978 | if (ti_newbuf_mini(sc, i, NULL, 0) == ENOBUFS) |
979 | return (ENOBUFS); | | 979 | return (ENOBUFS); |
980 | }; | | 980 | } |
981 | | | 981 | |
982 | TI_UPDATE_MINIPROD(sc, i - 1); | | 982 | TI_UPDATE_MINIPROD(sc, i - 1); |
983 | sc->ti_mini = i - 1; | | 983 | sc->ti_mini = i - 1; |
984 | | | 984 | |
985 | return (0); | | 985 | return (0); |
986 | } | | 986 | } |
987 | | | 987 | |
988 | static void | | 988 | static void |
989 | ti_free_rx_ring_mini(struct ti_softc *sc) | | 989 | ti_free_rx_ring_mini(struct ti_softc *sc) |
990 | { | | 990 | { |
991 | int i; | | 991 | int i; |
992 | | | 992 | |
993 | for (i = 0; i < TI_MINI_RX_RING_CNT; i++) { | | 993 | for (i = 0; i < TI_MINI_RX_RING_CNT; i++) { |
| @@ -2186,27 +2186,27 @@ ti_intr(void *xsc) | | | @@ -2186,27 +2186,27 @@ ti_intr(void *xsc) |
2186 | if ((ifp->if_flags & IFF_RUNNING) != 0) | | 2186 | if ((ifp->if_flags & IFF_RUNNING) != 0) |
2187 | if_schedule_deferred_start(ifp); | | 2187 | if_schedule_deferred_start(ifp); |
2188 | | | 2188 | |
2189 | return (1); | | 2189 | return (1); |
2190 | } | | 2190 | } |
2191 | | | 2191 | |
2192 | static void | | 2192 | static void |
2193 | ti_stats_update(struct ti_softc *sc) | | 2193 | ti_stats_update(struct ti_softc *sc) |
2194 | { | | 2194 | { |
2195 | struct ifnet *ifp = &sc->ethercom.ec_if; | | 2195 | struct ifnet *ifp = &sc->ethercom.ec_if; |
2196 | | | 2196 | |
2197 | TI_CDSTATSSYNC(sc, BUS_DMASYNC_POSTREAD); | | 2197 | TI_CDSTATSSYNC(sc, BUS_DMASYNC_POSTREAD); |
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. |