From patchwork Wed Mar 21 18:09:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10299997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E01766055B for ; Wed, 21 Mar 2018 18:10:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A8D298DE for ; Wed, 21 Mar 2018 18:10:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF731298E9; Wed, 21 Mar 2018 18:10:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0343B298DE for ; Wed, 21 Mar 2018 18:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752481AbeCUSKh (ORCPT ); Wed, 21 Mar 2018 14:10:37 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57466 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752495AbeCUSK0 (ORCPT ); Wed, 21 Mar 2018 14:10:26 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 21 Mar 2018 20:11:07 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w2LIAK6X014344; Wed, 21 Mar 2018 20:10:20 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w2LIAKc2007772; Wed, 21 Mar 2018 20:10:20 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w2LIAKgQ007771; Wed, 21 Mar 2018 20:10:20 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, matanb@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 05/11] mlx5: Add support to creating/modifying and destroying ESP flow_action Date: Wed, 21 Mar 2018 20:09:54 +0200 Message-Id: <1521655800-7287-6-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1521655800-7287-1-git-send-email-yishaih@mellanox.com> References: <1521655800-7287-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matan Barak Implementing create_flow_action_esp, modify_flow_action_esp and destroy_flow_action. This is essentially just calling libibverbs cmd_ioctl layer. Signed-off-by: Matan Barak Signed-off-by: Yishai Hadas --- libibverbs/cmd_flow_action.c | 4 +-- providers/mlx5/mlx5.c | 3 +++ providers/mlx5/mlx5.h | 5 ++++ providers/mlx5/verbs.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/libibverbs/cmd_flow_action.c b/libibverbs/cmd_flow_action.c index 122ad04..b5878db 100644 --- a/libibverbs/cmd_flow_action.c +++ b/libibverbs/cmd_flow_action.c @@ -118,8 +118,8 @@ int ibv_cmd_modify_flow_action_esp(struct verbs_flow_action *flow_action, int ibv_cmd_destroy_flow_action(struct verbs_flow_action *action) { - DECLARE_COMMAND_BUFFER(cmd, UVERBS_OBJECT_FLOW_ACTION, - UVERBS_METHOD_FLOW_ACTION_DESTROY, 1); + DECLARE_COMMAND_BUFFER_LINK(cmd, UVERBS_OBJECT_FLOW_ACTION, + UVERBS_METHOD_FLOW_ACTION_DESTROY, 1, NULL); fill_attr_in_obj(cmd, UVERBS_ATTR_DESTROY_FLOW_ACTION_HANDLE, action->handle); diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c index 39a3971..8878194 100644 --- a/providers/mlx5/mlx5.c +++ b/providers/mlx5/mlx5.c @@ -119,16 +119,19 @@ static const struct verbs_context_ops mlx5_ctx_common_ops = { .close_xrcd = mlx5_close_xrcd, .create_cq_ex = mlx5_create_cq_ex, .create_flow = mlx5_create_flow, + .create_flow_action_esp = mlx5_create_flow_action_esp, .create_qp_ex = mlx5_create_qp_ex, .create_rwq_ind_table = mlx5_create_rwq_ind_table, .create_srq_ex = mlx5_create_srq_ex, .create_wq = mlx5_create_wq, .dealloc_td = mlx5_dealloc_td, .destroy_flow = mlx5_destroy_flow, + .destroy_flow_action = mlx5_destroy_flow_action, .destroy_rwq_ind_table = mlx5_destroy_rwq_ind_table, .destroy_wq = mlx5_destroy_wq, .get_srq_num = mlx5_get_srq_num, .modify_cq = mlx5_modify_cq, + .modify_flow_action_esp = mlx5_modify_flow_action_esp, .modify_qp_rate_limit = mlx5_modify_qp_rate_limit, .modify_wq = mlx5_modify_wq, .open_xrcd = mlx5_open_xrcd, diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h index 9f640f7..18895db 100644 --- a/providers/mlx5/mlx5.h +++ b/providers/mlx5/mlx5.h @@ -807,6 +807,11 @@ struct ibv_srq *mlx5_create_srq_ex(struct ibv_context *context, int mlx5_post_srq_ops(struct ibv_srq *srq, struct ibv_ops_wr *wr, struct ibv_ops_wr **bad_wr); +struct ibv_flow_action *mlx5_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *attr); +int mlx5_destroy_flow_action(struct ibv_flow_action *action); +int mlx5_modify_flow_action_esp(struct ibv_flow_action *action, + struct ibv_flow_action_esp_attr *attr); struct ibv_td *mlx5_alloc_td(struct ibv_context *context, struct ibv_td_init_attr *init_attr); int mlx5_dealloc_td(struct ibv_td *td); diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 9ef4edd..06f6408 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -2964,3 +2964,61 @@ int mlx5_modify_cq(struct ibv_cq *cq, struct ibv_modify_cq_attr *attr) return ibv_cmd_modify_cq(cq, attr, &cmd, sizeof(cmd)); } + +static struct ibv_flow_action *_mlx5_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *attr, + struct ibv_command_buffer *driver_attr) +{ + struct verbs_flow_action *action; + int ret; + + if (!check_comp_mask(attr->comp_mask, IBV_FLOW_ACTION_ESP_MASK_ESN)) { + errno = EOPNOTSUPP; + return NULL; + } + + action = calloc(1, sizeof(*action)); + if (!action) { + errno = ENOMEM; + return NULL; + } + + ret = ibv_cmd_create_flow_action_esp(ctx, attr, action, driver_attr); + if (ret) { + free(action); + return NULL; + } + + return &action->action; +} + +struct ibv_flow_action *mlx5_create_flow_action_esp(struct ibv_context *ctx, + struct ibv_flow_action_esp_attr *attr) +{ + return _mlx5_create_flow_action_esp(ctx, attr, NULL); +} + +int mlx5_modify_flow_action_esp(struct ibv_flow_action *action, + struct ibv_flow_action_esp_attr *attr) +{ + struct verbs_flow_action *vaction = + container_of(action, struct verbs_flow_action, action); + + if (!check_comp_mask(attr->comp_mask, IBV_FLOW_ACTION_ESP_MASK_ESN)) + return EOPNOTSUPP; + + return ibv_cmd_modify_flow_action_esp(vaction, attr, NULL); +} + +int mlx5_destroy_flow_action(struct ibv_flow_action *action) +{ + struct verbs_flow_action *vaction = + container_of(action, struct verbs_flow_action, action); + int ret = ibv_cmd_destroy_flow_action(vaction); + + if (!ret) + free(action); + + return ret; +} +