Skip to content

Commit 53011af

Browse files
IoanaCiorneigregkh
authored andcommitted
staging: dpaa2-switch: add fast-ageing on bridge leave
Upon leaving a bridge, any MAC addresses learnt on the switch port prior to this point have to be removed so that we preserve the bridging domain configuration. Restructure the dpaa2_switch_port_fdb_dump() function in order to have a common dpaa2_switch_fdb_iterate() function between the FDB dump callback and the fast age procedure. To accomplish this, add a new callback - dpaa2_switch_fdb_cb_t - which will be called on each MAC addr and, depending on the situation, will either dump the FDB entry into a netlink message or will delete the address from the FDB table, in case of the fast-age. Signed-off-by: Ioana Ciornei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3cf26e8 commit 53011af

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

drivers/staging/fsl-dpaa2/ethsw/ethsw.c

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -729,21 +729,14 @@ static int dpaa2_switch_port_fdb_valid_entry(struct fdb_dump_entry *entry,
729729
return valid;
730730
}
731731

732-
static int dpaa2_switch_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
733-
struct net_device *net_dev,
734-
struct net_device *filter_dev, int *idx)
732+
static int dpaa2_switch_fdb_iterate(struct ethsw_port_priv *port_priv,
733+
dpaa2_switch_fdb_cb_t cb, void *data)
735734
{
736-
struct ethsw_port_priv *port_priv = netdev_priv(net_dev);
735+
struct net_device *net_dev = port_priv->netdev;
737736
struct ethsw_core *ethsw = port_priv->ethsw_data;
738737
struct device *dev = net_dev->dev.parent;
739738
struct fdb_dump_entry *fdb_entries;
740739
struct fdb_dump_entry fdb_entry;
741-
struct ethsw_dump_ctx dump = {
742-
.dev = net_dev,
743-
.skb = skb,
744-
.cb = cb,
745-
.idx = *idx,
746-
};
747740
dma_addr_t fdb_dump_iova;
748741
u16 num_fdb_entries;
749742
u32 fdb_dump_size;
@@ -778,17 +771,12 @@ static int dpaa2_switch_port_fdb_dump(struct sk_buff *skb, struct netlink_callba
778771
for (i = 0; i < num_fdb_entries; i++) {
779772
fdb_entry = fdb_entries[i];
780773

781-
if (!dpaa2_switch_port_fdb_valid_entry(&fdb_entry, port_priv))
782-
continue;
783-
784-
err = dpaa2_switch_fdb_dump_nl(&fdb_entry, &dump);
774+
err = cb(port_priv, &fdb_entry, data);
785775
if (err)
786776
goto end;
787777
}
788778

789779
end:
790-
*idx = dump.idx;
791-
792780
kfree(dma_mem);
793781

794782
return 0;
@@ -800,6 +788,59 @@ static int dpaa2_switch_port_fdb_dump(struct sk_buff *skb, struct netlink_callba
800788
return err;
801789
}
802790

791+
static int dpaa2_switch_fdb_entry_dump(struct ethsw_port_priv *port_priv,
792+
struct fdb_dump_entry *fdb_entry,
793+
void *data)
794+
{
795+
if (!dpaa2_switch_port_fdb_valid_entry(fdb_entry, port_priv))
796+
return 0;
797+
798+
return dpaa2_switch_fdb_dump_nl(fdb_entry, data);
799+
}
800+
801+
static int dpaa2_switch_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
802+
struct net_device *net_dev,
803+
struct net_device *filter_dev, int *idx)
804+
{
805+
struct ethsw_port_priv *port_priv = netdev_priv(net_dev);
806+
struct ethsw_dump_ctx dump = {
807+
.dev = net_dev,
808+
.skb = skb,
809+
.cb = cb,
810+
.idx = *idx,
811+
};
812+
int err;
813+
814+
err = dpaa2_switch_fdb_iterate(port_priv, dpaa2_switch_fdb_entry_dump, &dump);
815+
*idx = dump.idx;
816+
817+
return err;
818+
}
819+
820+
static int dpaa2_switch_fdb_entry_fast_age(struct ethsw_port_priv *port_priv,
821+
struct fdb_dump_entry *fdb_entry,
822+
void *data __always_unused)
823+
{
824+
if (!dpaa2_switch_port_fdb_valid_entry(fdb_entry, port_priv))
825+
return 0;
826+
827+
if (!(fdb_entry->type & DPSW_FDB_ENTRY_TYPE_DYNAMIC))
828+
return 0;
829+
830+
if (fdb_entry->type & DPSW_FDB_ENTRY_TYPE_UNICAST)
831+
dpaa2_switch_port_fdb_del_uc(port_priv, fdb_entry->mac_addr);
832+
else
833+
dpaa2_switch_port_fdb_del_mc(port_priv, fdb_entry->mac_addr);
834+
835+
return 0;
836+
}
837+
838+
static void dpaa2_switch_port_fast_age(struct ethsw_port_priv *port_priv)
839+
{
840+
dpaa2_switch_fdb_iterate(port_priv,
841+
dpaa2_switch_fdb_entry_fast_age, NULL);
842+
}
843+
803844
static int dpaa2_switch_port_vlan_add(struct net_device *netdev, __be16 proto,
804845
u16 vid)
805846
{
@@ -1511,6 +1552,9 @@ static int dpaa2_switch_port_bridge_leave(struct net_device *netdev)
15111552
struct ethsw_core *ethsw = port_priv->ethsw_data;
15121553
int err;
15131554

1555+
/* First of all, fast age any learn FDB addresses on this switch port */
1556+
dpaa2_switch_port_fast_age(port_priv);
1557+
15141558
/* Clear all RX VLANs installed through vlan_vid_add() either as VLAN
15151559
* upper devices or otherwise from the FDB table that we are about to
15161560
* leave

drivers/staging/fsl-dpaa2/ethsw/ethsw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,7 @@ int dpaa2_switch_port_vlans_add(struct net_device *netdev,
172172
int dpaa2_switch_port_vlans_del(struct net_device *netdev,
173173
const struct switchdev_obj_port_vlan *vlan);
174174

175+
typedef int dpaa2_switch_fdb_cb_t(struct ethsw_port_priv *port_priv,
176+
struct fdb_dump_entry *fdb_entry,
177+
void *data);
175178
#endif /* __ETHSW_H */

0 commit comments

Comments
 (0)