net: dsa: Implement ndo_get_phys_port_name()
Subsystems (3)
cover net: dsa: Implement ndo_get_phys_port_name()
Hi all,
This patch series implements ndo_get_phys_port_name() so we can revert ndo_get_phys_id() which was (ab)used in the DSA layer.
Thanks
Florian Fainelli (2):
net: dsa: Implement ndo_get_phys_port_name() Revert "net: dsa: Implement ndo_get_phys_port_id"
net/dsa/slave.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 net: dsa: Implement ndo_get_phys_port_name()
Return the physical port number of a DSA created network device using ndo_get_phys_port_name().
--- net/dsa/slave.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/dsa/slave.c +10 -0
@@ -990,6 +990,15 @@ static int dsa_slave_get_phys_port_id(struct net_device *dev, ppid->id_len =sizeof (p->port);memcpy (ppid->id, &p->port, ppid->id_len); +} + +static int dsa_slave_get_phys_port_name (struct net_device *dev, +char *name,size_t len) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +if (snprintf (name, len,"p%d" , p->port) >= len) +return -EINVAL ;return 0 ; }
@@ -1042,6 +1051,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_bridge_setlink = switchdev_port_bridge_setlink, .ndo_bridge_dellink = switchdev_port_bridge_dellink, .ndo_get_phys_port_id = dsa_slave_get_phys_port_id, + .ndo_get_phys_port_name = dsa_slave_get_phys_port_name, };static const struct switchdev_ops dsa_slave_switchdev_ops = {
Signature · 1 line
2.9.3
Hi Florian,
Quoted 4 lines · Florian Fainelli
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Vivien
Andrew Lunn
maintainerQuoted 2 lines · Florian Fainelli
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().
At what level does this need to be unique?
We can have multiple switches within one switch cluster. p->port will be unique within one switch, but can be repeated in a cluster.
We can also have multiple clusters, and again p->port will be re-used.
Andrew
Quoted 5 lines · Andrew Lunn
Quoted 2 lines · Florian Fainelli
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().At what level does this need to be unique?
This needs to be unique to the switch I would say, ndo_get_phys_switch_id would return the physical number of the switch device in the tree/cluster, so that number plus the port name should be an unique differentiator that is good enough for e.g: a persistent naming rule?
Quoted 5 lines
We can have multiple switches within one switch cluster.
p->portwill be unique within one switch, but can be repeated in a cluster.We can also have multiple clusters, and again
p->portwill be re-used.
Signature · 1 line
Florian
Quoted 8 lines · Tue, Jan 10, 2017 at 09:58:53PM CET, [email protected] wrote:
Quoted 5 lines · Andrew Lunn
Quoted 2 lines · Florian Fainelli
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().At what level does this need to be unique?
This needs to be unique to the switch I would say,
Yes.
Quoted 4 lines
ndo_get_phys_switch_idwould return the physical number of the switch device in the tree/cluster, so that number plus the port name should be an unique differentiator that is good enough for e.g: a persistent naming rule?
Yes.
Quoted 10 lines
Quoted 6 lines
We can have multiple switches within one switch cluster.
p->portwill be unique within one switch, but can be repeated in a cluster.We can also have multiple clusters, and again
p->portwill be re-used.Signature · 1 line
Florian
Hi Andrew,
Quoted 5 lines · Andrew Lunn
Quoted 2 lines · Florian Fainelli
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().At what level does this need to be unique?
The port name must be unique at the switch Linux device level.
Thanks,
Vivien
Quoted 4 lines · Tue, Jan 10, 2017 at 09:32:36PM CET, [email protected] wrote:
Return the physical port number of a DSA created network device using
ndo_get_phys_port_name().Signed-off-by Florian Fainelli <[email protected]>
Quoted 35 lines
---
net/dsa/slave.c| 10 ++++++++++1 file changed, 10 insertions(+)net/dsa/slave.c +10
-0@@ -990,6 +990,15 @@ static int dsa_slave_get_phys_port_id(struct net_device *dev, ppid->id_len =sizeof (p->port);memcpy (ppid->id, &p->port, ppid->id_len); +} + +static int dsa_slave_get_phys_port_name (struct net_device *dev, +char *name,size_t len) +{ +struct dsa_slave_priv *p =netdev_priv (dev); + +if (snprintf (name, len,"p%d" , p->port) >= len) +return -EINVAL ;return 0 ; }@@ -1042,6 +1051,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_bridge_setlink = switchdev_port_bridge_setlink, .ndo_bridge_dellink = switchdev_port_bridge_dellink, .ndo_get_phys_port_id = dsa_slave_get_phys_port_id, + .ndo_get_phys_port_name = dsa_slave_get_phys_port_name, };static const struct switchdev_ops dsa_slave_switchdev_ops = {Signature · 1 line
2.9.3
PATCH 2/2 Revert "net: dsa: Implement ndo_get_phys_port_id"
In reply to Florian FainelliThis reverts commit 3a543ef479868e36c95935de320608a7e41466ca ("net: dsa:
Implement ndo_get_phys_port_id") since it misuses the purpose of ndo_get_phys_port_id(). We have ndo_get_phys_port_name() to do the correct thing for us now.
--- net/dsa/slave.c | 10 ---------- 1 file changed, 10 deletions(-)
net/dsa/slave.c +0 -10
@@ -983,15 +983,6 @@ static void dsa_slave_poll_controller(struct net_device *dev) }#endif -static int dsa_slave_get_phys_port_id (struct net_device *dev, -struct netdev_phys_item_id *ppid) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - - ppid->id_len =sizeof (p->port); -memcpy (ppid->id, &p->port, ppid->id_len); -} -static int dsa_slave_get_phys_port_name (struct net_device *dev,char *name,size_t len) {
@@ -1050,7 +1041,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_bridge_getlink = switchdev_port_bridge_getlink, .ndo_bridge_setlink = switchdev_port_bridge_setlink, .ndo_bridge_dellink = switchdev_port_bridge_dellink, - .ndo_get_phys_port_id = dsa_slave_get_phys_port_id, .ndo_get_phys_port_name = dsa_slave_get_phys_port_name, };
Signature · 1 line
2.9.3
Re: [PATCH net-next 2/2] Revert "net: dsa: Implement ndo_get_phys_port_id"
Hi Florian,
Quoted 6 lines · Florian Fainelli
This reverts commit
3a543ef479868e36c95935de320608a7e41466ca("net: dsa:
Implementndo_get_phys_port_id") since it misuses the purpose ofndo_get_phys_port_id(). We havendo_get_phys_port_name()to do the correct thing for us now.Signed-off-by Florian Fainelli <[email protected]>
Thanks,
Vivien
Re: [PATCH net-next 2/2] Revert "net: dsa: Implement ndo_get_phys_port_id"
In reply to Florian FainelliQuoted 6 lines · Tue, Jan 10, 2017 at 09:32:37PM CET, [email protected] wrote:
This reverts commit
3a543ef479868e36c95935de320608a7e41466ca("net: dsa:
Implementndo_get_phys_port_id") since it misuses the purpose ofndo_get_phys_port_id(). We havendo_get_phys_port_name()to do the correct thing for us now.Signed-off-by Florian Fainelli <[email protected]>
Quoted 35 lines
---
net/dsa/slave.c| 10 ----------1 file changed, 10 deletions(-)net/dsa/slave.c +0
-10@@ -983,15 +983,6 @@ static void dsa_slave_poll_controller(struct net_device *dev) }#endif -static int dsa_slave_get_phys_port_id (struct net_device *dev, -struct netdev_phys_item_id *ppid) -{ -struct dsa_slave_priv *p =netdev_priv (dev); - - ppid->id_len =sizeof (p->port); -memcpy (ppid->id, &p->port, ppid->id_len); -} -static int dsa_slave_get_phys_port_name (struct net_device *dev,char *name,size_t len) {@@ -1050,7 +1041,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_bridge_getlink = switchdev_port_bridge_getlink, .ndo_bridge_setlink = switchdev_port_bridge_setlink, .ndo_bridge_dellink = switchdev_port_bridge_dellink, - .ndo_get_phys_port_id = dsa_slave_get_phys_port_id, .ndo_get_phys_port_name = dsa_slave_get_phys_port_name, };Signature · 1 line
2.9.3
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Tue, 10 Jan 2017 12:32:35 -0800
Quoted 2 lines
This patch series implements
ndo_get_phys_port_name()so we can revertndo_get_phys_id()which was (ab)used in the DSA layer.
Series applied, thanks Florian.