summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2020-10-04 18:12:52 +0200
committerDavid S. Miller <davem@davemloft.net>2020-10-04 23:38:52 +0200
commitf15ec13a9630f0c2297ff94f9fd588d2525fc020 (patch)
treed5005457cc3c4d7b116e7a02ed0afc4551e2c633 /net/dsa
parentnet: devlink: Add unused port flavour (diff)
downloadlinux-f15ec13a9630f0c2297ff94f9fd588d2525fc020.tar.xz
linux-f15ec13a9630f0c2297ff94f9fd588d2525fc020.zip
net: dsa: Make use of devlink port flavour unused
If a port is unused, still create a devlink port for it, but set the flavour to unused. This allows us to attach devlink regions to the port, etc. Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa2.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 3cf67f5fe54a..2c149fb36928 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -272,6 +272,15 @@ static int dsa_port_setup(struct dsa_port *dp)
switch (dp->type) {
case DSA_PORT_TYPE_UNUSED:
+ memset(dlp, 0, sizeof(*dlp));
+ attrs.flavour = DEVLINK_PORT_FLAVOUR_UNUSED;
+ devlink_port_attrs_set(dlp, &attrs);
+ err = devlink_port_register(dl, dlp, dp->index);
+ if (err)
+ break;
+
+ devlink_port_registered = true;
+
dsa_port_disable(dp);
break;
case DSA_PORT_TYPE_CPU:
@@ -355,6 +364,7 @@ static void dsa_port_teardown(struct dsa_port *dp)
switch (dp->type) {
case DSA_PORT_TYPE_UNUSED:
+ devlink_port_unregister(dlp);
break;
case DSA_PORT_TYPE_CPU:
dsa_port_disable(dp);