Deleted Added
sdiff udiff text old ( 45629 ) new ( 45693 )
full compact
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 * $Id: if_xl.c,v 1.83 1999/04/15 02:34:54 wpaul Exp $
33 */
34
35/*
36 * 3Com 3c90x Etherlink XL PCI NIC driver
37 *
38 * Supports the 3Com "boomerang" and "cyclone" PCI
39 * bus-master chips (3c90x cards and embedded controllers) including
40 * the following:
41 *
42 * 3Com 3c900-TPO 10Mbps/RJ-45
43 * 3Com 3c900-COMBO 10Mbps/RJ-45,AUI,BNC
44 * 3Com 3c905-TX 10/100Mbps/RJ-45
45 * 3Com 3c905-T4 10/100Mbps/RJ-45
46 * 3Com 3c900B-TPO 10Mbps/RJ-45
47 * 3Com 3c900B-COMBO 10Mbps/RJ-45,AUI,BNC
48 * 3Com 3c900B-TPC 10Mbps/RJ-45,BNC
49 * 3Com 3c905B-COMBO 10/100Mbps/RJ-45,AUI,BNC
50 * 3Com 3c905B-TX 10/100Mbps/RJ-45
51 * 3Com 3c905B-FL/FX 10/100Mbps/Fiber-optic
52 * 3Com 3c980-TX 10/100Mbps server adapter
53 * 3Com 3cSOHO100-TX 10/100Mbps/RJ-45
54 * Dell Optiplex GX1 on-board 3c918 10/100Mbps/RJ-45
55 * Dell Precision on-board 3c905B 10/100Mbps/RJ-45
56 * Dell Latitude laptop docking station embedded 3c905-TX

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

148 * recompile.
149 */
150/* #define XL_BACKGROUND_AUTONEG */
151
152#include <pci/if_xlreg.h>
153
154#if !defined(lint)
155static const char rcsid[] =
156 "$Id: if_xl.c,v 1.83 1999/04/15 02:34:54 wpaul Exp $";
157#endif
158
159/*
160 * Various supported device vendors/types and their names.
161 */
162static struct xl_type xl_devs[] = {
163 { TC_VENDORID, TC_DEVICEID_BOOMERANG_10BT,
164 "3Com 3c900-TPO Etherlink XL" },
165 { TC_VENDORID, TC_DEVICEID_BOOMERANG_10BT_COMBO,
166 "3Com 3c900-COMBO Etherlink XL" },
167 { TC_VENDORID, TC_DEVICEID_BOOMERANG_10_100BT,
168 "3Com 3c905-TX Fast Etherlink XL" },
169 { TC_VENDORID, TC_DEVICEID_BOOMERANG_100BT4,
170 "3Com 3c905-T4 Fast Etherlink XL" },
171 { TC_VENDORID, TC_DEVICEID_CYCLONE_10BT,
172 "3Com 3c900B-TPO Etherlink XL" },
173 { TC_VENDORID, TC_DEVICEID_CYCLONE_10BT_COMBO,
174 "3Com 3c900B-COMBO Etherlink XL" },
175 { TC_VENDORID, TC_DEVICEID_CYCLONE_10BT_TPC,
176 "3Com 3c900B-TPC Etherlink XL" },
177 { TC_VENDORID, TC_DEVICEID_CYCLONE_10FL,
178 "3Com 3c900B-FL Etherlink XL" },
179 { TC_VENDORID, TC_DEVICEID_CYCLONE_10_100BT,
180 "3Com 3c905B-TX Fast Etherlink XL" },
181 { TC_VENDORID, TC_DEVICEID_CYCLONE_10_100BT4,
182 "3Com 3c905B-T4 Fast Etherlink XL" },
183 { TC_VENDORID, TC_DEVICEID_CYCLONE_10_100FX,
184 "3Com 3c905B-FX/SC Fast Etherlink XL" },
185 { TC_VENDORID, TC_DEVICEID_CYCLONE_10_100_COMBO,
186 "3Com 3c905B-COMBO Fast Etherlink XL" },

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

448 */
449static int xl_mii_writereg(sc, frame)
450 struct xl_softc *sc;
451 struct xl_mii_frame *frame;
452
453{
454 int s;
455
456 s = splimp();
457 /*
458 * Set up frame for TX.
459 */
460
461 frame->mii_stdelim = XL_MII_STARTDELIM;
462 frame->mii_opcode = XL_MII_WRITEOP;
463 frame->mii_turnaround = XL_MII_TURNAROUND;

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

746
747/*
748 * Initiate an autonegotiation session.
749 */
750static void xl_autoneg_xmit(sc)
751 struct xl_softc *sc;
752{
753 u_int16_t phy_sts;
754 u_int32_t icfg;
755
756 xl_reset(sc);
757 XL_SEL_WIN(3);
758 icfg = CSR_READ_4(sc, XL_W3_INTERNAL_CFG);
759 icfg &= ~XL_ICFG_CONNECTOR_MASK;
760 if (sc->xl_media & XL_MEDIAOPT_MII ||
761 sc->xl_media & XL_MEDIAOPT_BT4)
762 icfg |= (XL_XCVR_MII << XL_ICFG_CONNECTOR_BITS);
763 if (sc->xl_media & XL_MEDIAOPT_BTX)
764 icfg |= (XL_XCVR_AUTO << XL_ICFG_CONNECTOR_BITS);
765 if (sc->xl_media & XL_MEDIAOPT_BFX)
766 icfg |= (XL_XCVR_100BFX << XL_ICFG_CONNECTOR_BITS);
767 CSR_WRITE_4(sc, XL_W3_INTERNAL_CFG, icfg);
768 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_COAX_STOP);
769
770 xl_phy_writereg(sc, PHY_BMCR, PHY_BMCR_RESET);
771 DELAY(500);
772 while(xl_phy_readreg(sc, XL_PHY_GENCTL)
773 & PHY_BMCR_RESET);
774
775 phy_sts = xl_phy_readreg(sc, PHY_BMCR);
776 phy_sts |= PHY_BMCR_AUTONEGENBL|PHY_BMCR_AUTONEGRSTR;
777 xl_phy_writereg(sc, PHY_BMCR, phy_sts);

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

1303 printf("xl%d: guessing 10BaseT transceiver\n", sc->xl_unit);
1304 break;
1305 case TC_DEVICEID_BOOMERANG_10BT_COMBO: /* 3c900-COMBO */
1306 case TC_DEVICEID_CYCLONE_10BT_COMBO: /* 3c900B-COMBO */
1307 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1308 sc->xl_xcvr = XL_XCVR_10BT;
1309 printf("xl%d: guessing COMBO (AUI/BNC/TP)\n", sc->xl_unit);
1310 break;
1311 case TC_DEVICEID_CYCLONE_10BT_TPC: /* 3c900B-TPC */
1312 sc->xl_media = XL_MEDIAOPT_BT|XL_MEDIAOPT_BNC;
1313 sc->xl_xcvr = XL_XCVR_10BT;
1314 printf("xl%d: guessing TPC (BNC/TP)\n", sc->xl_unit);
1315 break;
1316 case TC_DEVICEID_BOOMERANG_10_100BT: /* 3c905-TX */
1317 sc->xl_media = XL_MEDIAOPT_MII;
1318 sc->xl_xcvr = XL_XCVR_MII;
1319 printf("xl%d: guessing MII\n", sc->xl_unit);
1320 break;
1321 case TC_DEVICEID_BOOMERANG_100BT4: /* 3c905-T4 */
1322 case TC_DEVICEID_CYCLONE_10_100BT4: /* 3c905B-T4 */
1323 sc->xl_media = XL_MEDIAOPT_BT4;
1324 sc->xl_xcvr = XL_XCVR_MII;
1325 printf("xl%d: guessing 100BaseT4/MII\n", sc->xl_unit);
1326 break;
1327 case TC_DEVICEID_CYCLONE_10_100BT: /* 3c905B-TX */
1328 case TC_DEVICEID_CYCLONE_10_100BT_SERV: /* 3c980-TX */
1329 case TC_DEVICEID_HURRICANE_SOHO100TX: /* 3cSOHO100-TX */
1330 sc->xl_media = XL_MEDIAOPT_BTX;
1331 sc->xl_xcvr = XL_XCVR_AUTO;
1332 printf("xl%d: guessing 10/100 internal\n", sc->xl_unit);
1333 break;
1334 case TC_DEVICEID_CYCLONE_10_100_COMBO: /* 3c905B-COMBO */
1335 sc->xl_media = XL_MEDIAOPT_BTX|XL_MEDIAOPT_BNC|XL_MEDIAOPT_AUI;
1336 sc->xl_xcvr = XL_XCVR_AUTO;
1337 printf("xl%d: guessing 10/100 plus BNC/AUI\n", sc->xl_unit);
1338 break;
1339 default:
1340 printf("xl%d: unknown device ID: %x -- "
1341 "defaulting to 10baseT\n", sc->xl_unit, devid);
1342 sc->xl_media = XL_MEDIAOPT_BT;
1343 break;
1344 }
1345
1346 return;

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

1762 struct xl_chain_data *cd;
1763 struct xl_list_data *ld;
1764 int i;
1765
1766 cd = &sc->xl_cdata;
1767 ld = sc->xl_ldata;
1768 for (i = 0; i < XL_TX_LIST_CNT; i++) {
1769 cd->xl_tx_chain[i].xl_ptr = &ld->xl_tx_list[i];
1770 cd->xl_tx_chain[i].xl_unsent = 0;
1771 if (i == (XL_TX_LIST_CNT - 1))
1772 cd->xl_tx_chain[i].xl_next = NULL;
1773 else
1774 cd->xl_tx_chain[i].xl_next = &cd->xl_tx_chain[i + 1];
1775 }
1776
1777 cd->xl_tx_free = &cd->xl_tx_chain[0];
1778 cd->xl_tx_tail = cd->xl_tx_head = NULL;

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

1912 * can do in this situation.
1913 */
1914 if (xl_newbuf(sc, cur_rx) == ENOBUFS) {
1915 ifp->if_ierrors++;
1916 cur_rx->xl_ptr->xl_status = 0;
1917 continue;
1918 }
1919
1920 ifp->if_ipackets++;
1921 eh = mtod(m, struct ether_header *);
1922 m->m_pkthdr.rcvif = ifp;
1923#if NBPFILTER > 0
1924 /*
1925 * Handle BPF listeners. Let the BPF user see the packet, but
1926 * don't pass it up to the ether_input() layer unless it's
1927 * a broadcast packet, multicast packet, matches our ethernet
1928 * address or the interface is in promiscuous mode.

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

1994 * know that a frame has been downloaded, but the
1995 * original 3c900/3c905 adapters don't do that.
1996 * Consequently, we have to use a different test if
1997 * xl_type != XL_TYPE_905B.
1998 */
1999 while(sc->xl_cdata.xl_tx_head != NULL) {
2000 cur_tx = sc->xl_cdata.xl_tx_head;
2001 if ((sc->xl_type == XL_TYPE_905B &&
2002 !(cur_tx->xl_ptr->xl_status & XL_TXSTAT_DL_COMPLETE)) ||
2003 (CSR_READ_1(sc, XL_TX_STATUS) & XL_TXSTATUS_COMPLETE) ||
2004 cur_tx->xl_unsent) {
2005 break;
2006 }
2007 sc->xl_cdata.xl_tx_head = cur_tx->xl_next;
2008 m_freem(cur_tx->xl_mbuf);
2009 cur_tx->xl_mbuf = NULL;
2010 ifp->if_opackets++;
2011
2012 cur_tx->xl_next = sc->xl_cdata.xl_tx_free;
2013 sc->xl_cdata.xl_tx_free = cur_tx;
2014 }
2015
2016 if (sc->xl_cdata.xl_tx_head == NULL) {
2017 ifp->if_flags &= ~IFF_OACTIVE;
2018 sc->xl_cdata.xl_tx_tail = NULL;
2019 if (sc->xl_want_auto)
2020 xl_autoneg_mii(sc, XL_FLAG_SCHEDDELAY, 1);
2021 } else {
2022 if (sc->xl_cdata.xl_tx_head->xl_unsent) {
2023 sc->xl_cdata.xl_tx_head->xl_unsent = 0;
2024 CSR_WRITE_4(sc, XL_DOWNLIST_PTR,
2025 vtophys(sc->xl_cdata.xl_tx_head->xl_ptr));
2026 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_DOWN_UNSTALL);
2027 }
2028 }
2029
2030 return;
2031}

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

