| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_et.c,v 1.26 2019/08/01 13:36:37 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_et.c,v 1.27 2019/10/12 06:00:52 msaitoh Exp $ */ |
2 | /* $OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $ */ | | 2 | /* $OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $ */ |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2007 The DragonFly Project. All rights reserved. | | 4 | * Copyright (c) 2007 The DragonFly Project. All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to The DragonFly Project | | 6 | * This code is derived from software contributed to The DragonFly Project |
7 | * by Sepherosa Ziehau <sepherosa@gmail.com> | | 7 | * by Sepherosa Ziehau <sepherosa@gmail.com> |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * | | 12 | * |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | | 27 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, |
29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 30 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
31 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 31 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
33 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * $DragonFly: src/sys/dev/netif/et/if_et.c,v 1.1 2007/10/12 14:12:42 sephe Exp $ | | 36 | * $DragonFly: src/sys/dev/netif/et/if_et.c,v 1.1 2007/10/12 14:12:42 sephe Exp $ |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | __KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.26 2019/08/01 13:36:37 msaitoh Exp $"); | | 40 | __KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.27 2019/10/12 06:00:52 msaitoh Exp $"); |
41 | | | 41 | |
42 | #include "opt_inet.h" | | 42 | #include "opt_inet.h" |
43 | #include "vlan.h" | | 43 | #include "vlan.h" |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/endian.h> | | 46 | #include <sys/endian.h> |
47 | #include <sys/systm.h> | | 47 | #include <sys/systm.h> |
48 | #include <sys/types.h> | | 48 | #include <sys/types.h> |
49 | #include <sys/sockio.h> | | 49 | #include <sys/sockio.h> |
50 | #include <sys/mbuf.h> | | 50 | #include <sys/mbuf.h> |
51 | #include <sys/queue.h> | | 51 | #include <sys/queue.h> |
52 | #include <sys/kernel.h> | | 52 | #include <sys/kernel.h> |
53 | #include <sys/device.h> | | 53 | #include <sys/device.h> |
| @@ -1294,51 +1294,44 @@ et_free_rx_ring(struct et_softc *sc) | | | @@ -1294,51 +1294,44 @@ et_free_rx_ring(struct et_softc *sc) |
1294 | rx_ring->rr_dmap->dm_mapsize, BUS_DMASYNC_PREWRITE); | | 1294 | rx_ring->rr_dmap->dm_mapsize, BUS_DMASYNC_PREWRITE); |
1295 | } | | 1295 | } |
1296 | } | | 1296 | } |
1297 | | | 1297 | |
1298 | void | | 1298 | void |
1299 | et_setmulti(struct et_softc *sc) | | 1299 | et_setmulti(struct et_softc *sc) |
1300 | { | | 1300 | { |
1301 | struct ethercom *ec = &sc->sc_ethercom; | | 1301 | struct ethercom *ec = &sc->sc_ethercom; |
1302 | struct ifnet *ifp = &ec->ec_if; | | 1302 | struct ifnet *ifp = &ec->ec_if; |
1303 | uint32_t hash[4] = { 0, 0, 0, 0 }; | | 1303 | uint32_t hash[4] = { 0, 0, 0, 0 }; |
1304 | uint32_t rxmac_ctrl, pktfilt; | | 1304 | uint32_t rxmac_ctrl, pktfilt; |
1305 | struct ether_multi *enm; | | 1305 | struct ether_multi *enm; |
1306 | struct ether_multistep step; | | 1306 | struct ether_multistep step; |
1307 | uint8_t addr[ETHER_ADDR_LEN]; | | | |
1308 | int i, count; | | 1307 | int i, count; |
1309 | | | 1308 | |
1310 | pktfilt = CSR_READ_4(sc, ET_PKTFILT); | | 1309 | pktfilt = CSR_READ_4(sc, ET_PKTFILT); |
1311 | rxmac_ctrl = CSR_READ_4(sc, ET_RXMAC_CTRL); | | 1310 | rxmac_ctrl = CSR_READ_4(sc, ET_RXMAC_CTRL); |
1312 | | | 1311 | |
1313 | pktfilt &= ~(ET_PKTFILT_BCAST | ET_PKTFILT_MCAST | ET_PKTFILT_UCAST); | | 1312 | pktfilt &= ~(ET_PKTFILT_BCAST | ET_PKTFILT_MCAST | ET_PKTFILT_UCAST); |
1314 | if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) { | | 1313 | if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) { |
1315 | rxmac_ctrl |= ET_RXMAC_CTRL_NO_PKTFILT; | | 1314 | rxmac_ctrl |= ET_RXMAC_CTRL_NO_PKTFILT; |
1316 | goto back; | | 1315 | goto back; |
1317 | } | | 1316 | } |
1318 | | | 1317 | |
1319 | bcopy(etherbroadcastaddr, addr, ETHER_ADDR_LEN); | | | |
1320 | | | | |
1321 | count = 0; | | 1318 | count = 0; |
1322 | ETHER_LOCK(ec); | | 1319 | ETHER_LOCK(ec); |
1323 | ETHER_FIRST_MULTI(step, ec, enm); | | 1320 | ETHER_FIRST_MULTI(step, ec, enm); |
1324 | while (enm != NULL) { | | 1321 | while (enm != NULL) { |
1325 | uint32_t *hp, h; | | 1322 | uint32_t *hp, h; |
1326 | | | 1323 | |
1327 | for (i = 0; i < ETHER_ADDR_LEN; i++) { | | 1324 | h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN); |
1328 | addr[i] &= enm->enm_addrlo[i]; | | | |
1329 | } | | | |
1330 | | | | |
1331 | h = ether_crc32_be(addr, ETHER_ADDR_LEN); | | | |
1332 | h = (h & 0x3f800000) >> 23; | | 1325 | h = (h & 0x3f800000) >> 23; |
1333 | | | 1326 | |
1334 | hp = &hash[0]; | | 1327 | hp = &hash[0]; |
1335 | if (h >= 32 && h < 64) { | | 1328 | if (h >= 32 && h < 64) { |
1336 | h -= 32; | | 1329 | h -= 32; |
1337 | hp = &hash[1]; | | 1330 | hp = &hash[1]; |
1338 | } else if (h >= 64 && h < 96) { | | 1331 | } else if (h >= 64 && h < 96) { |
1339 | h -= 64; | | 1332 | h -= 64; |
1340 | hp = &hash[2]; | | 1333 | hp = &hash[2]; |
1341 | } else if (h >= 96) { | | 1334 | } else if (h >= 96) { |
1342 | h -= 96; | | 1335 | h -= 96; |
1343 | hp = &hash[3]; | | 1336 | hp = &hash[3]; |
1344 | } | | 1337 | } |