Skip to content

Commit

Permalink
net: spider_net: Use non-atomic bitmap API when applicable
Browse files Browse the repository at this point in the history
No concurrent access is possible when a bitmap is local to a function.
So prefer the non-atomic functions to save a few cycles.
   - replace a 'for' loop by an equivalent non-atomic 'bitmap_fill()' call
   - use '__set_bit()'

While at it, clear the 'bitmask' bitmap only when needed.

Signed-off-by: Christophe JAILLET <[email protected]>
Link: https://lore.kernel.org/r/3de0792f5088f00d135c835df6c19e63ae95f5d2.1638026251.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <[email protected]>
tititiou36 authored and kuba-moo committed Dec 2, 2021
1 parent 10184da commit 699e53e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/net/ethernet/toshiba/spider_net.c
Original file line number Diff line number Diff line change
@@ -595,24 +595,24 @@ spider_net_set_multi(struct net_device *netdev)
int i;
u32 reg;
struct spider_net_card *card = netdev_priv(netdev);
DECLARE_BITMAP(bitmask, SPIDER_NET_MULTICAST_HASHES) = {};
DECLARE_BITMAP(bitmask, SPIDER_NET_MULTICAST_HASHES);

spider_net_set_promisc(card);

if (netdev->flags & IFF_ALLMULTI) {
for (i = 0; i < SPIDER_NET_MULTICAST_HASHES; i++) {
set_bit(i, bitmask);
}
bitmap_fill(bitmask, SPIDER_NET_MULTICAST_HASHES);
goto write_hash;
}

bitmap_zero(bitmask, SPIDER_NET_MULTICAST_HASHES);

/* well, we know, what the broadcast hash value is: it's xfd
hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */
set_bit(0xfd, bitmask);
__set_bit(0xfd, bitmask);

netdev_for_each_mc_addr(ha, netdev) {
hash = spider_net_get_multicast_hash(netdev, ha->addr);
set_bit(hash, bitmask);
__set_bit(hash, bitmask);
}

write_hash:

0 comments on commit 699e53e

Please sign in to comment.