FreeBSD/sys/dev/cadence/if_cgem.c
/* After any change in rx flags or multi-cast addresses, set up
 * hash registers and net config register bits.
 */
After any change in rx flags or multi-cast addresses, set up
hash registers and net config register bits.
After any change in rx flags or multi - cast addresses set up hash registers and net config register bits .
static void
cgem_rx_filter(struct cgem_softc *sc)
{
	if_t ifp = sc->ifp;
	u_char *mta;
	int index, i, mcnt;
	uint32_t hash_hi, hash_lo;
	uint32_t net_cfg;
	hash_hi = 0;
	hash_lo = 0;
	net_cfg = RD4(sc, CGEM_NET_CFG);
	net_cfg &= ~(CGEM_NET_CFG_MULTI_HASH_EN |
		     CGEM_NET_CFG_NO_BCAST | 
		     CGEM_NET_CFG_COPY_ALL);
	if ((if_getflags(ifp) & IFF_PROMISC) != 0)
		net_cfg |= CGEM_NET_CFG_COPY_ALL;
	else {
		if ((if_getflags(ifp) & IFF_BROADCAST) == 0)
			net_cfg |= CGEM_NET_CFG_NO_BCAST;
		if ((if_getflags(ifp) & IFF_ALLMULTI) != 0) {
			hash_hi = 0xffffffff;
			hash_lo = 0xffffffff;
		} else {
			mcnt = if_multiaddr_count(ifp, -1);
			mta = malloc(ETHER_ADDR_LEN * mcnt, M_DEVBUF,
				     M_NOWAIT);
			if (mta == NULL) {
				device_printf(sc->dev,
				      "failed to allocate temp mcast list\n");
				return;
			}
			if_multiaddr_array(ifp, mta, &mcnt, mcnt);
			for (i = 0; i < mcnt; i++) {
				index = cgem_mac_hash(
					LLADDR((struct sockaddr_dl *)
					       (mta + (i * ETHER_ADDR_LEN))));
				if (index > 31)
					hash_hi |= (1 << (index - 32));
				else
					hash_lo |= (1 << index);
			}
			free(mta, M_DEVBUF);
		}
		if (hash_hi != 0 || hash_lo != 0)
			net_cfg |= CGEM_NET_CFG_MULTI_HASH_EN;
	}
	WR4(sc, CGEM_HASH_TOP, hash_hi);
	WR4(sc, CGEM_HASH_BOT, hash_lo);
	WR4(sc, CGEM_NET_CFG, net_cfg);
}
static void cgem_rx_filter ( struct cgem_softc * sc ) { if_t ifp = sc -> ifp ; u_char * mta ; int index , i , mcnt ; uint32_t hash_hi , hash_lo ; uint32_t net_cfg ; hash_hi = 0 ; hash_lo = 0 ; net_cfg = RD4 ( sc , CGEM_NET_CFG ) ; net_cfg &= ~ ( CGEM_NET_CFG_MULTI_HASH_EN | CGEM_NET_CFG_NO_BCAST | CGEM_NET_CFG_COPY_ALL ) ; if ( ( if_getflags ( ifp ) & IFF_PROMISC ) != 0 ) net_cfg |= CGEM_NET_CFG_COPY_ALL ; else { if ( ( if_getflags ( ifp ) & IFF_BROADCAST ) == 0 ) net_cfg |= CGEM_NET_CFG_NO_BCAST ; if ( ( if_getflags ( ifp ) & IFF_ALLMULTI ) != 0 ) { hash_hi = 0xffffffff ; hash_lo = 0xffffffff ; } else { mcnt = if_multiaddr_count ( ifp , -1 ) ; mta = malloc ( ETHER_ADDR_LEN * mcnt , M_DEVBUF , M_NOWAIT ) ; if ( mta == NULL ) { device_printf ( sc -> dev , " \n " ) ; return ; } if_multiaddr_array ( ifp , mta , & mcnt , mcnt ) ; for ( i = 0 ; i < mcnt ; i ++ ) { index = cgem_mac_hash ( LLADDR ( ( struct sockaddr_dl * ) ( mta + ( i * ETHER_ADDR_LEN ) ) ) ) ; if ( index > 31 ) hash_hi |= ( 1 << ( index - 32 ) ) ; else hash_lo |= ( 1 << index ) ; } free ( mta , M_DEVBUF ) ; } if ( hash_hi != 0 || hash_lo != 0 ) net_cfg |= CGEM_NET_CFG_MULTI_HASH_EN ; } WR4 ( sc , CGEM_HASH_TOP , hash_hi ) ; WR4 ( sc , CGEM_HASH_BOT , hash_lo ) ; WR4 ( sc , CGEM_NET_CFG , net_cfg ) ; }
After any change in rx flags or multi-cast addresses, set up
 hash registers and net config register bits.
After any change in rx flags or multi - cast addresses set up hash registers and net config register bits .