Deleted Added
full compact
midway.c (68616) midway.c (69152)
1/* $NetBSD: midway.c,v 1.30 1997/09/29 17:40:38 chuck Exp $ */
2/* (sync'd to midway.c 1.68) */
3
4/*
5 *
6 * Copyright (c) 1996 Charles D. Cranor and Washington University.
7 * All rights reserved.
8 *

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

27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
1/* $NetBSD: midway.c,v 1.30 1997/09/29 17:40:38 chuck Exp $ */
2/* (sync'd to midway.c 1.68) */
3
4/*
5 *
6 * Copyright (c) 1996 Charles D. Cranor and Washington University.
7 * All rights reserved.
8 *

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

27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * $FreeBSD: head/sys/dev/en/midway.c 68616 2000-11-11 23:01:44Z bmilekic $
35 * $FreeBSD: head/sys/dev/en/midway.c 69152 2000-11-25 07:35:38Z jlemon $
36 */
37
38/*
39 *
40 * m i d w a y . c e n i 1 5 5 d r i v e r
41 *
42 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
43 * started: spring, 1996 (written from scratch).

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

1361 * will free us!
1362 */
1363
1364 for (lcv = 0 ; lcv < MID_N_VC ; lcv++) {
1365 if (sc->rxvc2slot[lcv] == RX_NONE)
1366 continue;
1367 slot = sc->rxvc2slot[lcv];
1368 while (1) {
36 */
37
38/*
39 *
40 * m i d w a y . c e n i 1 5 5 d r i v e r
41 *
42 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
43 * started: spring, 1996 (written from scratch).

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

1361 * will free us!
1362 */
1363
1364 for (lcv = 0 ; lcv < MID_N_VC ; lcv++) {
1365 if (sc->rxvc2slot[lcv] == RX_NONE)
1366 continue;
1367 slot = sc->rxvc2slot[lcv];
1368 while (1) {
1369 IF_DEQUEUE(&sc->rxslot[slot].indma, m);
1369 _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
1370 if (m == NULL)
1371 break; /* >>> exit 'while(1)' here <<< */
1372 m_freem(m);
1373 }
1374 while (1) {
1370 if (m == NULL)
1371 break; /* >>> exit 'while(1)' here <<< */
1372 m_freem(m);
1373 }
1374 while (1) {
1375 IF_DEQUEUE(&sc->rxslot[slot].q, m);
1375 _IF_DEQUEUE(&sc->rxslot[slot].q, m);
1376 if (m == NULL)
1377 break; /* >>> exit 'while(1)' here <<< */
1378 m_freem(m);
1379 }
1380 sc->rxslot[slot].oth_flags &= ~ENOTHER_SWSL;
1381 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) {
1382 sc->rxslot[slot].oth_flags = ENOTHER_FREE;
1383 sc->rxvc2slot[lcv] = RX_NONE;

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

1388 }
1389
1390 /*
1391 * xmit: dump everything
1392 */
1393
1394 for (lcv = 0 ; lcv < EN_NTX ; lcv++) {
1395 while (1) {
1376 if (m == NULL)
1377 break; /* >>> exit 'while(1)' here <<< */
1378 m_freem(m);
1379 }
1380 sc->rxslot[slot].oth_flags &= ~ENOTHER_SWSL;
1381 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) {
1382 sc->rxslot[slot].oth_flags = ENOTHER_FREE;
1383 sc->rxvc2slot[lcv] = RX_NONE;

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

1388 }
1389
1390 /*
1391 * xmit: dump everything
1392 */
1393
1394 for (lcv = 0 ; lcv < EN_NTX ; lcv++) {
1395 while (1) {
1396 IF_DEQUEUE(&sc->txslot[lcv].indma, m);
1396 _IF_DEQUEUE(&sc->txslot[lcv].indma, m);
1397 if (m == NULL)
1398 break; /* >>> exit 'while(1)' here <<< */
1399 m_freem(m);
1400 }
1401 while (1) {
1397 if (m == NULL)
1398 break; /* >>> exit 'while(1)' here <<< */
1399 m_freem(m);
1400 }
1401 while (1) {
1402 IF_DEQUEUE(&sc->txslot[lcv].q, m);
1402 _IF_DEQUEUE(&sc->txslot[lcv].q, m);
1403 if (m == NULL)
1404 break; /* >>> exit 'while(1)' here <<< */
1405 m_freem(m);
1406 }
1407
1408 sc->txslot[lcv].mbsize = 0;
1409 }
1410

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

1720#ifdef EN_DEBUG
1721 printf("%s: tx%d: VPI=%d, VCI=%d, FLAGS=0x%x, speed=0x%x\n",
1722 sc->sc_dev.dv_xname, txchan, atm_vpi, atm_vci, atm_flags,
1723 sc->txspeed[atm_vci]);
1724 printf(" adjusted mlen=%d, mbsize=%d\n", mlen,
1725 sc->txslot[txchan].mbsize);
1726#endif
1727
1403 if (m == NULL)
1404 break; /* >>> exit 'while(1)' here <<< */
1405 m_freem(m);
1406 }
1407
1408 sc->txslot[lcv].mbsize = 0;
1409 }
1410

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

