Skip to content

Commit 349705c

Browse files
matanb10jgunthorpe
authored andcommitted
IB/mlx5: Add modify_flow_action_esp verb
Adding implementation in mlx5 driver to modify action_xfrm object. This merely call the accel layer. Currently a user can modify only the ESN parameters. Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent c6475a0 commit 349705c

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

  • drivers/infiniband/hw/mlx5

‎drivers/infiniband/hw/mlx5/main.c‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,6 +3201,54 @@ mlx5_ib_create_flow_action_esp(struct ib_device *device,
32013201
return ERR_PTR(err);
32023202
}
32033203

3204+
static int
3205+
mlx5_ib_modify_flow_action_esp(struct ib_flow_action *action,
3206+
const struct ib_flow_action_attrs_esp *attr,
3207+
struct uverbs_attr_bundle *attrs)
3208+
{
3209+
struct mlx5_ib_flow_action *maction = to_mflow_act(action);
3210+
struct mlx5_accel_esp_xfrm_attrs accel_attrs;
3211+
int err = 0;
3212+
3213+
if (attr->keymat || attr->replay || attr->encap ||
3214+
attr->spi || attr->seq || attr->tfc_pad ||
3215+
attr->hard_limit_pkts ||
3216+
(attr->flags & ~(IB_FLOW_ACTION_ESP_FLAGS_ESN_TRIGGERED |
3217+
IB_FLOW_ACTION_ESP_FLAGS_MOD_ESP_ATTRS |
3218+
IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW)))
3219+
return -EOPNOTSUPP;
3220+
3221+
/* Only the ESN value or the MLX5_ACCEL_ESP_FLAGS_ESN_STATE_OVERLAP can
3222+
* be modified.
3223+
*/
3224+
if (!(maction->esp_aes_gcm.ib_flags &
3225+
IB_FLOW_ACTION_ESP_FLAGS_ESN_TRIGGERED) &&
3226+
attr->flags & (IB_FLOW_ACTION_ESP_FLAGS_ESN_TRIGGERED |
3227+
IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW))
3228+
return -EINVAL;
3229+
3230+
memcpy(&accel_attrs, &maction->esp_aes_gcm.ctx->attrs,
3231+
sizeof(accel_attrs));
3232+
3233+
accel_attrs.esn = attr->esn;
3234+
if (attr->flags & IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW)
3235+
accel_attrs.flags |= MLX5_ACCEL_ESP_FLAGS_ESN_STATE_OVERLAP;
3236+
else
3237+
accel_attrs.flags &= ~MLX5_ACCEL_ESP_FLAGS_ESN_STATE_OVERLAP;
3238+
3239+
err = mlx5_accel_esp_modify_xfrm(maction->esp_aes_gcm.ctx,
3240+
&accel_attrs);
3241+
if (err)
3242+
return err;
3243+
3244+
maction->esp_aes_gcm.ib_flags &=
3245+
~IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW;
3246+
maction->esp_aes_gcm.ib_flags |=
3247+
attr->flags & IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW;
3248+
3249+
return 0;
3250+
}
3251+
32043252
static int mlx5_ib_destroy_flow_action(struct ib_flow_action *action)
32053253
{
32063254
struct mlx5_ib_flow_action *maction = to_mflow_act(action);
@@ -4927,6 +4975,7 @@ int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
49274975
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW);
49284976
dev->ib_dev.create_flow_action_esp = mlx5_ib_create_flow_action_esp;
49294977
dev->ib_dev.destroy_flow_action = mlx5_ib_destroy_flow_action;
4978+
dev->ib_dev.modify_flow_action_esp = mlx5_ib_modify_flow_action_esp;
49304979
dev->ib_dev.driver_id = RDMA_DRIVER_MLX5;
49314980

49324981
err = init_node_data(dev);

0 commit comments

Comments
 (0)