Skip to content

Commit 5a65d85

Browse files
roidayanSaeed Mahameed
authored andcommitted
net/mlx5e: Register nic devlink port with switch id
We will re-use the native NIC port net device instance for the Uplink representor. Since the netdev will be kept registered while we engage switchdev mode also the devlink will be kept registered. Register the nic devlink port with switch id so it will be available when changing profiles. Signed-off-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 865d6d1 commit 5a65d85

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,43 @@
22
/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
33

44
#include "en/devlink.h"
5+
#include "eswitch.h"
6+
7+
static void
8+
mlx5e_devlink_get_port_parent_id(struct mlx5_core_dev *dev, struct netdev_phys_item_id *ppid)
9+
{
10+
u64 parent_id;
11+
12+
parent_id = mlx5_query_nic_system_image_guid(dev);
13+
ppid->id_len = sizeof(parent_id);
14+
memcpy(ppid->id, &parent_id, sizeof(parent_id));
15+
}
516

617
int mlx5e_devlink_port_register(struct mlx5e_priv *priv)
718
{
819
struct devlink *devlink = priv_to_devlink(priv->mdev);
920
struct devlink_port_attrs attrs = {};
21+
struct netdev_phys_item_id ppid = {};
22+
unsigned int dl_port_index;
1023

1124
if (mlx5_core_is_pf(priv->mdev)) {
1225
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
1326
attrs.phys.port_number = PCI_FUNC(priv->mdev->pdev->devfn);
27+
if (MLX5_ESWITCH_MANAGER(priv->mdev)) {
28+
mlx5e_devlink_get_port_parent_id(priv->mdev, &ppid);
29+
memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);
30+
attrs.switch_id.id_len = ppid.id_len;
31+
}
32+
dl_port_index = mlx5_esw_vport_to_devlink_port_index(priv->mdev,
33+
MLX5_VPORT_UPLINK);
1434
} else {
1535
attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL;
36+
dl_port_index = mlx5_esw_vport_to_devlink_port_index(priv->mdev, 0);
1637
}
1738

1839
devlink_port_attrs_set(&priv->dl_port, &attrs);
1940

20-
return devlink_port_register(devlink, &priv->dl_port, 1);
41+
return devlink_port_register(devlink, &priv->dl_port, dl_port_index);
2142
}
2243

2344
void mlx5e_devlink_port_type_eth_set(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,13 @@ esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
781781
{
782782
return ERR_PTR(-EOPNOTSUPP);
783783
}
784+
785+
static inline unsigned int
786+
mlx5_esw_vport_to_devlink_port_index(const struct mlx5_core_dev *dev,
787+
u16 vport_num)
788+
{
789+
return vport_num;
790+
}
784791
#endif /* CONFIG_MLX5_ESWITCH */
785792

786793
#endif /* __MLX5_ESWITCH_H__ */

0 commit comments

Comments
 (0)