Skip to content

Commit 3e4cf1d

Browse files
Jianbo LiuSaeed Mahameed
authored andcommitted
net/mlx5e: kTLS, Fix protection domain in use syndrome when devlink reload
There are DEK objects cached in DEK pool after kTLS is used, and they are freed only in mlx5e_ktls_cleanup(). mlx5e_destroy_mdev_resources() is called in mlx5e_suspend() to free mdev resources, including protection domain (PD). However, PD is still referenced by the cached DEK objects in this case, because profile->cleanup() (and therefore mlx5e_ktls_cleanup()) is called after mlx5e_suspend() during devlink reload. So the following FW syndrome is generated: mlx5_cmd_out_err:803:(pid 12948): DEALLOC_PD(0x801) op_mod(0x0) failed, status bad resource state(0x9), syndrome (0xef0c8a), err(-22) To avoid this syndrome, move DEK pool destruction to mlx5e_ktls_cleanup_tx(), which is called by profile->cleanup_tx(). And move pool creation to mlx5e_ktls_init_tx() for symmetry. Fixes: f741db1 ("net/mlx5e: kTLS, Improve connection rate by using fast update encryption key") Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent eb02b93 commit 3e4cf1d

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ static void mlx5e_tls_debugfs_init(struct mlx5e_tls *tls,
188188

189189
int mlx5e_ktls_init(struct mlx5e_priv *priv)
190190
{
191-
struct mlx5_crypto_dek_pool *dek_pool;
192191
struct mlx5e_tls *tls;
193192

194193
if (!mlx5e_is_ktls_device(priv->mdev))
@@ -199,12 +198,6 @@ int mlx5e_ktls_init(struct mlx5e_priv *priv)
199198
return -ENOMEM;
200199
tls->mdev = priv->mdev;
201200

202-
dek_pool = mlx5_crypto_dek_pool_create(priv->mdev, MLX5_ACCEL_OBJ_TLS_KEY);
203-
if (IS_ERR(dek_pool)) {
204-
kfree(tls);
205-
return PTR_ERR(dek_pool);
206-
}
207-
tls->dek_pool = dek_pool;
208201
priv->tls = tls;
209202

210203
mlx5e_tls_debugfs_init(tls, priv->dfs_root);
@@ -222,7 +215,6 @@ void mlx5e_ktls_cleanup(struct mlx5e_priv *priv)
222215
debugfs_remove_recursive(tls->debugfs.dfs);
223216
tls->debugfs.dfs = NULL;
224217

225-
mlx5_crypto_dek_pool_destroy(tls->dek_pool);
226218
kfree(priv->tls);
227219
priv->tls = NULL;
228220
}

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,28 +908,51 @@ static void mlx5e_tls_tx_debugfs_init(struct mlx5e_tls *tls,
908908

909909
int mlx5e_ktls_init_tx(struct mlx5e_priv *priv)
910910
{
911+
struct mlx5_crypto_dek_pool *dek_pool;
911912
struct mlx5e_tls *tls = priv->tls;
913+
int err;
914+
915+
if (!mlx5e_is_ktls_device(priv->mdev))
916+
return 0;
917+
918+
/* DEK pool could be used by either or both of TX and RX. But we have to
919+
* put the creation here to avoid syndrome when doing devlink reload.
920+
*/
921+
dek_pool = mlx5_crypto_dek_pool_create(priv->mdev, MLX5_ACCEL_OBJ_TLS_KEY);
922+
if (IS_ERR(dek_pool))
923+
return PTR_ERR(dek_pool);
924+
tls->dek_pool = dek_pool;
912925

913926
if (!mlx5e_is_ktls_tx(priv->mdev))
914927
return 0;
915928

916929
priv->tls->tx_pool = mlx5e_tls_tx_pool_init(priv->mdev, &priv->tls->sw_stats);
917-
if (!priv->tls->tx_pool)
918-
return -ENOMEM;
930+
if (!priv->tls->tx_pool) {
931+
err = -ENOMEM;
932+
goto err_tx_pool_init;
933+
}
919934

920935
mlx5e_tls_tx_debugfs_init(tls, tls->debugfs.dfs);
921936

922937
return 0;
938+
939+
err_tx_pool_init:
940+
mlx5_crypto_dek_pool_destroy(dek_pool);
941+
return err;
923942
}
924943

925944
void mlx5e_ktls_cleanup_tx(struct mlx5e_priv *priv)
926945
{
927946
if (!mlx5e_is_ktls_tx(priv->mdev))
928-
return;
947+
goto dek_pool_destroy;
929948

930949
debugfs_remove_recursive(priv->tls->debugfs.dfs_tx);
931950
priv->tls->debugfs.dfs_tx = NULL;
932951

933952
mlx5e_tls_tx_pool_cleanup(priv->tls->tx_pool);
934953
priv->tls->tx_pool = NULL;
954+
955+
dek_pool_destroy:
956+
if (mlx5e_is_ktls_device(priv->mdev))
957+
mlx5_crypto_dek_pool_destroy(priv->tls->dek_pool);
935958
}

0 commit comments

Comments
 (0)