Deleted Added
full compact
if_xl.c (161239) if_xl.c (162315)
1/*-
2 * Copyright (c) 1997, 1998, 1999
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

--- 17 unchanged lines hidden (view full) ---

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
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998, 1999
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

--- 17 unchanged lines hidden (view full) ---

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
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 161239 2006-08-12 02:05:13Z yongari $");
34__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 162315 2006-09-15 10:40:54Z glebius $");
35
36/*
37 * 3Com 3c90x Etherlink XL PCI NIC driver
38 *
39 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
40 * bus-master chips (3c90x cards and embedded controllers) including
41 * the following:
42 *

--- 343 unchanged lines hidden (view full) ---

386 register int i;
387
388 for (i = 0; i < XL_TIMEOUT; i++) {
389 if ((CSR_READ_2(sc, XL_STATUS) & XL_STAT_CMDBUSY) == 0)
390 break;
391 }
392
393 if (i == XL_TIMEOUT)
35
36/*
37 * 3Com 3c90x Etherlink XL PCI NIC driver
38 *
39 * Supports the 3Com "boomerang", "cyclone" and "hurricane" PCI
40 * bus-master chips (3c90x cards and embedded controllers) including
41 * the following:
42 *

--- 343 unchanged lines hidden (view full) ---

386 register int i;
387
388 for (i = 0; i < XL_TIMEOUT; i++) {
389 if ((CSR_READ_2(sc, XL_STATUS) & XL_STAT_CMDBUSY) == 0)
390 break;
391 }
392
393 if (i == XL_TIMEOUT)
394 if_printf(sc->xl_ifp, "command never completed!\n");
394 device_printf(sc->xl_dev, "command never completed!\n");
395}
396
397/*
398 * MII access routines are provided for adapters with external
399 * PHYs (3c905-TX, 3c905-T4, 3c905B-T4) and those with built-in
400 * autoneg logic that's faked up to look like a PHY (3c905B-TX).
401 * Note: if you don't perform the MDIO operations just right,
402 * it's possible to end up with code that works correctly with

--- 248 unchanged lines hidden (view full) ---

651
652 if (sc->xl_media & (XL_MEDIAOPT_AUI | XL_MEDIAOPT_10FL)) {
653 /*
654 * Check for a 10baseFL board in disguise.
655 */
656 if (sc->xl_type == XL_TYPE_905B &&
657 sc->xl_media == XL_MEDIAOPT_10FL) {
658 if (bootverbose)
395}
396
397/*
398 * MII access routines are provided for adapters with external
399 * PHYs (3c905-TX, 3c905-T4, 3c905B-T4) and those with built-in
400 * autoneg logic that's faked up to look like a PHY (3c905B-TX).
401 * Note: if you don't perform the MDIO operations just right,
402 * it's possible to end up with code that works correctly with

--- 248 unchanged lines hidden (view full) ---

651
652 if (sc->xl_media & (XL_MEDIAOPT_AUI | XL_MEDIAOPT_10FL)) {
653 /*
654 * Check for a 10baseFL board in disguise.
655 */
656 if (sc->xl_type == XL_TYPE_905B &&
657 sc->xl_media == XL_MEDIAOPT_10FL) {
658 if (bootverbose)
659 if_printf(sc->xl_ifp,
660 "found 10baseFL\n");
659 device_printf(sc->xl_dev, "found 10baseFL\n");
661 ifmedia_add(ifm, IFM_ETHER | IFM_10_FL, 0, NULL);
662 ifmedia_add(ifm, IFM_ETHER | IFM_10_FL|IFM_HDX, 0,
663 NULL);
664 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX)
665 ifmedia_add(ifm,
666 IFM_ETHER | IFM_10_FL | IFM_FDX, 0, NULL);
667 } else {
668 if (bootverbose)
660 ifmedia_add(ifm, IFM_ETHER | IFM_10_FL, 0, NULL);
661 ifmedia_add(ifm, IFM_ETHER | IFM_10_FL|IFM_HDX, 0,
662 NULL);
663 if (sc->xl_caps & XL_CAPS_FULL_DUPLEX)
664 ifmedia_add(ifm,
665 IFM_ETHER | IFM_10_FL | IFM_FDX, 0, NULL);
666 } else {
667 if (bootverbose)
669 if_printf(sc->xl_ifp, "found AUI\n");
668 device_printf(sc->xl_dev, "found AUI\n");
670 ifmedia_add(ifm, IFM_ETHER | IFM_10_5, 0, NULL);
671 }
672 }
673
674 if (sc->xl_media & XL_MEDIAOPT_BNC) {
675 if (bootverbose)
669 ifmedia_add(ifm, IFM_ETHER | IFM_10_5, 0, NULL);
670 }
671 }
672
673 if (sc->xl_media & XL_MEDIAOPT_BNC) {
674 if (bootverbose)
676 if_printf(sc->xl_ifp, "found BNC\n");
675 device_printf(sc->xl_dev, "found BNC\n");
677 ifmedia_add(ifm, IFM_ETHER | IFM_10_2, 0, NULL);
678 }
679}
680
681/*
682 * The EEPROM is slow: give it time to come ready after issuing
683 * it a command.
684 */

