Skip to content

Commit e2578b4

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: Create single netdev per SD group
Integrate the SD library calls into the auxiliary_driver ops in preparation for creating a single netdev for the multiple devices belonging to the same SD group. SD is still disabled at this stage. It is enabled by a downstream patch when all needed parts are implemented. The netdev is created only when the SD group, with all its participants, are ready. It is later destroyed if any of the participating devices drops. Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent c82d360 commit e2578b4

File tree

1 file changed

+62
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+62
-7
lines changed

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

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "qos.h"
7171
#include "en/trap.h"
7272
#include "lib/devcom.h"
73+
#include "lib/sd.h"
7374

7475
bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev, u8 page_shift,
7576
enum mlx5e_mpwrq_umr_mode umr_mode)
@@ -5980,7 +5981,7 @@ void mlx5e_destroy_netdev(struct mlx5e_priv *priv)
59805981
free_netdev(netdev);
59815982
}
59825983

5983-
static int mlx5e_resume(struct auxiliary_device *adev)
5984+
static int _mlx5e_resume(struct auxiliary_device *adev)
59845985
{
59855986
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
59865987
struct mlx5e_dev *mlx5e_dev = auxiliary_get_drvdata(adev);
@@ -6005,6 +6006,23 @@ static int mlx5e_resume(struct auxiliary_device *adev)
60056006
return 0;
60066007
}
60076008

6009+
static int mlx5e_resume(struct auxiliary_device *adev)
6010+
{
6011+
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
6012+
struct mlx5_core_dev *mdev = edev->mdev;
6013+
struct auxiliary_device *actual_adev;
6014+
int err;
6015+
6016+
err = mlx5_sd_init(mdev);
6017+
if (err)
6018+
return err;
6019+
6020+
actual_adev = mlx5_sd_get_adev(mdev, adev, edev->idx);
6021+
if (actual_adev)
6022+
return _mlx5e_resume(actual_adev);
6023+
return 0;
6024+
}
6025+
60086026
static int _mlx5e_suspend(struct auxiliary_device *adev)
60096027
{
60106028
struct mlx5e_dev *mlx5e_dev = auxiliary_get_drvdata(adev);
@@ -6025,7 +6043,17 @@ static int _mlx5e_suspend(struct auxiliary_device *adev)
60256043

60266044
static int mlx5e_suspend(struct auxiliary_device *adev, pm_message_t state)
60276045
{
6028-
return _mlx5e_suspend(adev);
6046+
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
6047+
struct mlx5_core_dev *mdev = edev->mdev;
6048+
struct auxiliary_device *actual_adev;
6049+
int err = 0;
6050+
6051+
actual_adev = mlx5_sd_get_adev(mdev, adev, edev->idx);
6052+
if (actual_adev)
6053+
err = _mlx5e_suspend(actual_adev);
6054+
6055+
mlx5_sd_cleanup(mdev);
6056+
return err;
60296057
}
60306058

60316059
static int _mlx5e_probe(struct auxiliary_device *adev)
@@ -6071,9 +6099,9 @@ static int _mlx5e_probe(struct auxiliary_device *adev)
60716099
goto err_destroy_netdev;
60726100
}
60736101

6074-
err = mlx5e_resume(adev);
6102+
err = _mlx5e_resume(adev);
60756103
if (err) {
6076-
mlx5_core_err(mdev, "mlx5e_resume failed, %d\n", err);
6104+
mlx5_core_err(mdev, "_mlx5e_resume failed, %d\n", err);
60776105
goto err_profile_cleanup;
60786106
}
60796107

@@ -6104,15 +6132,29 @@ static int _mlx5e_probe(struct auxiliary_device *adev)
61046132
static int mlx5e_probe(struct auxiliary_device *adev,
61056133
const struct auxiliary_device_id *id)
61066134
{
6107-
return _mlx5e_probe(adev);
6135+
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
6136+
struct mlx5_core_dev *mdev = edev->mdev;
6137+
struct auxiliary_device *actual_adev;
6138+
int err;
6139+
6140+
err = mlx5_sd_init(mdev);
6141+
if (err)
6142+
return err;
6143+
6144+
actual_adev = mlx5_sd_get_adev(mdev, adev, edev->idx);
6145+
if (actual_adev)
6146+
return _mlx5e_probe(actual_adev);
6147+
return 0;
61086148
}
61096149

6110-
static void mlx5e_remove(struct auxiliary_device *adev)
6150+
static void _mlx5e_remove(struct auxiliary_device *adev)
61116151
{
6152+
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
61126153
struct mlx5e_dev *mlx5e_dev = auxiliary_get_drvdata(adev);
61136154
struct mlx5e_priv *priv = mlx5e_dev->priv;
6155+
struct mlx5_core_dev *mdev = edev->mdev;
61146156

6115-
mlx5_core_uplink_netdev_set(priv->mdev, NULL);
6157+
mlx5_core_uplink_netdev_set(mdev, NULL);
61166158
mlx5e_dcbnl_delete_app(priv);
61176159
unregister_netdev(priv->netdev);
61186160
_mlx5e_suspend(adev);
@@ -6122,6 +6164,19 @@ static void mlx5e_remove(struct auxiliary_device *adev)
61226164
mlx5e_destroy_devlink(mlx5e_dev);
61236165
}
61246166

6167+
static void mlx5e_remove(struct auxiliary_device *adev)
6168+
{
6169+
struct mlx5_adev *edev = container_of(adev, struct mlx5_adev, adev);
6170+
struct mlx5_core_dev *mdev = edev->mdev;
6171+
struct auxiliary_device *actual_adev;
6172+
6173+
actual_adev = mlx5_sd_get_adev(mdev, adev, edev->idx);
6174+
if (actual_adev)
6175+
_mlx5e_remove(actual_adev);
6176+
6177+
mlx5_sd_cleanup(mdev);
6178+
}
6179+
61256180
static const struct auxiliary_device_id mlx5e_id_table[] = {
61266181
{ .name = MLX5_ADEV_NAME ".eth", },
61276182
{},

0 commit comments

Comments
 (0)