Commit d38c6e3d authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

net: bridge: fdb: convert offloaded to use bitops

Convert the offloaded field to a flag and use bitops.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b5cd9f7c
...@@ -506,7 +506,6 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br, ...@@ -506,7 +506,6 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
set_bit(BR_FDB_LOCAL, &fdb->flags); set_bit(BR_FDB_LOCAL, &fdb->flags);
if (is_static) if (is_static)
set_bit(BR_FDB_STATIC, &fdb->flags); set_bit(BR_FDB_STATIC, &fdb->flags);
fdb->offloaded = 0;
fdb->updated = fdb->used = jiffies; fdb->updated = fdb->used = jiffies;
if (rhashtable_lookup_insert_fast(&br->fdb_hash_tbl, if (rhashtable_lookup_insert_fast(&br->fdb_hash_tbl,
&fdb->rhnode, &fdb->rhnode,
...@@ -656,7 +655,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br, ...@@ -656,7 +655,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex; ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex;
ndm->ndm_state = fdb_to_nud(br, fdb); ndm->ndm_state = fdb_to_nud(br, fdb);
if (fdb->offloaded) if (test_bit(BR_FDB_OFFLOADED, &fdb->flags))
ndm->ndm_flags |= NTF_OFFLOADED; ndm->ndm_flags |= NTF_OFFLOADED;
if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags))
ndm->ndm_flags |= NTF_EXT_LEARNED; ndm->ndm_flags |= NTF_EXT_LEARNED;
...@@ -1188,8 +1187,8 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, ...@@ -1188,8 +1187,8 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
spin_lock_bh(&br->hash_lock); spin_lock_bh(&br->hash_lock);
fdb = br_fdb_find(br, addr, vid); fdb = br_fdb_find(br, addr, vid);
if (fdb) if (fdb && offloaded != test_bit(BR_FDB_OFFLOADED, &fdb->flags))
fdb->offloaded = offloaded; change_bit(BR_FDB_OFFLOADED, &fdb->flags);
spin_unlock_bh(&br->hash_lock); spin_unlock_bh(&br->hash_lock);
} }
...@@ -1208,7 +1207,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid) ...@@ -1208,7 +1207,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
spin_lock_bh(&p->br->hash_lock); spin_lock_bh(&p->br->hash_lock);
hlist_for_each_entry(f, &p->br->fdb_list, fdb_node) { hlist_for_each_entry(f, &p->br->fdb_list, fdb_node) {
if (f->dst == p && f->key.vlan_id == vid) if (f->dst == p && f->key.vlan_id == vid)
f->offloaded = 0; clear_bit(BR_FDB_OFFLOADED, &f->flags);
} }
spin_unlock_bh(&p->br->hash_lock); spin_unlock_bh(&p->br->hash_lock);
} }
......
...@@ -179,6 +179,7 @@ enum { ...@@ -179,6 +179,7 @@ enum {
BR_FDB_STICKY, BR_FDB_STICKY,
BR_FDB_ADDED_BY_USER, BR_FDB_ADDED_BY_USER,
BR_FDB_ADDED_BY_EXT_LEARN, BR_FDB_ADDED_BY_EXT_LEARN,
BR_FDB_OFFLOADED,
}; };
struct net_bridge_fdb_key { struct net_bridge_fdb_key {
...@@ -193,7 +194,6 @@ struct net_bridge_fdb_entry { ...@@ -193,7 +194,6 @@ struct net_bridge_fdb_entry {
struct net_bridge_fdb_key key; struct net_bridge_fdb_key key;
struct hlist_node fdb_node; struct hlist_node fdb_node;
unsigned long flags; unsigned long flags;
unsigned char offloaded:1;
/* write-heavy members should not affect lookups */ /* write-heavy members should not affect lookups */
unsigned long updated ____cacheline_aligned_in_smp; unsigned long updated ____cacheline_aligned_in_smp;
......
...@@ -131,7 +131,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type) ...@@ -131,7 +131,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
fdb->dst->dev, fdb->dst->dev,
test_bit(BR_FDB_ADDED_BY_USER, test_bit(BR_FDB_ADDED_BY_USER,
&fdb->flags), &fdb->flags),
fdb->offloaded); test_bit(BR_FDB_OFFLOADED,
&fdb->flags));
break; break;
case RTM_NEWNEIGH: case RTM_NEWNEIGH:
br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr, br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
...@@ -139,7 +140,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type) ...@@ -139,7 +140,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
fdb->dst->dev, fdb->dst->dev,
test_bit(BR_FDB_ADDED_BY_USER, test_bit(BR_FDB_ADDED_BY_USER,
&fdb->flags), &fdb->flags),
fdb->offloaded); test_bit(BR_FDB_OFFLOADED,
&fdb->flags));
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment