All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible
@ 2019-03-26 12:02 Jiri Pirko
  2019-03-26 12:02 ` [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port Jiri Pirko
                   ` (11 more replies)
  0 siblings, 12 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:02 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

phys_port_name may be assembled by a helper in devlink. It is currently
the case only for mlxsw driver. Benefit from the get_devlink_port ndo
and call into devlink directly from dev_get_phys_port_name(). That saves
the trip to the driver, simplifies the code and makes it similar to
recently introduced ethtool-devlink compat helpers.

Move bnxt, dsa and partly nfp to let devlink core generate the name too.

Jiri Pirko (12):
  net: replace ndo_get_devlink with ndo_get_devlink_port
  net: devlink: introduce devlink_compat_phys_port_name_get()
  mlxsw: Implement ndo_get_devlink_port
  mlxsw: Remove ndo_get_phys_port_name implementation
  net: devlink: remove unused devlink_port_get_phys_port_name() function
  bnxt: implement ndo_get_devlink_port
  bnxt: remove ndo_get_phys_port_name implementation
  dsa: implement ndo_get_devlink_port
  dsa: don't fill-up remove ndo_get_phys_port_name for slaves
  nfp: do not handle nn->port defined case in
    nfp_net_get_phys_port_name()
  net: devlink: expose phys port name
  net: devlink: add warning for ndo_get_phys_port_name set when not
    needed

 drivers/net/ethernet/broadcom/bnxt/bnxt.c     |  26 ++--
 drivers/net/ethernet/mellanox/mlxsw/core.c    |  10 +-
 drivers/net/ethernet/mellanox/mlxsw/core.h    |   5 +-
 drivers/net/ethernet/mellanox/mlxsw/minimal.c |  22 ++--
 .../net/ethernet/mellanox/mlxsw/spectrum.c    |  22 ++--
 .../net/ethernet/mellanox/mlxsw/switchx2.c    |  22 ++--
 drivers/net/ethernet/netronome/nfp/nfp_app.h  |   2 +-
 .../net/ethernet/netronome/nfp/nfp_devlink.c  |  10 +-
 .../ethernet/netronome/nfp/nfp_net_common.c   |   7 +-
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |   2 +-
 include/linux/netdevice.h                     |   6 +-
 include/net/devlink.h                         |  25 +++-
 include/uapi/linux/devlink.h                  |   2 +
 net/core/dev.c                                |  11 +-
 net/core/devlink.c                            | 123 +++++++++++++-----
 net/dsa/dsa_priv.h                            |   1 +
 net/dsa/legacy.c                              |   2 +-
 net/dsa/slave.c                               |  49 ++++++-
 18 files changed, 234 insertions(+), 113 deletions(-)