1720#ifdef EN_DEBUG
1721 printf("%s: tx%d: VPI=%d, VCI=%d, FLAGS=0x%x, speed=0x%x\n",
1722 sc->sc_dev.dv_xname, txchan, atm_vpi, atm_vci, atm_flags,
1723 sc->txspeed[atm_vci]);
1724 printf(" adjusted mlen=%d, mbsize=%d\n", mlen,
1725 sc->txslot[txchan].mbsize);
1726#endif
1727
1728 IF_ENQUEUE(&sc->txslot[txchan].q, m);
1728 _IF_ENQUEUE(&sc->txslot[txchan].q, m);
1729
1730 en_txdma(sc, txchan);
1731
1732 }
1733 /*NOTREACHED*/
1734}
1735
1736

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

2088#endif
2089 return; /* >>> exit here if out of dtqs <<< */
2090 }
2091
2092 /*
2093 * it is a go, commit! dequeue mbuf start working on the xfer.
2094 */
2095
1729
1730 en_txdma(sc, txchan);
1731
1732 }
1733 /*NOTREACHED*/
1734}
1735
1736

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

2088#endif
2089 return; /* >>> exit here if out of dtqs <<< */
2090 }
2091
2092 /*
2093 * it is a go, commit! dequeue mbuf start working on the xfer.
2094 */
2095
2096 IF_DEQUEUE(&sc->txslot[chan].q, tmp);
2096 _IF_DEQUEUE(&sc->txslot[chan].q, tmp);
2097#ifdef EN_DIAG
2098 if (launch.t != tmp)
2099 panic("en dequeue");
2100#endif /* EN_DIAG */
2101
2102 /*
2103 * launch!
2104 */

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

2140 launch.t->m_len += size;
2141 }
2142#endif /* NBPF > 0 */
2143 /*
2144 * do some housekeeping and get the next packet
2145 */
2146
2147 sc->txslot[chan].bfree -= launch.need;
2097#ifdef EN_DIAG
2098 if (launch.t != tmp)
2099 panic("en dequeue");
2100#endif /* EN_DIAG */
2101
2102 /*
2103 * launch!
2104 */

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

2140 launch.t->m_len += size;
2141 }
2142#endif /* NBPF > 0 */
2143 /*
2144 * do some housekeeping and get the next packet
2145 */
2146
2147 sc->txslot[chan].bfree -= launch.need;
2148 IF_ENQUEUE(&sc->txslot[chan].indma, launch.t);
2148 _IF_ENQUEUE(&sc->txslot[chan].indma, launch.t);
2149 goto again;
2150
2151 /*
2152 * END of txdma loop!
2153 */
2154
2155 /*
2156 * error handles
2157 */
2158
2159dequeue_drop:
2149 goto again;
2150
2151 /*
2152 * END of txdma loop!
2153 */
2154
2155 /*
2156 * error handles
2157 */
2158
2159dequeue_drop:
2160 IF_DEQUEUE(&sc->txslot[chan].q, tmp);
2160 _IF_DEQUEUE(&sc->txslot[chan].q, tmp);
2161 if (launch.t != tmp)
2162 panic("en dequeue drop");
2163 m_freem(launch.t);
2164 sc->txslot[chan].mbsize -= launch.mlen;
2165 goto again;
2166}
2167
2168

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

