target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
static int rtl83xx_find_l2_hash_entry(struct rtl838x_switch_priv *priv, u64 seed,
				     bool must_exist, struct rtl838x_l2_entry *e)
{
	int i, idx = -1;
	u32 key = priv->r->l2_hash_key(priv, seed);
	u64 entry;

	pr_debug("%s: using key %x, for seed %016llx\n", __func__, key, seed);
	// Loop over all entries in the hash-bucket and over the second block on 93xx SoCs
	for (i = 0; i < priv->l2_bucket_size; i++) {
		entry = priv->r->read_l2_entry_using_hash(key, i, e);
		pr_debug("valid %d, mac %016llx\n", e->valid, ether_addr_to_u64(&e->mac[0]));
		if (must_exist && !e->valid)
			continue;
		if (!e->valid || ((entry & 0x0fffffffffffffffULL) == seed)) {
			idx = i > 3 ? ((key >> 14) & 0xffff) | i >> 1 : ((key << 2) | i) & 0xffff;
			break;
		}
	}

	return idx;
}
/*
 * Uses the seed to identify a hash bucket in the L2 using the derived hash key and then loops
 * over the entries in the bucket until either a matching entry is found or an empty slot
 * Returns the filled in rtl838x_l2_entry and the index in the bucket when an entry was found
 * when an empty slot was found and must exist is false, the index of the slot is returned
 * when no slots are available returns -1
 */
Uses the seed to identify a hash bucket in the L2 using the derived hash key and then loops
over the entries in the bucket until either a matching entry is found or an empty slot
Returns the filled in rtl838x_l2_entry and the index in the bucket when an entry was found
when an empty slot was found and must exist is false, the index of the slot is returned
when no slots are available returns -1
Uses the seed to identify a hash bucket in the L2 using the derived hash key and then loops over the entries in the bucket until either a matching entry is found or an empty slot Returns the filled in rtl838x_l2_entry and the index in the bucket when an entry was found when an empty slot was found and must exist is false the index of the slot is returned when no slots are available returns - 1
static int rtl83xx_find_l2_hash_entry(struct rtl838x_switch_priv *priv, u64 seed,
				     bool must_exist, struct rtl838x_l2_entry *e)
{
	int i, idx = -1;
	u32 key = priv->r->l2_hash_key(priv, seed);
	u64 entry;
	pr_debug("%s: using key %x, for seed %016llx\n", __func__, key, seed);
	for (i = 0; i < priv->l2_bucket_size; i++) {
		entry = priv->r->read_l2_entry_using_hash(key, i, e);
		pr_debug("valid %d, mac %016llx\n", e->valid, ether_addr_to_u64(&e->mac[0]));
		if (must_exist && !e->valid)
			continue;
		if (!e->valid || ((entry & 0x0fffffffffffffffULL) == seed)) {
			idx = i > 3 ? ((key >> 14) & 0xffff) | i >> 1 : ((key << 2) | i) & 0xffff;
			break;
		}
	}
	return idx;
}
static int rtl83xx_find_l2_hash_entry ( struct rtl838x_switch_priv * priv , u64 seed , bool must_exist , struct rtl838x_l2_entry * e ) { int i , idx = -1 ; u32 key = priv -> r -> l2_hash_key ( priv , seed ) ; u64 entry ; pr_debug ( " \n " , __func__ , key , seed ) ; for ( i = 0 ; i < priv -> l2_bucket_size ; i ++ ) { entry = priv -> r -> read_l2_entry_using_hash ( key , i , e ) ; pr_debug ( " \n " , e -> valid , ether_addr_to_u64 ( & e -> mac [ 0 ] ) ) ; if ( must_exist && ! e -> valid ) continue ; if ( ! e -> valid || ( ( entry & 0x0fffffffffffffffULL ) == seed ) ) { idx = i > 3 ? ( ( key >> 14 ) & 0xffff ) | i >> 1 : ( ( key << 2 ) | i ) & 0xffff ; break ; } } return idx ; }
Uses the seed to identify a hash bucket in the L2 using the derived hash key and then loops
 over the entries in the bucket until either a matching entry is found or an empty slot
 Returns the filled in rtl838x_l2_entry and the index in the bucket when an entry was found
 when an empty slot was found and must exist is false, the index of the slot is returned
 when no slots are available returns -1
Uses the seed to identify a hash bucket in the L2 using the derived hash key and then loops over the entries in the bucket until either a matching entry is found or an empty slot Returns the filled in rtl838x_l2_entry and the index in the bucket when an entry was found when an empty slot was found and must exist is false the index of the slot is returned when no slots are available returns - 1
// Loop over all entries in the hash-bucket and over the second block on 93xx SoCs