if_nge.c (78287) | if_nge.c (78323) |
---|---|
1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <wpaul@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: --- 16 unchanged lines hidden (view full) --- 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * | 1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <wpaul@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: --- 16 unchanged lines hidden (view full) --- 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 * $FreeBSD: head/sys/dev/nge/if_nge.c 78287 2001-06-15 19:02:55Z wpaul $ | 33 * $FreeBSD: head/sys/dev/nge/if_nge.c 78323 2001-06-16 03:38:44Z wpaul $ |
34 */ 35 36/* 37 * National Semiconductor DP83820/DP83821 gigabit ethernet driver 38 * for FreeBSD. Datasheets are available from: 39 * 40 * http://www.national.com/ds/DP/DP83820.pdf 41 * http://www.national.com/ds/DP/DP83821.pdf --- 22 unchanged lines hidden (view full) --- 64 * hardware checksum offload (IPv4 only), VLAN tagging and filtering, 65 * priority TX and RX queues, a 2048 bit multicast hash filter, 4 RX pattern 66 * matching buffers, one perfect address filter buffer and interrupt 67 * moderation. The 83820 supports both 64-bit and 32-bit addressing 68 * and data transfers: the 64-bit support can be toggled on or off 69 * via software. This affects the size of certain fields in the DMA 70 * descriptors. 71 * | 34 */ 35 36/* 37 * National Semiconductor DP83820/DP83821 gigabit ethernet driver 38 * for FreeBSD. Datasheets are available from: 39 * 40 * http://www.national.com/ds/DP/DP83820.pdf 41 * http://www.national.com/ds/DP/DP83821.pdf --- 22 unchanged lines hidden (view full) --- 64 * hardware checksum offload (IPv4 only), VLAN tagging and filtering, 65 * priority TX and RX queues, a 2048 bit multicast hash filter, 4 RX pattern 66 * matching buffers, one perfect address filter buffer and interrupt 67 * moderation. The 83820 supports both 64-bit and 32-bit addressing 68 * and data transfers: the 64-bit support can be toggled on or off 69 * via software. This affects the size of certain fields in the DMA 70 * descriptors. 71 * |
72 * As far as I can tell, the 83820 and 83821 are decent chips, marred by 73 * only one flaw: the RX buffers must be aligned on 64-bit boundaries. 74 * So far this is the only gigE MAC that I've encountered with this 75 * requirement. | 72 * There are two bugs/misfeatures in the 83820/83821 that I have 73 * discovered so far: 74 * 75 * - Receive buffers must be aligned on 64-bit boundaries, which means 76 * you must resort to copying data in order to fix up the payload 77 * alignment. 78 * 79 * - In order to transmit jumbo frames larger than 8170 bytes, you have 80 * to turn off transmit checksum offloading, because the chip can't 81 * compute the checksum on an outgoing frame unless it fits entirely 82 * within the TX FIFO, which is only 8192 bytes in size. If you have 83 * TX checksum offload enabled and you transmit attempt to transmit a 84 * frame larger than 8170 bytes, the transmitter will wedge. 85 * 86 * To work around the latter problem, TX checksum offload is disabled 87 * if the user selects an MTU larger than 8152 (8170 - 18). |
76 */ 77 78#include "vlan.h" 79 80#include <sys/param.h> 81#include <sys/systm.h> 82#include <sys/sockio.h> 83#include <sys/mbuf.h> --- 36 unchanged lines hidden (view full) --- 120 121MODULE_DEPEND(nge, miibus, 1, 1, 1); 122 123/* "controller miibus0" required. See GENERIC if you get errors here. */ 124#include "miibus_if.h" 125 126#ifndef lint 127static const char rcsid[] = | 88 */ 89 90#include "vlan.h" 91 92#include <sys/param.h> 93#include <sys/systm.h> 94#include <sys/sockio.h> 95#include <sys/mbuf.h> --- 36 unchanged lines hidden (view full) --- 132 133MODULE_DEPEND(nge, miibus, 1, 1, 1); 134 135/* "controller miibus0" required. See GENERIC if you get errors here. */ 136#include "miibus_if.h" 137 138#ifndef lint 139static const char rcsid[] = |
128 "$FreeBSD: head/sys/dev/nge/if_nge.c 78287 2001-06-15 19:02:55Z wpaul $"; | 140 "$FreeBSD: head/sys/dev/nge/if_nge.c 78323 2001-06-16 03:38:44Z wpaul $"; |
129#endif 130 131#define NGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) 132 133/* 134 * Various supported device vendors/types and their names. 135 */ 136static struct nge_type nge_devs[] = { --- 1146 unchanged lines hidden (view full) --- 1283 1284 ifp->if_ipackets++; 1285 eh = mtod(m, struct ether_header *); 1286 1287 /* Remove header from mbuf and pass it on. */ 1288 m_adj(m, sizeof(struct ether_header)); 1289 1290 /* Do IP checksum checking. */ | 141#endif 142 143#define NGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) 144 145/* 146 * Various supported device vendors/types and their names. 147 */ 148static struct nge_type nge_devs[] = { --- 1146 unchanged lines hidden (view full) --- 1295 1296 ifp->if_ipackets++; 1297 eh = mtod(m, struct ether_header *); 1298 1299 /* Remove header from mbuf and pass it on. */ 1300 m_adj(m, sizeof(struct ether_header)); 1301 1302 /* Do IP checksum checking. */ |
1291 if (ifp->if_hwassist) { 1292 if (extsts & NGE_RXEXTSTS_IPPKT) 1293 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; 1294 if (!(extsts & NGE_RXEXTSTS_IPCSUMERR)) 1295 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; 1296 if ((extsts & NGE_RXEXTSTS_TCPPKT && 1297 !(extsts & NGE_RXEXTSTS_TCPCSUMERR)) || 1298 (extsts & NGE_RXEXTSTS_UDPPKT && 1299 !(extsts & NGE_RXEXTSTS_UDPCSUMERR))) { 1300 m->m_pkthdr.csum_flags |= 1301 CSUM_DATA_VALID|CSUM_PSEUDO_HDR; 1302 m->m_pkthdr.csum_data = 0xffff; 1303 } 1304 } | 1303 if (extsts & NGE_RXEXTSTS_IPPKT) 1304 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; 1305 if (!(extsts & NGE_RXEXTSTS_IPCSUMERR)) 1306 m->m_pkthdr.csum_flags |= CSUM_IP_VALID; 1307 if ((extsts & NGE_RXEXTSTS_TCPPKT && 1308 !(extsts & NGE_RXEXTSTS_TCPCSUMERR)) || 1309 (extsts & NGE_RXEXTSTS_UDPPKT && 1310 !(extsts & NGE_RXEXTSTS_UDPCSUMERR))) { 1311 m->m_pkthdr.csum_flags |= 1312 CSUM_DATA_VALID|CSUM_PSEUDO_HDR; 1313 m->m_pkthdr.csum_data = 0xffff; 1314 } |
1305 1306#if NVLAN > 0 1307 /* 1308 * If we received a packet with a vlan tag, pass it 1309 * to vlan_input() instead of ether_input(). 1310 */ 1311 if (extsts & NGE_RXEXTSTS_VLANPKT) { 1312 vlan_input_tag(eh, m, extsts & NGE_RXEXTSTS_VTCI); --- 403 unchanged lines hidden (view full) --- 1716 vtophys(&sc->nge_ldata->nge_tx_list[0])); 1717 1718 /* Set RX configuration */ 1719 CSR_WRITE_4(sc, NGE_RX_CFG, NGE_RXCFG); 1720 /* 1721 * Enable hardware checksum validation for all IPv4 1722 * packets, do not reject packets with bad checksums. 1723 */ | 1315 1316#if NVLAN > 0 1317 /* 1318 * If we received a packet with a vlan tag, pass it 1319 * to vlan_input() instead of ether_input(). 1320 */ 1321 if (extsts & NGE_RXEXTSTS_VLANPKT) { 1322 vlan_input_tag(eh, m, extsts & NGE_RXEXTSTS_VTCI); --- 403 unchanged lines hidden (view full) --- 1726 vtophys(&sc->nge_ldata->nge_tx_list[0])); 1727 1728 /* Set RX configuration */ 1729 CSR_WRITE_4(sc, NGE_RX_CFG, NGE_RXCFG); 1730 /* 1731 * Enable hardware checksum validation for all IPv4 1732 * packets, do not reject packets with bad checksums. 1733 */ |
1724 if (ifp->if_hwassist) 1725 CSR_WRITE_4(sc, NGE_VLAN_IP_RXCTL, NGE_VIPRXCTL_IPCSUM_ENB); | 1734 CSR_WRITE_4(sc, NGE_VLAN_IP_RXCTL, NGE_VIPRXCTL_IPCSUM_ENB); |
1726 1727#if NVLAN > 0 1728 /* 1729 * If VLAN support is enabled, tell the chip to detect 1730 * and strip VLAN tag info from received frames. The tag 1731 * will be provided in the extsts field in the RX descriptors. 1732 */ 1733 NGE_SETBIT(sc, NGE_VLAN_IP_RXCTL, 1734 NGE_VIPRXCTL_TAG_DETECT_ENB|NGE_VIPRXCTL_TAG_STRIP_ENB); 1735#endif 1736 1737 /* Set TX configuration */ 1738 CSR_WRITE_4(sc, NGE_TX_CFG, NGE_TXCFG); 1739 1740 /* 1741 * Enable TX IPv4 checksumming on a per-packet basis. 1742 */ | 1735 1736#if NVLAN > 0 1737 /* 1738 * If VLAN support is enabled, tell the chip to detect 1739 * and strip VLAN tag info from received frames. The tag 1740 * will be provided in the extsts field in the RX descriptors. 1741 */ 1742 NGE_SETBIT(sc, NGE_VLAN_IP_RXCTL, 1743 NGE_VIPRXCTL_TAG_DETECT_ENB|NGE_VIPRXCTL_TAG_STRIP_ENB); 1744#endif 1745 1746 /* Set TX configuration */ 1747 CSR_WRITE_4(sc, NGE_TX_CFG, NGE_TXCFG); 1748 1749 /* 1750 * Enable TX IPv4 checksumming on a per-packet basis. 1751 */ |
1743 if (ifp->if_hwassist) 1744 CSR_WRITE_4(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_CSUM_PER_PKT); | 1752 CSR_WRITE_4(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_CSUM_PER_PKT); |
1745 1746#if NVLAN > 0 1747 /* 1748 * If VLAN support is enabled, tell the chip to insert 1749 * VLAN tags on a per-packet basis as dictated by the 1750 * code in the frame encapsulation routine. 1751 */ 1752 NGE_SETBIT(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_TAG_PER_PKT); --- 98 unchanged lines hidden (view full) --- 1851 switch(command) { 1852 case SIOCSIFADDR: 1853 case SIOCGIFADDR: 1854 error = ether_ioctl(ifp, command, data); 1855 break; 1856 case SIOCSIFMTU: 1857 if (ifr->ifr_mtu > NGE_JUMBO_MTU) 1858 error = EINVAL; | 1753 1754#if NVLAN > 0 1755 /* 1756 * If VLAN support is enabled, tell the chip to insert 1757 * VLAN tags on a per-packet basis as dictated by the 1758 * code in the frame encapsulation routine. 1759 */ 1760 NGE_SETBIT(sc, NGE_VLAN_IP_TXCTL, NGE_VIPTXCTL_TAG_PER_PKT); --- 98 unchanged lines hidden (view full) --- 1859 switch(command) { 1860 case SIOCSIFADDR: 1861 case SIOCGIFADDR: 1862 error = ether_ioctl(ifp, command, data); 1863 break; 1864 case SIOCSIFMTU: 1865 if (ifr->ifr_mtu > NGE_JUMBO_MTU) 1866 error = EINVAL; |
1859 else | 1867 else { |
1860 ifp->if_mtu = ifr->ifr_mtu; | 1868 ifp->if_mtu = ifr->ifr_mtu; |
1869 /* 1870 * Workaround: if the MTU is larger than 1871 * 8152 (TX FIFO size minus 64 minus 18), turn off 1872 * TX checksum offloading. 1873 */ 1874 if (ifr->ifr_mtu == 8152) 1875 ifp->if_hwassist = 0; 1876 else 1877 ifp->if_hwassist = NGE_CSUM_FEATURES; 1878 } |
|
1861 break; 1862 case SIOCSIFFLAGS: 1863 if (ifp->if_flags & IFF_UP) { 1864 if (ifp->if_flags & IFF_RUNNING && 1865 ifp->if_flags & IFF_PROMISC && 1866 !(sc->nge_if_flags & IFF_PROMISC)) { 1867 NGE_SETBIT(sc, NGE_RXFILT_CTL, 1868 NGE_RXFILTCTL_ALLPHYS| --- 148 unchanged lines hidden --- | 1879 break; 1880 case SIOCSIFFLAGS: 1881 if (ifp->if_flags & IFF_UP) { 1882 if (ifp->if_flags & IFF_RUNNING && 1883 ifp->if_flags & IFF_PROMISC && 1884 !(sc->nge_if_flags & IFF_PROMISC)) { 1885 NGE_SETBIT(sc, NGE_RXFILT_CTL, 1886 NGE_RXFILTCTL_ALLPHYS| --- 148 unchanged lines hidden --- |