2619 printf("%s: cleared need DTQ condition\n", sc->sc_dev.dv_xname);
2620#endif
2621 }
2622 while (idx != val) {
2623 sc->dtq_free++;
2624 if ((dtq = sc->dtq[idx]) != 0) {
2625 sc->dtq[idx] = 0; /* don't forget to zero it out when done */
2626 slot = EN_DQ_SLOT(dtq);
2161 if (launch.t != tmp)
2162 panic("en dequeue drop");
2163 m_freem(launch.t);
2164 sc->txslot[chan].mbsize -= launch.mlen;
2165 goto again;
2166}
2167
2168

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

2619 printf("%s: cleared need DTQ condition\n", sc->sc_dev.dv_xname);
2620#endif
2621 }
2622 while (idx != val) {
2623 sc->dtq_free++;
2624 if ((dtq = sc->dtq[idx]) != 0) {
2625 sc->dtq[idx] = 0; /* don't forget to zero it out when done */
2626 slot = EN_DQ_SLOT(dtq);
2627 IF_DEQUEUE(&sc->txslot[slot].indma, m);
2627 _IF_DEQUEUE(&sc->txslot[slot].indma, m);
2628 if (!m) panic("enintr: dtqsync");
2629 sc->txslot[slot].mbsize -= EN_DQ_LEN(dtq);
2630#ifdef EN_DEBUG
2631 printf("%s: tx%d: free %d dma bytes, mbsize now %d\n",
2632 sc->sc_dev.dv_xname, slot, EN_DQ_LEN(dtq),
2633 sc->txslot[slot].mbsize);
2634#endif
2635 m_freem(m);

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

2670 while (idx != val) {
2671 sc->drq_free++;
2672 if ((drq = sc->drq[idx]) != 0) {
2673 sc->drq[idx] = 0; /* don't forget to zero it out when done */
2674 slot = EN_DQ_SLOT(drq);
2675 if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */
2676 m = NULL;
2677 } else {
2628 if (!m) panic("enintr: dtqsync");
2629 sc->txslot[slot].mbsize -= EN_DQ_LEN(dtq);
2630#ifdef EN_DEBUG
2631 printf("%s: tx%d: free %d dma bytes, mbsize now %d\n",
2632 sc->sc_dev.dv_xname, slot, EN_DQ_LEN(dtq),
2633 sc->txslot[slot].mbsize);
2634#endif
2635 m_freem(m);

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

2670 while (idx != val) {
2671 sc->drq_free++;
2672 if ((drq = sc->drq[idx]) != 0) {
2673 sc->drq[idx] = 0; /* don't forget to zero it out when done */
2674 slot = EN_DQ_SLOT(drq);
2675 if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */
2676 m = NULL;
2677 } else {
2678 IF_DEQUEUE(&sc->rxslot[slot].indma, m);
2678 _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
2679 if (!m)
2680 panic("enintr: drqsync: %s: lost mbuf in slot %d!",
2681 sc->sc_dev.dv_xname, slot);
2682 }
2683 /* do something with this mbuf */
2684 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) { /* drain? */
2685 if (m)
2686 m_freem(m);

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

2973#ifdef EN_DEBUG
2974 printf("%s: rx%d: q'ed mbuf %p not ours\n",
2975 sc->sc_dev.dv_xname, slot, m);
2976#endif
2977 m = NULL; /* wasn't ours */
2978 EN_COUNT(sc->rxqnotus);
2979 } else {
2980 EN_COUNT(sc->rxqus);
2679 if (!m)
2680 panic("enintr: drqsync: %s: lost mbuf in slot %d!",
2681 sc->sc_dev.dv_xname, slot);
2682 }
2683 /* do something with this mbuf */
2684 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) { /* drain? */
2685 if (m)
2686 m_freem(m);

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

2973#ifdef EN_DEBUG
2974 printf("%s: rx%d: q'ed mbuf %p not ours\n",
2975 sc->sc_dev.dv_xname, slot, m);
2976#endif
2977 m = NULL; /* wasn't ours */
2978 EN_COUNT(sc->rxqnotus);
2979 } else {
2980 EN_COUNT(sc->rxqus);
2981 IF_DEQUEUE(&sc->rxslot[slot].q, m);
2981 _IF_DEQUEUE(&sc->rxslot[slot].q, m);
2982 drqneed = sav[1];
2983#ifdef EN_DEBUG
2984 printf("%s: rx%d: recovered q'ed mbuf %p (drqneed=%d)\n",
2985 sc->sc_dev.dv_xname, slot, m, drqneed);
2986#endif
2987 }
2988 }
2989

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

3021#ifdef EN_DEBUG
3022 printf("%s: rx%d: out of DRQs *and* mbufs!\n", sc->sc_dev.dv_xname, slot);
3023#endif
3024 return; /* >>> exit here if out of both mbufs and DRQs <<< */
3025 }
3026 sav = mtod(m, u_int32_t *);
3027 sav[0] = cur;
3028 sav[1] = drqneed;
2982 drqneed = sav[1];
2983#ifdef EN_DEBUG
2984 printf("%s: rx%d: recovered q'ed mbuf %p (drqneed=%d)\n",
2985 sc->sc_dev.dv_xname, slot, m, drqneed);
2986#endif
2987 }
2988 }
2989

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

