if_hme.c (130026) | if_hme.c (130270) |
---|---|
1/*- 2 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * Copyright (c) 2001-2003 Thomas Moestl <tmm@FreeBSD.org>. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Paul Kranenburg. 8 * --- 24 unchanged lines hidden (view full) --- 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 * from: NetBSD: hme.c,v 1.29 2002/05/05 03:02:38 thorpej Exp 38 */ 39 40#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * Copyright (c) 2001-2003 Thomas Moestl <tmm@FreeBSD.org>. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Paul Kranenburg. 8 * --- 24 unchanged lines hidden (view full) --- 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 * from: NetBSD: hme.c,v 1.29 2002/05/05 03:02:38 thorpej Exp 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme.c 130026 2004-06-03 06:10:02Z phk $"); | 41__FBSDID("$FreeBSD: head/sys/dev/hme/if_hme.c 130270 2004-06-09 14:34:04Z naddy $"); |
42 43/* 44 * HME Ethernet module driver. 45 * 46 * The HME is e.g. part of the PCIO PCI multi function device. 47 * It supports TX gathering and TX and RX checksum offloading. 48 * RX buffers must be aligned at a programmable offset modulo 16. We choose 2 49 * for this offset: mbuf clusters are usually on about 2^11 boundaries, 2 bytes --- 1350 unchanged lines hidden (view full) --- 1400 * Set up the logical address filter. 1401 */ 1402static void 1403hme_setladrf(struct hme_softc *sc, int reenable) 1404{ 1405 struct ifnet *ifp = &sc->sc_arpcom.ac_if; 1406 struct ifmultiaddr *inm; 1407 struct sockaddr_dl *sdl; | 42 43/* 44 * HME Ethernet module driver. 45 * 46 * The HME is e.g. part of the PCIO PCI multi function device. 47 * It supports TX gathering and TX and RX checksum offloading. 48 * RX buffers must be aligned at a programmable offset modulo 16. We choose 2 49 * for this offset: mbuf clusters are usually on about 2^11 boundaries, 2 bytes --- 1350 unchanged lines hidden (view full) --- 1400 * Set up the logical address filter. 1401 */ 1402static void 1403hme_setladrf(struct hme_softc *sc, int reenable) 1404{ 1405 struct ifnet *ifp = &sc->sc_arpcom.ac_if; 1406 struct ifmultiaddr *inm; 1407 struct sockaddr_dl *sdl; |
1408 u_char *cp; | |
1409 u_int32_t crc; 1410 u_int32_t hash[4]; 1411 u_int32_t macc; 1412 int len; 1413 1414 /* Clear hash table */ 1415 hash[3] = hash[2] = hash[1] = hash[0] = 0; 1416 --- 37 unchanged lines hidden (view full) --- 1454 * selects the word, while the rest of the bits select the bit within 1455 * the word. 1456 */ 1457 1458 TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) { 1459 if (inm->ifma_addr->sa_family != AF_LINK) 1460 continue; 1461 sdl = (struct sockaddr_dl *)inm->ifma_addr; | 1408 u_int32_t crc; 1409 u_int32_t hash[4]; 1410 u_int32_t macc; 1411 int len; 1412 1413 /* Clear hash table */ 1414 hash[3] = hash[2] = hash[1] = hash[0] = 0; 1415 --- 37 unchanged lines hidden (view full) --- 1453 * selects the word, while the rest of the bits select the bit within 1454 * the word. 1455 */ 1456 1457 TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) { 1458 if (inm->ifma_addr->sa_family != AF_LINK) 1459 continue; 1460 sdl = (struct sockaddr_dl *)inm->ifma_addr; |
1462 cp = LLADDR(sdl); 1463 crc = 0xffffffff; 1464 for (len = sdl->sdl_alen; --len >= 0;) { 1465 int octet = *cp++; 1466 int i; | 1461 crc = ether_crc32_le(sdl, ETHER_ADDR_LEN); |
1467 | 1462 |
1468#define MC_POLY_LE 0xedb88320UL /* mcast crc, little endian */ 1469 for (i = 0; i < 8; i++) { 1470 if ((crc & 1) ^ (octet & 1)) { 1471 crc >>= 1; 1472 crc ^= MC_POLY_LE; 1473 } else { 1474 crc >>= 1; 1475 } 1476 octet >>= 1; 1477 } 1478 } | |
1479 /* Just want the 6 most significant bits. */ 1480 crc >>= 26; 1481 1482 /* Set the corresponding bit in the filter. */ 1483 hash[crc >> 4] |= 1 << (crc & 0xf); 1484 } 1485 1486 ifp->if_flags &= ~IFF_ALLMULTI; 1487 1488chipit: 1489 /* Now load the hash table into the chip */ 1490 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB0, hash[0]); 1491 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB1, hash[1]); 1492 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB2, hash[2]); 1493 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB3, hash[3]); 1494 hme_mac_bitflip(sc, HME_MACI_RXCFG, macc, 0, 1495 macc & (HME_MAC_RXCFG_ENABLE | HME_MAC_RXCFG_HENABLE)); 1496} | 1463 /* Just want the 6 most significant bits. */ 1464 crc >>= 26; 1465 1466 /* Set the corresponding bit in the filter. */ 1467 hash[crc >> 4] |= 1 << (crc & 0xf); 1468 } 1469 1470 ifp->if_flags &= ~IFF_ALLMULTI; 1471 1472chipit: 1473 /* Now load the hash table into the chip */ 1474 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB0, hash[0]); 1475 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB1, hash[1]); 1476 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB2, hash[2]); 1477 HME_MAC_WRITE_4(sc, HME_MACI_HASHTAB3, hash[3]); 1478 hme_mac_bitflip(sc, HME_MACI_RXCFG, macc, 0, 1479 macc & (HME_MAC_RXCFG_ENABLE | HME_MAC_RXCFG_HENABLE)); 1480} |