Deleted Added
full compact
if_gem.c (148654) if_gem.c (148887)
1/*-
2 * Copyright (C) 2001 Eduardo Horvath.
3 * Copyright (c) 2001-2003 Thomas Moestl
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: NetBSD: gem.c,v 1.21 2002/06/01 23:50:58 lukem Exp
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2001 Eduardo Horvath.
3 * Copyright (c) 2001-2003 Thomas Moestl
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: NetBSD: gem.c,v 1.21 2002/06/01 23:50:58 lukem Exp
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/gem/if_gem.c 148654 2005-08-03 00:18:35Z rwatson $");
31__FBSDID("$FreeBSD: head/sys/dev/gem/if_gem.c 148887 2005-08-09 10:20:02Z rwatson $");
32
33/*
34 * Driver for Sun GEM ethernet controllers.
35 */
36
37#if 0
38#define GEM_DEBUG
39#endif

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

633 }
634
635 if (disable)
636 gem_rxdrain(sc);
637
638 /*
639 * Mark the interface down and cancel the watchdog timer.
640 */
32
33/*
34 * Driver for Sun GEM ethernet controllers.
35 */
36
37#if 0
38#define GEM_DEBUG
39#endif

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

633 }
634
635 if (disable)
636 gem_rxdrain(sc);
637
638 /*
639 * Mark the interface down and cancel the watchdog timer.
640 */
641 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
641 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
642 ifp->if_timer = 0;
643}
644
645/*
646 * Reset the receiver
647 */
648int
649gem_reset_rx(sc)

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

967 /* step 14. Issue Transmit Pending command */
968
969 /* step 15. Give the reciever a swift kick */
970 bus_space_write_4(t, h, GEM_RX_KICK, GEM_NRXDESC-4);
971
972 /* Start the one second timer. */
973 callout_reset(&sc->sc_tick_ch, hz, gem_tick, sc);
974
642 ifp->if_timer = 0;
643}
644
645/*
646 * Reset the receiver
647 */
648int
649gem_reset_rx(sc)

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

967 /* step 14. Issue Transmit Pending command */
968
969 /* step 15. Give the reciever a swift kick */
970 bus_space_write_4(t, h, GEM_RX_KICK, GEM_NRXDESC-4);
971
972 /* Start the one second timer. */
973 callout_reset(&sc->sc_tick_ch, hz, gem_tick, sc);
974
975 ifp->if_flags |= IFF_RUNNING;
976 ifp->if_flags &= ~IFF_OACTIVE;
975 ifp->if_drv_flags |= IFF_DRV_RUNNING;
976 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
977 ifp->if_timer = 0;
978 sc->sc_ifflags = ifp->if_flags;
979}
980
981static int
982gem_load_txmbuf(sc, m0)
983 struct gem_softc *sc;
984 struct mbuf *m0;

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

1134static void
1135gem_start_locked(ifp)
1136 struct ifnet *ifp;
1137{
1138 struct gem_softc *sc = (struct gem_softc *)ifp->if_softc;
1139 struct mbuf *m0 = NULL;
1140 int firsttx, ntx = 0, ofree, txmfail;
1141
977 ifp->if_timer = 0;
978 sc->sc_ifflags = ifp->if_flags;
979}
980
981static int
982gem_load_txmbuf(sc, m0)
983 struct gem_softc *sc;
984 struct mbuf *m0;

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

1134static void
1135gem_start_locked(ifp)
1136 struct ifnet *ifp;
1137{
1138 struct gem_softc *sc = (struct gem_softc *)ifp->if_softc;
1139 struct mbuf *m0 = NULL;
1140 int firsttx, ntx = 0, ofree, txmfail;
1141
1142 if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
1142 if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
1143 IFF_DRV_RUNNING)
1143 return;
1144
1145 /*
1146 * Remember the previous number of free descriptors and
1147 * the first descriptor we'll use.
1148 */
1149 ofree = sc->sc_txfree;
1150 firsttx = sc->sc_txnext;

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