3021#ifdef EN_DEBUG
3022 printf("%s: rx%d: out of DRQs *and* mbufs!\n", sc->sc_dev.dv_xname, slot);
3023#endif
3024 return; /* >>> exit here if out of both mbufs and DRQs <<< */
3025 }
3026 sav = mtod(m, u_int32_t *);
3027 sav[0] = cur;
3028 sav[1] = drqneed;
3029 IF_ENQUEUE(&sc->rxslot[slot].q, m);
3029 _IF_ENQUEUE(&sc->rxslot[slot].q, m);
3030 EN_COUNT(sc->rxdrqout);
3031#ifdef EN_DEBUG
3032 printf("%s: rx%d: out of DRQs\n", sc->sc_dev.dv_xname, slot);
3033#endif
3034 return; /* >>> exit here if out of DRQs <<< */
3035 }
3036
3037 /*

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

3213 if (m) {
3214 if (!raw) {
3215 cnt = MID_RBD_SIZE;
3216 if (!aal5) cnt += MID_CHDR_SIZE;
3217 m->m_len -= cnt; /* chop! */
3218 m->m_pkthdr.len -= cnt;
3219 m->m_data += cnt;
3220 }
3030 EN_COUNT(sc->rxdrqout);
3031#ifdef EN_DEBUG
3032 printf("%s: rx%d: out of DRQs\n", sc->sc_dev.dv_xname, slot);
3033#endif
3034 return; /* >>> exit here if out of DRQs <<< */
3035 }
3036
3037 /*

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

3213 if (m) {
3214 if (!raw) {
3215 cnt = MID_RBD_SIZE;
3216 if (!aal5) cnt += MID_CHDR_SIZE;
3217 m->m_len -= cnt; /* chop! */
3218 m->m_pkthdr.len -= cnt;
3219 m->m_data += cnt;
3220 }
3221 IF_ENQUEUE(&sc->rxslot[slot].indma, m);
3221 _IF_ENQUEUE(&sc->rxslot[slot].indma, m);
3222 }
3223 sc->rxslot[slot].cur = cur; /* update master copy of 'cur' */
3224
3225#ifdef EN_DEBUG
3226 printf("%s: rx%d: vci%d: DONE! cur now =0x%x\n",
3227 sc->sc_dev.dv_xname, slot, vci, cur);
3228#endif
3229

--- 237 unchanged lines hidden ---
3222 }
3223 sc->rxslot[slot].cur = cur; /* update master copy of 'cur' */
3224
3225#ifdef EN_DEBUG
3226 printf("%s: rx%d: vci%d: DONE! cur now =0x%x\n",
3227 sc->sc_dev.dv_xname, slot, vci, cur);
3228#endif
3229

--- 237 unchanged lines hidden ---