-- 
2.17.2


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
@ 2019-03-26 12:02 ` Jiri Pirko
  2019-03-26 20:27   ` Jakub Kicinski
  2019-03-26 12:02 ` [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get() Jiri Pirko
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:02 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Follow-up patch is going to need a devlink port instance according to
a netdev. Devlink port instance should be always available when devlink
is used. So change the recently introduced ndo_get_devlink to
ndo_get_devlink_port. With that, adjust the wrapper for the only
user to get devlink pointer.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
v1->v2:
- s/for/with/ in patch subject
- rebased
---
 drivers/net/ethernet/netronome/nfp/nfp_app.h       |  2 +-
 drivers/net/ethernet/netronome/nfp/nfp_devlink.c   | 10 +++++-----
 .../net/ethernet/netronome/nfp/nfp_net_common.c    |  2 +-
 drivers/net/ethernet/netronome/nfp/nfp_net_repr.c  |  2 +-
 include/linux/netdevice.h                          |  6 +++---
 include/net/devlink.h                              | 14 ++++++++++++--
 6 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app.h b/drivers/net/ethernet/netronome/nfp/nfp_app.h
index f8d422713705..a6fda07fce43 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app.h
@@ -433,6 +433,6 @@ int nfp_app_nic_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
 int nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
 				   struct nfp_net *nn, unsigned int id);
 
-struct devlink *nfp_devlink_get_devlink(struct net_device *netdev);
+struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev);
 
 #endif
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index cb59a18ec6a6..919da0d84fb4 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -386,13 +386,13 @@ void nfp_devlink_port_type_clear(struct nfp_port *port)
 	devlink_port_type_clear(&port->dl_port);
 }
 
-struct devlink *nfp_devlink_get_devlink(struct net_device *netdev)
+struct devlink_port *nfp_devlink_get_devlink_port(struct net_device *netdev)
 {
-	struct nfp_app *app;
+	struct nfp_port *port;
 
-	app = nfp_app_from_netdev(netdev);
-	if (!app)
+	port = nfp_port_from_netdev(netdev);
+	if (!port)
 		return NULL;
 
-	return priv_to_devlink(app->pf);
+	return &port->dl_port;
 }
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index ad2f133bd545..b676943e54f4 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -3531,7 +3531,7 @@ const struct net_device_ops nfp_net_netdev_ops = {
 	.ndo_udp_tunnel_del	= nfp_net_del_vxlan_port,
 	.ndo_bpf		= nfp_net_xdp,
 	.ndo_get_port_parent_id	= nfp_port_get_port_parent_id,
-	.ndo_get_devlink	= nfp_devlink_get_devlink,
+	.ndo_get_devlink_port	= nfp_devlink_get_devlink_port,
 };
 
 /**
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index d2c803bb4e56..bf621674f583 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -273,7 +273,7 @@ const struct net_device_ops nfp_repr_netdev_ops = {
 	.ndo_set_features	= nfp_port_set_features,
 	.ndo_set_mac_address    = eth_mac_addr,
 	.ndo_get_port_parent_id	= nfp_port_get_port_parent_id,
-	.ndo_get_devlink	= nfp_devlink_get_devlink,
+	.ndo_get_devlink_port	= nfp_devlink_get_devlink_port,
 };
 
 void
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 166fdc0a78b4..78f5ec4ebf64 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1250,8 +1250,8 @@ struct devlink;
  *	that got dropped are freed/returned via xdp_return_frame().
  *	Returns negative number, means general error invoking ndo, meaning
  *	no frames were xmit'ed and core-caller will free all frames.
- * struct devlink *(*ndo_get_devlink)(struct net_device *dev);
- *	Get devlink instance associated with a given netdev.
+ * struct devlink_port *(*ndo_get_devlink_port)(struct net_device *dev);
+ *	Get devlink port instance associated with a given netdev.
  *	Called with a reference on the netdevice and devlink locks only,
  *	rtnl_lock is not held.
  */
@@ -1451,7 +1451,7 @@ struct net_device_ops {
 						u32 flags);
 	int			(*ndo_xsk_async_xmit)(struct net_device *dev,
 						      u32 queue_id);
-	struct devlink *	(*ndo_get_devlink)(struct net_device *dev);
+	struct devlink_port *	(*ndo_get_devlink_port)(struct net_device *dev);
 };
 
 /**
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 03fb16f4fb6c..81b5ed04a341 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -547,10 +547,20 @@ static inline struct devlink *priv_to_devlink(void *priv)
 	return container_of(priv, struct devlink, priv);
 }
 
+static inline struct devlink_port *
+netdev_to_devlink_port(struct net_device *dev)
+{
+	if (dev->netdev_ops->ndo_get_devlink_port)
+		return dev->netdev_ops->ndo_get_devlink_port(dev);
+	return NULL;
+}
+
 static inline struct devlink *netdev_to_devlink(struct net_device *dev)
 {
-	if (dev->netdev_ops->ndo_get_devlink)
-		return dev->netdev_ops->ndo_get_devlink(dev);
+	struct devlink_port *devlink_port = netdev_to_devlink_port(dev);
+
+	if (devlink_port)
+		return devlink_port->devlink;
 	return NULL;
 }
 
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get()
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
  2019-03-26 12:02 ` [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port Jiri Pirko
@ 2019-03-26 12:02 ` Jiri Pirko
  2019-03-26 20:30   ` Jakub Kicinski
  2019-03-26 12:02 ` [patch net-next v2 03/12] mlxsw: Implement ndo_get_devlink_port Jiri Pirko
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:02 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Introduce devlink_compat_phys_port_name_get() helper that
gets the physical port name for specified netdevice
according to devlink port attributes.
Call this helper from dev_get_phys_port_name()
in case ndo_get_phys_port_name is not defined.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- don't take devlink locks
- try ndo first and if it returns EOPNOTSUPP fallback to devlink
- rebase
---
 include/net/devlink.h |  9 +++++++++
 net/core/dev.c        | 11 ++++++++---
 net/core/devlink.c    | 28 ++++++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 81b5ed04a341..85e577d6ec3b 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -739,6 +739,8 @@ devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
 void devlink_compat_running_version(struct net_device *dev,
 				    char *buf, size_t len);
 int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
+int devlink_compat_phys_port_name_get(struct net_device *dev,
+				      char *name, size_t len);
 
 #else
 
@@ -753,6 +755,13 @@ devlink_compat_flash_update(struct net_device *dev, const char *file_name)
 	return -EOPNOTSUPP;
 }
 
+static inline int
+devlink_compat_phys_port_name_get(struct net_device *dev,
+				  char *name, size_t len)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif
 
 #endif /* _NET_DEVLINK_H_ */
diff --git a/net/core/dev.c b/net/core/dev.c
index 9ca2d3abfd1a..9823b7713f79 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -146,6 +146,7 @@
 #include <net/udp_tunnel.h>
 #include <linux/net_namespace.h>
 #include <linux/indirect_call_wrapper.h>
+#include <net/devlink.h>
 
 #include "net-sysfs.h"
 
@@ -7877,10 +7878,14 @@ int dev_get_phys_port_name(struct net_device *dev,
 			   char *name, size_t len)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
+	int err;
 
-	if (!ops->ndo_get_phys_port_name)
-		return -EOPNOTSUPP;
-	return ops->ndo_get_phys_port_name(dev, name, len);
+	if (ops->ndo_get_phys_port_name) {
+		err = ops->ndo_get_phys_port_name(dev, name, len);
+		if (err != -EOPNOTSUPP)
+			return err;
+	}
+	return devlink_compat_phys_port_name_get(dev, name, len);
 }
 EXPORT_SYMBOL(dev_get_phys_port_name);
 
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 37d01c39071e..8bb2c3e3f202 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5414,8 +5414,8 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
 }
 EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
 
-int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
-				    char *name, size_t len)
+static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
+					     char *name, size_t len)
 {
 	struct devlink_port_attrs *attrs = &devlink_port->attrs;
 	int n = 0;
@@ -5445,6 +5445,12 @@ int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
 
 	return 0;
 }
+
+int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
+				    char *name, size_t len)
+{
+	return __devlink_port_phys_port_name_get(devlink_port, name, len);
+}
 EXPORT_SYMBOL_GPL(devlink_port_get_phys_port_name);
 
 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
@@ -6459,6 +6465,24 @@ int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
 	return ret;
 }
 
+int devlink_compat_phys_port_name_get(struct net_device *dev,
+				      char *name, size_t len)
+{
+	struct devlink_port *devlink_port;
+
+	/* RTNL mutex is held here which ensures that devlink_port
+	 * instance cannot disappear in the middle. No need to take
+	 * any devlink lock as only permanent values are accessed.
+	 */
+	ASSERT_RTNL();
+
+	devlink_port = netdev_to_devlink_port(dev);
+	if (!devlink_port)
+		return -EOPNOTSUPP;
+
+	return __devlink_port_phys_port_name_get(devlink_port, name, len);
+}
+
 static int __init devlink_init(void)
 {
 	return genl_register_family(&devlink_nl_family);
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 03/12] mlxsw: Implement ndo_get_devlink_port
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
  2019-03-26 12:02 ` [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port Jiri Pirko
  2019-03-26 12:02 ` [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get() Jiri Pirko
@ 2019-03-26 12:02 ` Jiri Pirko
  2019-03-26 12:02 ` [patch net-next v2 04/12] mlxsw: Remove ndo_get_phys_port_name implementation Jiri Pirko
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:02 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

In order for devlink compat functions to work, implement
ndo_get_devlink_port.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core.c     | 12 ++++++++++++
 drivers/net/ethernet/mellanox/mlxsw/core.h     |  3 +++
 drivers/net/ethernet/mellanox/mlxsw/minimal.c  | 11 +++++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 +++++++++++
 drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 11 +++++++++++
 5 files changed, 48 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index e70bb673eeec..aa71aeb44101 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1807,6 +1807,18 @@ int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
 }
 EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name);
 
+struct devlink_port *
+mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
+				 u8 local_port)
+{
+	struct mlxsw_core_port *mlxsw_core_port =
+					&mlxsw_core->ports[local_port];
+	struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
+
+	return devlink_port;
+}
+EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get);
+
 static void mlxsw_core_buf_dump_dbg(struct mlxsw_core *mlxsw_core,
 				    const char *buf, size_t size)
 {
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index 74e95e943b24..cb870502f04c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -178,6 +178,9 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
 						u8 local_port);
 int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
 				       u8 local_port, char *name, size_t len);
+struct devlink_port *
+mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
+				 u8 local_port);
 
 int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
 bool mlxsw_core_schedule_work(struct work_struct *work);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
index 0ee1656609f5..d6e6042223f9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
@@ -73,11 +73,22 @@ static int mlxsw_m_port_get_port_parent_id(struct net_device *dev,
 	return 0;
 }
 
+static struct devlink_port *
+mlxsw_m_port_get_devlink_port(struct net_device *dev)
+{
+	struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
+	struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
+
+	return mlxsw_core_port_devlink_port_get(mlxsw_m->core,
+						mlxsw_m_port->local_port);
+}
+
 static const struct net_device_ops mlxsw_m_port_netdev_ops = {
 	.ndo_open		= mlxsw_m_port_dummy_open_stop,
 	.ndo_stop		= mlxsw_m_port_dummy_open_stop,
 	.ndo_get_phys_port_name	= mlxsw_m_port_get_phys_port_name,
 	.ndo_get_port_parent_id	= mlxsw_m_port_get_port_parent_id,
+	.ndo_get_devlink_port	= mlxsw_m_port_get_devlink_port,
 };
 
 static int mlxsw_m_get_module_info(struct net_device *netdev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index eaf86c4c2f6c..1225fa50f36f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1726,6 +1726,16 @@ static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
 	return 0;
 }
 
+static struct devlink_port *
+mlxsw_sp_port_get_devlink_port(struct net_device *dev)
+{
+	struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+
+	return mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
+						mlxsw_sp_port->local_port);
+}
+
 static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
 	.ndo_open		= mlxsw_sp_port_open,
 	.ndo_stop		= mlxsw_sp_port_stop,
@@ -1742,6 +1752,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
 	.ndo_get_phys_port_name	= mlxsw_sp_port_get_phys_port_name,
 	.ndo_set_features	= mlxsw_sp_set_features,
 	.ndo_get_port_parent_id	= mlxsw_sp_port_get_port_parent_id,
+	.ndo_get_devlink_port	= mlxsw_sp_port_get_devlink_port,
 };
 
 static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 568883fc40df..696b8c8547bc 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -401,6 +401,16 @@ static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
 	return 0;
 }
 
+static struct devlink_port *
+mlxsw_sx_port_get_devlink_port(struct net_device *dev)
+{
+	struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
+	struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
+
+	return mlxsw_core_port_devlink_port_get(mlxsw_sx->core,
+						mlxsw_sx_port->local_port);
+}
+
 static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
 	.ndo_open		= mlxsw_sx_port_open,
 	.ndo_stop		= mlxsw_sx_port_stop,
@@ -409,6 +419,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
 	.ndo_get_stats64	= mlxsw_sx_port_get_stats64,
 	.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
 	.ndo_get_port_parent_id	= mlxsw_sx_port_get_port_parent_id,
+	.ndo_get_devlink_port	= mlxsw_sx_port_get_devlink_port,
 };
 
 static void mlxsw_sx_port_get_drvinfo(struct net_device *dev,
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 04/12] mlxsw: Remove ndo_get_phys_port_name implementation
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (2 preceding siblings ...)
  2019-03-26 12:02 ` [patch net-next v2 03/12] mlxsw: Implement ndo_get_devlink_port Jiri Pirko
@ 2019-03-26 12:02 ` Jiri Pirko
  2019-03-26 12:03 ` [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function Jiri Pirko
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:02 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Rely on the previously introduced fallback and let the core call
devlink directly in order to get the physical port name.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- adjusted patch description
---
 drivers/net/ethernet/mellanox/mlxsw/core.c     | 10 ----------
 drivers/net/ethernet/mellanox/mlxsw/core.h     |  2 --
 drivers/net/ethernet/mellanox/mlxsw/minimal.c  | 11 -----------
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 -----------
 drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 11 -----------
 5 files changed, 45 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index aa71aeb44101..e55b4aa91e3b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1796,16 +1796,6 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
 }
 EXPORT_SYMBOL(mlxsw_core_port_type_get);
 
-int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
-				       u8 local_port, char *name, size_t len)
-{
-	struct mlxsw_core_port *mlxsw_core_port =
-					&mlxsw_core->ports[local_port];
-	struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
-
-	return devlink_port_get_phys_port_name(devlink_port, name, len);
-}
-EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name);
 
 struct devlink_port *
 mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index cb870502f04c..e8c424da534c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -176,8 +176,6 @@ void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
 			   void *port_driver_priv);
 enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
 						u8 local_port);