--- 5 unchanged lines hidden (view full) ---

690 for (i = 0; i < 100; i++) {
691 if (CSR_READ_2(sc, XL_W0_EE_CMD) & XL_EE_BUSY)
692 DELAY(162);
693 else
694 break;
695 }
696
697 if (i == 100) {
676 ifmedia_add(ifm, IFM_ETHER | IFM_10_2, 0, NULL);
677 }
678}
679
680/*
681 * The EEPROM is slow: give it time to come ready after issuing
682 * it a command.
683 */

--- 5 unchanged lines hidden (view full) ---

689 for (i = 0; i < 100; i++) {
690 if (CSR_READ_2(sc, XL_W0_EE_CMD) & XL_EE_BUSY)
691 DELAY(162);
692 else
693 break;
694 }
695
696 if (i == 100) {
698 if_printf(sc->xl_ifp, "eeprom failed to come ready\n");
697 device_printf(sc->xl_dev, "eeprom failed to come ready\n");
699 return (1);
700 }
701
702 return (0);
703}
704
705/*
706 * Read a sequence of words from the EEPROM. Note that ethernet address

--- 272 unchanged lines hidden (view full) ---

979
980 CSR_WRITE_4(sc, XL_W3_INTERNAL_CFG, icfg);
981 XL_SEL_WIN(4);
982 CSR_WRITE_2(sc, XL_W4_MEDIA_STATUS, mediastat);
983
984 DELAY(800);
985 XL_SEL_WIN(7);
986
698 return (1);
699 }
700
701 return (0);
702}
703
704/*
705 * Read a sequence of words from the EEPROM. Note that ethernet address

--- 272 unchanged lines hidden (view full) ---

978
979 CSR_WRITE_4(sc, XL_W3_INTERNAL_CFG, icfg);
980 XL_SEL_WIN(4);
981 CSR_WRITE_2(sc, XL_W4_MEDIA_STATUS, mediastat);
982
983 DELAY(800);
984 XL_SEL_WIN(7);
985
987 if_printf(sc->xl_ifp, "selecting %s, %s duplex\n", pmsg, dmsg);
986 device_printf(sc->xl_dev, "selecting %s, %s duplex\n", pmsg, dmsg);
988}
989
990static void
991xl_reset(struct xl_softc *sc)
992{
993 register int i;
994
995 XL_LOCK_ASSERT(sc);

--- 15 unchanged lines hidden (view full) ---

1011
1012 for (i = 0; i < XL_TIMEOUT; i++) {
1013 DELAY(10);
1014 if (!(CSR_READ_2(sc, XL_STATUS) & XL_STAT_CMDBUSY))
1015 break;
1016 }
1017
1018 if (i == XL_TIMEOUT)
987}
988
989static void
990xl_reset(struct xl_softc *sc)
991{
992 register int i;
993
994 XL_LOCK_ASSERT(sc);

--- 15 unchanged lines hidden (view full) ---

1010
1011 for (i = 0; i < XL_TIMEOUT; i++) {
1012 DELAY(10);
1013 if (!(CSR_READ_2(sc, XL_STATUS) & XL_STAT_CMDBUSY))
1014 break;
1015 }
1016
1017 if (i == XL_TIMEOUT)
1019 if_printf(sc->xl_ifp, "reset didn't complete\n");
1018 device_printf(sc->xl_dev, "reset didn't complete\n");
1020
1021 /* Reset TX and RX. */
1022 /* Note: the RX reset takes an absurd amount of time
1023 * on newer versions of the Tornado chips such as those
1024 * on the 3c905CX and newer 3c908C cards. We wait an
1025 * extra amount of time so that xl_wait() doesn't complain
1026 * and annoy the users.
1027 */

