Deleted Added
sdiff udiff text old ( 66006 ) new ( 66007 )
full compact
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Modifications to support NetBSD and media selection:
6 * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: head/sys/dev/fxp/if_fxp.c 66006 2000-09-17 22:01:21Z cp $
31 */
32
33/*
34 * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>

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

216 FXP_MEDIA_DEFAULT_DEFMEDIA },
217};
218#define NFXPMEDIA (sizeof(fxp_media) / sizeof(fxp_media[0]))
219
220static int fxp_mediachange __P((struct ifnet *));
221static void fxp_mediastatus __P((struct ifnet *, struct ifmediareq *));
222static void fxp_set_media __P((struct fxp_softc *, int));
223static __inline void fxp_scb_wait __P((struct fxp_softc *));
224static FXP_INTR_TYPE fxp_intr __P((void *));
225static void fxp_start __P((struct ifnet *));
226static int fxp_ioctl __P((struct ifnet *,
227 FXP_IOCTLCMD_TYPE, caddr_t));
228static void fxp_init __P((void *));
229static void fxp_stop __P((struct fxp_softc *));
230static void fxp_watchdog __P((struct ifnet *));
231static int fxp_add_rfabuf __P((struct fxp_softc *, struct mbuf *));

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

285 * completed).
286 */
287static __inline void
288fxp_scb_wait(sc)
289 struct fxp_softc *sc;
290{
291 int i = 10000;
292
293 while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i);
294}
295
296/*************************************************************
297 * Operating system-specific autoconfiguration glue
298 *************************************************************/
299
300#if defined(__NetBSD__)
301
302#ifdef __BROKEN_INDIRECT_CONFIG
303static int fxp_match __P((struct device *, void *, void *));

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

682 * Make sure that DMA is disabled prior to reboot. Not doing
683 * do could allow DMA to corrupt kernel memory during the
684 * reboot before the driver initializes.
685 */
686 fxp_stop((struct fxp_softc *) device_get_softc(dev));
687 return 0;
688}
689
690static device_method_t fxp_methods[] = {
691 /* Device interface */
692 DEVMETHOD(device_probe, fxp_probe),
693 DEVMETHOD(device_attach, fxp_attach),
694 DEVMETHOD(device_detach, fxp_detach),
695 DEVMETHOD(device_shutdown, fxp_shutdown),
696
697 { 0, 0 }
698};
699
700static driver_t fxp_driver = {
701 "fxp",
702 fxp_methods,
703 sizeof(struct fxp_softc),

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

1121 u_int8_t statack;
1122#if defined(__NetBSD__)
1123 int claimed = 0;
1124#else
1125
1126 FXP_LOCK(sc, s);
1127#endif
1128
1129 while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
1130#if defined(__NetBSD__)
1131 claimed = 1;
1132#endif
1133 /*
1134 * First ACK all the interrupts in this pass.
1135 */
1136 CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, statack);
1137

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

1359 struct ifnet *ifp = &sc->sc_if;
1360 struct fxp_cb_tx *txp;
1361 int i;
1362
1363#if !defined(__NetBSD__)
1364 FXP_LOCK(sc, s);
1365#endif
1366
1367 /*
1368 * Cancel stats updater.
1369 */
1370 untimeout(fxp_stats_update, sc, sc->stat_ch);
1371
1372 /*
1373 * Issue software reset
1374 */

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

1402 * This "can't happen" - we're at splimp()
1403 * and we just freed all the buffers we need
1404 * above.
1405 */
1406 panic("fxp_stop: no buffers!");
1407 }
1408 }
1409
1410 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
1411 ifp->if_timer = 0;
1412#if !defined(__NetBSD__)
1413 FXP_UNLOCK(sc, s);
1414#endif
1415}
1416
1417/*
1418 * Watchdog/transmission transmit timeout handler. Called when a
1419 * transmission is started on the interface, but no interrupt is

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

1521
1522 /*
1523 * Start the config command/DMA.
1524 */
1525 fxp_scb_wait(sc);
1526 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, vtophys(&cbp->cb_status));
1527 CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
1528 /* ...and wait for it to complete. */
1529 while (!(cbp->cb_status & FXP_CB_STATUS_C));
1530
1531 /*
1532 * Now initialize the station address. Temporarily use the TxCB
1533 * memory area like we did above for the config CB.
1534 */
1535 cb_ias = (struct fxp_cb_ias *) sc->cbl_base;
1536 cb_ias->cb_status = 0;
1537 cb_ias->cb_command = FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL;

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

1545#endif /* __NetBSD__ */
1546
1547 /*
1548 * Start the IAS (Individual Address Setup) command/DMA.
1549 */
1550 fxp_scb_wait(sc);
1551 CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
1552 /* ...and wait for it to complete. */
1553 while (!(cb_ias->cb_status & FXP_CB_STATUS_C));
1554
1555 /*
1556 * Initialize transmit control block (TxCB) list.
1557 */
1558
1559 txp = sc->cbl_base;
1560 bzero(txp, sizeof(struct fxp_cb_tx) * FXP_NTXCB);
1561 for (i = 0; i < FXP_NTXCB; i++) {

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

1985static void
1986fxp_mc_setup(sc)
1987 struct fxp_softc *sc;
1988{
1989 struct fxp_cb_mcs *mcsp = sc->mcsp;
1990 struct ifnet *ifp = &sc->sc_if;
1991 struct ifmultiaddr *ifma;
1992 int nmcasts;
1993
1994 /*
1995 * If there are queued commands, we must wait until they are all
1996 * completed. If we are already waiting, then add a NOP command
1997 * with interrupt option so that we're notified when all commands
1998 * have been completed - fxp_start() ensures that no additional
1999 * TX commands will be added when need_mcsetup is true.
2000 */

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

2067 mcsp->mc_cnt = nmcasts * 6;
2068 sc->cbl_first = sc->cbl_last = (struct fxp_cb_tx *) mcsp;
2069 sc->tx_queued = 1;
2070
2071 /*
2072 * Wait until command unit is not active. This should never
2073 * be the case when nothing is queued, but make sure anyway.
2074 */
2075 while ((CSR_READ_1(sc, FXP_CSR_SCB_RUSCUS) >> 6) ==
2076 FXP_SCB_CUS_ACTIVE) ;
2077
2078 /*
2079 * Start the multicast setup command.
2080 */
2081 fxp_scb_wait(sc);
2082 CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, vtophys(&mcsp->cb_status));
2083 CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
2084
2085 ifp->if_timer = 2;
2086 return;
2087}