-int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
-				       u8 local_port, char *name, size_t len);
 struct devlink_port *
 mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
 				 u8 local_port);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
index d6e6042223f9..ec5f5a66b607 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c
@@ -51,16 +51,6 @@ static int mlxsw_m_port_dummy_open_stop(struct net_device *dev)
 	return 0;
 }
 
-static int
-mlxsw_m_port_get_phys_port_name(struct net_device *dev, char *name, size_t len)
-{
-	struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
-	struct mlxsw_core *core = mlxsw_m_port->mlxsw_m->core;
-	u8 local_port = mlxsw_m_port->local_port;
-
-	return mlxsw_core_port_get_phys_port_name(core, local_port, name, len);
-}
-
 static int mlxsw_m_port_get_port_parent_id(struct net_device *dev,
 					   struct netdev_phys_item_id *ppid)
 {
@@ -86,7 +76,6 @@ mlxsw_m_port_get_devlink_port(struct net_device *dev)
 static const struct net_device_ops mlxsw_m_port_netdev_ops = {
 	.ndo_open		= mlxsw_m_port_dummy_open_stop,
 	.ndo_stop		= mlxsw_m_port_dummy_open_stop,
-	.ndo_get_phys_port_name	= mlxsw_m_port_get_phys_port_name,
 	.ndo_get_port_parent_id	= mlxsw_m_port_get_port_parent_id,
 	.ndo_get_devlink_port	= mlxsw_m_port_get_devlink_port,
 };
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1225fa50f36f..8b9a6870dbc2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1254,16 +1254,6 @@ static int mlxsw_sp_port_kill_vid(struct net_device *dev,
 	return 0;
 }
 
-static int mlxsw_sp_port_get_phys_port_name(struct net_device *dev, char *name,
-					    size_t len)
-{
-	struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
-
-	return mlxsw_core_port_get_phys_port_name(mlxsw_sp_port->mlxsw_sp->core,
-						  mlxsw_sp_port->local_port,
-						  name, len);
-}
-
 static struct mlxsw_sp_port_mall_tc_entry *
 mlxsw_sp_port_mall_tc_entry_find(struct mlxsw_sp_port *port,
 				 unsigned long cookie) {
@@ -1749,7 +1739,6 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
 	.ndo_get_offload_stats	= mlxsw_sp_port_get_offload_stats,
 	.ndo_vlan_rx_add_vid	= mlxsw_sp_port_add_vid,
 	.ndo_vlan_rx_kill_vid	= mlxsw_sp_port_kill_vid,
-	.ndo_get_phys_port_name	= mlxsw_sp_port_get_phys_port_name,
 	.ndo_set_features	= mlxsw_sp_set_features,
 	.ndo_get_port_parent_id	= mlxsw_sp_port_get_port_parent_id,
 	.ndo_get_devlink_port	= mlxsw_sp_port_get_devlink_port,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
index 696b8c8547bc..5312dc1f339b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c
@@ -379,16 +379,6 @@ mlxsw_sx_port_get_stats64(struct net_device *dev,
 	stats->tx_dropped	= tx_dropped;
 }
 
-static int mlxsw_sx_port_get_phys_port_name(struct net_device *dev, char *name,
-					    size_t len)
-{
-	struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
-
-	return mlxsw_core_port_get_phys_port_name(mlxsw_sx_port->mlxsw_sx->core,
-						  mlxsw_sx_port->local_port,
-						  name, len);
-}
-
 static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
 					    struct netdev_phys_item_id *ppid)
 {
@@ -417,7 +407,6 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
 	.ndo_start_xmit		= mlxsw_sx_port_xmit,
 	.ndo_change_mtu		= mlxsw_sx_port_change_mtu,
 	.ndo_get_stats64	= mlxsw_sx_port_get_stats64,
-	.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
 	.ndo_get_port_parent_id	= mlxsw_sx_port_get_port_parent_id,
 	.ndo_get_devlink_port	= mlxsw_sx_port_get_devlink_port,
 };
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (3 preceding siblings ...)
  2019-03-26 12:02 ` [patch net-next v2 04/12] mlxsw: Remove ndo_get_phys_port_name implementation Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 20:31   ` Jakub Kicinski
  2019-03-26 12:03 ` [patch net-next v2 06/12] bnxt: implement ndo_get_devlink_port Jiri Pirko
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Now it is unused, remove it.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- rebase
---
 include/net/devlink.h | 2 --
 net/core/devlink.c    | 7 -------
 2 files changed, 9 deletions(-)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 85e577d6ec3b..31d5cec4d06b 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -583,8 +583,6 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
 			    enum devlink_port_flavour flavour,
 			    u32 port_number, bool split,
 			    u32 split_subport_number);
-int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
-				    char *name, size_t len);
 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
 			u32 size, u16 ingress_pools_count,
 			u16 egress_pools_count, u16 ingress_tc_count,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 8bb2c3e3f202..6bbd07e3861e 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5446,13 +5446,6 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
 	return 0;
 }
 
-int devlink_port_get_phys_port_name(struct devlink_port *devlink_port,
-				    char *name, size_t len)
-{
-	return __devlink_port_phys_port_name_get(devlink_port, name, len);
-}
-EXPORT_SYMBOL_GPL(devlink_port_get_phys_port_name);
-
 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
 			u32 size, u16 ingress_pools_count,
 			u16 egress_pools_count, u16 ingress_tc_count,
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 06/12] bnxt: implement ndo_get_devlink_port
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (4 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 12:03 ` [patch net-next v2 07/12] bnxt: remove ndo_get_phys_port_name implementation Jiri Pirko
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

In order for devlink compat functions to work, implement
ndo_get_devlink_port. Legacy slaves does not have devlink port instances
created for themselves.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 0bb9d7b3a2b6..eca36cac594e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10083,6 +10083,13 @@ int bnxt_get_port_parent_id(struct net_device *dev,
 	return 0;
 }
 
+static struct devlink_port *bnxt_get_devlink_port(struct net_device *dev)
+{
+	struct bnxt *bp = netdev_priv(dev);
+
+	return &bp->dl_port;
+}
+
 static const struct net_device_ops bnxt_netdev_ops = {
 	.ndo_open		= bnxt_open,
 	.ndo_start_xmit		= bnxt_start_xmit,
@@ -10115,7 +10122,8 @@ static const struct net_device_ops bnxt_netdev_ops = {
 	.ndo_bridge_getlink	= bnxt_bridge_getlink,
 	.ndo_bridge_setlink	= bnxt_bridge_setlink,
 	.ndo_get_port_parent_id	= bnxt_get_port_parent_id,
-	.ndo_get_phys_port_name = bnxt_get_phys_port_name
+	.ndo_get_phys_port_name = bnxt_get_phys_port_name,
+	.ndo_get_devlink_port	= bnxt_get_devlink_port,
 };
 
 static void bnxt_remove_one(struct pci_dev *pdev)
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 07/12] bnxt: remove ndo_get_phys_port_name implementation
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (5 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 06/12] bnxt: implement ndo_get_devlink_port Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 12:03 ` [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port Jiri Pirko
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Rely on the previously introduced fallback and let the core
call devlink in order to get the physical port name.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index eca36cac594e..35e34e23ba33 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10048,23 +10048,6 @@ static int bnxt_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
 	return rc;
 }
 
-static int bnxt_get_phys_port_name(struct net_device *dev, char *buf,
-				   size_t len)
-{
-	struct bnxt *bp = netdev_priv(dev);
-	int rc;
-
-	/* The PF and it's VF-reps only support the switchdev framework */
-	if (!BNXT_PF(bp))
-		return -EOPNOTSUPP;
-
-	rc = snprintf(buf, len, "p%d", bp->pf.port_id);
-
-	if (rc >= len)
-		return -EOPNOTSUPP;
-	return 0;
-}
-
 int bnxt_get_port_parent_id(struct net_device *dev,
 			    struct netdev_phys_item_id *ppid)
 {
@@ -10122,7 +10105,6 @@ static const struct net_device_ops bnxt_netdev_ops = {
 	.ndo_bridge_getlink	= bnxt_bridge_getlink,
 	.ndo_bridge_setlink	= bnxt_bridge_setlink,
 	.ndo_get_port_parent_id	= bnxt_get_port_parent_id,
-	.ndo_get_phys_port_name = bnxt_get_phys_port_name,
 	.ndo_get_devlink_port	= bnxt_get_devlink_port,
 };
 
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (6 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 07/12] bnxt: remove ndo_get_phys_port_name implementation Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-27 19:54   ` Florian Fainelli
  2019-03-26 12:03 ` [patch net-next v2 09/12] dsa: don't fill-up remove ndo_get_phys_port_name for slaves Jiri Pirko
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

In order for devlink compat functions to work, implement
ndo_get_devlink_port. Legacy slaves does not have devlink port instances
created for themselves.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 net/dsa/dsa_priv.h |  1 +
 net/dsa/legacy.c   |  2 +-
 net/dsa/slave.c    | 48 ++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 093b7d145eb1..688c765cd1db 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -176,6 +176,7 @@ void dsa_port_link_unregister_of(struct dsa_port *dp);
 extern const struct dsa_device_ops notag_netdev_ops;
 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
 int dsa_slave_create(struct dsa_port *dp);
+int dsa_slave_create_legacy(struct dsa_port *dp);
 void dsa_slave_destroy(struct net_device *slave_dev);
 int dsa_slave_suspend(struct net_device *slave_dev);
 int dsa_slave_resume(struct net_device *slave_dev);
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index cb42939db776..f9a1f9c4a58c 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -197,7 +197,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
 		if (!dsa_is_user_port(ds, i))
 			continue;
 
-		ret = dsa_slave_create(&ds->ports[i]);
+		ret = dsa_slave_create_legacy(&ds->ports[i]);
 		if (ret < 0)
 			netdev_err(master, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
 				   index, i, cd->port_names[i], ret);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 093eef6f2599..46c98cb8a2b5 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1096,6 +1096,38 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
 	return dsa_port_fdb_del(dp, addr, vid);
 }
 
+static struct devlink_port *dsa_slave_get_devlink_port(struct net_device *dev)
+{
+	struct dsa_port *dp = dsa_slave_to_port(dev);
+
+	return &dp->devlink_port;
+}
+
+static const struct net_device_ops dsa_slave_netdev_ops_legacy = {
+	.ndo_open	 	= dsa_slave_open,
+	.ndo_stop		= dsa_slave_close,
+	.ndo_start_xmit		= dsa_slave_xmit,
+	.ndo_change_rx_flags	= dsa_slave_change_rx_flags,
+	.ndo_set_rx_mode	= dsa_slave_set_rx_mode,
+	.ndo_set_mac_address	= dsa_slave_set_mac_address,
+	.ndo_fdb_add		= dsa_legacy_fdb_add,
+	.ndo_fdb_del		= dsa_legacy_fdb_del,
+	.ndo_fdb_dump		= dsa_slave_fdb_dump,
+	.ndo_do_ioctl		= dsa_slave_ioctl,
+	.ndo_get_iflink		= dsa_slave_get_iflink,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_netpoll_setup	= dsa_slave_netpoll_setup,
+	.ndo_netpoll_cleanup	= dsa_slave_netpoll_cleanup,
+	.ndo_poll_controller	= dsa_slave_poll_controller,
+#endif
+	.ndo_get_phys_port_name	= dsa_slave_get_phys_port_name,
+	.ndo_setup_tc		= dsa_slave_setup_tc,
+	.ndo_get_stats64	= dsa_slave_get_stats64,
+	.ndo_get_port_parent_id	= dsa_slave_get_port_parent_id,
+	.ndo_vlan_rx_add_vid	= dsa_slave_vlan_rx_add_vid,
+	.ndo_vlan_rx_kill_vid	= dsa_slave_vlan_rx_kill_vid,
+};
+
 static const struct net_device_ops dsa_slave_netdev_ops = {
 	.ndo_open	 	= dsa_slave_open,
 	.ndo_stop		= dsa_slave_close,
@@ -1119,6 +1151,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
 	.ndo_get_port_parent_id	= dsa_slave_get_port_parent_id,
 	.ndo_vlan_rx_add_vid	= dsa_slave_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= dsa_slave_vlan_rx_kill_vid,
+	.ndo_get_devlink_port	= dsa_slave_get_devlink_port,
 };
 
 static struct device_type dsa_type = {
@@ -1355,7 +1388,8 @@ static void dsa_slave_notify(struct net_device *dev, unsigned long val)
 	call_dsa_notifiers(val, dev, &rinfo.info);
 }
 
-int dsa_slave_create(struct dsa_port *port)
+static int __dsa_slave_create(struct dsa_port *port,
+			      const struct net_device_ops *netdev_ops)
 {
 	const struct dsa_port *cpu_dp = port->cpu_dp;
 	struct net_device *master = cpu_dp->master;
@@ -1380,7 +1414,7 @@ int dsa_slave_create(struct dsa_port *port)
 	slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
 	eth_hw_addr_inherit(slave_dev, master);
 	slave_dev->priv_flags |= IFF_NO_QUEUE;
-	slave_dev->netdev_ops = &dsa_slave_netdev_ops;
+	slave_dev->netdev_ops = netdev_ops;
 	slave_dev->min_mtu = 0;
 	slave_dev->max_mtu = ETH_MAX_MTU;
 	SET_NETDEV_DEVTYPE(slave_dev, &dsa_type);
@@ -1434,6 +1468,16 @@ int dsa_slave_create(struct dsa_port *port)
 	return ret;
 }
 
+int dsa_slave_create(struct dsa_port *port)
+{
+	return __dsa_slave_create(port, &dsa_slave_netdev_ops);
+}
+
+int dsa_slave_create_legacy(struct dsa_port *port)
+{
+	return __dsa_slave_create(port, &dsa_slave_netdev_ops_legacy);
+}
+
 void dsa_slave_destroy(struct net_device *slave_dev)
 {
 	struct dsa_port *dp = dsa_slave_to_port(slave_dev);
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 09/12] dsa: don't fill-up remove ndo_get_phys_port_name for slaves
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (7 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 12:03 ` [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name() Jiri Pirko
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Leave it only for legacy. But since each slave has its own devlink port
instance correctly set, rely on devlink core to generate correct phys
port name.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 net/dsa/slave.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 46c98cb8a2b5..75bcac39a326 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1145,7 +1145,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
 	.ndo_netpoll_cleanup	= dsa_slave_netpoll_cleanup,
 	.ndo_poll_controller	= dsa_slave_poll_controller,
 #endif
-	.ndo_get_phys_port_name	= dsa_slave_get_phys_port_name,
 	.ndo_setup_tc		= dsa_slave_setup_tc,
 	.ndo_get_stats64	= dsa_slave_get_stats64,
 	.ndo_get_port_parent_id	= dsa_slave_get_port_parent_id,
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name()
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (8 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 09/12] dsa: don't fill-up remove ndo_get_phys_port_name for slaves Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 20:31   ` Jakub Kicinski
  2019-03-26 12:03 ` [patch net-next v2 11/12] net: devlink: expose phys port name Jiri Pirko
  2019-03-26 12:03 ` [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed Jiri Pirko
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

If nn->port is defined it means that devlink_port has been registered
for this port as well. Devlink core is handling the port name
formatting.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index b676943e54f4..99200b5dac76 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -3324,8 +3324,11 @@ nfp_net_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
 	struct nfp_net *nn = netdev_priv(netdev);
 	int n;
 
+	/* If port is defined, devlink_port is registered and devlink core
+	 * is taking care of name formatting.
+	 */
 	if (nn->port)
-		return nfp_port_get_phys_port_name(netdev, name, len);
+		return -EOPNOTSUPP;
 
 	if (nn->dp.is_vf || nn->vnic_no_name)
 		return -EOPNOTSUPP;
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 11/12] net: devlink: expose phys port name
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (9 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name() Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 20:35   ` Jakub Kicinski
  2019-03-26 12:03 ` [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed Jiri Pirko
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Currently, it is exposed via rtnetlink. But it is relevant to devlink
ports, so expose it here too.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 include/uapi/linux/devlink.h |  2 +
 net/core/devlink.c           | 86 ++++++++++++++++++++++--------------
 2 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 5bb4ea67d84f..2d0365e45141 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -332,6 +332,8 @@ enum devlink_attr {
 	DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME,	/* string */
 	DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,	/* string */
 
+	DEVLINK_ATTR_PORT_PHYS_NAME,		/* string */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 6bbd07e3861e..356d7ee7c404 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -508,6 +508,57 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
 				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
 }
 
+static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
+					     char *name, size_t len)
+{
+	struct devlink_port_attrs *attrs = &devlink_port->attrs;
+	int n = 0;
+
+	if (!attrs->set)
+		return -EOPNOTSUPP;
+
+	switch (attrs->flavour) {
+	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
+		if (!attrs->split)
+			n = snprintf(name, len, "p%u", attrs->port_number);
+		else
+			n = snprintf(name, len, "p%us%u", attrs->port_number,
+				     attrs->split_subport_number);
+		break;
+	case DEVLINK_PORT_FLAVOUR_CPU:
+	case DEVLINK_PORT_FLAVOUR_DSA:
+		/* As CPU and DSA ports do not have a netdevice associated
+		 * case should not ever happen.
+		 */
+		WARN_ON(1);
+		return -EINVAL;
+	}
+
+	if (n >= len)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int devlink_nl_port_phys_port_name_put(struct sk_buff *msg,
+					      struct devlink_port *devlink_port)
+{
+	struct devlink_port_attrs *attrs = &devlink_port->attrs;
+	char phys_name[IFNAMSIZ];
+	int err;
+
+	if (attrs->flavour != DEVLINK_PORT_FLAVOUR_PHYSICAL)
+		return 0;
+
+	err = __devlink_port_phys_port_name_get(devlink_port,
+						phys_name, sizeof(phys_name));
+	if (err)
+		return err;
+	if (nla_put_string(msg, DEVLINK_ATTR_PORT_PHYS_NAME, phys_name))
+		return -EMSGSIZE;
+	return 0;
+}
+
 static int devlink_nl_port_attrs_put(struct sk_buff *msg,
 				     struct devlink_port *devlink_port)
 {
@@ -526,6 +577,9 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
 	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
 			attrs->split_subport_number))
 		return -EMSGSIZE;
+	if (devlink_nl_port_phys_port_name_put(msg, devlink_port))
+		return -EMSGSIZE;
+
 	return 0;
 }
 
@@ -5414,38 +5468,6 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
 }
 EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
 
-static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
-					     char *name, size_t len)
-{
-	struct devlink_port_attrs *attrs = &devlink_port->attrs;
-	int n = 0;
-
-	if (!attrs->set)
-		return -EOPNOTSUPP;
-
-	switch (attrs->flavour) {
-	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
-		if (!attrs->split)
-			n = snprintf(name, len, "p%u", attrs->port_number);
-		else
-			n = snprintf(name, len, "p%us%u", attrs->port_number,
-				     attrs->split_subport_number);
-		break;
-	case DEVLINK_PORT_FLAVOUR_CPU:
-	case DEVLINK_PORT_FLAVOUR_DSA:
-		/* As CPU and DSA ports do not have a netdevice associated
-		 * case should not ever happen.
-		 */
-		WARN_ON(1);
-		return -EINVAL;
-	}
-
-	if (n >= len)
-		return -EINVAL;
-
-	return 0;
-}
-
 int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
 			u32 size, u16 ingress_pools_count,
 			u16 egress_pools_count, u16 ingress_tc_count,
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed
  2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
                   ` (10 preceding siblings ...)
  2019-03-26 12:03 ` [patch net-next v2 11/12] net: devlink: expose phys port name Jiri Pirko