--- 66 unchanged lines hidden (view full) ---

1094 if (sc->xl_media & (XL_MEDIAOPT_MASK & ~XL_MEDIAOPT_VCO)) {
1095 /*
1096 * Check the XCVR value. If it's not in the normal range
1097 * of values, we need to fake it up here.
1098 */
1099 if (sc->xl_xcvr <= XL_XCVR_AUTO)
1100 return;
1101 else {
1019
1020 /* Reset TX and RX. */
1021 /* Note: the RX reset takes an absurd amount of time
1022 * on newer versions of the Tornado chips such as those
1023 * on the 3c905CX and newer 3c908C cards. We wait an
1024 * extra amount of time so that xl_wait() doesn't complain
1025 * and annoy the users.
1026 */

--- 66 unchanged lines hidden (view full) ---

1093 if (sc->xl_media & (XL_MEDIAOPT_MASK & ~XL_MEDIAOPT_VCO)) {
1094 /*
1095 * Check the XCVR value. If it's not in the normal range
1096 * of values, we need to fake it up here.
1097 */
1098 if (sc->xl_xcvr <= XL_XCVR_AUTO)
1099 return;
1100 else {
1102 if_printf(sc->xl_ifp,
1101 device_printf(sc->xl_dev,
1103 "bogus xcvr value in EEPROM (%x)\n", sc->xl_xcvr);
1102 "bogus xcvr value in EEPROM (%x)\n", sc->xl_xcvr);
1104 if_printf(sc->xl_ifp,
1103 device_printf(sc->xl_dev,
1105 "choosing new default based on card type\n");
1106 }
1107 } else {
1108 if (sc->xl_type == XL_TYPE_905B &&
1109 sc->xl_media & XL_MEDIAOPT_10FL)
1110 return;
1104 "choosing new default based on card type\n");
1105 }
1106 } else {
1107 if (sc->xl_type == XL_TYPE_905B &&
1108 sc->xl_media & XL_MEDIAOPT_10FL)
1109 return;
1111 if_printf(sc->xl_ifp,
1110 device_printf(sc->xl_dev,
1112"WARNING: no media options bits set in the media options register!!\n");
1111"WARNING: no media options bits set in the media options register!!\n");
1113 if_printf(sc->xl_ifp,
1112 device_printf(sc->xl_dev,
1114"this could be a manufacturing defect in your adapter or system\n");
1113"this could be a manufacturing defect in your adapter or system\n");
1115 if_printf(sc->xl_ifp,
1114 device_printf(sc->xl_dev,
1116"attempting to guess media type; you should probably consult your vendor\n");
1117 }
1118
1119 xl_choose_xcvr(sc, 1);
1120}
1121
1122static void
1123xl_choose_xcvr(struct xl_softc *sc, int verbose)

--- 8 unchanged lines hidden (view full) ---

1132 xl_read_eeprom(sc, (caddr_t)&devid, XL_EE_PRODID, 1, 0);
1133
1134 switch (devid) {
1135 case TC_DEVICEID_BOOMERANG_10BT: /* 3c900-TPO */
1136 case TC_DEVICEID_KRAKATOA_10BT: /* 3c900B-TPO */
1137 sc->xl_media = XL_MEDIAOPT_BT;
1138 sc->xl_xcvr = XL_XCVR_10BT;
1139 if (verbose)
1115"attempting to guess media type; you should probably consult your vendor\n");
1116 }
1117
1118 xl_choose_xcvr(sc, 1);
1119}
1120
1121static void
1122xl_choose_xcvr(struct xl_softc *sc, int verbose)