2161 p = (u_int8_t *)&xl_stats;
2162
2163 /* Read all the stats registers. */
2164 XL_SEL_WIN(6);
2165
2166 for (i = 0; i < 16; i++)
2167 *p++ = CSR_READ_1(sc, XL_W6_CARRIER_LOST + i);
2168
2169 ifp->if_ierrors += xl_stats.xl_rx_overrun;
2170
2171 ifp->if_collisions += xl_stats.xl_tx_multi_collision +
2172 xl_stats.xl_tx_single_collision +
2173 xl_stats.xl_tx_late_collision;
2174
2175 /*
2176 * Boomerang and cyclone chips have an extra stats counter

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

2344 * Place the request for the upload interrupt
2345 * in the last descriptor in the chain. This way, if
2346 * we're chaining several packets at once, we'll only
2347 * get an interupt once for the whole chain rather than
2348 * once for each packet.
2349 */
2350 cur_tx->xl_ptr->xl_status |= XL_TXSTAT_DL_INTR;
2351
2352 if (sc->xl_cdata.xl_tx_head == NULL) {
2353 sc->xl_cdata.xl_tx_head = start_tx;
2354 sc->xl_cdata.xl_tx_tail = cur_tx;
2355 CSR_WRITE_4(sc, XL_DOWNLIST_PTR, vtophys(start_tx->xl_ptr));
2356 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_DOWN_UNSTALL);
2357 } else {
2358 start_tx->xl_unsent++;
2359 sc->xl_cdata.xl_tx_tail->xl_next = start_tx;
2360 sc->xl_cdata.xl_tx_tail = cur_tx;
2361 }
2362
2363 /*
2364 * Set a timeout in case the chip goes out to lunch.
2365 */
2366 ifp->if_timer = 5;
2367
2368 /*
2369 * XXX Under certain conditions, usually on slower machines
2370 * where interrupts may be dropped, it's possible for the

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

2578 struct ifmedia *ifm;
2579
2580 sc = ifp->if_softc;
2581 ifm = &sc->ifmedia;
2582
2583 if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
2584 return(EINVAL);
2585
2586 switch(IFM_SUBTYPE(ifm->ifm_media)) {
2587 case IFM_100_FX:
2588 case IFM_10_2:
2589 case IFM_10_5:
2590 xl_setmode(sc, ifm->ifm_media);
2591 return(0);
2592 break;
2593 default:
2594 break;
2595 }
2596
2597 if (sc->xl_media & XL_MEDIAOPT_MII || sc->xl_media & XL_MEDIAOPT_BTX
2598 || sc->xl_media & XL_MEDIAOPT_BT4) {
2599 if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO)
2600 xl_autoneg_mii(sc, XL_FLAG_SCHEDDELAY, 1);
2601 else
2602 xl_setmode_mii(sc, ifm->ifm_media);
2603 } else {
2604 xl_setmode(sc, ifm->ifm_media);

--- 252 unchanged lines hidden ---