if_txp.c (148654) | if_txp.c (148887) |
---|---|
1/* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ 2 3/*- 4 * Copyright (c) 2001 5 * Jason L. Wright <jason@thought.net>, Theo de Raadt, and 6 * Aaron Campbell <aaron@monkey.org>. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> | 1/* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ 2 3/*- 4 * Copyright (c) 2001 5 * Jason L. Wright <jason@thought.net>, Theo de Raadt, and 6 * Aaron Campbell <aaron@monkey.org>. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 21 unchanged lines hidden (view full) --- 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 34 * THE POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148654 2005-08-03 00:18:35Z rwatson $"); | 38__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"); |
39 40/* 41 * Driver for 3c990 (Typhoon) Ethernet ASIC 42 */ 43 44#include <sys/cdefs.h> | 39 40/* 41 * Driver for 3c990 (Typhoon) Ethernet ASIC 42 */ 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148654 2005-08-03 00:18:35Z rwatson $"); | 45__FBSDID("$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"); |
46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/sockio.h> 50#include <sys/mbuf.h> 51#include <sys/malloc.h> 52#include <sys/kernel.h> 53#include <sys/module.h> --- 33 unchanged lines hidden (view full) --- 87#define TXP_USEIOSPACE 88#define __STRICT_ALIGNMENT 89 90#include <dev/txp/if_txpreg.h> 91#include <dev/txp/3c990img.h> 92 93#ifndef lint 94static const char rcsid[] = | 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/sockio.h> 50#include <sys/mbuf.h> 51#include <sys/malloc.h> 52#include <sys/kernel.h> 53#include <sys/module.h> --- 33 unchanged lines hidden (view full) --- 87#define TXP_USEIOSPACE 88#define __STRICT_ALIGNMENT 89 90#include <dev/txp/if_txpreg.h> 91#include <dev/txp/3c990img.h> 92 93#ifndef lint 94static const char rcsid[] = |
95 "$FreeBSD: head/sys/dev/txp/if_txp.c 148654 2005-08-03 00:18:35Z rwatson $"; | 95 "$FreeBSD: head/sys/dev/txp/if_txp.c 148887 2005-08-09 10:20:02Z rwatson $"; |
96#endif 97 98/* 99 * Various supported device vendors/types and their names. 100 */ 101static struct txp_type txp_devs[] = { 102 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_TX_95, 103 "3Com 3cR990-TX-95 Etherlink with 3XP Processor" }, --- 702 unchanged lines hidden (view full) --- 806 struct txp_softc *sc; 807{ 808 struct ifnet *ifp = sc->sc_ifp; 809 struct txp_hostvar *hv = sc->sc_hostvar; 810 struct txp_rxbuf_desc *rbd; 811 struct txp_swdesc *sd; 812 u_int32_t i; 813 | 96#endif 97 98/* 99 * Various supported device vendors/types and their names. 100 */ 101static struct txp_type txp_devs[] = { 102 { TXP_VENDORID_3COM, TXP_DEVICEID_3CR990_TX_95, 103 "3Com 3cR990-TX-95 Etherlink with 3XP Processor" }, --- 702 unchanged lines hidden (view full) --- 806 struct txp_softc *sc; 807{ 808 struct ifnet *ifp = sc->sc_ifp; 809 struct txp_hostvar *hv = sc->sc_hostvar; 810 struct txp_rxbuf_desc *rbd; 811 struct txp_swdesc *sd; 812 u_int32_t i; 813 |
814 if (!(ifp->if_flags & IFF_RUNNING)) | 814 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) |
815 return; 816 817 i = sc->sc_rxbufprod; 818 rbd = sc->sc_rxbufs + i; 819 820 while (1) { 821 sd = rbd->rb_sd; 822 if (sd->sd_mbuf != NULL) --- 56 unchanged lines hidden (view full) --- 879 m = sd->sd_mbuf; 880 if (m != NULL) { 881 m_freem(m); 882 txd->tx_addrlo = 0; 883 txd->tx_addrhi = 0; 884 ifp->if_opackets++; 885 } 886 } | 815 return; 816 817 i = sc->sc_rxbufprod; 818 rbd = sc->sc_rxbufs + i; 819 820 while (1) { 821 sd = rbd->rb_sd; 822 if (sd->sd_mbuf != NULL) --- 56 unchanged lines hidden (view full) --- 879 m = sd->sd_mbuf; 880 if (m != NULL) { 881 m_freem(m); 882 txd->tx_addrlo = 0; 883 txd->tx_addrhi = 0; 884 ifp->if_opackets++; 885 } 886 } |
887 ifp->if_flags &= ~IFF_OACTIVE; | 887 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
888 889 if (++cons == TX_ENTRIES) { 890 txd = r->r_desc; 891 cons = 0; 892 sd = sc->sc_txd; 893 } else { 894 txd++; 895 sd++; --- 177 unchanged lines hidden (view full) --- 1073 1074 s = splnet(); 1075 1076 switch(command) { 1077 case SIOCSIFFLAGS: 1078 if (ifp->if_flags & IFF_UP) { 1079 txp_init(sc); 1080 } else { | 888 889 if (++cons == TX_ENTRIES) { 890 txd = r->r_desc; 891 cons = 0; 892 sd = sc->sc_txd; 893 } else { 894 txd++; 895 sd++; --- 177 unchanged lines hidden (view full) --- 1073 1074 s = splnet(); 1075 1076 switch(command) { 1077 case SIOCSIFFLAGS: 1078 if (ifp->if_flags & IFF_UP) { 1079 txp_init(sc); 1080 } else { |
1081 if (ifp->if_flags & IFF_RUNNING) | 1081 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1082 txp_stop(sc); 1083 } 1084 break; 1085 case SIOCADDMULTI: 1086 case SIOCDELMULTI: 1087 /* 1088 * Multicast list has changed; set the hardware 1089 * filter accordingly. --- 83 unchanged lines hidden (view full) --- 1173 struct ifnet *ifp; 1174 u_int16_t p1; 1175 u_int32_t p2; 1176 int s; 1177 1178 sc = xsc; 1179 ifp = sc->sc_ifp; 1180 | 1082 txp_stop(sc); 1083 } 1084 break; 1085 case SIOCADDMULTI: 1086 case SIOCDELMULTI: 1087 /* 1088 * Multicast list has changed; set the hardware 1089 * filter accordingly. --- 83 unchanged lines hidden (view full) --- 1173 struct ifnet *ifp; 1174 u_int16_t p1; 1175 u_int32_t p2; 1176 int s; 1177 1178 sc = xsc; 1179 ifp = sc->sc_ifp; 1180 |
1181 if (ifp->if_flags & IFF_RUNNING) | 1181 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1182 return; 1183 1184 txp_stop(sc); 1185 1186 s = splnet(); 1187 1188 txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0, 1189 NULL, NULL, NULL, 1); --- 17 unchanged lines hidden (view full) --- 1207 1208 WRITE_REG(sc, TXP_IER, TXP_INT_RESERVED | TXP_INT_SELF | 1209 TXP_INT_A2H_7 | TXP_INT_A2H_6 | TXP_INT_A2H_5 | TXP_INT_A2H_4 | 1210 TXP_INT_A2H_2 | TXP_INT_A2H_1 | TXP_INT_A2H_0 | 1211 TXP_INT_DMA3 | TXP_INT_DMA2 | TXP_INT_DMA1 | TXP_INT_DMA0 | 1212 TXP_INT_PCI_TABORT | TXP_INT_PCI_MABORT | TXP_INT_LATCH); 1213 WRITE_REG(sc, TXP_IMR, TXP_INT_A2H_3); 1214 | 1182 return; 1183 1184 txp_stop(sc); 1185 1186 s = splnet(); 1187 1188 txp_command(sc, TXP_CMD_MAX_PKT_SIZE_WRITE, TXP_MAX_PKTLEN, 0, 0, 1189 NULL, NULL, NULL, 1); --- 17 unchanged lines hidden (view full) --- 1207 1208 WRITE_REG(sc, TXP_IER, TXP_INT_RESERVED | TXP_INT_SELF | 1209 TXP_INT_A2H_7 | TXP_INT_A2H_6 | TXP_INT_A2H_5 | TXP_INT_A2H_4 | 1210 TXP_INT_A2H_2 | TXP_INT_A2H_1 | TXP_INT_A2H_0 | 1211 TXP_INT_DMA3 | TXP_INT_DMA2 | TXP_INT_DMA1 | TXP_INT_DMA0 | 1212 TXP_INT_PCI_TABORT | TXP_INT_PCI_MABORT | TXP_INT_LATCH); 1213 WRITE_REG(sc, TXP_IMR, TXP_INT_A2H_3); 1214 |
1215 ifp->if_flags |= IFF_RUNNING; 1216 ifp->if_flags &= ~IFF_OACTIVE; | 1215 ifp->if_drv_flags |= IFF_DRV_RUNNING; 1216 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
1217 ifp->if_timer = 0; 1218 1219 sc->sc_tick = timeout(txp_tick, sc, hz); 1220 1221 splx(s); 1222} 1223 1224static void --- 46 unchanged lines hidden (view full) --- 1271 struct txp_tx_ring *r = &sc->sc_txhir; 1272 struct txp_tx_desc *txd; 1273 struct txp_frag_desc *fxd; 1274 struct mbuf *m, *m0; 1275 struct txp_swdesc *sd; 1276 u_int32_t firstprod, firstcnt, prod, cnt; 1277 struct m_tag *mtag; 1278 | 1217 ifp->if_timer = 0; 1218 1219 sc->sc_tick = timeout(txp_tick, sc, hz); 1220 1221 splx(s); 1222} 1223 1224static void --- 46 unchanged lines hidden (view full) --- 1271 struct txp_tx_ring *r = &sc->sc_txhir; 1272 struct txp_tx_desc *txd; 1273 struct txp_frag_desc *fxd; 1274 struct mbuf *m, *m0; 1275 struct txp_swdesc *sd; 1276 u_int32_t firstprod, firstcnt, prod, cnt; 1277 struct m_tag *mtag; 1278 |
1279 if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING) | 1279 if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != 1280 IFF_DRV_RUNNING) |
1280 return; 1281 1282 prod = r->r_prod; 1283 cnt = r->r_cnt; 1284 1285 while (1) { 1286 IF_DEQUEUE(&ifp->if_snd, m); 1287 if (m == NULL) --- 69 unchanged lines hidden (view full) --- 1357 WRITE_REG(sc, r->r_reg, TXP_IDX2OFFSET(prod)); 1358 } 1359 1360 r->r_prod = prod; 1361 r->r_cnt = cnt; 1362 return; 1363 1364oactive: | 1281 return; 1282 1283 prod = r->r_prod; 1284 cnt = r->r_cnt; 1285 1286 while (1) { 1287 IF_DEQUEUE(&ifp->if_snd, m); 1288 if (m == NULL) --- 69 unchanged lines hidden (view full) --- 1358 WRITE_REG(sc, r->r_reg, TXP_IDX2OFFSET(prod)); 1359 } 1360 1361 r->r_prod = prod; 1362 r->r_cnt = cnt; 1363 return; 1364 1365oactive: |
1365 ifp->if_flags |= IFF_OACTIVE; | 1366 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
1366 r->r_prod = firstprod; 1367 r->r_cnt = firstcnt; 1368 IF_PREPEND(&ifp->if_snd, m); 1369 return; 1370} 1371 1372/* 1373 * Handle simple commands sent to the typhoon --- 201 unchanged lines hidden (view full) --- 1575static void 1576txp_stop(sc) 1577 struct txp_softc *sc; 1578{ 1579 struct ifnet *ifp; 1580 1581 ifp = sc->sc_ifp; 1582 | 1367 r->r_prod = firstprod; 1368 r->r_cnt = firstcnt; 1369 IF_PREPEND(&ifp->if_snd, m); 1370 return; 1371} 1372 1373/* 1374 * Handle simple commands sent to the typhoon --- 201 unchanged lines hidden (view full) --- 1576static void 1577txp_stop(sc) 1578 struct txp_softc *sc; 1579{ 1580 struct ifnet *ifp; 1581 1582 ifp = sc->sc_ifp; 1583 |
1583 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); | 1584 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
1584 1585 untimeout(txp_tick, sc, sc->sc_tick); 1586 1587 txp_command(sc, TXP_CMD_TX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); 1588 txp_command(sc, TXP_CMD_RX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); 1589 1590 txp_rxring_empty(sc); 1591 --- 294 unchanged lines hidden --- | 1585 1586 untimeout(txp_tick, sc, sc->sc_tick); 1587 1588 txp_command(sc, TXP_CMD_TX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); 1589 txp_command(sc, TXP_CMD_RX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 1); 1590 1591 txp_rxring_empty(sc); 1592 --- 294 unchanged lines hidden --- |