--- 8 unchanged lines hidden (view full) ---

1131 xl_read_eeprom(sc, (caddr_t)&devid, XL_EE_PRODID, 1, 0);
1132
1133 switch (devid) {
1134 case TC_DEVICEID_BOOMERANG_10BT: /* 3c900-TPO */
1135 case TC_DEVICEID_KRAKATOA_10BT: /* 3c900B-TPO */
1136 sc->xl_media = XL_MEDIAOPT_BT;
1137 sc->xl_xcvr = XL_XCVR_10BT;
1138 if (verbose)
1140 if_printf(sc->xl_ifp,
1139 device_printf(sc->xl_dev,
1141 "guessing 10BaseT transceiver\n");
1142 break;
1143 case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */
1144 case TC_DEVICEID_KRAKATOA_10BT_COMBO: /* 3c900B-COMBO */
1145 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1146 sc->xl_xcvr = XL_XCVR_10BT;
1147 if (verbose)
1140 "guessing 10BaseT transceiver\n");
1141 break;
1142 case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */
1143 case TC_DEVICEID_KRAKATOA_10BT_COMBO: /* 3c900B-COMBO */
1144 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1145 sc->xl_xcvr = XL_XCVR_10BT;
1146 if (verbose)
1148 if_printf(sc->xl_ifp,
1147 device_printf(sc->xl_dev,
1149 "guessing COMBO (AUI/BNC/TP)\n");
1150 break;
1151 case TC_DEVICEID_KRAKATOA_10BT_TPC: /* 3c900B-TPC */
1152 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC;
1153 sc->xl_xcvr = XL_XCVR_10BT;
1154 if (verbose)
1148 "guessing COMBO (AUI/BNC/TP)\n");
1149 break;
1150 case TC_DEVICEID_KRAKATOA_10BT_TPC: /* 3c900B-TPC */
1151 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC;
1152 sc->xl_xcvr = XL_XCVR_10BT;
1153 if (verbose)
1155 if_printf(sc->xl_ifp, "guessing TPC (BNC/TP)\n");
1154 device_printf(sc->xl_dev, "guessing TPC (BNC/TP)\n");
1156 break;
1157 case TC_DEVICEID_CYCLONE_10FL: /* 3c900B-FL */
1158 sc->xl_media = XL_MEDIAOPT_10FL;
1159 sc->xl_xcvr = XL_XCVR_AUI;
1160 if (verbose)
1155 break;
1156 case TC_DEVICEID_CYCLONE_10FL: /* 3c900B-FL */
1157 sc->xl_media = XL_MEDIAOPT_10FL;
1158 sc->xl_xcvr = XL_XCVR_AUI;
1159 if (verbose)
1161 if_printf(sc->xl_ifp, "guessing 10baseFL\n");
1160 device_printf(sc->xl_dev, "guessing 10baseFL\n");
1162 break;
1163 case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */
1164 case TC_DEVICEID_HURRICANE_555: /* 3c555 */
1165 case TC_DEVICEID_HURRICANE_556: /* 3c556 */
1166 case TC_DEVICEID_HURRICANE_556B: /* 3c556B */
1167 case TC_DEVICEID_HURRICANE_575A: /* 3c575TX */
1168 case TC_DEVICEID_HURRICANE_575B: /* 3c575B */
1169 case TC_DEVICEID_HURRICANE_575C: /* 3c575C */
1170 case TC_DEVICEID_HURRICANE_656: /* 3c656 */
1171 case TC_DEVICEID_HURRICANE_656B: /* 3c656B */
1172 case TC_DEVICEID_TORNADO_656C: /* 3c656C */
1173 case TC_DEVICEID_TORNADO_10_100BT_920B: /* 3c920B-EMB */
1174 case TC_DEVICEID_TORNADO_10_100BT_920B_WNM: /* 3c920B-EMB-WNM */
1175 sc->xl_media = XL_MEDIAOPT_MII;
1176 sc->xl_xcvr = XL_XCVR_MII;
1177 if (verbose)
1161 break;
1162 case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */
1163 case TC_DEVICEID_HURRICANE_555: /* 3c555 */
1164 case TC_DEVICEID_HURRICANE_556: /* 3c556 */
1165 case TC_DEVICEID_HURRICANE_556B: /* 3c556B */
1166 case TC_DEVICEID_HURRICANE_575A: /* 3c575TX */
1167 case TC_DEVICEID_HURRICANE_575B: /* 3c575B */
1168 case TC_DEVICEID_HURRICANE_575C: /* 3c575C */
1169 case TC_DEVICEID_HURRICANE_656: /* 3c656 */
1170 case TC_DEVICEID_HURRICANE_656B: /* 3c656B */
1171 case TC_DEVICEID_TORNADO_656C: /* 3c656C */
1172 case TC_DEVICEID_TORNADO_10_100BT_920B: /* 3c920B-EMB */
1173 case TC_DEVICEID_TORNADO_10_100BT_920B_WNM: /* 3c920B-EMB-WNM */
1174 sc->xl_media = XL_MEDIAOPT_MII;
1175 sc->xl_xcvr = XL_XCVR_MII;
1176 if (verbose)
1178 if_printf(sc->xl_ifp, "guessing MII\n");
1177 device_printf(sc->xl_dev, "guessing MII\n");
1179 break;
1180 case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */
1181 case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */
1182 sc->xl_media = XL_MEDIAOPT_BT4;
1183 sc->xl_xcvr = XL_XCVR_MII;
1184 if (verbose)
1178 break;
1179 case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */
1180 case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */
1181 sc->xl_media = XL_MEDIAOPT_BT4;
1182 sc->xl_xcvr = XL_XCVR_MII;
1183 if (verbose)
1185 if_printf(sc->xl_ifp,
1186 "guessing 100baseT4/MII\n");
1184 device_printf(sc->xl_dev, "guessing 100baseT4/MII\n");
1187 break;
1188 case TC_DEVICEID_HURRICANE_10_100BT: /* 3c905B-TX */
1189 case TC_DEVICEID_HURRICANE_10_100BT_SERV:/*3c980-TX */
1190 case TC_DEVICEID_TORNADO_10_100BT_SERV: /* 3c980C-TX */
1191 case TC_DEVICEID_HURRICANE_SOHO100TX: /* 3cSOHO100-TX */
1192 case TC_DEVICEID_TORNADO_10_100BT: /* 3c905C-TX */
1193 case TC_DEVICEID_TORNADO_HOMECONNECT: /* 3c450-TX */
1194 sc->xl_media = XL_MEDIAOPT_BTX;
1195 sc->xl_xcvr = XL_XCVR_AUTO;
1196 if (verbose)
1185 break;
1186 case TC_DEVICEID_HURRICANE_10_100BT: /* 3c905B-TX */
1187 case TC_DEVICEID_HURRICANE_10_100BT_SERV:/*3c980-TX */
1188 case TC_DEVICEID_TORNADO_10_100BT_SERV: /* 3c980C-TX */
1189 case TC_DEVICEID_HURRICANE_SOHO100TX: /* 3cSOHO100-TX */
1190 case TC_DEVICEID_TORNADO_10_100BT: /* 3c905C-TX */
1191 case TC_DEVICEID_TORNADO_HOMECONNECT: /* 3c450-TX */
1192 sc->xl_media = XL_MEDIAOPT_BTX;
1193 sc->xl_xcvr = XL_XCVR_AUTO;
1194 if (verbose)
1197 if_printf(sc->xl_ifp,
1198 "guessing 10/100 internal\n");
1195 device_printf(sc->xl_dev, "guessing 10/100 internal\n");
1199 break;
1200 case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */
1201 sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1202 sc->xl_xcvr = XL_XCVR_AUTO;
1203 if (verbose)
1196 break;
1197 case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */
1198 sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1199 sc->xl_xcvr = XL_XCVR_AUTO;
1200 if (verbose)
1204 if_printf(sc->xl_ifp,
1201 device_printf(sc->xl_dev,
1205 "guessing 10/100 plus BNC/AUI\n");
1206 break;
1207 default:
1202 "guessing 10/100 plus BNC/AUI\n");
1203 break;
1204 default:
1208 if_printf(sc->xl_ifp,
1205 device_printf(sc->xl_dev,
1209 "unknown device ID: %x -- defaulting to 10baseT\n", devid);
1210 sc->xl_media = XL_MEDIAOPT_BT;
1211 break;
1212 }
1213}
1214
1215/*
1216 * Attach the interface. Allocate softc structures, do ifmedia

--- 6 unchanged lines hidden (view full) ---

1223 u_int16_t xcvr[2];
1224 struct xl_softc *sc;
1225 struct ifnet *ifp;
1226 int media;
1227 int unit, error = 0, rid, res;
1228 uint16_t did;
1229
1230 sc = device_get_softc(dev);
1206 "unknown device ID: %x -- defaulting to 10baseT\n", devid);
1207 sc->xl_media = XL_MEDIAOPT_BT;
1208 break;
1209 }
1210}
1211
1212/*
1213 * Attach the interface. Allocate softc structures, do ifmedia

--- 6 unchanged lines hidden (view full) ---

1220 u_int16_t xcvr[2];
1221 struct xl_softc *sc;
1222 struct ifnet *ifp;
1223 int media;
1224 int unit, error = 0, rid, res;
1225 uint16_t did;
1226
1227 sc = device_get_softc(dev);
1228 sc->xl_dev = dev;
1229
1231 unit = device_get_unit(dev);
1232
1233 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1234 MTX_DEF);
1235 ifmedia_init(&sc->ifmedia, 0, xl_ifmedia_upd, xl_ifmedia_sts);
1236
1237 did = pci_get_device(dev);
1238

--- 419 unchanged lines hidden (view full) ---

1658 case XL_XCVR_100BTX:
1659 case XL_XCVR_MII:
1660 /* Chosen by miibus */
1661 break;
1662 case XL_XCVR_100BFX:
1663 *media = IFM_ETHER|IFM_100_FX;
1664 break;
1665 default:
1230 unit = device_get_unit(dev);
1231
1232 mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1233 MTX_DEF);
1234 ifmedia_init(&sc->ifmedia, 0, xl_ifmedia_upd, xl_ifmedia_sts);
1235
1236 did = pci_get_device(dev);
1237

