Deleted Added
full compact
if_de.c (68021) if_de.c (69152)
1/* $NetBSD: if_de.c,v 1.86 1999/06/01 19:17:59 thorpej Exp $ */
2
1/* $NetBSD: if_de.c,v 1.86 1999/06/01 19:17:59 thorpej Exp $ */
2
3/* $FreeBSD: head/sys/dev/de/if_de.c 68021 2000-10-31 01:25:10Z markm $ */
3/* $FreeBSD: head/sys/dev/de/if_de.c 69152 2000-11-25 07:35:38Z jlemon $ */
4
5/*-
6 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:

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

3196 /*
3197 * Free all the mbufs that were on the transmit ring.
3198 */
3199 for (;;) {
3200#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3201 bus_dmamap_t map;
3202#endif
3203 struct mbuf *m;
4
5/*-
6 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:

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

3196 /*
3197 * Free all the mbufs that were on the transmit ring.
3198 */
3199 for (;;) {
3200#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3201 bus_dmamap_t map;
3202#endif
3203 struct mbuf *m;
3204 IF_DEQUEUE(&sc->tulip_txq, m);
3204 _IF_DEQUEUE(&sc->tulip_txq, m);
3205 if (m == NULL)
3206 break;
3207#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3208 map = M_GETCTX(m, bus_dmamap_t);
3209 bus_dmamap_unload(sc->tulip_dmatag, map);
3210 sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
3211#endif
3212 m_freem(m);

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

3242 0, sc->tulip_rxdescmap->dm_mapsize,
3243 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
3244#endif
3245 for (;;) {
3246#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3247 bus_dmamap_t map;
3248#endif
3249 struct mbuf *m;
3205 if (m == NULL)
3206 break;
3207#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3208 map = M_GETCTX(m, bus_dmamap_t);
3209 bus_dmamap_unload(sc->tulip_dmatag, map);
3210 sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
3211#endif
3212 m_freem(m);

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

3242 0, sc->tulip_rxdescmap->dm_mapsize,
3243 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
3244#endif
3245 for (;;) {
3246#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3247 bus_dmamap_t map;
3248#endif
3249 struct mbuf *m;
3250 IF_DEQUEUE(&sc->tulip_rxq, m);
3250 _IF_DEQUEUE(&sc->tulip_rxq, m);
3251 if (m == NULL)
3252 break;
3253#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3254 map = M_GETCTX(m, bus_dmamap_t);
3255 bus_dmamap_unload(sc->tulip_dmatag, map);
3256 sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
3257#endif
3258 m_freem(m);

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

3377 break;
3378
3379 /*
3380 * 90% of the packets will fit in one descriptor. So we optimize
3381 * for that case.
3382 */
3383 TULIP_RXDESC_POSTSYNC(sc, eop, sizeof(*eop));
3384 if ((((volatile tulip_desc_t *) eop)->d_status & (TULIP_DSTS_OWNER|TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) == (TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) {
3251 if (m == NULL)
3252 break;
3253#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3254 map = M_GETCTX(m, bus_dmamap_t);
3255 bus_dmamap_unload(sc->tulip_dmatag, map);
3256 sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
3257#endif
3258 m_freem(m);

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

3377 break;
3378
3379 /*
3380 * 90% of the packets will fit in one descriptor. So we optimize
3381 * for that case.
3382 */
3383 TULIP_RXDESC_POSTSYNC(sc, eop, sizeof(*eop));
3384 if ((((volatile tulip_desc_t *) eop)->d_status & (TULIP_DSTS_OWNER|TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) == (TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) {
3385 IF_DEQUEUE(&sc->tulip_rxq, ms);
3385 _IF_DEQUEUE(&sc->tulip_rxq, ms);
3386 me = ms;
3387 } else {
3388 /*
3389 * If still owned by the TULIP, don't touch it.
3390 */
3391 if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
3392 break;
3393

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

3417 * this will be the only one we need to dequeue. However, if the
3418 * packet consumed multiple descriptors, then we need to dequeue
3419 * those buffers and chain to the starting mbuf. All buffers but
3420 * the last buffer have the same length so we can set that now.
3421 * (we add to last_offset instead of multiplying since we normally
3422 * won't go into the loop and thereby saving a ourselves from
3423 * doing a multiplication by 0 in the normal case).
3424 */
3386 me = ms;
3387 } else {
3388 /*
3389 * If still owned by the TULIP, don't touch it.
3390 */
3391 if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
3392 break;
3393

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

3417 * this will be the only one we need to dequeue. However, if the
3418 * packet consumed multiple descriptors, then we need to dequeue
3419 * those buffers and chain to the starting mbuf. All buffers but
3420 * the last buffer have the same length so we can set that now.
3421 * (we add to last_offset instead of multiplying since we normally
3422 * won't go into the loop and thereby saving a ourselves from
3423 * doing a multiplication by 0 in the normal case).
3424 */
3425 IF_DEQUEUE(&sc->tulip_rxq, ms);
3425 _IF_DEQUEUE(&sc->tulip_rxq, ms);
3426 for (me = ms; total_len > 0; total_len--) {
3427#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3428 map = M_GETCTX(me, bus_dmamap_t);
3429 TULIP_RXMAP_POSTSYNC(sc, map);
3430 bus_dmamap_unload(sc->tulip_dmatag, map);
3431 sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
3432#if defined(DIAGNOSTIC)
3433 M_SETCTX(me, NULL);
3434#endif
3435#endif /* TULIP_BUS_DMA */
3436 me->m_len = TULIP_RX_BUFLEN;
3437 last_offset += TULIP_RX_BUFLEN;
3426 for (me = ms; total_len > 0; total_len--) {
3427#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
3428 map = M_GETCTX(me, bus_dmamap_t);
3429 TULIP_RXMAP_POSTSYNC(sc, map);
3430 bus_dmamap_unload(sc->tulip_dmatag, map);
3431 sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
3432#if defined(DIAGNOSTIC)
3433 M_SETCTX(me, NULL);
3434#endif
3435#endif /* TULIP_BUS_DMA */
3436 me->m_len = TULIP_RX_BUFLEN;
3437 last_offset += TULIP_RX_BUFLEN;
3438 IF_DEQUEUE(&sc->tulip_rxq, me->m_next);
3438 _IF_DEQUEUE(&sc->tulip_rxq, me->m_next);
3439 me = me->m_next;
3440 }
3441 }
3442
3443 /*
3444 * Now get the size of received packet (minus the CRC).
3445 */
3446 total_len = ((eop->d_status >> 16) & 0x7FFF) - 4;

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

3639 nextout->d_length1 = TULIP_RX_BUFLEN;
3640#endif /* TULIP_BUS_DMA */
3641 nextout->d_status = TULIP_DSTS_OWNER;
3642 TULIP_RXDESC_POSTSYNC(sc, nextout, sizeof(u_int32_t));
3643 if (++ri->ri_nextout == ri->ri_last)
3644 ri->ri_nextout = ri->ri_first;
3645 me = ms->m_next;
3646 ms->m_next = NULL;
3439 me = me->m_next;
3440 }
3441 }
3442
3443 /*
3444 * Now get the size of received packet (minus the CRC).
3445 */
3446 total_len = ((eop->d_status >> 16) & 0x7FFF) - 4;

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

3639 nextout->d_length1 = TULIP_RX_BUFLEN;
3640#endif /* TULIP_BUS_DMA */
3641 nextout->d_status = TULIP_DSTS_OWNER;
3642 TULIP_RXDESC_POSTSYNC(sc, nextout, sizeof(u_int32_t));
3643 if (++ri->ri_nextout == ri->ri_last)
3644 ri->ri_nextout = ri->ri_first;
3645 me = ms->m_next;
3646 ms->m_next = NULL;
3647 IF_ENQUEUE(&sc->tulip_rxq, ms);
3647 _IF_ENQUEUE(&sc->tulip_rxq, ms);
3648 } while ((ms = me) != NULL);
3649
3650 if (sc->tulip_rxq.ifq_len >= TULIP_RXQ_TARGET)
3651 sc->tulip_flags &= ~TULIP_RXBUFSLOW;
3652 TULIP_PERFEND(rxget);
3653 }
3654
3655#if defined(TULIP_DEBUG)

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

3697 sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
3698 sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
3699 TULIP_CSR_WRITE(sc, csr_status, TULIP_STS_RXSTOPPED);
3700 TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
3701 TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
3702 }
3703 } else {
3704 const u_int32_t d_status = ri->ri_nextin->d_status;
3648 } while ((ms = me) != NULL);
3649
3650 if (sc->tulip_rxq.ifq_len >= TULIP_RXQ_TARGET)
3651 sc->tulip_flags &= ~TULIP_RXBUFSLOW;
3652 TULIP_PERFEND(rxget);
3653 }
3654
3655#if defined(TULIP_DEBUG)

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

3697 sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
3698 sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
3699 TULIP_CSR_WRITE(sc, csr_status, TULIP_STS_RXSTOPPED);
3700 TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
3701 TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
3702 }
3703 } else {
3704 const u_int32_t d_status = ri->ri_nextin->d_status;
3705 IF_DEQUEUE(&sc->tulip_txq, m);
3705 _IF_DEQUEUE(&sc->tulip_txq, m);
3706 if (m != NULL) {
3707#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3708 bus_dmamap_t map = M_GETCTX(m, bus_dmamap_t);
3709 TULIP_TXMAP_POSTSYNC(sc, map);
3710 sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
3711#endif /* TULIP_BUS_DMA */
3712 m_freem(m);
3713#if defined(TULIP_DEBUG)

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

4338 */
4339 if (sc->tulip_if.if_bpf != NULL)
4340 bpf_mtap(&sc->tulip_if, m);
4341
4342 /*
4343 * The descriptors have been filled in. Now get ready
4344 * to transmit.
4345 */
3706 if (m != NULL) {
3707#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
3708 bus_dmamap_t map = M_GETCTX(m, bus_dmamap_t);
3709 TULIP_TXMAP_POSTSYNC(sc, map);
3710 sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
3711#endif /* TULIP_BUS_DMA */
3712 m_freem(m);
3713#if defined(TULIP_DEBUG)

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

4338 */
4339 if (sc->tulip_if.if_bpf != NULL)
4340 bpf_mtap(&sc->tulip_if, m);
4341
4342 /*
4343 * The descriptors have been filled in. Now get ready
4344 * to transmit.
4345 */
4346 IF_ENQUEUE(&sc->tulip_txq, m);
4346 _IF_ENQUEUE(&sc->tulip_txq, m);
4347 m = NULL;
4348
4349 /*
4350 * Make sure the next descriptor after this packet is owned
4351 * by us since it may have been set up above if we ran out
4352 * of room in the ring.
4353 */
4354 nextout->d_status = 0;

--- 919 unchanged lines hidden ---
4347 m = NULL;
4348
4349 /*
4350 * Make sure the next descriptor after this packet is owned
4351 * by us since it may have been set up above if we ran out
4352 * of room in the ring.
4353 */
4354 nextout->d_status = 0;

--- 919 unchanged lines hidden ---