]> www.infradead.org Git - users/hch/misc.git/commitdiff
net/mlx5e: Implement PSP key_rotate operation
authorRaed Salem <raeds@nvidia.com>
Wed, 17 Sep 2025 00:09:46 +0000 (17:09 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 18 Sep 2025 10:32:07 +0000 (12:32 +0200)
Implement .key_rotate operation where when invoked will cause the HW to use
a new master key to derive PSP spi/key pairs with complience with PSP spec.

Signed-off-by: Raed Salem <raeds@nvidia.com>
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20250917000954.859376-20-daniel.zahka@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c

index 372513edfb92799ccd46cc966c3ebb34a9d0eb59..b4cb131c5f811eda2b38e37a38f7c42e47cbe61d 100644 (file)
@@ -827,11 +827,34 @@ static void mlx5e_psp_assoc_del(struct psp_dev *psd, struct psp_assoc *pas)
        atomic_dec(&psp->tx_key_cnt);
 }
 
+static int mlx5e_psp_rotate_key(struct mlx5_core_dev *mdev)
+{
+       u32 in[MLX5_ST_SZ_DW(psp_rotate_key_in)] = {};
+       u32 out[MLX5_ST_SZ_DW(psp_rotate_key_out)];
+
+       MLX5_SET(psp_rotate_key_in, in, opcode,
+                MLX5_CMD_OP_PSP_ROTATE_KEY);
+
+       return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
+}
+
+static int
+mlx5e_psp_key_rotate(struct psp_dev *psd, struct netlink_ext_ack *exack)
+{
+       struct mlx5e_priv *priv = netdev_priv(psd->main_netdev);
+
+       /* no support for protecting against external rotations */
+       psd->generation = 0;
+
+       return mlx5e_psp_rotate_key(priv->mdev);
+}
+
 static struct psp_dev_ops mlx5_psp_ops = {
        .set_config   = mlx5e_psp_set_config,
        .rx_spi_alloc = mlx5e_psp_rx_spi_alloc,
        .tx_key_add   = mlx5e_psp_assoc_add,
        .tx_key_del   = mlx5e_psp_assoc_del,
+       .key_rotate   = mlx5e_psp_key_rotate,
 };
 
 void mlx5e_psp_unregister(struct mlx5e_priv *priv)