@ 2019-03-26 12:03 ` Jiri Pirko
  2019-03-26 20:36   ` Jakub Kicinski
  11 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-26 12:03 UTC (permalink / raw)
  To: netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, f.fainelli, andrew,
	vivien.didelot, michael.chan

From: Jiri Pirko <jiri@mellanox.com>

Currently if the driver registers devlink port instance, it should set
the devlink port attributes as well. Then the devlink core is able to
obtain physical port name itself, no need for driver to implement
the ndo. Once all drivers will implement devlink port registration,
this ndo should be removed. This warning guides new
drivers to do things as they should be done.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- new patch
---
 net/core/devlink.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 356d7ee7c404..3eb5d6025154 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5412,6 +5412,24 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
 			       struct net_device *netdev)
 {
+	/* If driver registers devlink port, it should set devlink port
+	 * attributes accordingly so the compat functions are called
+	 * and the original ops are not used.
+	 */
+	if (netdev->netdev_ops->ndo_get_phys_port_name) {
+		/* Some drivers use the same set of ndos for netdevs
+		 * that have devlink_port registered and also for
+		 * those who don't. Make sure that ndo_get_phys_port_name
+		 * returns -EOPNOTSUPP here in case it is defined.
+		 * Warn if not.
+		 */
+		const struct net_device_ops *ops = netdev->netdev_ops;
+		char name[IFNAMSIZ];
+		int err;
+
+		err = ops->ndo_get_phys_port_name(netdev, name, sizeof(name));
+		WARN_ON(err != -EOPNOTSUPP);
+	}
 	__devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev);
 }
 EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port
  2019-03-26 12:02 ` [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port Jiri Pirko
@ 2019-03-26 20:27   ` Jakub Kicinski
  2019-03-27  7:47     ` Jiri Pirko
  0 siblings, 1 reply; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:27 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:02:56 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Follow-up patch is going to need a devlink port instance according to
> a netdev. Devlink port instance should be always available when devlink
> is used. So change the recently introduced ndo_get_devlink to
> ndo_get_devlink_port. With that, adjust the wrapper for the only
> user to get devlink pointer.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Makes sense, but you gotta fix up the nfp to register devlink ports
first, like I did in:

https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git/commit/?h=devlink-pci-ports&id=1debfdef5aef369412e72f370d11120d309a6a74

please.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get()
  2019-03-26 12:02 ` [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get() Jiri Pirko
@ 2019-03-26 20:30   ` Jakub Kicinski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:30 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:02:57 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Introduce devlink_compat_phys_port_name_get() helper that
> gets the physical port name for specified netdevice
> according to devlink port attributes.
> Call this helper from dev_get_phys_port_name()
> in case ndo_get_phys_port_name is not defined.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function
  2019-03-26 12:03 ` [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function Jiri Pirko
@ 2019-03-26 20:31   ` Jakub Kicinski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:31 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:03:00 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Now it is unused, remove it.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name()
  2019-03-26 12:03 ` [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name() Jiri Pirko
@ 2019-03-26 20:31   ` Jakub Kicinski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:31 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:03:05 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> If nn->port is defined it means that devlink_port has been registered
> for this port as well. Devlink core is handling the port name
> formatting.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 11/12] net: devlink: expose phys port name
  2019-03-26 12:03 ` [patch net-next v2 11/12] net: devlink: expose phys port name Jiri Pirko
@ 2019-03-26 20:35   ` Jakub Kicinski
  2019-03-27  7:45     ` Jiri Pirko
  0 siblings, 1 reply; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:35 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:03:06 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Currently, it is exposed via rtnetlink. But it is relevant to devlink
> ports, so expose it here too.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Why?  User space has access to all the components which are used to
generate the name in a typed, structured form.  That's strictly
superior to the string netdev string.

Do you have some use in mind for the new attribute?

> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> index 5bb4ea67d84f..2d0365e45141 100644
> --- a/include/uapi/linux/devlink.h
> +++ b/include/uapi/linux/devlink.h
> @@ -332,6 +332,8 @@ enum devlink_attr {
>  	DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME,	/* string */
>  	DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,	/* string */
>  
> +	DEVLINK_ATTR_PORT_PHYS_NAME,		/* string */
> +
>  	/* add new attributes above here, update the policy in devlink.c */
>  
>  	__DEVLINK_ATTR_MAX,
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index 6bbd07e3861e..356d7ee7c404 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -508,6 +508,57 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
>  				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
>  }
>  
> +static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
> +					     char *name, size_t len)
> +{
> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
> +	int n = 0;
> +
> +	if (!attrs->set)
> +		return -EOPNOTSUPP;
> +
> +	switch (attrs->flavour) {
> +	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
> +		if (!attrs->split)
> +			n = snprintf(name, len, "p%u", attrs->port_number);
> +		else
> +			n = snprintf(name, len, "p%us%u", attrs->port_number,
> +				     attrs->split_subport_number);
> +		break;
> +	case DEVLINK_PORT_FLAVOUR_CPU:
> +	case DEVLINK_PORT_FLAVOUR_DSA:
> +		/* As CPU and DSA ports do not have a netdevice associated
> +		 * case should not ever happen.
> +		 */
> +		WARN_ON(1);
> +		return -EINVAL;
> +	}
> +
> +	if (n >= len)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static int devlink_nl_port_phys_port_name_put(struct sk_buff *msg,
> +					      struct devlink_port *devlink_port)
> +{
> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
> +	char phys_name[IFNAMSIZ];
> +	int err;
> +
> +	if (attrs->flavour != DEVLINK_PORT_FLAVOUR_PHYSICAL)
> +		return 0;
> +
> +	err = __devlink_port_phys_port_name_get(devlink_port,
> +						phys_name, sizeof(phys_name));
> +	if (err)
> +		return err;
> +	if (nla_put_string(msg, DEVLINK_ATTR_PORT_PHYS_NAME, phys_name))
> +		return -EMSGSIZE;
> +	return 0;
> +}
> +
>  static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>  				     struct devlink_port *devlink_port)
>  {
> @@ -526,6 +577,9 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>  	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
>  			attrs->split_subport_number))
>  		return -EMSGSIZE;
> +	if (devlink_nl_port_phys_port_name_put(msg, devlink_port))
> +		return -EMSGSIZE;
> +
>  	return 0;
>  }
>  
> @@ -5414,38 +5468,6 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
>  }
>  EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
>  
> -static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
> -					     char *name, size_t len)
> -{
> -	struct devlink_port_attrs *attrs = &devlink_port->attrs;
> -	int n = 0;
> -
> -	if (!attrs->set)
> -		return -EOPNOTSUPP;
> -
> -	switch (attrs->flavour) {
> -	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
> -		if (!attrs->split)
> -			n = snprintf(name, len, "p%u", attrs->port_number);
> -		else
> -			n = snprintf(name, len, "p%us%u", attrs->port_number,
> -				     attrs->split_subport_number);
> -		break;
> -	case DEVLINK_PORT_FLAVOUR_CPU:
> -	case DEVLINK_PORT_FLAVOUR_DSA:
> -		/* As CPU and DSA ports do not have a netdevice associated
> -		 * case should not ever happen.
> -		 */
> -		WARN_ON(1);
> -		return -EINVAL;
> -	}
> -
> -	if (n >= len)
> -		return -EINVAL;
> -
> -	return 0;
> -}
> -
>  int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
>  			u32 size, u16 ingress_pools_count,
>  			u16 egress_pools_count, u16 ingress_tc_count,


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed
  2019-03-26 12:03 ` [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed Jiri Pirko
@ 2019-03-26 20:36   ` Jakub Kicinski
  0 siblings, 0 replies; 26+ messages in thread