1193 sc->sc_txnext);
1194
1195 if (ifp->if_bpf != NULL)
1196 bpf_mtap(ifp->if_bpf, m0);
1197 } while (1);
1198
1199 if (txmfail == -1 || sc->sc_txfree == 0) {
1200 /* No more slots left; notify upper layer. */
1144 return;
1145
1146 /*
1147 * Remember the previous number of free descriptors and
1148 * the first descriptor we'll use.
1149 */
1150 ofree = sc->sc_txfree;
1151 firsttx = sc->sc_txnext;

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

1194 sc->sc_txnext);
1195
1196 if (ifp->if_bpf != NULL)
1197 bpf_mtap(ifp->if_bpf, m0);
1198 } while (1);
1199
1200 if (txmfail == -1 || sc->sc_txfree == 0) {
1201 /* No more slots left; notify upper layer. */
1201 ifp->if_flags |= IFF_OACTIVE;
1202 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
1202 }
1203
1204 if (ntx > 0) {
1205 GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE);
1206
1207#ifdef GEM_DEBUG
1208 CTR2(KTR_GEM, "%s: packets enqueued, OWN on %d",
1209 device_get_name(sc->sc_dev), firsttx);

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

1333 GEM_TX_DATA_PTR_LO),
1334 bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_COMPLETION));
1335#endif
1336
1337 if (progress) {
1338 if (sc->sc_txfree == GEM_NTXDESC - 1)
1339 sc->sc_txwin = 0;
1340
1203 }
1204
1205 if (ntx > 0) {
1206 GEM_CDSYNC(sc, BUS_DMASYNC_PREWRITE);
1207
1208#ifdef GEM_DEBUG
1209 CTR2(KTR_GEM, "%s: packets enqueued, OWN on %d",
1210 device_get_name(sc->sc_dev), firsttx);

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

1334 GEM_TX_DATA_PTR_LO),
1335 bus_space_read_4(sc->sc_bustag, sc->sc_h, GEM_TX_COMPLETION));
1336#endif
1337
1338 if (progress) {
1339 if (sc->sc_txfree == GEM_NTXDESC - 1)
1340 sc->sc_txwin = 0;
1341
1341 /* Freed some descriptors, so reset IFF_OACTIVE and restart. */
1342 ifp->if_flags &= ~IFF_OACTIVE;
1342 /* Freed some descriptors, so reset IFF_DRV_OACTIVE and restart. */
1343 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1343 gem_start_locked(ifp);
1344
1345 if (STAILQ_EMPTY(&sc->sc_txdirtyq))
1346 ifp->if_timer = 0;
1347 }
1348
1349#ifdef GEM_DEBUG
1350 CTR2(KTR_GEM, "%s: gem_tint: watchdog %d",

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

1868 break;
1869 case SIOCSIFFLAGS:
1870 if (ifp->if_flags & IFF_UP) {
1871 if ((sc->sc_ifflags ^ ifp->if_flags) == IFF_PROMISC)
1872 gem_setladrf(sc);
1873 else
1874 gem_init_locked(sc);
1875 } else {
1344 gem_start_locked(ifp);
1345
1346 if (STAILQ_EMPTY(&sc->sc_txdirtyq))
1347 ifp->if_timer = 0;
1348 }
1349
1350#ifdef GEM_DEBUG
1351 CTR2(KTR_GEM, "%s: gem_tint: watchdog %d",

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

1869 break;
1870 case SIOCSIFFLAGS:
1871 if (ifp->if_flags & IFF_UP) {
1872 if ((sc->sc_ifflags ^ ifp->if_flags) == IFF_PROMISC)
1873 gem_setladrf(sc);
1874 else
1875 gem_init_locked(sc);
1876 } else {
1876 if (ifp->if_flags & IFF_RUNNING)
1877 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1877 gem_stop(ifp, 0);
1878 }
1879 sc->sc_ifflags = ifp->if_flags;
1880 error = 0;
1881 break;
1882 case SIOCADDMULTI:
1883 case SIOCDELMULTI:
1884 gem_setladrf(sc);

--- 100 unchanged lines hidden ---
1878 gem_stop(ifp, 0);
1879 }
1880 sc->sc_ifflags = ifp->if_flags;
1881 error = 0;
1882 break;
1883 case SIOCADDMULTI:
1884 case SIOCDELMULTI:
1885 gem_setladrf(sc);

--- 100 unchanged lines hidden ---