--- 419 unchanged lines hidden (view full) ---

1657 case XL_XCVR_100BTX:
1658 case XL_XCVR_MII:
1659 /* Chosen by miibus */
1660 break;
1661 case XL_XCVR_100BFX:
1662 *media = IFM_ETHER|IFM_100_FX;
1663 break;
1664 default:
1666 if_printf(sc->xl_ifp, "unknown XCVR type: %d\n",
1665 device_printf(sc->xl_dev, "unknown XCVR type: %d\n",
1667 sc->xl_xcvr);
1668 /*
1669 * This will probably be wrong, but it prevents
1670 * the ifmedia code from panicking.
1671 */
1672 *media = IFM_ETHER|IFM_10_T;
1673 break;
1674 }

--- 231 unchanged lines hidden (view full) ---

1906
1907 /* Force longword alignment for packet payload. */
1908 m_adj(m_new, ETHER_ALIGN);
1909
1910 error = bus_dmamap_load_mbuf(sc->xl_mtag, sc->xl_tmpmap, m_new,
1911 xl_dma_map_rxbuf, &baddr, BUS_DMA_NOWAIT);
1912 if (error) {
1913 m_freem(m_new);
1666 sc->xl_xcvr);
1667 /*
1668 * This will probably be wrong, but it prevents
1669 * the ifmedia code from panicking.
1670 */
1671 *media = IFM_ETHER|IFM_10_T;
1672 break;
1673 }

