Skip to content

Commit 25ba860

Browse files
ffainellidavem330
authored andcommitted
mlxsw: Implement ndo_get_port_parent_id()
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>
1 parent 6dcfa23 commit 25ba860

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,18 @@ static int mlxsw_sp_set_features(struct net_device *dev,
17001700
mlxsw_sp_feature_hw_tc);
17011701
}
17021702

1703+
static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
1704+
struct netdev_phys_item_id *ppid)
1705+
{
1706+
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
1707+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1708+
1709+
ppid->id_len = sizeof(mlxsw_sp->base_mac);
1710+
memcpy(&ppid->id, &mlxsw_sp->base_mac, ppid->id_len);
1711+
1712+
return 0;
1713+
}
1714+
17031715
static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
17041716
.ndo_open = mlxsw_sp_port_open,
17051717
.ndo_stop = mlxsw_sp_port_stop,
@@ -1715,6 +1727,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
17151727
.ndo_vlan_rx_kill_vid = mlxsw_sp_port_kill_vid,
17161728
.ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name,
17171729
.ndo_set_features = mlxsw_sp_set_features,
1730+
.ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id,
17181731
};
17191732

17201733
static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
451451
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
452452

453453
switch (attr->id) {
454-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
455-
attr->u.ppid.id_len = sizeof(mlxsw_sp->base_mac);
456-
memcpy(&attr->u.ppid.id, &mlxsw_sp->base_mac,
457-
attr->u.ppid.id_len);
458-
break;
459454
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
460455
mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
461456
&attr->u.brport_flags);

drivers/net/ethernet/mellanox/mlxsw/switchx2.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/device.h>
1212
#include <linux/skbuff.h>
1313
#include <linux/if_vlan.h>
14-
#include <net/switchdev.h>
1514

1615
#include "pci.h"
1716
#include "core.h"
@@ -390,13 +389,26 @@ static int mlxsw_sx_port_get_phys_port_name(struct net_device *dev, char *name,
390389
name, len);
391390
}
392391

392+
static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
393+
struct netdev_phys_item_id *ppid)
394+
{
395+
struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
396+
struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
397+
398+
ppid->id_len = sizeof(mlxsw_sx->hw_id);
399+
memcpy(&ppid->id, &mlxsw_sx->hw_id, ppid->id_len);
400+
401+
return 0;
402+
}
403+
393404
static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
394405
.ndo_open = mlxsw_sx_port_open,
395406
.ndo_stop = mlxsw_sx_port_stop,
396407
.ndo_start_xmit = mlxsw_sx_port_xmit,
397408
.ndo_change_mtu = mlxsw_sx_port_change_mtu,
398409
.ndo_get_stats64 = mlxsw_sx_port_get_stats64,
399410
.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
411+
.ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id,
400412
};
401413

402414
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 = {
901913
.set_link_ksettings = mlxsw_sx_port_set_link_ksettings,
902914
};
903915

904-
static int mlxsw_sx_port_attr_get(struct net_device *dev,
905-
struct switchdev_attr *attr)
906-
{
907-
struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
908-
struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
909-
910-
switch (attr->id) {
911-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
912-
attr->u.ppid.id_len = sizeof(mlxsw_sx->hw_id);
913-
memcpy(&attr->u.ppid.id, &mlxsw_sx->hw_id, attr->u.ppid.id_len);
914-
break;
915-
default:
916-
return -EOPNOTSUPP;
917-
}
918-
919-
return 0;
920-
}
921-
922-
static const struct switchdev_ops mlxsw_sx_port_switchdev_ops = {
923-
.switchdev_port_attr_get = mlxsw_sx_port_attr_get,
924-
};
925-
926916
static int mlxsw_sx_hw_id_get(struct mlxsw_sx *mlxsw_sx)
927917
{
928918
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,
10341024

10351025
dev->netdev_ops = &mlxsw_sx_port_netdev_ops;
10361026
dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops;
1037-
dev->switchdev_ops = &mlxsw_sx_port_switchdev_ops;
10381027

10391028
err = mlxsw_sx_port_dev_addr_get(mlxsw_sx_port);
10401029
if (err) {

0 commit comments

Comments
 (0)