if_pcn.c (148738) | if_pcn.c (148887) |
---|---|
1/*- 2 * Copyright (c) 2000 Berkeley Software Design, Inc. 3 * Copyright (c) 1997, 1998, 1999, 2000 4 * Bill Paul <wpaul@osd.bsdi.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) 2000 Berkeley Software Design, Inc. 3 * Copyright (c) 1997, 1998, 1999, 2000 4 * Bill Paul <wpaul@osd.bsdi.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/pci/if_pcn.c 148738 2005-08-05 16:03:16Z jhb $"); | 35__FBSDID("$FreeBSD: head/sys/pci/if_pcn.c 148887 2005-08-09 10:20:02Z rwatson $"); |
36 37/* 38 * AMD Am79c972 fast ethernet PCI NIC driver. Datasheets are available 39 * from http://www.amd.com. 40 * 41 * The AMD PCnet/PCI controllers are more advanced and functional 42 * versions of the venerable 7990 LANCE. The PCnet/PCI chips retain 43 * backwards compatibility with the LANCE and thus can be made --- 860 unchanged lines hidden (view full) --- 904 905 sc->pcn_cdata.pcn_tx_cnt--; 906 PCN_INC(idx, PCN_TX_LIST_CNT); 907 } 908 909 if (idx != sc->pcn_cdata.pcn_tx_cons) { 910 /* Some buffers have been freed. */ 911 sc->pcn_cdata.pcn_tx_cons = idx; | 36 37/* 38 * AMD Am79c972 fast ethernet PCI NIC driver. Datasheets are available 39 * from http://www.amd.com. 40 * 41 * The AMD PCnet/PCI controllers are more advanced and functional 42 * versions of the venerable 7990 LANCE. The PCnet/PCI chips retain 43 * backwards compatibility with the LANCE and thus can be made --- 860 unchanged lines hidden (view full) --- 904 905 sc->pcn_cdata.pcn_tx_cnt--; 906 PCN_INC(idx, PCN_TX_LIST_CNT); 907 } 908 909 if (idx != sc->pcn_cdata.pcn_tx_cons) { 910 /* Some buffers have been freed. */ 911 sc->pcn_cdata.pcn_tx_cons = idx; |
912 ifp->if_flags &= ~IFF_OACTIVE; | 912 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
913 } 914 ifp->if_timer = (sc->pcn_cdata.pcn_tx_cnt == 0) ? 0 : 5; 915 916 return; 917} 918 919static void 920pcn_tick(xsc) 921 void *xsc; 922{ 923 struct pcn_softc *sc; 924 struct mii_data *mii; 925 struct ifnet *ifp; 926 927 sc = xsc; 928 ifp = sc->pcn_ifp; 929 PCN_LOCK(sc); | 913 } 914 ifp->if_timer = (sc->pcn_cdata.pcn_tx_cnt == 0) ? 0 : 5; 915 916 return; 917} 918 919static void 920pcn_tick(xsc) 921 void *xsc; 922{ 923 struct pcn_softc *sc; 924 struct mii_data *mii; 925 struct ifnet *ifp; 926 927 sc = xsc; 928 ifp = sc->pcn_ifp; 929 PCN_LOCK(sc); |
930 if (!(ifp->if_flags & IFF_RUNNING)) { | 930 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
931 PCN_UNLOCK(sc); 932 return; 933 } 934 935 mii = device_get_softc(sc->pcn_miibus); 936 mii_tick(mii); 937 938 /* link just died */ --- 143 unchanged lines hidden (view full) --- 1082 1083 PCN_LOCK_ASSERT(sc); 1084 1085 if (!sc->pcn_link) 1086 return; 1087 1088 idx = sc->pcn_cdata.pcn_tx_prod; 1089 | 931 PCN_UNLOCK(sc); 932 return; 933 } 934 935 mii = device_get_softc(sc->pcn_miibus); 936 mii_tick(mii); 937 938 /* link just died */ --- 143 unchanged lines hidden (view full) --- 1082 1083 PCN_LOCK_ASSERT(sc); 1084 1085 if (!sc->pcn_link) 1086 return; 1087 1088 idx = sc->pcn_cdata.pcn_tx_prod; 1089 |
1090 if (ifp->if_flags & IFF_OACTIVE) | 1090 if (ifp->if_drv_flags & IFF_DRV_OACTIVE) |
1091 return; 1092 1093 while(sc->pcn_cdata.pcn_tx_chain[idx] == NULL) { 1094 IF_DEQUEUE(&ifp->if_snd, m_head); 1095 if (m_head == NULL) 1096 break; 1097 1098 if (pcn_encap(sc, m_head, &idx)) { 1099 IF_PREPEND(&ifp->if_snd, m_head); | 1091 return; 1092 1093 while(sc->pcn_cdata.pcn_tx_chain[idx] == NULL) { 1094 IF_DEQUEUE(&ifp->if_snd, m_head); 1095 if (m_head == NULL) 1096 break; 1097 1098 if (pcn_encap(sc, m_head, &idx)) { 1099 IF_PREPEND(&ifp->if_snd, m_head); |
1100 ifp->if_flags |= IFF_OACTIVE; | 1100 ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
1101 break; 1102 } 1103 1104 /* 1105 * If there's a BPF listener, bounce a copy of this frame 1106 * to him. 1107 */ 1108 BPF_MTAP(ifp, m_head); --- 140 unchanged lines hidden (view full) --- 1249 pcn_bcr_write(sc, PCN_BCR_PHYSEL, 1250 PCN_PHYSEL_PCNET|PCN_PHY_HOMEPNA); 1251 1252 /* Enable interrupts and start the controller running. */ 1253 pcn_csr_write(sc, PCN_CSR_CSR, PCN_CSR_INTEN|PCN_CSR_START); 1254 1255 mii_mediachg(mii); 1256 | 1101 break; 1102 } 1103 1104 /* 1105 * If there's a BPF listener, bounce a copy of this frame 1106 * to him. 1107 */ 1108 BPF_MTAP(ifp, m_head); --- 140 unchanged lines hidden (view full) --- 1249 pcn_bcr_write(sc, PCN_BCR_PHYSEL, 1250 PCN_PHYSEL_PCNET|PCN_PHY_HOMEPNA); 1251 1252 /* Enable interrupts and start the controller running. */ 1253 pcn_csr_write(sc, PCN_CSR_CSR, PCN_CSR_INTEN|PCN_CSR_START); 1254 1255 mii_mediachg(mii); 1256 |
1257 ifp->if_flags |= IFF_RUNNING; 1258 ifp->if_flags &= ~IFF_OACTIVE; | 1257 ifp->if_drv_flags |= IFF_DRV_RUNNING; 1258 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
1259 1260 callout_reset(&sc->pcn_stat_callout, hz, pcn_tick, sc); 1261 1262 return; 1263} 1264 1265/* 1266 * Set media options. --- 54 unchanged lines hidden (view full) --- 1321 struct ifreq *ifr = (struct ifreq *) data; 1322 struct mii_data *mii = NULL; 1323 int error = 0; 1324 1325 switch(command) { 1326 case SIOCSIFFLAGS: 1327 PCN_LOCK(sc); 1328 if (ifp->if_flags & IFF_UP) { | 1259 1260 callout_reset(&sc->pcn_stat_callout, hz, pcn_tick, sc); 1261 1262 return; 1263} 1264 1265/* 1266 * Set media options. --- 54 unchanged lines hidden (view full) --- 1321 struct ifreq *ifr = (struct ifreq *) data; 1322 struct mii_data *mii = NULL; 1323 int error = 0; 1324 1325 switch(command) { 1326 case SIOCSIFFLAGS: 1327 PCN_LOCK(sc); 1328 if (ifp->if_flags & IFF_UP) { |
1329 if (ifp->if_flags & IFF_RUNNING && | 1329 if (ifp->if_drv_flags & IFF_DRV_RUNNING && |
1330 ifp->if_flags & IFF_PROMISC && 1331 !(sc->pcn_if_flags & IFF_PROMISC)) { 1332 PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, 1333 PCN_EXTCTL1_SPND); 1334 pcn_setfilt(ifp); 1335 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, 1336 PCN_EXTCTL1_SPND); 1337 pcn_csr_write(sc, PCN_CSR_CSR, 1338 PCN_CSR_INTEN|PCN_CSR_START); | 1330 ifp->if_flags & IFF_PROMISC && 1331 !(sc->pcn_if_flags & IFF_PROMISC)) { 1332 PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, 1333 PCN_EXTCTL1_SPND); 1334 pcn_setfilt(ifp); 1335 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, 1336 PCN_EXTCTL1_SPND); 1337 pcn_csr_write(sc, PCN_CSR_CSR, 1338 PCN_CSR_INTEN|PCN_CSR_START); |
1339 } else if (ifp->if_flags & IFF_RUNNING && | 1339 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING && |
1340 !(ifp->if_flags & IFF_PROMISC) && 1341 sc->pcn_if_flags & IFF_PROMISC) { 1342 PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, 1343 PCN_EXTCTL1_SPND); 1344 pcn_setfilt(ifp); 1345 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, 1346 PCN_EXTCTL1_SPND); 1347 pcn_csr_write(sc, PCN_CSR_CSR, 1348 PCN_CSR_INTEN|PCN_CSR_START); | 1340 !(ifp->if_flags & IFF_PROMISC) && 1341 sc->pcn_if_flags & IFF_PROMISC) { 1342 PCN_CSR_SETBIT(sc, PCN_CSR_EXTCTL1, 1343 PCN_EXTCTL1_SPND); 1344 pcn_setfilt(ifp); 1345 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, 1346 PCN_EXTCTL1_SPND); 1347 pcn_csr_write(sc, PCN_CSR_CSR, 1348 PCN_CSR_INTEN|PCN_CSR_START); |
1349 } else if (!(ifp->if_flags & IFF_RUNNING)) | 1349 } else if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) |
1350 pcn_init_locked(sc); 1351 } else { | 1350 pcn_init_locked(sc); 1351 } else { |
1352 if (ifp->if_flags & IFF_RUNNING) | 1352 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
1353 pcn_stop(sc); 1354 } 1355 sc->pcn_if_flags = ifp->if_flags; 1356 PCN_UNLOCK(sc); 1357 error = 0; 1358 break; 1359 case SIOCADDMULTI: 1360 case SIOCDELMULTI: --- 83 unchanged lines hidden (view full) --- 1444 m_freem(sc->pcn_cdata.pcn_tx_chain[i]); 1445 sc->pcn_cdata.pcn_tx_chain[i] = NULL; 1446 } 1447 } 1448 1449 bzero((char *)&sc->pcn_ldata->pcn_tx_list, 1450 sizeof(sc->pcn_ldata->pcn_tx_list)); 1451 | 1353 pcn_stop(sc); 1354 } 1355 sc->pcn_if_flags = ifp->if_flags; 1356 PCN_UNLOCK(sc); 1357 error = 0; 1358 break; 1359 case SIOCADDMULTI: 1360 case SIOCDELMULTI: --- 83 unchanged lines hidden (view full) --- 1444 m_freem(sc->pcn_cdata.pcn_tx_chain[i]); 1445 sc->pcn_cdata.pcn_tx_chain[i] = NULL; 1446 } 1447 } 1448 1449 bzero((char *)&sc->pcn_ldata->pcn_tx_list, 1450 sizeof(sc->pcn_ldata->pcn_tx_list)); 1451 |
1452 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); | 1452 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
1453 1454 return; 1455} 1456 1457/* 1458 * Stop all chip I/O so that the kernel's probe routines don't 1459 * get confused by errant DMAs when rebooting. 1460 */ --- 15 unchanged lines hidden --- | 1453 1454 return; 1455} 1456 1457/* 1458 * Stop all chip I/O so that the kernel's probe routines don't 1459 * get confused by errant DMAs when rebooting. 1460 */ --- 15 unchanged lines hidden --- |