mlxsw: Implement ndo_get_port_parent_id()
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 6 Feb 2019 17:45:39 +0000 (09:45 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Feb 2019 22:16:11 +0000 (14:16 -0800)
mlxsw implements SWITCHDEV_ATTR_ID_PORT_PARENT_ID and we want to get rid
of switchdev_ops eventually, ease that migration by implementing a
ndo_get_port_parent_id() function which returns what
switchdev_port_attr_get() would do.

Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/mellanox/mlxsw/switchx2.c

index a88169738b4a7eff9aeadde4ab36f5ff2b4f5018..8dd808b7f9314a3c0cf73ac4a23afc16182af249 100644 (file)
@@ -1700,6 +1700,18 @@ static int mlxsw_sp_set_features(struct net_device *dev,
                                       mlxsw_sp_feature_hw_tc);
 }
 
+static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
+                                           struct netdev_phys_item_id *ppid)
+{
+       struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+
+       ppid->id_len = sizeof(mlxsw_sp->base_mac);
+       memcpy(&ppid->id, &mlxsw_sp->base_mac, ppid->id_len);
+
+       return 0;
+}
+
 static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
        .ndo_open               = mlxsw_sp_port_open,
        .ndo_stop               = mlxsw_sp_port_stop,
@@ -1715,6 +1727,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
        .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,
 };
 
 static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
index a4a9fe9921933adb845531d379376772327f1edf..95e37de3e48f710789fda93b11d519586eac90c2 100644 (file)
@@ -451,11 +451,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 
        switch (attr->id) {
-       case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-               attr->u.ppid.id_len = sizeof(mlxsw_sp->base_mac);
-               memcpy(&attr->u.ppid.id, &mlxsw_sp->base_mac,
-                      attr->u.ppid.id_len);
-               break;
        case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
                mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
                                               &attr->u.brport_flags);
index 2d4f213e154d8ca72deb092efd36c638e434c3b7..533fe6235b7c8d65a1fafc684b570479e4023b6a 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/device.h>
 #include <linux/skbuff.h>
 #include <linux/if_vlan.h>
-#include <net/switchdev.h>
 
 #include "pci.h"
 #include "core.h"
@@ -390,6 +389,18 @@ static int mlxsw_sx_port_get_phys_port_name(struct net_device *dev, char *name,
                                                  name, len);
 }
 
+static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
+                                           struct netdev_phys_item_id *ppid)
+{
+       struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
+       struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
+
+       ppid->id_len = sizeof(mlxsw_sx->hw_id);
+       memcpy(&ppid->id, &mlxsw_sx->hw_id, ppid->id_len);
+
+       return 0;
+}
+
 static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
        .ndo_open               = mlxsw_sx_port_open,
        .ndo_stop               = mlxsw_sx_port_stop,
@@ -397,6 +408,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
        .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,
 };
 
 static void mlxsw_sx_port_get_drvinfo(struct net_device *dev,
@@ -901,28 +913,6 @@ static const struct ethtool_ops mlxsw_sx_port_ethtool_ops = {
        .set_link_ksettings     = mlxsw_sx_port_set_link_ksettings,
 };
 
-static int mlxsw_sx_port_attr_get(struct net_device *dev,
-                                 struct switchdev_attr *attr)
-{
-       struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
-       struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
-
-       switch (attr->id) {
-       case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
-               attr->u.ppid.id_len = sizeof(mlxsw_sx->hw_id);
-               memcpy(&attr->u.ppid.id, &mlxsw_sx->hw_id, attr->u.ppid.id_len);
-               break;
-       default:
-               return -EOPNOTSUPP;
-       }
-
-       return 0;
-}
-
-static const struct switchdev_ops mlxsw_sx_port_switchdev_ops = {
-       .switchdev_port_attr_get        = mlxsw_sx_port_attr_get,
-};
-
 static int mlxsw_sx_hw_id_get(struct mlxsw_sx *mlxsw_sx)
 {
        char spad_pl[MLXSW_REG_SPAD_LEN] = {0};
@@ -1034,7 +1024,6 @@ static int __mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port,
 
        dev->netdev_ops = &mlxsw_sx_port_netdev_ops;
        dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops;
-       dev->switchdev_ops = &mlxsw_sx_port_switchdev_ops;
 
        err = mlxsw_sx_port_dev_addr_get(mlxsw_sx_port);
        if (err) {