Skip to content

Commit 6dcfa23

Browse files
ffainellidavem330
authored andcommitted
net/mlx5e: Implement ndo_get_port_parent_id()
mlx5e only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a great candidate to be converted to use the ndo_get_port_parent_id() NDO instead of implementing switchdev_port_attr_get(). Since mlx5e makes use of switchdev_port_parent_id() convert it to use netdev_port_same_parent_id(). Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c4bf245 commit 6dcfa23

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
2525
/* if the egress device isn't on the same HW e-switch or
2626
* it's a LAG device, use the uplink
2727
*/
28-
if (!switchdev_port_same_parent_id(priv->netdev, dev) ||
28+
if (!netdev_port_same_parent_id(priv->netdev, dev) ||
2929
dst_is_lag_dev) {
3030
*route_dev = uplink_dev;
3131
*out_dev = *route_dev;

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = {
381381
.set_pauseparam = mlx5e_uplink_rep_set_pauseparam,
382382
};
383383

384-
static int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
384+
static int mlx5e_rep_get_port_parent_id(struct net_device *dev,
385+
struct netdev_phys_item_id *ppid)
385386
{
386387
struct mlx5e_priv *priv = netdev_priv(dev);
387388
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
@@ -398,20 +399,14 @@ static int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
398399
uplink_priv = netdev_priv(uplink_dev);
399400
}
400401

401-
switch (attr->id) {
402-
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
403-
attr->u.ppid.id_len = ETH_ALEN;
404-
if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
405-
ether_addr_copy(attr->u.ppid.id, uplink_upper->dev_addr);
406-
} else {
407-
struct mlx5e_rep_priv *rpriv = priv->ppriv;
408-
struct mlx5_eswitch_rep *rep = rpriv->rep;
402+
ppid->id_len = ETH_ALEN;
403+
if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
404+
ether_addr_copy(ppid->id, uplink_upper->dev_addr);
405+
} else {
406+
struct mlx5e_rep_priv *rpriv = priv->ppriv;
407+
struct mlx5_eswitch_rep *rep = rpriv->rep;
409408

410-
ether_addr_copy(attr->u.ppid.id, rep->hw_id);
411-
}
412-
break;
413-
default:
414-
return -EOPNOTSUPP;
409+
ether_addr_copy(ppid->id, rep->hw_id);
415410
}
416411

417412
return 0;
@@ -1284,10 +1279,6 @@ static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan
12841279
return 0;
12851280
}
12861281

1287-
static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
1288-
.switchdev_port_attr_get = mlx5e_attr_get,
1289-
};
1290-
12911282
static const struct net_device_ops mlx5e_netdev_ops_vf_rep = {
12921283
.ndo_open = mlx5e_vf_rep_open,
12931284
.ndo_stop = mlx5e_vf_rep_close,
@@ -1298,6 +1289,7 @@ static const struct net_device_ops mlx5e_netdev_ops_vf_rep = {
12981289
.ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
12991290
.ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
13001291
.ndo_change_mtu = mlx5e_vf_rep_change_mtu,
1292+
.ndo_get_port_parent_id = mlx5e_rep_get_port_parent_id,
13011293
};
13021294

13031295
static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
@@ -1319,6 +1311,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
13191311
.ndo_get_vf_config = mlx5e_get_vf_config,
13201312
.ndo_get_vf_stats = mlx5e_get_vf_stats,
13211313
.ndo_set_vf_vlan = mlx5e_uplink_rep_set_vf_vlan,
1314+
.ndo_get_port_parent_id = mlx5e_rep_get_port_parent_id,
13221315
};
13231316

13241317
bool mlx5e_eswitch_rep(struct net_device *netdev)
@@ -1393,8 +1386,6 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev)
13931386
netdev->watchdog_timeo = 15 * HZ;
13941387

13951388

1396-
netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
1397-
13981389
netdev->features |= NETIF_F_HW_TC | NETIF_F_NETNS_LOCAL;
13991390
netdev->hw_features |= NETIF_F_HW_TC;
14001391

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <linux/mlx5/fs.h>
3939
#include <linux/mlx5/device.h>
4040
#include <linux/rhashtable.h>
41-
#include <net/switchdev.h>
4241
#include <net/tc_act/tc_mirred.h>
4342
#include <net/tc_act/tc_vlan.h>
4443
#include <net/tc_act/tc_tunnel_key.h>
@@ -2525,8 +2524,8 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
25252524

25262525
action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
25272526
MLX5_FLOW_CONTEXT_ACTION_COUNT;
2528-
if (switchdev_port_same_parent_id(priv->netdev,
2529-
out_dev) ||
2527+
if (netdev_port_same_parent_id(priv->netdev,
2528+
out_dev) ||
25302529
is_merged_eswitch_dev(priv, out_dev)) {
25312530
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
25322531
struct net_device *uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);

0 commit comments

Comments
 (0)