1 |
From 9019dbfb39a5f570c0acd29fb46783d67921838b Mon Sep 17 00:00:00 2001 |
2 |
From: Sasha Levin <sashal@kernel.org> |
3 |
Date: Fri, 17 Jun 2022 14:12:50 +0530 |
4 |
Subject: net: dsa: microchip: move the port mirror to ksz_common |
5 |
|
6 |
From: Arun Ramadoss <arun.ramadoss@microchip.com> |
7 |
|
8 |
[ Upstream commit 00a298bbc23876288b1cd04c38752d8e7ed53ae2 ] |
9 |
|
10 |
This patch updates the common port mirror add/del dsa_switch_ops in |
11 |
ksz_common.c. The individual switches implementation is executed based |
12 |
on the ksz_dev_ops function pointers. |
13 |
|
14 |
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> |
15 |
Reviewed-by: Vladimir Oltean <olteanv@gmail.com> |
16 |
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> |
17 |
Signed-off-by: Paolo Abeni <pabeni@redhat.com> |
18 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
19 |
--- |
20 |
drivers/net/dsa/microchip/ksz8795.c | 13 ++++++------- |
21 |
drivers/net/dsa/microchip/ksz9477.c | 12 ++++++------ |
22 |
drivers/net/dsa/microchip/ksz_common.c | 23 +++++++++++++++++++++++ |
23 |
drivers/net/dsa/microchip/ksz_common.h | 10 ++++++++++ |
24 |
4 files changed, 45 insertions(+), 13 deletions(-) |
25 |
|
26 |
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c |
27 |
index 16e946dbd9d42..2e3d24a3260e1 100644 |
28 |
--- a/drivers/net/dsa/microchip/ksz8795.c |
29 |
+++ b/drivers/net/dsa/microchip/ksz8795.c |
30 |
@@ -1089,12 +1089,10 @@ static int ksz8_port_vlan_del(struct ksz_device *dev, int port, |
31 |
return 0; |
32 |
} |
33 |
|
34 |
-static int ksz8_port_mirror_add(struct dsa_switch *ds, int port, |
35 |
+static int ksz8_port_mirror_add(struct ksz_device *dev, int port, |
36 |
struct dsa_mall_mirror_tc_entry *mirror, |
37 |
bool ingress, struct netlink_ext_ack *extack) |
38 |
{ |
39 |
- struct ksz_device *dev = ds->priv; |
40 |
- |
41 |
if (ingress) { |
42 |
ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true); |
43 |
dev->mirror_rx |= BIT(port); |
44 |
@@ -1113,10 +1111,9 @@ static int ksz8_port_mirror_add(struct dsa_switch *ds, int port, |
45 |
return 0; |
46 |
} |
47 |
|
48 |
-static void ksz8_port_mirror_del(struct dsa_switch *ds, int port, |
49 |
+static void ksz8_port_mirror_del(struct ksz_device *dev, int port, |
50 |
struct dsa_mall_mirror_tc_entry *mirror) |
51 |
{ |
52 |
- struct ksz_device *dev = ds->priv; |
53 |
u8 data; |
54 |
|
55 |
if (mirror->ingress) { |
56 |
@@ -1400,8 +1397,8 @@ static const struct dsa_switch_ops ksz8_switch_ops = { |
57 |
.port_fdb_dump = ksz_port_fdb_dump, |
58 |
.port_mdb_add = ksz_port_mdb_add, |
59 |
.port_mdb_del = ksz_port_mdb_del, |
60 |
- .port_mirror_add = ksz8_port_mirror_add, |
61 |
- .port_mirror_del = ksz8_port_mirror_del, |
62 |
+ .port_mirror_add = ksz_port_mirror_add, |
63 |
+ .port_mirror_del = ksz_port_mirror_del, |
64 |
}; |
65 |
|
66 |
static u32 ksz8_get_port_addr(int port, int offset) |
67 |
@@ -1464,6 +1461,8 @@ static const struct ksz_dev_ops ksz8_dev_ops = { |
68 |
.vlan_filtering = ksz8_port_vlan_filtering, |
69 |
.vlan_add = ksz8_port_vlan_add, |
70 |
.vlan_del = ksz8_port_vlan_del, |
71 |
+ .mirror_add = ksz8_port_mirror_add, |
72 |
+ .mirror_del = ksz8_port_mirror_del, |
73 |
.shutdown = ksz8_reset_switch, |
74 |
.init = ksz8_switch_init, |
75 |
.exit = ksz8_switch_exit, |
76 |
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c |
77 |
index 1bb994a9109cd..cd4a3088e9473 100644 |
78 |
--- a/drivers/net/dsa/microchip/ksz9477.c |
79 |
+++ b/drivers/net/dsa/microchip/ksz9477.c |
80 |
@@ -819,11 +819,10 @@ static int ksz9477_port_mdb_del(struct dsa_switch *ds, int port, |
81 |
return ret; |
82 |
} |
83 |
|
84 |
-static int ksz9477_port_mirror_add(struct dsa_switch *ds, int port, |
85 |
+static int ksz9477_port_mirror_add(struct ksz_device *dev, int port, |
86 |
struct dsa_mall_mirror_tc_entry *mirror, |
87 |
bool ingress, struct netlink_ext_ack *extack) |
88 |
{ |
89 |
- struct ksz_device *dev = ds->priv; |
90 |
u8 data; |
91 |
int p; |
92 |
|
93 |
@@ -859,10 +858,9 @@ static int ksz9477_port_mirror_add(struct dsa_switch *ds, int port, |
94 |
return 0; |
95 |
} |
96 |
|
97 |
-static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port, |
98 |
+static void ksz9477_port_mirror_del(struct ksz_device *dev, int port, |
99 |
struct dsa_mall_mirror_tc_entry *mirror) |
100 |
{ |
101 |
- struct ksz_device *dev = ds->priv; |
102 |
bool in_use = false; |
103 |
u8 data; |
104 |
int p; |
105 |
@@ -1335,8 +1333,8 @@ static const struct dsa_switch_ops ksz9477_switch_ops = { |
106 |
.port_fdb_del = ksz9477_port_fdb_del, |
107 |
.port_mdb_add = ksz9477_port_mdb_add, |
108 |
.port_mdb_del = ksz9477_port_mdb_del, |
109 |
- .port_mirror_add = ksz9477_port_mirror_add, |
110 |
- .port_mirror_del = ksz9477_port_mirror_del, |
111 |
+ .port_mirror_add = ksz_port_mirror_add, |
112 |
+ .port_mirror_del = ksz_port_mirror_del, |
113 |
.get_stats64 = ksz_get_stats64, |
114 |
.port_change_mtu = ksz9477_change_mtu, |
115 |
.port_max_mtu = ksz9477_max_mtu, |
116 |
@@ -1412,6 +1410,8 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { |
117 |
.vlan_filtering = ksz9477_port_vlan_filtering, |
118 |
.vlan_add = ksz9477_port_vlan_add, |
119 |
.vlan_del = ksz9477_port_vlan_del, |
120 |
+ .mirror_add = ksz9477_port_mirror_add, |
121 |
+ .mirror_del = ksz9477_port_mirror_del, |
122 |
.shutdown = ksz9477_reset_switch, |
123 |
.init = ksz9477_switch_init, |
124 |
.exit = ksz9477_switch_exit, |
125 |
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c |
126 |
index 5db2b55152885..676669d353ea6 100644 |
127 |
--- a/drivers/net/dsa/microchip/ksz_common.c |
128 |
+++ b/drivers/net/dsa/microchip/ksz_common.c |
129 |
@@ -991,6 +991,29 @@ int ksz_port_vlan_del(struct dsa_switch *ds, int port, |
130 |
} |
131 |
EXPORT_SYMBOL_GPL(ksz_port_vlan_del); |
132 |
|
133 |
+int ksz_port_mirror_add(struct dsa_switch *ds, int port, |
134 |
+ struct dsa_mall_mirror_tc_entry *mirror, |
135 |
+ bool ingress, struct netlink_ext_ack *extack) |
136 |
+{ |
137 |
+ struct ksz_device *dev = ds->priv; |
138 |
+ |
139 |
+ if (!dev->dev_ops->mirror_add) |
140 |
+ return -EOPNOTSUPP; |
141 |
+ |
142 |
+ return dev->dev_ops->mirror_add(dev, port, mirror, ingress, extack); |
143 |
+} |
144 |
+EXPORT_SYMBOL_GPL(ksz_port_mirror_add); |
145 |
+ |
146 |
+void ksz_port_mirror_del(struct dsa_switch *ds, int port, |
147 |
+ struct dsa_mall_mirror_tc_entry *mirror) |
148 |
+{ |
149 |
+ struct ksz_device *dev = ds->priv; |
150 |
+ |
151 |
+ if (dev->dev_ops->mirror_del) |
152 |
+ dev->dev_ops->mirror_del(dev, port, mirror); |
153 |
+} |
154 |
+EXPORT_SYMBOL_GPL(ksz_port_mirror_del); |
155 |
+ |
156 |
static int ksz_switch_detect(struct ksz_device *dev) |
157 |
{ |
158 |
u8 id1, id2; |
159 |
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h |
160 |
index 1baa270859aa2..c724cbb437e29 100644 |
161 |
--- a/drivers/net/dsa/microchip/ksz_common.h |
162 |
+++ b/drivers/net/dsa/microchip/ksz_common.h |
163 |
@@ -187,6 +187,11 @@ struct ksz_dev_ops { |
164 |
struct netlink_ext_ack *extack); |
165 |
int (*vlan_del)(struct ksz_device *dev, int port, |
166 |
const struct switchdev_obj_port_vlan *vlan); |
167 |
+ int (*mirror_add)(struct ksz_device *dev, int port, |
168 |
+ struct dsa_mall_mirror_tc_entry *mirror, |
169 |
+ bool ingress, struct netlink_ext_ack *extack); |
170 |
+ void (*mirror_del)(struct ksz_device *dev, int port, |
171 |
+ struct dsa_mall_mirror_tc_entry *mirror); |
172 |
void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); |
173 |
void (*port_init_cnt)(struct ksz_device *dev, int port); |
174 |
int (*shutdown)(struct ksz_device *dev); |
175 |
@@ -247,6 +252,11 @@ int ksz_port_vlan_add(struct dsa_switch *ds, int port, |
176 |
struct netlink_ext_ack *extack); |
177 |
int ksz_port_vlan_del(struct dsa_switch *ds, int port, |
178 |
const struct switchdev_obj_port_vlan *vlan); |
179 |
+int ksz_port_mirror_add(struct dsa_switch *ds, int port, |
180 |
+ struct dsa_mall_mirror_tc_entry *mirror, |
181 |
+ bool ingress, struct netlink_ext_ack *extack); |
182 |
+void ksz_port_mirror_del(struct dsa_switch *ds, int port, |
183 |
+ struct dsa_mall_mirror_tc_entry *mirror); |
184 |
|
185 |
/* Common register access functions */ |
186 |
|
187 |
-- |
188 |
2.35.1 |
189 |
|