Skip to content

Commit 7e092af

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: tag_8021q: setup tagging via a single function call
There is no point in calling dsa_port_setup_8021q_tagging for each individual port. Additionally, it will become more difficult to do that when we'll have a context structure to tag_8021q (next patch). So refactor this now. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 568a36a commit 7e092af

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,18 +1934,11 @@ static void sja1105_crosschip_bridge_leave(struct dsa_switch *ds,
19341934
static int sja1105_setup_8021q_tagging(struct dsa_switch *ds, bool enabled)
19351935
{
19361936
struct sja1105_private *priv = ds->priv;
1937-
int rc, i;
1937+
int rc;
19381938

1939-
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
1940-
priv->expect_dsa_8021q = true;
1941-
rc = dsa_port_setup_8021q_tagging(ds, i, enabled);
1942-
priv->expect_dsa_8021q = false;
1943-
if (rc < 0) {
1944-
dev_err(ds->dev, "Failed to setup VLAN tagging for port %d: %d\n",
1945-
i, rc);
1946-
return rc;
1947-
}
1948-
}
1939+
rc = dsa_8021q_setup(priv->ds, enabled);
1940+
if (rc)
1941+
return rc;
19491942

19501943
dev_info(ds->dev, "%s switch tagging\n",
19511944
enabled ? "Enabled" : "Disabled");

include/linux/dsa/8021q.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ struct dsa_8021q_crosschip_link {
2525

2626
#if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)
2727

28-
int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
29-
bool enabled);
28+
int dsa_8021q_setup(struct dsa_switch *ds, bool enabled);
3029

3130
int dsa_8021q_crosschip_bridge_join(struct dsa_switch *ds, int port,
3231
struct dsa_switch *other_ds,
@@ -57,8 +56,7 @@ bool vid_is_dsa_8021q(u16 vid);
5756

5857
#else
5958

60-
int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
61-
bool enabled)
59+
int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
6260
{
6361
return 0;
6462
}

net/dsa/tag_8021q.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int dsa_8021q_vid_apply(struct dsa_switch *ds, int port, u16 vid,
209209
* +-+-----+-+-----+-+-----+-+-----+-+ +-+-----+-+-----+-+-----+-+-----+-+
210210
* swp0 swp1 swp2 swp3 swp0 swp1 swp2 swp3
211211
*/
212-
int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int port, bool enabled)
212+
static int dsa_8021q_setup_port(struct dsa_switch *ds, int port, bool enabled)
213213
{
214214
int upstream = dsa_upstream_port(ds, port);
215215
u16 rx_vid = dsa_8021q_rx_vid(ds, port);
@@ -275,7 +275,24 @@ int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int port, bool enabled)
275275

276276
return err;
277277
}
278-
EXPORT_SYMBOL_GPL(dsa_port_setup_8021q_tagging);
278+
279+
int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
280+
{
281+
int rc, port;
282+
283+
for (port = 0; port < ds->num_ports; port++) {
284+
rc = dsa_8021q_setup_port(ds, port, enabled);
285+
if (rc < 0) {
286+
dev_err(ds->dev,
287+
"Failed to setup VLAN tagging for port %d: %d\n",
288+
port, rc);
289+
return rc;
290+
}
291+
}
292+
293+
return 0;
294+
}
295+
EXPORT_SYMBOL_GPL(dsa_8021q_setup);
279296

280297
static int dsa_8021q_crosschip_link_apply(struct dsa_switch *ds, int port,
281298
struct dsa_switch *other_ds,

0 commit comments

Comments
 (0)