Deleted Added
full compact
midway.c (114201) midway.c (114739)
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 114201 2003-04-29 08:07:44Z harti $
35 * $FreeBSD: head/sys/dev/en/midway.c 114739 2003-05-05 16:35:52Z harti $
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).

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

86#define EN_DDBHOOK 1
87
88/*
89 * This macro removes almost all the EN_DEBUG conditionals in the code that make
90 * to code a good deal less readable.
91 */
92#define DBG(SC, FL, PRINT) do { \
93 if ((SC)->debug & DBG_##FL) { \
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).

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

86#define EN_DDBHOOK 1
87
88/*
89 * This macro removes almost all the EN_DEBUG conditionals in the code that make
90 * to code a good deal less readable.
91 */
92#define DBG(SC, FL, PRINT) do { \
93 if ((SC)->debug & DBG_##FL) { \
94 if_printf(&(SC)->enif, "%s: "#FL": ", __func__); \
94 if_printf(&(SC)->ifatm.ifnet, "%s: "#FL": ", __func__); \
95 printf PRINT; \
96 printf("\n"); \
97 } \
98 } while (0)
99
100enum {
101 DBG_INIT = 0x0001, /* debug attach/detach */
102 DBG_TX = 0x0002, /* debug transmitting */

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

132#include <sys/socket.h>
133#include <sys/mbuf.h>
134#include <sys/endian.h>
135#include <sys/sbuf.h>
136#include <sys/stdint.h>
137#include <vm/uma.h>
138
139#include <net/if.h>
95 printf PRINT; \
96 printf("\n"); \
97 } \
98 } while (0)
99
100enum {
101 DBG_INIT = 0x0001, /* debug attach/detach */
102 DBG_TX = 0x0002, /* debug transmitting */

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

132#include <sys/socket.h>
133#include <sys/mbuf.h>
134#include <sys/endian.h>
135#include <sys/sbuf.h>
136#include <sys/stdint.h>
137#include <vm/uma.h>
138
139#include <net/if.h>
140#include <net/if_media.h>
140#include <net/if_atm.h>
141
142#if defined(INET) || defined(INET6)
143#include <netinet/in.h>
144#include <netinet/if_atm.h>
145#endif
146
147#ifdef NATM

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

385en_dump_packet(struct en_softc *sc, struct mbuf *m)
386{
387 int plen = m->m_pkthdr.len;
388 u_int pos = 0;
389 u_int totlen = 0;
390 int len;
391 u_char *ptr;
392
141#include <net/if_atm.h>
142
143#if defined(INET) || defined(INET6)
144#include <netinet/in.h>
145#include <netinet/if_atm.h>
146#endif
147
148#ifdef NATM

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

386en_dump_packet(struct en_softc *sc, struct mbuf *m)
387{
388 int plen = m->m_pkthdr.len;
389 u_int pos = 0;
390 u_int totlen = 0;
391 int len;
392 u_char *ptr;
393
393 if_printf(&sc->enif, "packet len=%d", plen);
394 if_printf(&sc->ifatm.ifnet, "packet len=%d", plen);
394 while (m != NULL) {
395 totlen += m->m_len;
396 ptr = mtod(m, u_char *);
397 for (len = 0; len < m->m_len; len++, pos++, ptr++) {
398 if (pos % 16 == 8)
399 printf(" ");
400 if (pos % 16 == 0)
401 printf("\n");

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

439 int err;
440
441 if (map->sc == NULL)
442 map->sc = sc;
443
444 if (!(map->flags & ENMAP_ALLOC)) {
445 err = bus_dmamap_create(sc->txtag, 0, &map->map);
446 if (err != 0)
395 while (m != NULL) {
396 totlen += m->m_len;
397 ptr = mtod(m, u_char *);
398 for (len = 0; len < m->m_len; len++, pos++, ptr++) {
399 if (pos % 16 == 8)
400 printf(" ");
401 if (pos % 16 == 0)
402 printf("\n");

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

440 int err;
441
442 if (map->sc == NULL)
443 map->sc = sc;
444
445 if (!(map->flags & ENMAP_ALLOC)) {
446 err = bus_dmamap_create(sc->txtag, 0, &map->map);
447 if (err != 0)
447 if_printf(&sc->enif, "cannot create DMA map %d\n", err);
448 if_printf(&sc->ifatm.ifnet,
449 "cannot create DMA map %d\n", err);
448 else
449 map->flags |= ENMAP_ALLOC;
450 }
451 map->flags &= ~ENMAP_LOADED;
452}
453
454/*
455 * Map destructor.

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

748 */
749 error = bus_dmamap_load_mbuf(sc->txtag, map->map, tx.m,
750 en_txdma_load, &tx, 0);
751
752 if (lastm != NULL)
753 lastm->m_next = NULL;
754
755 if (error != 0) {
450 else
451 map->flags |= ENMAP_ALLOC;
452 }
453 map->flags &= ~ENMAP_LOADED;
454}
455
456/*
457 * Map destructor.

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

750 */
751 error = bus_dmamap_load_mbuf(sc->txtag, map->map, tx.m,
752 en_txdma_load, &tx, 0);
753
754 if (lastm != NULL)
755 lastm->m_next = NULL;
756
757 if (error != 0) {
756 if_printf(&sc->enif, "loading TX map failed %d\n", error);
758 if_printf(&sc->ifatm.ifnet, "loading TX map failed %d\n",
759 error);
757 goto dequeue_drop;
758 }
759 map->flags |= ENMAP_LOADED;
760 if (tx.wait) {
761 /* probably not enough space */
762 bus_dmamap_unload(map->sc->txtag, map->map);
763 map->flags &= ~ENMAP_LOADED;
764
765 sc->need_dtqs = 1;
766 DBG(sc, TX, ("tx%td: out of transmit DTQs", slot - sc->txslot));
767 goto waitres;
768 }
769
770 EN_COUNT(sc->stats.launch);
760 goto dequeue_drop;
761 }
762 map->flags |= ENMAP_LOADED;
763 if (tx.wait) {
764 /* probably not enough space */
765 bus_dmamap_unload(map->sc->txtag, map->map);
766 map->flags &= ~ENMAP_LOADED;
767
768 sc->need_dtqs = 1;
769 DBG(sc, TX, ("tx%td: out of transmit DTQs", slot - sc->txslot));
770 goto waitres;
771 }
772
773 EN_COUNT(sc->stats.launch);
771 sc->enif.if_opackets++;
774 sc->ifatm.ifnet.if_opackets++;
772
773#ifdef ENABLE_BPF
775
776#ifdef ENABLE_BPF
774 if (sc->enif.if_bpf != NULL) {
777 if (sc->ifatm.ifnet.if_bpf != NULL) {
775 /*
776 * adjust the top of the mbuf to skip the TBD if present
777 * before passing the packet to bpf.
778 * Also remove padding and the PDU trailer. Assume both of
779 * them to be in the same mbuf. pktlen, m_len and m_data
780 * are not needed anymore so we can change them.
781 */
782 if (tx.flags & TX_HAS_TBD) {
783 tx.m->m_data += MID_TBD_SIZE;
784 tx.m->m_len -= MID_TBD_SIZE;
785 }
786 tx.m->m_pkthdr.len = m_length(tx.m, &lastm);
787 if (tx.m->m_pkthdr.len > tx.datalen) {
788 lastm->m_len -= tx.m->m_pkthdr.len - tx.datalen;
789 tx.m->m_pkthdr.len = tx.datalen;
790 }
791
778 /*
779 * adjust the top of the mbuf to skip the TBD if present
780 * before passing the packet to bpf.
781 * Also remove padding and the PDU trailer. Assume both of
782 * them to be in the same mbuf. pktlen, m_len and m_data
783 * are not needed anymore so we can change them.
784 */
785 if (tx.flags & TX_HAS_TBD) {
786 tx.m->m_data += MID_TBD_SIZE;
787 tx.m->m_len -= MID_TBD_SIZE;
788 }
789 tx.m->m_pkthdr.len = m_length(tx.m, &lastm);
790 if (tx.m->m_pkthdr.len > tx.datalen) {
791 lastm->m_len -= tx.m->m_pkthdr.len - tx.datalen;
792 tx.m->m_pkthdr.len = tx.datalen;
793 }
794
792 BPF_MTAP(&sc->enif, tx.m);
795 BPF_MTAP(&sc->ifatm.ifnet, tx.m);
793 }
794#endif
795
796 /*
797 * do some housekeeping and get the next packet
798 */
799 slot->bfree -= tx.m->m_pkthdr.len;
800 _IF_ENQUEUE(&slot->indma, tx.m);

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

1279 */
1280static void
1281en_reset_ul(struct en_softc *sc)
1282{
1283 struct en_map *map;
1284 struct mbuf *m;
1285 int lcv, slot;
1286
796 }
797#endif
798
799 /*
800 * do some housekeeping and get the next packet
801 */
802 slot->bfree -= tx.m->m_pkthdr.len;
803 _IF_ENQUEUE(&slot->indma, tx.m);

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

1282 */
1283static void
1284en_reset_ul(struct en_softc *sc)
1285{
1286 struct en_map *map;
1287 struct mbuf *m;
1288 int lcv, slot;
1289
1287 if_printf(&sc->enif, "reset\n");
1290 if_printf(&sc->ifatm.ifnet, "reset\n");
1288
1289 if (sc->en_busreset)
1290 sc->en_busreset(sc);
1291 en_write(sc, MID_RESID, 0x0); /* reset hardware */
1292
1293 /*
1294 * recv: dump any mbufs we are dma'ing into, if DRAINing, then a reset
1295 * will free us!

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

1368 * LOCK: locked, needed
1369 */
1370static void
1371en_init(struct en_softc *sc)
1372{
1373 int vc, slot;
1374 uint32_t loc;
1375
1291
1292 if (sc->en_busreset)
1293 sc->en_busreset(sc);
1294 en_write(sc, MID_RESID, 0x0); /* reset hardware */
1295
1296 /*
1297 * recv: dump any mbufs we are dma'ing into, if DRAINing, then a reset
1298 * will free us!

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

1371 * LOCK: locked, needed
1372 */
1373static void
1374en_init(struct en_softc *sc)
1375{
1376 int vc, slot;
1377 uint32_t loc;
1378
1376 if ((sc->enif.if_flags & IFF_UP) == 0) {
1379 if ((sc->ifatm.ifnet.if_flags & IFF_UP) == 0) {
1377 DBG(sc, INIT, ("going down"));
1378 en_reset(sc); /* to be safe */
1380 DBG(sc, INIT, ("going down"));
1381 en_reset(sc); /* to be safe */
1379 sc->enif.if_flags &= ~IFF_RUNNING; /* disable */
1382 sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; /* disable */
1380 return;
1381 }
1382
1383 DBG(sc, INIT, ("going up"));
1383 return;
1384 }
1385
1386 DBG(sc, INIT, ("going up"));
1384 sc->enif.if_flags |= IFF_RUNNING; /* enable */
1387 sc->ifatm.ifnet.if_flags |= IFF_RUNNING; /* enable */
1385
1386 if (sc->en_busreset)
1387 sc->en_busreset(sc);
1388 en_write(sc, MID_RESID, 0x0); /* reset */
1389
1390 /*
1391 * init obmem data structures: vc tab, dma q's, slist.
1392 *

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

1763 slot = EN_DQ_SLOT(drq);
1764 if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */
1765 m = NULL;
1766 map = NULL;
1767 } else {
1768 _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
1769 if (m == NULL)
1770 panic("enintr: drqsync: %s%d: lost mbuf"
1388
1389 if (sc->en_busreset)
1390 sc->en_busreset(sc);
1391 en_write(sc, MID_RESID, 0x0); /* reset */
1392
1393 /*
1394 * init obmem data structures: vc tab, dma q's, slist.
1395 *

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

1766 slot = EN_DQ_SLOT(drq);
1767 if (EN_DQ_LEN(drq) == 0) { /* "JK" trash DMA? */
1768 m = NULL;
1769 map = NULL;
1770 } else {
1771 _IF_DEQUEUE(&sc->rxslot[slot].indma, m);
1772 if (m == NULL)
1773 panic("enintr: drqsync: %s%d: lost mbuf"
1771 " in slot %d!", sc->enif.if_name,
1772 sc->enif.if_unit, slot);
1774 " in slot %d!",
1775 sc->ifatm.ifnet.if_name,
1776 sc->ifatm.ifnet.if_unit, slot);
1773 map = (void *)m->m_pkthdr.rcvif;
1774 uma_zfree(sc->map_zone, map);
1775 }
1776 /* do something with this mbuf */
1777 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) {
1778 /* drain? */
1779 if (m != NULL)
1780 m_freem(m);

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

1797 ATM_PH_FLAGS(&ah) = sc->rxslot[slot].atm_flags;
1798 ATM_PH_VPI(&ah) = 0;
1799 ATM_PH_SETVCI(&ah, sc->rxslot[slot].atm_vci);
1800 DBG(sc, INTR, ("rx%d: rxvci%d: atm_input, "
1801 "mbuf %p, len %d, hand %p", slot,
1802 sc->rxslot[slot].atm_vci, m,
1803 EN_DQ_LEN(drq), sc->rxslot[slot].rxhand));
1804
1777 map = (void *)m->m_pkthdr.rcvif;
1778 uma_zfree(sc->map_zone, map);
1779 }
1780 /* do something with this mbuf */
1781 if (sc->rxslot[slot].oth_flags & ENOTHER_DRAIN) {
1782 /* drain? */
1783 if (m != NULL)
1784 m_freem(m);

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

1801 ATM_PH_FLAGS(&ah) = sc->rxslot[slot].atm_flags;
1802 ATM_PH_VPI(&ah) = 0;
1803 ATM_PH_SETVCI(&ah, sc->rxslot[slot].atm_vci);
1804 DBG(sc, INTR, ("rx%d: rxvci%d: atm_input, "
1805 "mbuf %p, len %d, hand %p", slot,
1806 sc->rxslot[slot].atm_vci, m,
1807 EN_DQ_LEN(drq), sc->rxslot[slot].rxhand));
1808
1805 m->m_pkthdr.rcvif = &sc->enif;
1806 sc->enif.if_ipackets++;
1809 m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
1810 sc->ifatm.ifnet.if_ipackets++;
1807#ifdef EN_DEBUG
1808 if (sc->debug & DBG_IPACKETS)
1809 en_dump_packet(sc, m);
1810#endif
1811#ifdef ENABLE_BPF
1811#ifdef EN_DEBUG
1812 if (sc->debug & DBG_IPACKETS)
1813 en_dump_packet(sc, m);
1814#endif
1815#ifdef ENABLE_BPF
1812 BPF_MTAP(&sc->enif, m);
1816 BPF_MTAP(&sc->ifatm.ifnet, m);
1813#endif
1817#endif
1814 atm_input(&sc->enif, &ah, m,
1818 atm_input(&sc->ifatm.ifnet, &ah, m,
1815 sc->rxslot[slot].rxhand);
1816 }
1817 }
1818 EN_WRAPADD(0, MID_DRQ_N, idx, 1);
1819 }
1820 sc->drq_chip = MID_DRQ_REG2A(val); /* sync softc */
1821
1822 if (sc->need_drqs) {

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

2165 pdu = cur + MID_RBD_CNT(rbd) * MID_ATMDATASZ +
2166 MID_RBD_SIZE - MID_PDU_SIZE;
2167 if (pdu >= slot->stop)
2168 pdu -= EN_RXSZ * 1024;
2169 pdu = en_read(sc, pdu);
2170
2171 if (MID_RBD_CNT(rbd) * MID_ATMDATASZ <
2172 MID_PDU_LEN(pdu)) {
1819 sc->rxslot[slot].rxhand);
1820 }
1821 }
1822 EN_WRAPADD(0, MID_DRQ_N, idx, 1);
1823 }
1824 sc->drq_chip = MID_DRQ_REG2A(val); /* sync softc */
1825
1826 if (sc->need_drqs) {

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

2169 pdu = cur + MID_RBD_CNT(rbd) * MID_ATMDATASZ +
2170 MID_RBD_SIZE - MID_PDU_SIZE;
2171 if (pdu >= slot->stop)
2172 pdu -= EN_RXSZ * 1024;
2173 pdu = en_read(sc, pdu);
2174
2175 if (MID_RBD_CNT(rbd) * MID_ATMDATASZ <
2176 MID_PDU_LEN(pdu)) {
2173 if_printf(&sc->enif, "invalid AAL5 length\n");
2177 if_printf(&sc->ifatm.ifnet, "invalid AAL5 length\n");
2174 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
2175 mlen = 0;
2178 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
2179 mlen = 0;
2176 sc->enif.if_ierrors++;
2180 sc->ifatm.ifnet.if_ierrors++;
2177
2178 } else if (rbd & MID_RBD_CRCERR) {
2181
2182 } else if (rbd & MID_RBD_CRCERR) {
2179 if_printf(&sc->enif, "CRC error\n");
2183 if_printf(&sc->ifatm.ifnet, "CRC error\n");
2180 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
2181 mlen = 0;
2184 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
2185 mlen = 0;
2182 sc->enif.if_ierrors++;
2186 sc->ifatm.ifnet.if_ierrors++;
2183
2184 } else {
2185 mlen = MID_PDU_LEN(pdu);
2186 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ - mlen;
2187 }
2188 }
2189
2190 /*

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

2251 uma_zfree(sc->map_zone, map);
2252 goto skip;
2253 }
2254 rx.m = m;
2255 error = bus_dmamap_load_mbuf(sc->txtag, map->map, m,
2256 en_rxdma_load, &rx, 0);
2257
2258 if (error != 0) {
2187
2188 } else {
2189 mlen = MID_PDU_LEN(pdu);
2190 rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ - mlen;
2191 }
2192 }
2193
2194 /*

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

2255 uma_zfree(sc->map_zone, map);
2256 goto skip;
2257 }
2258 rx.m = m;
2259 error = bus_dmamap_load_mbuf(sc->txtag, map->map, m,
2260 en_rxdma_load, &rx, 0);
2261
2262 if (error != 0) {
2259 if_printf(&sc->enif, "loading RX map failed "
2263 if_printf(&sc->ifatm.ifnet, "loading RX map failed "
2260 "%d\n", error);
2261 uma_zfree(sc->map_zone, map);
2262 m_freem(m);
2263 rx.post_skip += mlen;
2264 goto skip;
2265
2266 }
2267 map->flags |= ENMAP_LOADED;

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

2347 EN_UNLOCK(sc);
2348 return;
2349 }
2350
2351 /*
2352 * unexpected errors that need a reset
2353 */
2354 if ((reg & (MID_INT_IDENT | MID_INT_LERR | MID_INT_DMA_ERR)) != 0) {
2264 "%d\n", error);
2265 uma_zfree(sc->map_zone, map);
2266 m_freem(m);
2267 rx.post_skip += mlen;
2268 goto skip;
2269
2270 }
2271 map->flags |= ENMAP_LOADED;

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

2351 EN_UNLOCK(sc);
2352 return;
2353 }
2354
2355 /*
2356 * unexpected errors that need a reset
2357 */
2358 if ((reg & (MID_INT_IDENT | MID_INT_LERR | MID_INT_DMA_ERR)) != 0) {
2355 if_printf(&sc->enif, "unexpected interrupt=0x%b, resetting\n",
2356 reg, MID_INTBITS);
2359 if_printf(&sc->ifatm.ifnet, "unexpected interrupt=0x%b, "
2360 "resetting\n", reg, MID_INTBITS);
2357#ifdef EN_DEBUG
2358#ifdef DDB
2359 Debugger("en: unexpected error");
2360#endif /* DDB */
2361#ifdef EN_DEBUG
2362#ifdef DDB
2363 Debugger("en: unexpected error");
2364#endif /* DDB */
2361 sc->enif.if_flags &= ~IFF_RUNNING; /* FREEZE! */
2365 sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; /* FREEZE! */
2362#else
2363 en_reset_ul(sc);
2364 en_init(sc);
2365#endif
2366 EN_UNLOCK(sc);
2367 return;
2368 }
2369
2370#if 0
2371 if (reg & MID_INT_SUNI)
2366#else
2367 en_reset_ul(sc);
2368 en_init(sc);
2369#endif
2370 EN_UNLOCK(sc);
2371 return;
2372 }
2373
2374#if 0
2375 if (reg & MID_INT_SUNI)
2372 if_printf(&sc->enif, "interrupt from SUNI (probably carrier "
2373 "change)\n");
2376 if_printf(&sc->ifatm.ifnet, "interrupt from SUNI (probably "
2377 "carrier change)\n");
2374#endif
2375
2376 kick = 0;
2377 if (reg & MID_INT_TX)
2378 kick |= en_intr_tx(sc, reg);
2379
2380 if (reg & MID_INT_DMA_TX)
2381 kick |= en_intr_tx_dma(sc);

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

2674/*
2675 * Attach to the card.
2676 *
2677 * LOCK: unlocked, not needed (but initialized)
2678 */
2679int
2680en_attach(struct en_softc *sc)
2681{
2378#endif
2379
2380 kick = 0;
2381 if (reg & MID_INT_TX)
2382 kick |= en_intr_tx(sc, reg);
2383
2384 if (reg & MID_INT_DMA_TX)
2385 kick |= en_intr_tx_dma(sc);

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

2678/*
2679 * Attach to the card.
2680 *
2681 * LOCK: unlocked, not needed (but initialized)
2682 */
2683int
2684en_attach(struct en_softc *sc)
2685{
2682 struct ifnet *ifp = &sc->enif;
2686 struct ifnet *ifp = &sc->ifatm.ifnet;
2683 int sz;
2684 uint32_t reg, lcv, check, ptr, sav, midvloc;
2685
2686#ifdef EN_DEBUG
2687 sc->debug = EN_DEBUG;
2688#endif
2689 /*
2690 * Probe card to determine memory size.

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

2729 en_write(sc, MID_RESID, 0x0); /* reset */
2730
2731 /* zero memory */
2732 bus_space_set_region_4(sc->en_memt, sc->en_base,
2733 MID_RAMOFF, 0, sc->en_obmemsz / 4);
2734
2735 reg = en_read(sc, MID_RESID);
2736
2687 int sz;
2688 uint32_t reg, lcv, check, ptr, sav, midvloc;
2689
2690#ifdef EN_DEBUG
2691 sc->debug = EN_DEBUG;
2692#endif
2693 /*
2694 * Probe card to determine memory size.

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

2733 en_write(sc, MID_RESID, 0x0); /* reset */
2734
2735 /* zero memory */
2736 bus_space_set_region_4(sc->en_memt, sc->en_base,
2737 MID_RAMOFF, 0, sc->en_obmemsz / 4);
2738
2739 reg = en_read(sc, MID_RESID);
2740
2737 if_printf(&sc->enif, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
2741 if_printf(&sc->ifatm.ifnet, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
2738 "%ldKB on-board RAM\n", MID_VER(reg), MID_MID(reg), MID_DID(reg),
2739 (MID_IS_SABRE(reg)) ? "sabre controller, " : "",
2740 (MID_IS_SUNI(reg)) ? "SUNI" : "Utopia",
2741 (!MID_IS_SUNI(reg) && MID_IS_UPIPE(reg)) ? " (pipelined)" : "",
2742 (long)sc->en_obmemsz / 1024);
2743
2742 "%ldKB on-board RAM\n", MID_VER(reg), MID_MID(reg), MID_DID(reg),
2743 (MID_IS_SABRE(reg)) ? "sabre controller, " : "",
2744 (MID_IS_SUNI(reg)) ? "SUNI" : "Utopia",
2745 (!MID_IS_SUNI(reg) && MID_IS_UPIPE(reg)) ? " (pipelined)" : "",
2746 (long)sc->en_obmemsz / 1024);
2747
2748 /*
2749 * fill in common ATM interface stuff
2750 */
2751 sc->ifatm.mib.hw_version = (MID_VER(reg) << 16) |
2752 (MID_MID(reg) << 8) | MID_DID(reg);
2753 if (MID_DID(reg) & 0x4)
2754 sc->ifatm.mib.media = IFM_ATM_UTP_155;
2755 else
2756 sc->ifatm.mib.media = IFM_ATM_MM_155;
2757
2758 sc->ifatm.mib.pcr = ATM_RATE_155M;
2759 sc->ifatm.mib.vpi_bits = 0;
2760 sc->ifatm.mib.vci_bits = MID_VCI_BITS;
2761 sc->ifatm.mib.max_vccs = MID_N_VC;
2762 sc->ifatm.mib.max_vpcs = 0;
2763
2744 if (sc->is_adaptec) {
2764 if (sc->is_adaptec) {
2765 sc->ifatm.mib.device = ATM_DEVICE_ADP155P;
2745 if (sc->bestburstlen == 64 && sc->alburst == 0)
2766 if (sc->bestburstlen == 64 && sc->alburst == 0)
2746 if_printf(&sc->enif, "passed 64 byte DMA test\n");
2767 if_printf(&sc->ifatm.ifnet,
2768 "passed 64 byte DMA test\n");
2747 else
2769 else
2748 if_printf(&sc->enif, "FAILED DMA TEST: burst=%d, "
2749 "alburst=%d\n", sc->bestburstlen, sc->alburst);
2770 if_printf(&sc->ifatm.ifnet, "FAILED DMA TEST: "
2771 "burst=%d, alburst=%d\n", sc->bestburstlen,
2772 sc->alburst);
2750 } else {
2773 } else {
2751 if_printf(&sc->enif, "maximum DMA burst length = %d bytes%s\n",
2752 sc->bestburstlen, sc->alburst ? sc->noalbursts ?
2753 " (no large bursts)" : " (must align)" : "");
2774 sc->ifatm.mib.device = ATM_DEVICE_ENI155P;
2775 if_printf(&sc->ifatm.ifnet, "maximum DMA burst length = %d "
2776 "bytes%s\n", sc->bestburstlen, sc->alburst ?
2777 sc->noalbursts ? " (no large bursts)" : " (must align)" :
2778 "");
2754 }
2755
2756 /*
2757 * link into network subsystem and prepare card
2758 */
2779 }
2780
2781 /*
2782 * link into network subsystem and prepare card
2783 */
2759 sc->enif.if_softc = sc;
2784 sc->ifatm.ifnet.if_softc = sc;
2760 ifp->if_flags = IFF_SIMPLEX;
2761 ifp->if_ioctl = en_ioctl;
2762 ifp->if_start = en_start;
2763
2764 /*
2765 * Make the sysctl tree
2766 */
2767 sysctl_ctx_init(&sc->sysctl_ctx);

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

2811 sc->txvc2slot[lcv] = 0; /* full speed == slot 0 */
2812 }
2813
2814 sz = sc->en_obmemsz - (MID_BUFOFF - MID_RAMOFF);
2815 ptr = sav = MID_BUFOFF;
2816 ptr = roundup(ptr, EN_TXSZ * 1024); /* align */
2817 sz = sz - (ptr - sav);
2818 if (EN_TXSZ*1024 * EN_NTX > sz) {
2785 ifp->if_flags = IFF_SIMPLEX;
2786 ifp->if_ioctl = en_ioctl;
2787 ifp->if_start = en_start;
2788
2789 /*
2790 * Make the sysctl tree
2791 */
2792 sysctl_ctx_init(&sc->sysctl_ctx);

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

2836 sc->txvc2slot[lcv] = 0; /* full speed == slot 0 */
2837 }
2838
2839 sz = sc->en_obmemsz - (MID_BUFOFF - MID_RAMOFF);
2840 ptr = sav = MID_BUFOFF;
2841 ptr = roundup(ptr, EN_TXSZ * 1024); /* align */
2842 sz = sz - (ptr - sav);
2843 if (EN_TXSZ*1024 * EN_NTX > sz) {
2819 if_printf(&sc->enif, "EN_NTX/EN_TXSZ too big\n");
2844 if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ too big\n");
2820 goto fail;
2821 }
2822 for (lcv = 0 ;lcv < EN_NTX ;lcv++) {
2823 sc->txslot[lcv].mbsize = 0;
2824 sc->txslot[lcv].start = ptr;
2825 ptr += (EN_TXSZ * 1024);
2826 sz -= (EN_TXSZ * 1024);
2827 sc->txslot[lcv].stop = ptr;
2828 sc->txslot[lcv].nref = 0;
2829 DBG(sc, INIT, ("tx%d: start 0x%x, stop 0x%x", lcv,
2830 sc->txslot[lcv].start, sc->txslot[lcv].stop));
2831 }
2832
2833 sav = ptr;
2834 ptr = roundup(ptr, EN_RXSZ * 1024); /* align */
2835 sz = sz - (ptr - sav);
2836 sc->en_nrx = sz / (EN_RXSZ * 1024);
2837 if (sc->en_nrx <= 0) {
2845 goto fail;
2846 }
2847 for (lcv = 0 ;lcv < EN_NTX ;lcv++) {
2848 sc->txslot[lcv].mbsize = 0;
2849 sc->txslot[lcv].start = ptr;
2850 ptr += (EN_TXSZ * 1024);
2851 sz -= (EN_TXSZ * 1024);
2852 sc->txslot[lcv].stop = ptr;
2853 sc->txslot[lcv].nref = 0;
2854 DBG(sc, INIT, ("tx%d: start 0x%x, stop 0x%x", lcv,
2855 sc->txslot[lcv].start, sc->txslot[lcv].stop));
2856 }
2857
2858 sav = ptr;
2859 ptr = roundup(ptr, EN_RXSZ * 1024); /* align */
2860 sz = sz - (ptr - sav);
2861 sc->en_nrx = sz / (EN_RXSZ * 1024);
2862 if (sc->en_nrx <= 0) {
2838 if_printf(&sc->enif, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
2863 if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
2839 goto fail;
2840 }
2841
2842 /*
2843 * ensure that there is always one VC slot on the service list free
2844 * so that we can tell the difference between a full and empty list.
2845 */
2846 if (sc->en_nrx >= MID_N_VC)

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

2862 sc->rxslot[lcv].mode = midvloc |
2863 (en_k2sz(EN_RXSZ) << MIDV_SZSHIFT) | MIDV_TRASH;
2864
2865 DBG(sc, INIT, ("rx%d: start 0x%x, stop 0x%x, mode 0x%x", lcv,
2866 sc->rxslot[lcv].start, sc->rxslot[lcv].stop,
2867 sc->rxslot[lcv].mode));
2868 }
2869
2864 goto fail;
2865 }
2866
2867 /*
2868 * ensure that there is always one VC slot on the service list free
2869 * so that we can tell the difference between a full and empty list.
2870 */
2871 if (sc->en_nrx >= MID_N_VC)

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

2887 sc->rxslot[lcv].mode = midvloc |
2888 (en_k2sz(EN_RXSZ) << MIDV_SZSHIFT) | MIDV_TRASH;
2889
2890 DBG(sc, INIT, ("rx%d: start 0x%x, stop 0x%x, mode 0x%x", lcv,
2891 sc->rxslot[lcv].start, sc->rxslot[lcv].stop,
2892 sc->rxslot[lcv].mode));
2893 }
2894
2870 bzero(&sc->stats, sizeof(sc->stats));
2871
2872 if_printf(&sc->enif, "%d %dKB receive buffers, %d %dKB transmit "
2895 if_printf(&sc->ifatm.ifnet, "%d %dKB receive buffers, %d %dKB transmit "
2873 "buffers\n", sc->en_nrx, EN_RXSZ, EN_NTX, EN_TXSZ);
2896 "buffers\n", sc->en_nrx, EN_RXSZ, EN_NTX, EN_TXSZ);
2874 if_printf(&sc->enif, "end station identifier (mac address) %6D\n",
2875 sc->macaddr, ":");
2897 if_printf(&sc->ifatm.ifnet, "end station identifier (mac address) "
2898 "%6D\n", sc->ifatm.mib.esi, ":");
2876
2877 /*
2878 * final commit
2879 */
2880 atm_ifattach(ifp);
2881
2882#ifdef ENABLE_BPF
2883 bpfattach(ifp, DLT_ATM_RFC1483, sizeof(struct atmllc));

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

