From patchwork Tue Mar 14 11:15:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9623055 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 7811560492 for ; Tue, 14 Mar 2017 11:16:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E4A32838E for ; Tue, 14 Mar 2017 11:16:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6360728532; Tue, 14 Mar 2017 11:16:31 +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 0611A2838E for ; Tue, 14 Mar 2017 11:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750960AbdCNLQ1 (ORCPT ); Tue, 14 Mar 2017 07:16:27 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48991 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750942AbdCNLQX (ORCPT ); Tue, 14 Mar 2017 07:16:23 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 14 Mar 2017 13:16:16 +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 v2EBGGQJ014190; Tue, 14 Mar 2017 13:16:16 +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 v2EBGGxj029142; Tue, 14 Mar 2017 13:16:16 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v2EBGGwo029141; Tue, 14 Mar 2017 13:16:16 +0200 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, noaos@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/7] ibverbs: Allow creation and modification of WQ with cvlan offload Date: Tue, 14 Mar 2017 13:15:38 +0200 Message-Id: <1489490143-29018-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1489490143-29018-1-git-send-email-yishaih@mellanox.com> References: <1489490143-29018-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: Noa Osherovich Enable WQ creation and modification with cvlan stripping offload. This includes: - Adding flags and flags mask fields to ibv_wq_init_attr and ibv_wq_attr. - Similarly extend ibv_wq_attr to allow setting and unsetting this offload during ibv_modify_wq. Signed-off-by: Noa Osherovich Reviewed-by: Maor Gottlieb Reviewed-by: Yishai Hadas --- libibverbs/cmd.c | 18 ++++++++++++++++++ libibverbs/kern-abi.h | 4 ++++ libibverbs/verbs.h | 14 ++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 4aebbb5..b8fe76d 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1894,6 +1894,15 @@ int ibv_cmd_create_wq(struct ibv_context *context, cmd->max_wr = wq_init_attr->max_wr; cmd->comp_mask = 0; + if (cmd_core_size >= offsetof(struct ibv_create_wq, create_flags) + + sizeof(cmd->create_flags)) { + if (wq_init_attr->comp_mask & IBV_WQ_INIT_ATTR_FLAGS) { + if (wq_init_attr->create_flags & ~(IBV_WQ_FLAGS_RESERVED - 1)) + return EOPNOTSUPP; + cmd->create_flags = wq_init_attr->create_flags; + } + } + err = write(context->cmd_fd, cmd, cmd_size); if (err != cmd_size) return errno; @@ -1927,6 +1936,15 @@ int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr, cmd->curr_wq_state = attr->curr_wq_state; cmd->wq_state = attr->wq_state; + if (cmd_core_size >= offsetof(struct ibv_modify_wq, flags_mask) + + sizeof(cmd->flags_mask)) { + if (attr->attr_mask & IBV_WQ_ATTR_FLAGS) { + if (attr->flags_mask & ~(IBV_WQ_FLAGS_RESERVED - 1)) + return EOPNOTSUPP; + cmd->flags = attr->flags; + cmd->flags_mask = attr->flags_mask; + } + } cmd->wq_handle = wq->handle; cmd->attr_mask = attr->attr_mask; diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 3958f0c..72a16b6 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -1249,6 +1249,8 @@ struct ibv_create_wq { __u32 cq_handle; __u32 max_wr; __u32 max_sge; + __u32 create_flags; + __u32 reserved; }; struct ibv_create_wq_resp { @@ -1279,6 +1281,8 @@ struct ibv_modify_wq { __u32 wq_handle; __u32 wq_state; __u32 curr_wq_state; + __u32 flags; + __u32 flags_mask; }; struct ibv_create_rwq_ind_table { diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 604b09e..3398566 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -667,7 +667,13 @@ enum ibv_wq_type { }; enum ibv_wq_init_attr_mask { - IBV_WQ_INIT_ATTR_RESERVED = 1 << 0, + IBV_WQ_INIT_ATTR_FLAGS = 1 << 0, + IBV_WQ_INIT_ATTR_RESERVED = 1 << 1, +}; + +enum ibv_wq_flags { + IBV_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0, + IBV_WQ_FLAGS_RESERVED = 1 << 1, }; struct ibv_wq_init_attr { @@ -678,6 +684,7 @@ struct ibv_wq_init_attr { struct ibv_pd *pd; struct ibv_cq *cq; uint32_t comp_mask; + uint32_t create_flags; /* use ibv_wq_flags */ }; enum ibv_wq_state { @@ -690,7 +697,8 @@ enum ibv_wq_state { enum ibv_wq_attr_mask { IBV_WQ_ATTR_STATE = 1 << 0, IBV_WQ_ATTR_CURR_STATE = 1 << 1, - IBV_WQ_ATTR_RESERVED = 1 << 2 + IBV_WQ_ATTR_FLAGS = 1 << 2, + IBV_WQ_ATTR_RESERVED = 1 << 3, }; struct ibv_wq_attr { @@ -700,6 +708,8 @@ struct ibv_wq_attr { enum ibv_wq_state wq_state; /* Assume this is the current WQ state */ enum ibv_wq_state curr_wq_state; + uint32_t flags; /* Use ibv_wq_flags */ + uint32_t flags_mask; /* Use ibv_wq_flags */ }; /*