@@ -162,6 +162,9 @@ struct dsa_switch_tree {
/* Track the largest switch index within a tree */
unsigned int last_switch;
+
+ /* List of port mirror routes */
+ struct list_head mirrors;
};
/* LAG IDs are one-based, the dst->lags array is zero-based */
@@ -368,6 +371,21 @@ struct dsa_vlan {
struct list_head list;
};
+struct dsa_mirror {
+ struct list_head list;
+ const struct dsa_port *from_dp;
+ const struct dsa_port *to_dp;
+ bool ingress;
+ struct list_head route;
+};
+
+struct dsa_route {
+ struct list_head list;
+ int sw_index;
+ int from_local_p;
+ int to_local_p;
+};
+
struct dsa_switch {
struct device *dev;
@@ -228,6 +228,8 @@ static struct dsa_switch_tree *dsa_tree_alloc(int index)
kref_init(&dst->refcount);
+ INIT_LIST_HEAD(&dst->mirrors);
+
return dst;
}
@@ -923,6 +925,8 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
static void dsa_tree_teardown(struct dsa_switch_tree *dst)
{
struct dsa_link *dl, *next;
+ struct dsa_mirror *dm, *m;
+ struct dsa_route *dr, *r;
if (!dst->setup)
return;
@@ -942,6 +946,16 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst)
kfree(dl);
}
+ list_for_each_entry_safe(dm, m, &dst->mirrors, list) {
+ list_for_each_entry_safe(dr, r, &dm->route, list) {
+ list_del(&dr->list);
+ kfree(dr);
+ }
+
+ list_del(&dm->list);
+ kfree(dm);
+ }
+
pr_info("DSA: tree %d torn down\n", dst->index);
dst->setup = false;
cross chip mirroring require routing mirrored data from source to destination switch. Add the necessary groundwork. Signed-off-by: Ante Knezic <ante.knezic@helmholz.de> --- include/net/dsa.h | 18 ++++++++++++++++++ net/dsa/dsa.c | 14 ++++++++++++++ 2 files changed, 32 insertions(+)