Skip to content

Commit d9ee049

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Use dedicated uplink vport netdev representor
Currently, when running in sriov switchdev mode, we are using the PF netdevice as the uplink representor, this is problematic from few aspects: - will break when the PF isn't eswitch manager (e.g smart NIC env) - misalignment with other NIC switchdev drivers - makes us have and maintain special code, hurts the driver quality/robustness - which in turn opens the door for future bugs As of each and all of the above, we move to have a dedicated netdev representor for the uplink vport in a similar manner done for for the VF vports. This includes the following: 1. have an uplink rep netdev as we have for VF reps 2. all reps use same load/unload functions 3. HW stats for uplink based on physical port counters and not vport counters 4. link state for the uplink managed through PAOS and not vport state 5. the uplink rep has sysfs link to the PF PCI function && uses the PF MAC address Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 025380b commit d9ee049

File tree

8 files changed

+212
-121
lines changed

8 files changed

+212
-121
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
775775
struct mlx5e_wqe_frag_info *wi, u32 cqe_bcnt);
776776

777777
void mlx5e_update_stats(struct mlx5e_priv *priv);
778+
void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
778779

779780
void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
780781
int mlx5e_self_test_num(struct mlx5e_priv *priv);
@@ -939,7 +940,6 @@ int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
939940
void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn);
940941

941942
int mlx5e_create_tises(struct mlx5e_priv *priv);
942-
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv);
943943
int mlx5e_close(struct net_device *netdev);
944944
int mlx5e_open(struct net_device *netdev);
945945
void mlx5e_update_ndo_stats(struct mlx5e_priv *priv);
@@ -948,6 +948,7 @@ void mlx5e_queue_update_stats(struct mlx5e_priv *priv);
948948
int mlx5e_bits_invert(unsigned long a, int size);
949949

950950
typedef int (*change_hw_mtu_cb)(struct mlx5e_priv *priv);
951+
int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv);
951952
int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
952953
change_hw_mtu_cb set_mtu_cb);
953954

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ static void mlx5e_query_mtu(struct mlx5_core_dev *mdev,
28212821
*mtu = MLX5E_HW2SW_MTU(params, hw_mtu);
28222822
}
28232823

2824-
static int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
2824+
int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
28252825
{
28262826
struct mlx5e_params *params = &priv->channels.params;
28272827
struct net_device *netdev = priv->netdev;
@@ -2901,7 +2901,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
29012901
mlx5e_activate_channels(&priv->channels);
29022902
netif_tx_start_all_queues(priv->netdev);
29032903

2904-
if (MLX5_ESWITCH_MANAGER(priv->mdev))
2904+
if (mlx5e_is_vport_rep(priv))
29052905
mlx5e_add_sqs_fwd_rules(priv);
29062906

29072907
mlx5e_wait_channels_min_rx_wqes(&priv->channels);
@@ -2912,7 +2912,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
29122912
{
29132913
mlx5e_redirect_rqts_to_drop(priv);
29142914

2915-
if (MLX5_ESWITCH_MANAGER(priv->mdev))
2915+
if (mlx5e_is_vport_rep(priv))
29162916
mlx5e_remove_sqs_fwd_rules(priv);
29172917

29182918
/* FIXME: This is a W/A only for tx timeout watch dog false alarm when
@@ -3164,7 +3164,7 @@ int mlx5e_create_tises(struct mlx5e_priv *priv)
31643164
return err;
31653165
}
31663166

3167-
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
3167+
static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
31683168
{
31693169
int tc;
31703170

@@ -3409,7 +3409,8 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
34093409

34103410
switch (type) {
34113411
case TC_SETUP_CLSFLOWER:
3412-
return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS);
3412+
return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS |
3413+
MLX5E_TC_NIC_OFFLOAD);
34133414
default:
34143415
return -EOPNOTSUPP;
34153416
}
@@ -3452,7 +3453,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
34523453
}
34533454
}
34543455

3455-
static void
3456+
void
34563457
mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
34573458
{
34583459
struct mlx5e_priv *priv = netdev_priv(dev);
@@ -3596,7 +3597,7 @@ static int set_feature_tc_num_filters(struct net_device *netdev, bool enable)
35963597
{
35973598
struct mlx5e_priv *priv = netdev_priv(netdev);
35983599

3599-
if (!enable && mlx5e_tc_num_filters(priv)) {
3600+
if (!enable && mlx5e_tc_num_filters(priv, MLX5E_TC_NIC_OFFLOAD)) {
36003601
netdev_err(netdev,
36013602
"Active offloaded tc filters, can't turn hw_tc_offload off\n");
36023603
return -EINVAL;
@@ -4607,12 +4608,6 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
46074608
}
46084609
}
46094610

4610-
#if IS_ENABLED(CONFIG_MLX5_ESWITCH)
4611-
static const struct switchdev_ops mlx5e_switchdev_ops = {
4612-
.switchdev_port_attr_get = mlx5e_attr_get,
4613-
};
4614-
#endif
4615-
46164611
static void mlx5e_build_nic_netdev(struct net_device *netdev)
46174612
{
46184613
struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -4722,12 +4717,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
47224717
netdev->priv_flags |= IFF_UNICAST_FLT;
47234718

47244719
mlx5e_set_netdev_dev_addr(netdev);
4725-
4726-
#if IS_ENABLED(CONFIG_MLX5_ESWITCH)
4727-
if (MLX5_ESWITCH_MANAGER(mdev))
4728-
netdev->switchdev_ops = &mlx5e_switchdev_ops;
4729-
#endif
4730-
47314720
mlx5e_ipsec_build_netdev(priv);
47324721
mlx5e_tls_build_netdev(priv);
47334722
}
@@ -4908,7 +4897,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
49084897
mlx5e_monitor_counter_init(priv);
49094898

49104899
if (MLX5_ESWITCH_MANAGER(priv->mdev))
4911-
mlx5e_register_vport_reps(priv);
4900+
mlx5e_rep_register_vport_reps(priv);
49124901

49134902
if (netdev->reg_state != NETREG_REGISTERED)
49144903
return;
@@ -4943,7 +4932,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
49434932
queue_work(priv->wq, &priv->set_rx_mode_work);
49444933

49454934
if (MLX5_ESWITCH_MANAGER(priv->mdev))
4946-
mlx5e_unregister_vport_reps(priv);
4935+
mlx5e_rep_unregister_vport_reps(priv);
49474936

49484937
if (mlx5e_monitor_counter_supported(priv))
49494938
mlx5e_monitor_counter_cleanup(priv);

0 commit comments

Comments
 (0)