--- 231 unchanged lines hidden (view full) ---

1905
1906 /* Force longword alignment for packet payload. */
1907 m_adj(m_new, ETHER_ALIGN);
1908
1909 error = bus_dmamap_load_mbuf(sc->xl_mtag, sc->xl_tmpmap, m_new,
1910 xl_dma_map_rxbuf, &baddr, BUS_DMA_NOWAIT);
1911 if (error) {
1912 m_freem(m_new);
1914 if_printf(sc->xl_ifp, "can't map mbuf (error %d)\n",
1913 device_printf(sc->xl_dev, "can't map mbuf (error %d)\n",
1915 error);
1916 return (error);
1917 }
1918
1919 bus_dmamap_unload(sc->xl_mtag, c->xl_map);
1920 map = c->xl_map;
1921 c->xl_map = sc->xl_tmpmap;
1922 sc->xl_tmpmap = map;

--- 82 unchanged lines hidden (view full) ---

2005 }
2006
2007 /*
2008 * If the error bit was not set, the upload complete
2009 * bit should be set which means we have a valid packet.
2010 * If not, something truly strange has happened.
2011 */
2012 if (!(rxstat & XL_RXSTAT_UP_CMPLT)) {
1914 error);
1915 return (error);
1916 }
1917
1918 bus_dmamap_unload(sc->xl_mtag, c->xl_map);
1919 map = c->xl_map;
1920 c->xl_map = sc->xl_tmpmap;
1921 sc->xl_tmpmap = map;

