net: dsa: remove bitmap operations
Subsystems (3)
PATCH 1/1 net: dsa: remove bitmap operations
The bitmap operations were introduced to simplify the switch drivers in the future, since most of them could implement the common VLAN and MDB operations (add, del, dump) with simple functions taking all target ports at once, and thus limiting the number of hardware accesses.
Programming an MDB or VLAN this way in a single operation would clearly simplify the drivers a lot but would require a new get-set interface in DSA. The usage of such bitmap from the stack also raised concerned in the past, leading to the dynamic allocation of a new ds->_bitmap member in the dsa_switch structure. So let's get rid of them for now.
This commit nicely wraps the ds->ops->port_{mdb,vlan}_{prepare,add} switch operations into new dsa_switch_{mdb,vlan}_{prepare,add} variants not using any bitmap argument anymore.
New dsa_switch_{mdb,vlan}_match helpers have been introduced to make clear which local port of a switch must be programmed with the target object. While the targeted user port is an obvious candidate, the DSA links must also be programmed, as well as the CPU port for VLANs.
While at it, also remove local variables that are only used once.
--- include/net/dsa.h | 3 -- net/dsa/dsa2.c | 14 ----- net/dsa/switch.c | 132 +++++++++++++++++++++------------------------- 3 files changed, 59 insertions(+), 90 deletions(-)
include/net/dsa.h +0 -3
@@ -275,9 +275,6 @@ struct dsa_switch {*/ bool vlan_filtering; -unsigned long *bitmap; -unsigned long _bitmap; -/* Dynamically allocated ports, keep last */ size_t num_ports;struct dsa_port ports[];
net/dsa/dsa2.c +0 -14
@@ -834,20 +834,6 @@ struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n)if (!ds)return NULL ; -/* We avoid allocating memory outside dsa_switch -* if it is not needed. -*/ -if (n <=sizeof (ds->_bitmap) *8 ) { - ds->bitmap = &ds->_bitmap; - }else { - ds->bitmap =devm_kcalloc (dev, -BITS_TO_LONGS (n), -sizeof (unsigned long ), -GFP_KERNEL ); -if (unlikely (!ds->bitmap)) -return NULL ; - } - ds->dev = dev; ds->num_ports = n;
net/dsa/switch.c +59 -73
201 lines not on this page · raw message
Signature · 1 line
2.23.0
Quoted 15 lines · Vivien Didelot
The bitmap operations were introduced to simplify the switch drivers in the future, since most of them could implement the common VLAN and MDB operations (add, del, dump) with simple functions taking all target ports at once, and thus limiting the number of hardware accesses.
Programming an MDB or VLAN this way in a single operation would clearly simplify the drivers a lot but would require a new get-set interface in DSA. The usage of such bitmap from the stack also raised concerned in the past, leading to the dynamic allocation of a new
ds->_bitmapmember in thedsa_switchstructure. So let's get rid of them for now.This commit nicely wraps the ds->ops->port_{mdb,vlan}_{prepare,add} switch operations into new dsa_switch_{mdb,vlan}_{prepare,add} variants not using any bitmap argument anymore.
Quoted 8 lines
New dsa_switch_{mdb,vlan}_match helpers have been introduced to make clear which local port of a switch must be programmed with the target object. While the targeted user port is an obvious candidate, the DSA links must also be programmed, as well as the CPU port for VLANs.
While at it, also remove local variables that are only used once.
Signed-off-by Vivien Didelot <[email protected]>
David, I've included this patch into a new series with other related patches, you can ignore this one now.
Thanks,
Vivien
David Miller
maintainerFrom: Vivien Didelot <[email protected]>
Date: Thu, 22 Aug 2019 16:17:28 -0400
Quoted 2 lines
David, I've included this patch into a new series with other related patches, you can ignore this one now.
Ok, thanks for letting me know.