@@ -2880,7 +2880,8 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
28802880
28812881static void mlx5e_build_nic_netdev_priv (struct mlx5_core_dev * mdev ,
28822882 struct net_device * netdev ,
2883- const struct mlx5e_profile * profile )
2883+ const struct mlx5e_profile * profile ,
2884+ void * ppriv )
28842885{
28852886 struct mlx5e_priv * priv = netdev_priv (netdev );
28862887 u32 link_speed = 0 ;
@@ -2962,6 +2963,7 @@ static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
29622963 priv -> netdev = netdev ;
29632964 priv -> params .num_channels = profile -> max_nch (mdev );
29642965 priv -> profile = profile ;
2966+ priv -> ppriv = ppriv ;
29652967
29662968#ifdef CONFIG_MLX5_CORE_EN_DCB
29672969 mlx5e_ets_init (priv );
@@ -3126,18 +3128,25 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv)
31263128
31273129static void mlx5e_nic_init (struct mlx5_core_dev * mdev ,
31283130 struct net_device * netdev ,
3129- const struct mlx5e_profile * profile )
3131+ const struct mlx5e_profile * profile ,
3132+ void * ppriv )
31303133{
31313134 struct mlx5e_priv * priv = netdev_priv (netdev );
31323135
3133- mlx5e_build_nic_netdev_priv (mdev , netdev , profile );
3136+ mlx5e_build_nic_netdev_priv (mdev , netdev , profile , ppriv );
31343137 mlx5e_build_nic_netdev (netdev );
31353138 mlx5e_vxlan_init (priv );
31363139}
31373140
31383141static void mlx5e_nic_cleanup (struct mlx5e_priv * priv )
31393142{
3143+ struct mlx5_core_dev * mdev = priv -> mdev ;
3144+ struct mlx5_eswitch * esw = mdev -> priv .eswitch ;
3145+
31403146 mlx5e_vxlan_cleanup (priv );
3147+
3148+ if (MLX5_CAP_GEN (mdev , vport_group_manager ))
3149+ mlx5_eswitch_unregister_vport_rep (esw , 0 );
31413150}
31423151
31433152static int mlx5e_init_nic_rx (struct mlx5e_priv * priv )
@@ -3229,6 +3238,8 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
32293238{
32303239 struct net_device * netdev = priv -> netdev ;
32313240 struct mlx5_core_dev * mdev = priv -> mdev ;
3241+ struct mlx5_eswitch * esw = mdev -> priv .eswitch ;
3242+ struct mlx5_eswitch_rep rep ;
32323243
32333244 if (mlx5e_vxlan_allowed (mdev )) {
32343245 rtnl_lock ();
@@ -3238,6 +3249,12 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
32383249
32393250 mlx5e_enable_async_events (priv );
32403251 queue_work (priv -> wq , & priv -> set_rx_mode_work );
3252+
3253+ if (MLX5_CAP_GEN (mdev , vport_group_manager )) {
3254+ rep .vport = 0 ;
3255+ rep .priv_data = priv ;
3256+ mlx5_eswitch_register_vport_rep (esw , & rep );
3257+ }
32413258}
32423259
32433260static void mlx5e_nic_disable (struct mlx5e_priv * priv )
@@ -3261,7 +3278,7 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
32613278};
32623279
32633280static void * mlx5e_create_netdev (struct mlx5_core_dev * mdev ,
3264- const struct mlx5e_profile * profile )
3281+ const struct mlx5e_profile * profile , void * ppriv )
32653282{
32663283 struct net_device * netdev ;
32673284 struct mlx5e_priv * priv ;
@@ -3276,7 +3293,7 @@ static void *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
32763293 return NULL ;
32773294 }
32783295
3279- profile -> init (mdev , netdev , profile );
3296+ profile -> init (mdev , netdev , profile , ppriv );
32803297
32813298 netif_carrier_off (netdev );
32823299
@@ -3343,8 +3360,27 @@ static void *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
33433360 return NULL ;
33443361}
33453362
3363+ static void mlx5e_register_vport_rep (struct mlx5_core_dev * mdev )
3364+ {
3365+ struct mlx5_eswitch * esw = mdev -> priv .eswitch ;
3366+ int total_vfs = MLX5_TOTAL_VPORTS (mdev );
3367+ int vport ;
3368+
3369+ if (!MLX5_CAP_GEN (mdev , vport_group_manager ))
3370+ return ;
3371+
3372+ for (vport = 1 ; vport < total_vfs ; vport ++ ) {
3373+ struct mlx5_eswitch_rep rep ;
3374+
3375+ rep .vport = vport ;
3376+ mlx5_eswitch_register_vport_rep (esw , & rep );
3377+ }
3378+ }
3379+
33463380static void * mlx5e_add (struct mlx5_core_dev * mdev )
33473381{
3382+ struct mlx5_eswitch * esw = mdev -> priv .eswitch ;
3383+ void * ppriv = NULL ;
33483384 void * ret ;
33493385
33503386 if (mlx5e_check_required_hca_cap (mdev ))
@@ -3353,7 +3389,12 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
33533389 if (mlx5e_create_mdev_resources (mdev ))
33543390 return NULL ;
33553391
3356- ret = mlx5e_create_netdev (mdev , & mlx5e_nic_profile );
3392+ mlx5e_register_vport_rep (mdev );
3393+
3394+ if (MLX5_CAP_GEN (mdev , vport_group_manager ))
3395+ ppriv = & esw -> offloads .vport_reps [0 ];
3396+
3397+ ret = mlx5e_create_netdev (mdev , & mlx5e_nic_profile , ppriv );
33573398 if (!ret ) {
33583399 mlx5e_destroy_mdev_resources (mdev );
33593400 return NULL ;
@@ -3394,9 +3435,16 @@ static void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *
33943435
33953436static void mlx5e_remove (struct mlx5_core_dev * mdev , void * vpriv )
33963437{
3438+ struct mlx5_eswitch * esw = mdev -> priv .eswitch ;
3439+ int total_vfs = MLX5_TOTAL_VPORTS (mdev );
33973440 struct mlx5e_priv * priv = vpriv ;
3441+ int vport ;
33983442
33993443 mlx5e_destroy_netdev (mdev , priv );
3444+
3445+ for (vport = 1 ; vport < total_vfs ; vport ++ )
3446+ mlx5_eswitch_unregister_vport_rep (esw , vport );
3447+
34003448 mlx5e_destroy_mdev_resources (mdev );
34013449}
34023450
0 commit comments