--- 82 unchanged lines hidden (view full) ---

2004 }
2005
2006 /*
2007 * If the error bit was not set, the upload complete
2008 * bit should be set which means we have a valid packet.
2009 * If not, something truly strange has happened.
2010 */
2011 if (!(rxstat & XL_RXSTAT_UP_CMPLT)) {
2013 if_printf(ifp,
2012 device_printf(sc->xl_dev,
2014 "bad receive status -- packet dropped\n");
2015 ifp->if_ierrors++;
2016 cur_rx->xl_ptr->xl_status = 0;
2017 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag,
2018 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE);
2019 continue;
2020 }
2021

--- 198 unchanged lines hidden (view full) ---

2220 u_int8_t txstat;
2221
2222 XL_LOCK_ASSERT(sc);
2223
2224 while ((txstat = CSR_READ_1(sc, XL_TX_STATUS))) {
2225 if (txstat & XL_TXSTATUS_UNDERRUN ||
2226 txstat & XL_TXSTATUS_JABBER ||
2227 txstat & XL_TXSTATUS_RECLAIM) {
2013 "bad receive status -- packet dropped\n");
2014 ifp->if_ierrors++;
2015 cur_rx->xl_ptr->xl_status = 0;
2016 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag,
2017 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE);
2018 continue;
2019 }
2020

--- 198 unchanged lines hidden (view full) ---