3105 maxunit = devclass_get_maxunit(dc);
3106 for (lcv = 0 ; lcv < maxunit ; lcv++) {
3107 sc = devclass_get_softc(dc, lcv);
3108 if (sc == NULL)
3109 continue;
3110 if (unit != -1 && unit != lcv)
3111 continue;
3112
2899
2900 /*
2901 * final commit
2902 */
2903 atm_ifattach(ifp);
2904
2905#ifdef ENABLE_BPF
2906 bpfattach(ifp, DLT_ATM_RFC1483, sizeof(struct atmllc));

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

3128 maxunit = devclass_get_maxunit(dc);
3129 for (lcv = 0 ; lcv < maxunit ; lcv++) {
3130 sc = devclass_get_softc(dc, lcv);
3131 if (sc == NULL)
3132 continue;
3133 if (unit != -1 && unit != lcv)
3134 continue;
3135
3113 if_printf(&sc->enif, "dumping device at level 0x%b\n",
3136 if_printf(&sc->ifatm.ifnet, "dumping device at level 0x%b\n",
3114 level, END_BITS);
3115
3116 if (sc->dtq_us == 0) {
3117 printf("<hasn't been en_init'd yet>\n");
3118 continue;
3119 }
3120
3121 if (level & END_STATS)

--- 60 unchanged lines hidden ---
3137 level, END_BITS);
3138
3139 if (sc->dtq_us == 0) {
3140 printf("<hasn't been en_init'd yet>\n");
3141 continue;
3142 }
3143
3144 if (level & END_STATS)

--- 60 unchanged lines hidden ---