From: Jakub Kicinski @ 2019-03-26 20:36 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

On Tue, 26 Mar 2019 13:03:07 +0100, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Currently if the driver registers devlink port instance, it should set
> the devlink port attributes as well. Then the devlink core is able to
> obtain physical port name itself, no need for driver to implement
> the ndo. Once all drivers will implement devlink port registration,
> this ndo should be removed. This warning guides new
> drivers to do things as they should be done.
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 11/12] net: devlink: expose phys port name
  2019-03-26 20:35   ` Jakub Kicinski
@ 2019-03-27  7:45     ` Jiri Pirko
  2019-03-27 11:56       ` Jiri Pirko
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-27  7:45 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

Tue, Mar 26, 2019 at 09:35:58PM CET, jakub.kicinski@netronome.com wrote:
>On Tue, 26 Mar 2019 13:03:06 +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> Currently, it is exposed via rtnetlink. But it is relevant to devlink
>> ports, so expose it here too.
>> 
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>
>Why?  User space has access to all the components which are used to
>generate the name in a typed, structured form.  That's strictly

Nope. It does has access only to flavour. Not to port number for
example. So I thought either expose that or the generated name.

>superior to the string netdev string.
>
>Do you have some use in mind for the new attribute?
>
>> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>> index 5bb4ea67d84f..2d0365e45141 100644
>> --- a/include/uapi/linux/devlink.h
>> +++ b/include/uapi/linux/devlink.h
>> @@ -332,6 +332,8 @@ enum devlink_attr {
>>  	DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME,	/* string */
>>  	DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,	/* string */
>>  
>> +	DEVLINK_ATTR_PORT_PHYS_NAME,		/* string */
>> +
>>  	/* add new attributes above here, update the policy in devlink.c */
>>  
>>  	__DEVLINK_ATTR_MAX,
>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index 6bbd07e3861e..356d7ee7c404 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -508,6 +508,57 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
>>  				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
>>  }
>>  
>> +static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>> +					     char *name, size_t len)
>> +{
>> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>> +	int n = 0;
>> +
>> +	if (!attrs->set)
>> +		return -EOPNOTSUPP;
>> +
>> +	switch (attrs->flavour) {
>> +	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>> +		if (!attrs->split)
>> +			n = snprintf(name, len, "p%u", attrs->port_number);
>> +		else
>> +			n = snprintf(name, len, "p%us%u", attrs->port_number,
>> +				     attrs->split_subport_number);
>> +		break;
>> +	case DEVLINK_PORT_FLAVOUR_CPU:
>> +	case DEVLINK_PORT_FLAVOUR_DSA:
>> +		/* As CPU and DSA ports do not have a netdevice associated
>> +		 * case should not ever happen.
>> +		 */
>> +		WARN_ON(1);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (n >= len)
>> +		return -EINVAL;
>> +
>> +	return 0;
>> +}
>> +
>> +static int devlink_nl_port_phys_port_name_put(struct sk_buff *msg,
>> +					      struct devlink_port *devlink_port)
>> +{
>> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>> +	char phys_name[IFNAMSIZ];
>> +	int err;
>> +
>> +	if (attrs->flavour != DEVLINK_PORT_FLAVOUR_PHYSICAL)
>> +		return 0;
>> +
>> +	err = __devlink_port_phys_port_name_get(devlink_port,
>> +						phys_name, sizeof(phys_name));
>> +	if (err)
>> +		return err;
>> +	if (nla_put_string(msg, DEVLINK_ATTR_PORT_PHYS_NAME, phys_name))
>> +		return -EMSGSIZE;
>> +	return 0;
>> +}
>> +
>>  static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>>  				     struct devlink_port *devlink_port)
>>  {
>> @@ -526,6 +577,9 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>>  	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
>>  			attrs->split_subport_number))
>>  		return -EMSGSIZE;
>> +	if (devlink_nl_port_phys_port_name_put(msg, devlink_port))
>> +		return -EMSGSIZE;
>> +
>>  	return 0;
>>  }
>>  
>> @@ -5414,38 +5468,6 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
>>  }
>>  EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
>>  
>> -static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>> -					     char *name, size_t len)
>> -{
>> -	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>> -	int n = 0;
>> -
>> -	if (!attrs->set)
>> -		return -EOPNOTSUPP;
>> -
>> -	switch (attrs->flavour) {
>> -	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>> -		if (!attrs->split)
>> -			n = snprintf(name, len, "p%u", attrs->port_number);
>> -		else
>> -			n = snprintf(name, len, "p%us%u", attrs->port_number,
>> -				     attrs->split_subport_number);
>> -		break;
>> -	case DEVLINK_PORT_FLAVOUR_CPU:
>> -	case DEVLINK_PORT_FLAVOUR_DSA:
>> -		/* As CPU and DSA ports do not have a netdevice associated
>> -		 * case should not ever happen.
>> -		 */
>> -		WARN_ON(1);
>> -		return -EINVAL;
>> -	}
>> -
>> -	if (n >= len)
>> -		return -EINVAL;
>> -
>> -	return 0;
>> -}
>> -
>>  int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
>>  			u32 size, u16 ingress_pools_count,
>>  			u16 egress_pools_count, u16 ingress_tc_count,
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port
  2019-03-26 20:27   ` Jakub Kicinski