2219 u_int8_t txstat;
2220
2221 XL_LOCK_ASSERT(sc);
2222
2223 while ((txstat = CSR_READ_1(sc, XL_TX_STATUS))) {
2224 if (txstat & XL_TXSTATUS_UNDERRUN ||
2225 txstat & XL_TXSTATUS_JABBER ||
2226 txstat & XL_TXSTATUS_RECLAIM) {
2228 if_printf(sc->xl_ifp,
2227 device_printf(sc->xl_dev,
2229 "transmission error: %x\n", txstat);
2230 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET);
2231 xl_wait(sc);
2232 if (sc->xl_type == XL_TYPE_905B) {
2233 if (sc->xl_cdata.xl_tx_cnt) {
2234 int i;
2235 struct xl_chain *c;
2236

--- 11 unchanged lines hidden (view full) ---

2248 /*
2249 * Remember to set this for the
2250 * first generation 3c90X chips.
2251 */
2252 CSR_WRITE_1(sc, XL_TX_FREETHRESH, XL_PACKET_SIZE >> 8);
2253 if (txstat & XL_TXSTATUS_UNDERRUN &&
2254 sc->xl_tx_thresh < XL_PACKET_SIZE) {
2255 sc->xl_tx_thresh += XL_MIN_FRAMELEN;
2228 "transmission error: %x\n", txstat);
2229 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET);
2230 xl_wait(sc);
2231 if (sc->xl_type == XL_TYPE_905B) {
2232 if (sc->xl_cdata.xl_tx_cnt) {
2233 int i;
2234 struct xl_chain *c;
2235

--- 11 unchanged lines hidden (view full) ---

2247 /*
2248 * Remember to set this for the
2249 * first generation 3c90X chips.
2250 */
2251 CSR_WRITE_1(sc, XL_TX_FREETHRESH, XL_PACKET_SIZE >> 8);
2252 if (txstat & XL_TXSTATUS_UNDERRUN &&
2253 sc->xl_tx_thresh < XL_PACKET_SIZE) {
2254 sc->xl_tx_thresh += XL_MIN_FRAMELEN;
2256 if_printf(sc->xl_ifp,
2255 device_printf(sc->xl_dev,
2257"tx underrun, increasing tx start threshold to %d bytes\n", sc->xl_tx_thresh);
2258 }
2259 CSR_WRITE_2(sc, XL_COMMAND,
2260 XL_CMD_TX_SET_START|sc->xl_tx_thresh);
2261 if (sc->xl_type == XL_TYPE_905B) {
2262 CSR_WRITE_2(sc, XL_COMMAND,
2263 XL_CMD_SET_TX_RECLAIM|(XL_PACKET_SIZE >> 4));
2264 }

--- 554 unchanged lines hidden (view full) ---

2819 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_RESET);
2820 xl_wait(sc);
2821 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET);
2822 xl_wait(sc);
2823#endif
2824 /* Init circular RX list. */
2825 error = xl_list_rx_init(sc);
2826 if (error) {
2256"tx underrun, increasing tx start threshold to %d bytes\n", sc->xl_tx_thresh);
2257 }
2258 CSR_WRITE_2(sc, XL_COMMAND,
2259 XL_CMD_TX_SET_START|sc->xl_tx_thresh);
2260 if (sc->xl_type == XL_TYPE_905B) {
2261 CSR_WRITE_2(sc, XL_COMMAND,
2262 XL_CMD_SET_TX_RECLAIM|(XL_PACKET_SIZE >> 4));
2263 }

--- 554 unchanged lines hidden (view full) ---

2818 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_RESET);
2819 xl_wait(sc);
2820 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_TX_RESET);
2821 xl_wait(sc);
2822#endif
2823 /* Init circular RX list. */
2824 error = xl_list_rx_init(sc);
2825 if (error) {
2827 if_printf(ifp, "initialization of the rx ring failed (%d)\n",
2826 device_printf(sc->xl_dev, "initialization of the rx ring failed (%d)\n",
2828 error);
2829 xl_stop(sc);
2830 return;
2831 }
2832
2833 /* Init TX descriptors. */
2834 if (sc->xl_type == XL_TYPE_905B)
2835 error = xl_list_tx_init_90xB(sc);
2836 else
2837 error = xl_list_tx_init(sc);
2838 if (error) {
2827 error);
2828 xl_stop(sc);
2829 return;
2830 }
2831
2832 /* Init TX descriptors. */
2833 if (sc->xl_type == XL_TYPE_905B)
2834 error = xl_list_tx_init_90xB(sc);
2835 else
2836 error = xl_list_tx_init(sc);
2837 if (error) {
2839 if_printf(ifp, "initialization of the tx ring failed (%d)\n",
2838 device_printf(sc->xl_dev, "initialization of the tx ring failed (%d)\n",
2840 error);
2841 xl_stop(sc);
2842 return;
2843 }
2844
2845 /*
2846 * Set the TX freethresh value.
2847 * Note that this has no effect on 3c905B "cyclone"

--- 545 unchanged lines hidden ---
2839 error);
2840 xl_stop(sc);
2841 return;
2842 }
2843
2844 /*
2845 * Set the TX freethresh value.
2846 * Note that this has no effect on 3c905B "cyclone"

--- 545 unchanged lines hidden ---