if_lge.c (148654) | if_lge.c (148887) |
---|---|
1/*- 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <william.paul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <william.paul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 148654 2005-08-03 00:18:35Z rwatson $"); | 35__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 148887 2005-08-09 10:20:02Z rwatson $"); |
36 37/* 38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public 39 * documentation not available, but ask me nicely. 40 * 41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs. 42 * It's a 64-bit PCI part that supports TCP/IP checksum offload, 43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There --- 937 unchanged lines hidden (view full) --- 981 982static void 983lge_rxeoc(sc) 984 struct lge_softc *sc; 985{ 986 struct ifnet *ifp; 987 988 ifp = sc->lge_ifp; | 36 37/* 38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public 39 * documentation not available, but ask me nicely. 40 * 41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs. 42 * It's a 64-bit PCI part that supports TCP/IP checksum offload, 43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There --- 937 unchanged lines hidden (view full) --- 981 982static void 983lge_rxeoc(sc) 984 struct lge_softc *sc; 985{ 986 struct ifnet *ifp; 987 988 ifp = sc->lge_ifp; |
989 ifp->if_flags &= ~IFF_RUNNING; | 989 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
990 lge_init(sc); 991 return; 992} 993 994/* 995 * A frame was downloaded to the chip. It's safe for us to clean up 996 * the list buffers. 997 */ --- 31 unchanged lines hidden (view full) --- 1029 txdone--; 1030 LGE_INC(idx, LGE_TX_LIST_CNT); 1031 ifp->if_timer = 0; 1032 } 1033 1034 sc->lge_cdata.lge_tx_cons = idx; 1035 1036 if (cur_tx != NULL) | 990 lge_init(sc); 991 return; 992} 993 994/* 995 * A frame was downloaded to the chip. It's safe for us to clean up 996 * the list buffers. 997 */ --- 31 unchanged lines hidden (view full) --- 1029 txdone--; 1030 LGE_INC(idx, LGE_TX_LIST_CNT); 1031 ifp->if_timer = 0; 1032 } 1033 1034 sc->lge_cdata.lge_tx_cons = idx; 1035 1036 if (cur_tx != NULL) |
1037 ifp->if_flags &= ~IFF_OACTIVE; | 1037 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
1038 1039 return; 1040} 1041 1042static void 1043lge_tick(xsc) 1044 void *xsc; 1045{ --- 153 unchanged lines hidden (view full) --- 1199 1200 sc = ifp->if_softc; 1201 1202 if (!sc->lge_link) 1203 return; 1204 1205 idx = sc->lge_cdata.lge_tx_prod; 1206 | 1038 1039 return; 1040} 1041 1042static void 1043lge_tick(xsc) 1044 void *xsc; 1045{ --- 153 unchanged lines hidden (view full) --- 1199 1200 sc = ifp->if_softc; 1201 1202 if (!sc->lge_link) 1203 return; 1204 1205 idx = sc->lge_cdata.lge_tx_prod; 1206 |
1207 if (ifp->if_flags & IFF_OACTIVE) | 1207 if (ifp->if_drv_flags & IFF_DRV_OACTIVE) |
1208 return; 1209 1210 while(sc->lge_ldata->lge_tx_list[idx].lge_mbuf == NULL) { 1211 if (CSR_READ_1(sc, LGE_TXCMDFREE_8BIT) == 0) 1212 break; 1213 1214 IF_DEQUEUE(&ifp->if_snd, m_head); 1215 if (m_head == NULL) 1216 break; 1217 1218 if (lge_encap(sc, m_head, &idx)) { 1219 IF_PREPEND(&ifp->if_snd, m_head); | 1208 return; 1209 1210 while(sc->lge_ldata->lge_tx_list[idx].lge_mbuf == NULL) { 1211 if (CSR_READ_1(sc, LGE_TXCMDFREE_8BIT) == 0) 1212 break; 1213 1214 IF_DEQUEUE(&ifp->if_snd, m_head); 1215 if (m_head == NULL) 1216 break; 1217 1218 if (lge_encap(sc, m_head, &idx)) { 1219 IF_PREPEND(&ifp->if_snd, m_head); |
1220 ifp->if_flags |= IFF_OACTIVE; | 1220 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
1221 break; 1222 } 1223 1224 /* 1225 * If there's a BPF listener, bounce a copy of this frame 1226 * to him. 1227 */ 1228 BPF_MTAP(ifp, m_head); --- 13 unchanged lines hidden (view full) --- 1242lge_init(xsc) 1243 void *xsc; 1244{ 1245 struct lge_softc *sc = xsc; 1246 struct ifnet *ifp = sc->lge_ifp; 1247 struct mii_data *mii; 1248 int s; 1249 | 1221 break; 1222 } 1223 1224 /* 1225 * If there's a BPF listener, bounce a copy of this frame 1226 * to him. 1227 */ 1228 BPF_MTAP(ifp, m_head); --- 13 unchanged lines hidden (view full) --- 1242lge_init(xsc) 1243 void *xsc; 1244{ 1245 struct lge_softc *sc = xsc; 1246 struct ifnet *ifp = sc->lge_ifp; 1247 struct mii_data *mii; 1248 int s; 1249 |
1250 if (ifp->if_flags & IFF_RUNNING) | 1250 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1251 return; 1252 1253 s = splimp(); 1254 1255 /* 1256 * Cancel pending I/O and free all RX/TX buffers. 1257 */ 1258 lge_stop(sc); --- 99 unchanged lines hidden (view full) --- 1358 /* 1359 * Enable interrupts. 1360 */ 1361 CSR_WRITE_4(sc, LGE_IMR, LGE_IMR_SETRST_CTL0| 1362 LGE_IMR_SETRST_CTL1|LGE_IMR_INTR_ENB|LGE_INTRS); 1363 1364 lge_ifmedia_upd(ifp); 1365 | 1251 return; 1252 1253 s = splimp(); 1254 1255 /* 1256 * Cancel pending I/O and free all RX/TX buffers. 1257 */ 1258 lge_stop(sc); --- 99 unchanged lines hidden (view full) --- 1358 /* 1359 * Enable interrupts. 1360 */ 1361 CSR_WRITE_4(sc, LGE_IMR, LGE_IMR_SETRST_CTL0| 1362 LGE_IMR_SETRST_CTL1|LGE_IMR_INTR_ENB|LGE_INTRS); 1363 1364 lge_ifmedia_upd(ifp); 1365 |
1366 ifp->if_flags |= IFF_RUNNING; 1367 ifp->if_flags &= ~IFF_OACTIVE; | 1366 ifp->if_drv_flags |= IFF_DRV_RUNNING; 1367 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
1368 1369 (void)splx(s); 1370 1371 sc->lge_stat_ch = timeout(lge_tick, sc, hz); 1372 1373 return; 1374} 1375 --- 60 unchanged lines hidden (view full) --- 1436 case SIOCSIFMTU: 1437 if (ifr->ifr_mtu > LGE_JUMBO_MTU) 1438 error = EINVAL; 1439 else 1440 ifp->if_mtu = ifr->ifr_mtu; 1441 break; 1442 case SIOCSIFFLAGS: 1443 if (ifp->if_flags & IFF_UP) { | 1368 1369 (void)splx(s); 1370 1371 sc->lge_stat_ch = timeout(lge_tick, sc, hz); 1372 1373 return; 1374} 1375 --- 60 unchanged lines hidden (view full) --- 1436 case SIOCSIFMTU: 1437 if (ifr->ifr_mtu > LGE_JUMBO_MTU) 1438 error = EINVAL; 1439 else 1440 ifp->if_mtu = ifr->ifr_mtu; 1441 break; 1442 case SIOCSIFFLAGS: 1443 if (ifp->if_flags & IFF_UP) { |
1444 if (ifp->if_flags & IFF_RUNNING && | 1444 if (ifp->if_drv_flags & IFF_DRV_RUNNING && |
1445 ifp->if_flags & IFF_PROMISC && 1446 !(sc->lge_if_flags & IFF_PROMISC)) { 1447 CSR_WRITE_4(sc, LGE_MODE1, 1448 LGE_MODE1_SETRST_CTL1| 1449 LGE_MODE1_RX_PROMISC); | 1445 ifp->if_flags & IFF_PROMISC && 1446 !(sc->lge_if_flags & IFF_PROMISC)) { 1447 CSR_WRITE_4(sc, LGE_MODE1, 1448 LGE_MODE1_SETRST_CTL1| 1449 LGE_MODE1_RX_PROMISC); |
1450 } else if (ifp->if_flags & IFF_RUNNING && | 1450 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING && |
1451 !(ifp->if_flags & IFF_PROMISC) && 1452 sc->lge_if_flags & IFF_PROMISC) { 1453 CSR_WRITE_4(sc, LGE_MODE1, 1454 LGE_MODE1_RX_PROMISC); 1455 } else { | 1451 !(ifp->if_flags & IFF_PROMISC) && 1452 sc->lge_if_flags & IFF_PROMISC) { 1453 CSR_WRITE_4(sc, LGE_MODE1, 1454 LGE_MODE1_RX_PROMISC); 1455 } else { |
1456 ifp->if_flags &= ~IFF_RUNNING; | 1456 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
1457 lge_init(sc); 1458 } 1459 } else { | 1457 lge_init(sc); 1458 } 1459 } else { |
1460 if (ifp->if_flags & IFF_RUNNING) | 1460 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1461 lge_stop(sc); 1462 } 1463 sc->lge_if_flags = ifp->if_flags; 1464 error = 0; 1465 break; 1466 case SIOCADDMULTI: 1467 case SIOCDELMULTI: 1468 lge_setmulti(sc); --- 22 unchanged lines hidden (view full) --- 1491 1492 sc = ifp->if_softc; 1493 1494 ifp->if_oerrors++; 1495 printf("lge%d: watchdog timeout\n", sc->lge_unit); 1496 1497 lge_stop(sc); 1498 lge_reset(sc); | 1461 lge_stop(sc); 1462 } 1463 sc->lge_if_flags = ifp->if_flags; 1464 error = 0; 1465 break; 1466 case SIOCADDMULTI: 1467 case SIOCDELMULTI: 1468 lge_setmulti(sc); --- 22 unchanged lines hidden (view full) --- 1491 1492 sc = ifp->if_softc; 1493 1494 ifp->if_oerrors++; 1495 printf("lge%d: watchdog timeout\n", sc->lge_unit); 1496 1497 lge_stop(sc); 1498 lge_reset(sc); |
1499 ifp->if_flags &= ~IFF_RUNNING; | 1499 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
1500 lge_init(sc); 1501 1502 if (ifp->if_snd.ifq_head != NULL) 1503 lge_start(ifp); 1504 1505 return; 1506} 1507 --- 37 unchanged lines hidden (view full) --- 1545 m_freem(sc->lge_ldata->lge_tx_list[i].lge_mbuf); 1546 sc->lge_ldata->lge_tx_list[i].lge_mbuf = NULL; 1547 } 1548 } 1549 1550 bzero((char *)&sc->lge_ldata->lge_tx_list, 1551 sizeof(sc->lge_ldata->lge_tx_list)); 1552 | 1500 lge_init(sc); 1501 1502 if (ifp->if_snd.ifq_head != NULL) 1503 lge_start(ifp); 1504 1505 return; 1506} 1507 --- 37 unchanged lines hidden (view full) --- 1545 m_freem(sc->lge_ldata->lge_tx_list[i].lge_mbuf); 1546 sc->lge_ldata->lge_tx_list[i].lge_mbuf = NULL; 1547 } 1548 } 1549 1550 bzero((char *)&sc->lge_ldata->lge_tx_list, 1551 sizeof(sc->lge_ldata->lge_tx_list)); 1552 |
1553 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); | 1553 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
1554 1555 return; 1556} 1557 1558/* 1559 * Stop all chip I/O so that the kernel's probe routines don't 1560 * get confused by errant DMAs when rebooting. 1561 */ --- 13 unchanged lines hidden --- | 1554 1555 return; 1556} 1557 1558/* 1559 * Stop all chip I/O so that the kernel's probe routines don't 1560 * get confused by errant DMAs when rebooting. 1561 */ --- 13 unchanged lines hidden --- |