@ 2019-03-27  7:47     ` Jiri Pirko
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-27  7:47 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

Tue, Mar 26, 2019 at 09:27:37PM CET, jakub.kicinski@netronome.com wrote:
>On Tue, 26 Mar 2019 13:02:56 +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> Follow-up patch is going to need a devlink port instance according to
>> a netdev. Devlink port instance should be always available when devlink
>> is used. So change the recently introduced ndo_get_devlink to
>> ndo_get_devlink_port. With that, adjust the wrapper for the only
>> user to get devlink pointer.
>> 
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
>> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
>
>Makes sense, but you gotta fix up the nfp to register devlink ports
>first, like I did in:
>
>https://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git/commit/?h=devlink-pci-ports&id=1debfdef5aef369412e72f370d11120d309a6a74
>
>please.

I have it in next patchset:
https://github.com/jpirko/linux_mlxsw/commit/d1ea97ec57762f1950d26842191070b4498044c6

Will put it here.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 11/12] net: devlink: expose phys port name
  2019-03-27  7:45     ` Jiri Pirko
@ 2019-03-27 11:56       ` Jiri Pirko
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-27 11:56 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, davem, mlxsw, idosch, f.fainelli, andrew, vivien.didelot,
	michael.chan

Wed, Mar 27, 2019 at 08:45:38AM CET, jiri@resnulli.us wrote:
>Tue, Mar 26, 2019 at 09:35:58PM CET, jakub.kicinski@netronome.com wrote:
>>On Tue, 26 Mar 2019 13:03:06 +0100, Jiri Pirko wrote:
>>> From: Jiri Pirko <jiri@mellanox.com>
>>> 
>>> Currently, it is exposed via rtnetlink. But it is relevant to devlink
>>> ports, so expose it here too.
>>> 
>>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>>
>>Why?  User space has access to all the components which are used to
>>generate the name in a typed, structured form.  That's strictly
>
>Nope. It does has access only to flavour. Not to port number for
>example. So I thought either expose that or the generated name.

To correct myself, all is exposed by kernel, just not implemented in
userspace. I thought that generated port name would be good to have.
Not really good idea to generate it again in userspace. Anyway, I'll
leave this patch out for now, I can send it separatelly later on.


>
>>superior to the string netdev string.
>>
>>Do you have some use in mind for the new attribute?
>>
>>> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>>> index 5bb4ea67d84f..2d0365e45141 100644
>>> --- a/include/uapi/linux/devlink.h
>>> +++ b/include/uapi/linux/devlink.h
>>> @@ -332,6 +332,8 @@ enum devlink_attr {
>>>  	DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME,	/* string */
>>>  	DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,	/* string */
>>>  
>>> +	DEVLINK_ATTR_PORT_PHYS_NAME,		/* string */
>>> +
>>>  	/* add new attributes above here, update the policy in devlink.c */
>>>  
>>>  	__DEVLINK_ATTR_MAX,
>>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>>> index 6bbd07e3861e..356d7ee7c404 100644
>>> --- a/net/core/devlink.c
>>> +++ b/net/core/devlink.c
>>> @@ -508,6 +508,57 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
>>>  				msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
>>>  }
>>>  
>>> +static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>>> +					     char *name, size_t len)
>>> +{
>>> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>>> +	int n = 0;
>>> +
>>> +	if (!attrs->set)
>>> +		return -EOPNOTSUPP;
>>> +
>>> +	switch (attrs->flavour) {
>>> +	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>>> +		if (!attrs->split)
>>> +			n = snprintf(name, len, "p%u", attrs->port_number);
>>> +		else
>>> +			n = snprintf(name, len, "p%us%u", attrs->port_number,
>>> +				     attrs->split_subport_number);
>>> +		break;
>>> +	case DEVLINK_PORT_FLAVOUR_CPU:
>>> +	case DEVLINK_PORT_FLAVOUR_DSA:
>>> +		/* As CPU and DSA ports do not have a netdevice associated
>>> +		 * case should not ever happen.
>>> +		 */
>>> +		WARN_ON(1);
>>> +		return -EINVAL;
>>> +	}
>>> +
>>> +	if (n >= len)
>>> +		return -EINVAL;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +static int devlink_nl_port_phys_port_name_put(struct sk_buff *msg,
>>> +					      struct devlink_port *devlink_port)
>>> +{
>>> +	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>>> +	char phys_name[IFNAMSIZ];
>>> +	int err;
>>> +
>>> +	if (attrs->flavour != DEVLINK_PORT_FLAVOUR_PHYSICAL)
>>> +		return 0;
>>> +
>>> +	err = __devlink_port_phys_port_name_get(devlink_port,
>>> +						phys_name, sizeof(phys_name));
>>> +	if (err)
>>> +		return err;
>>> +	if (nla_put_string(msg, DEVLINK_ATTR_PORT_PHYS_NAME, phys_name))
>>> +		return -EMSGSIZE;
>>> +	return 0;
>>> +}
>>> +
>>>  static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>>>  				     struct devlink_port *devlink_port)
>>>  {
>>> @@ -526,6 +577,9 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
>>>  	if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
>>>  			attrs->split_subport_number))
>>>  		return -EMSGSIZE;
>>> +	if (devlink_nl_port_phys_port_name_put(msg, devlink_port))
>>> +		return -EMSGSIZE;
>>> +
>>>  	return 0;
>>>  }
>>>  
>>> @@ -5414,38 +5468,6 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
>>>  }
>>>  EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
>>>  
>>> -static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>>> -					     char *name, size_t len)
>>> -{
>>> -	struct devlink_port_attrs *attrs = &devlink_port->attrs;
>>> -	int n = 0;
>>> -
>>> -	if (!attrs->set)
>>> -		return -EOPNOTSUPP;
>>> -
>>> -	switch (attrs->flavour) {
>>> -	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>>> -		if (!attrs->split)
>>> -			n = snprintf(name, len, "p%u", attrs->port_number);
>>> -		else
>>> -			n = snprintf(name, len, "p%us%u", attrs->port_number,
>>> -				     attrs->split_subport_number);
>>> -		break;
>>> -	case DEVLINK_PORT_FLAVOUR_CPU:
>>> -	case DEVLINK_PORT_FLAVOUR_DSA:
>>> -		/* As CPU and DSA ports do not have a netdevice associated
>>> -		 * case should not ever happen.
>>> -		 */
>>> -		WARN_ON(1);
>>> -		return -EINVAL;
>>> -	}
>>> -
>>> -	if (n >= len)
>>> -		return -EINVAL;
>>> -
>>> -	return 0;
>>> -}
>>> -
>>>  int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
>>>  			u32 size, u16 ingress_pools_count,
>>>  			u16 egress_pools_count, u16 ingress_tc_count,
>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port
  2019-03-26 12:03 ` [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port Jiri Pirko
@ 2019-03-27 19:54   ` Florian Fainelli
  2019-03-27 20:01     ` Jiri Pirko
  0 siblings, 1 reply; 26+ messages in thread
From: Florian Fainelli @ 2019-03-27 19:54 UTC (permalink / raw)
  To: Jiri Pirko, netdev
  Cc: davem, mlxsw, idosch, jakub.kicinski, andrew, vivien.didelot,
	michael.chan

On 3/26/2019 5:03 AM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> In order for devlink compat functions to work, implement
> ndo_get_devlink_port. Legacy slaves does not have devlink port instances
> created for themselves.

Not a big fan of de-duplicating the entire set of netdev_ops for legacy
vs. non-legacy, can we just check that the devlink instance was r
-- 
Florian

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port
  2019-03-27 19:54   ` Florian Fainelli
@ 2019-03-27 20:01     ` Jiri Pirko
  2019-03-27 20:13       ` Florian Fainelli
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Pirko @ 2019-03-27 20:01 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, davem, mlxsw, idosch, jakub.kicinski, andrew,
	vivien.didelot, michael.chan

Wed, Mar 27, 2019 at 08:54:41PM CET, f.fainelli@gmail.com wrote:
>On 3/26/2019 5:03 AM, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> In order for devlink compat functions to work, implement
>> ndo_get_devlink_port. Legacy slaves does not have devlink port instances
>> created for themselves.
>
>Not a big fan of de-duplicating the entire set of netdev_ops for legacy
>vs. non-legacy, can we just check that the devlink instance was r

In nfp, I make legacy and non-legacy ndos to be shared. However there,
they are doing to eventually all use devlink ports. In dsa on the other
hand, I don't think that legacy is going to use devlink port, would it?
I wan't to eventually have WARN_ON in devlink code in case devlink_port
exists and phys_port_name ndo is present at the same time.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port
  2019-03-27 20:01     ` Jiri Pirko
@ 2019-03-27 20:13       ` Florian Fainelli
  2019-03-27 23:46         ` Jiri Pirko
  0 siblings, 1 reply; 26+ messages in thread
From: Florian Fainelli @ 2019-03-27 20:13 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, mlxsw, idosch, jakub.kicinski, andrew,
	vivien.didelot, michael.chan

On 3/27/19 1:01 PM, Jiri Pirko wrote:
> Wed, Mar 27, 2019 at 08:54:41PM CET, f.fainelli@gmail.com wrote:
>> On 3/26/2019 5:03 AM, Jiri Pirko wrote:
>>> From: Jiri Pirko <jiri@mellanox.com>
>>>
>>> In order for devlink compat functions to work, implement
>>> ndo_get_devlink_port. Legacy slaves does not have devlink port instances
>>> created for themselves.
>>
>> Not a big fan of de-duplicating the entire set of netdev_ops for legacy
>> vs. non-legacy, can we just check that the devlink instance was r
> 
> In nfp, I make legacy and non-legacy ndos to be shared. However there,
> they are doing to eventually all use devlink ports. In dsa on the other
> hand, I don't think that legacy is going to use devlink port, would it?

The legacy probing method has not been updated to match what
net/dsa/dsa2.c does, but there is no technical reason for not supporting
devlink instances over ports registered through the legacy interface. So
eventually all of what you did here will be thrown away (not sure by
which timeframe, probably after mv88e6060 finally gets converted to the
new binding).

> I wan't to eventually have WARN_ON in devlink code in case devlink_port
> exists and phys_port_name ndo is present at the same time.
> 

No sure, but you could always do something like:

if (!dp->devlink_registered)
	return dsa_slave_get_phys_port_name();

return &dp->devlink_port;

is what I had in mind. This just requires adding a boolean to track the
registration of devlink ports within net/dsa/dsa2.c which should be
fewer lines of code and easier to remove in the future. No strong
objections though.
-- 
Florian

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port
  2019-03-27 20:13       ` Florian Fainelli
@ 2019-03-27 23:46         ` Jiri Pirko
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Pirko @ 2019-03-27 23:46 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, davem, mlxsw, idosch, jakub.kicinski, andrew,
	vivien.didelot, michael.chan

Wed, Mar 27, 2019 at 09:13:00PM CET, f.fainelli@gmail.com wrote:
>On 3/27/19 1:01 PM, Jiri Pirko wrote:
>> Wed, Mar 27, 2019 at 08:54:41PM CET, f.fainelli@gmail.com wrote:
>>> On 3/26/2019 5:03 AM, Jiri Pirko wrote:
>>>> From: Jiri Pirko <jiri@mellanox.com>
>>>>
>>>> In order for devlink compat functions to work, implement
>>>> ndo_get_devlink_port. Legacy slaves does not have devlink port instances
>>>> created for themselves.
>>>
>>> Not a big fan of de-duplicating the entire set of netdev_ops for legacy
>>> vs. non-legacy, can we just check that the devlink instance was r
>> 
>> In nfp, I make legacy and non-legacy ndos to be shared. However there,
>> they are doing to eventually all use devlink ports. In dsa on the other
>> hand, I don't think that legacy is going to use devlink port, would it?
>
>The legacy probing method has not been updated to match what
>net/dsa/dsa2.c does, but there is no technical reason for not supporting
>devlink instances over ports registered through the legacy interface. So
>eventually all of what you did here will be thrown away (not sure by
>which timeframe, probably after mv88e6060 finally gets converted to the
>new binding).

Okay. In that case, when you say legacy will be eventually remove,
Will do the same as I did for nfp. Thanks!

>
>> I wan't to eventually have WARN_ON in devlink code in case devlink_port
>> exists and phys_port_name ndo is present at the same time.
>> 
>
>No sure, but you could always do something like:
>
>if (!dp->devlink_registered)
>	return dsa_slave_get_phys_port_name();
>
>return &dp->devlink_port;
>
>is what I had in mind. This just requires adding a boolean to track the
>registration of devlink ports within net/dsa/dsa2.c which should be
>fewer lines of code and easier to remove in the future. No strong
>objections though.
>-- 
>Florian

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-03-27 23:47 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 12:02 [patch net-next v2 00/12] net: call for phys_port_name into devlink directly if possible Jiri Pirko
2019-03-26 12:02 ` [patch net-next v2 01/12] net: replace ndo_get_devlink with ndo_get_devlink_port Jiri Pirko
2019-03-26 20:27   ` Jakub Kicinski
2019-03-27  7:47     ` Jiri Pirko
2019-03-26 12:02 ` [patch net-next v2 02/12] net: devlink: introduce devlink_compat_phys_port_name_get() Jiri Pirko
2019-03-26 20:30   ` Jakub Kicinski
2019-03-26 12:02 ` [patch net-next v2 03/12] mlxsw: Implement ndo_get_devlink_port Jiri Pirko
2019-03-26 12:02 ` [patch net-next v2 04/12] mlxsw: Remove ndo_get_phys_port_name implementation Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 05/12] net: devlink: remove unused devlink_port_get_phys_port_name() function Jiri Pirko
2019-03-26 20:31   ` Jakub Kicinski
2019-03-26 12:03 ` [patch net-next v2 06/12] bnxt: implement ndo_get_devlink_port Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 07/12] bnxt: remove ndo_get_phys_port_name implementation Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 08/12] dsa: implement ndo_get_devlink_port Jiri Pirko
2019-03-27 19:54   ` Florian Fainelli
2019-03-27 20:01     ` Jiri Pirko
2019-03-27 20:13       ` Florian Fainelli
2019-03-27 23:46         ` Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 09/12] dsa: don't fill-up remove ndo_get_phys_port_name for slaves Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 10/12] nfp: do not handle nn->port defined case in nfp_net_get_phys_port_name() Jiri Pirko
2019-03-26 20:31   ` Jakub Kicinski
2019-03-26 12:03 ` [patch net-next v2 11/12] net: devlink: expose phys port name Jiri Pirko
2019-03-26 20:35   ` Jakub Kicinski
2019-03-27  7:45     ` Jiri Pirko
2019-03-27 11:56       ` Jiri Pirko
2019-03-26 12:03 ` [patch net-next v2 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed Jiri Pirko
2019-03-26 20:36   ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.