From patchwork Wed Mar 15 15:27:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 9625919 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 8C65E6048C for ; Wed, 15 Mar 2017 15:28:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CA59285A1 for ; Wed, 15 Mar 2017 15:28:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FBAB2863E; Wed, 15 Mar 2017 15:28:32 +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 C47AB285A1 for ; Wed, 15 Mar 2017 15:28:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752904AbdCOP2a (ORCPT ); Wed, 15 Mar 2017 11:28:30 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:36892 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753881AbdCOP2E (ORCPT ); Wed, 15 Mar 2017 11:28:04 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 Mar 2017 17:27:59 +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 v2FFRwgK020186; Wed, 15 Mar 2017 17:27:58 +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 v2FFRwED014163; Wed, 15 Mar 2017 17:27:58 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v2FFRwCU014162; Wed, 15 Mar 2017 17:27:58 +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 V1 rdma-core 4/6] ibverbs: Add an option to poll cvlan value from a CQ Date: Wed, 15 Mar 2017 17:27:44 +0200 Message-Id: <1489591666-14062-5-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1489591666-14062-1-git-send-email-yishaih@mellanox.com> References: <1489591666-14062-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 When a WQ or a QP is created with cvlan stripping option, it is stripped from the incoming packet and included in the work completion. Extend the poll_cq_ex mechanism with a function that reads the stripped cvlan value from the work completion. In addition, as a part of introcuding the new functionality in the man page, align it with current code (typo fix, add a missing field). Signed-off-by: Noa Osherovich Reviewed-by: Maor Gottlieb Reviewed-by: Yishai Hadas --- libibverbs/man/ibv_create_cq_ex.3 | 9 +++++++-- libibverbs/verbs.h | 10 +++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libibverbs/man/ibv_create_cq_ex.3 b/libibverbs/man/ibv_create_cq_ex.3 index a6ae769..020bbb4 100644 --- a/libibverbs/man/ibv_create_cq_ex.3 +++ b/libibverbs/man/ibv_create_cq_ex.3 @@ -17,10 +17,10 @@ creates a completion queue (CQ) for RDMA device context .I context\fR. The argument .I cq_attr -is a pointer to struct ibv_create_cq_attr_ex as defined in . +is a pointer to struct ibv_cq_init_attr_ex as defined in . .PP .nf -struct ibv_create_cq_attr_ex { +struct ibv_cq_init_attr_ex { .in +8 int cqe; /* Minimum number of entries required for CQ */ void *cq_context; /* Consumer-supplied context returned for completion events */ @@ -28,6 +28,7 @@ struct ibv_comp_channel *channel; /* Completion channel where completio int comp_vector; /* Completion vector used to signal completion events. Must be >= 0 and < context->num_comp_vectors. */ uint64_t wc_flags; /* The wc_flags that should be returned in ibv_poll_cq_ex. Or'ed bit of enum ibv_wc_flags_ex. */ uint32_t comp_mask; /* compatibility mask (extended verb). */ +uint32_t flags /* One or more flags from enum ibv_create_cq_attr_flags */ .in -8 }; @@ -40,6 +41,7 @@ enum ibv_wc_flags_ex { IBV_WC_EX_WITH_SL = 1 << 5, /* Require sl in WC */ IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6, /* Require dlid path bits in WC */ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, /* Require completion timestamp in WC /* + IBV_WC_EX_WITH_CVLAN = 1 << 8, /* Require VLAN info in WC */ }; enum ibv_cq_init_attr_mask { @@ -128,6 +130,9 @@ Below members and functions are used in order to poll the current completion. Th .BI "uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex " "*cq"); \c Get the completion timestamp from the current completion. +.BI "uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex " "*cq"); \c + Get the CVLAN field from the current completion. + .SH "RETURN VALUE" .B ibv_create_cq_ex() returns a pointer to the CQ, or NULL if the request fails. diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index c9084ea..15e93b3 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -435,6 +435,7 @@ enum ibv_create_cq_wc_flags { IBV_WC_EX_WITH_SL = 1 << 5, IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6, IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, + IBV_WC_EX_WITH_CVLAN = 1 << 8, }; enum { @@ -449,7 +450,8 @@ enum { enum { IBV_CREATE_CQ_SUP_WC_FLAGS = IBV_WC_STANDARD_FLAGS | - IBV_WC_EX_WITH_COMPLETION_TIMESTAMP + IBV_WC_EX_WITH_COMPLETION_TIMESTAMP | + IBV_WC_EX_WITH_CVLAN }; enum ibv_wc_flags { @@ -1092,6 +1094,7 @@ struct ibv_cq_ex { uint8_t (*read_sl)(struct ibv_cq_ex *current); uint8_t (*read_dlid_path_bits)(struct ibv_cq_ex *current); uint64_t (*read_completion_ts)(struct ibv_cq_ex *current); + uint16_t (*read_cvlan)(struct ibv_cq_ex *current); }; static inline struct ibv_cq *ibv_cq_ex_to_cq(struct ibv_cq_ex *cq) @@ -1170,6 +1173,11 @@ static inline uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq) return cq->read_completion_ts(cq); } +static inline uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq) +{ + return cq->read_cvlan(cq); +} + static inline int ibv_post_wq_recv(struct ibv_wq *wq, struct ibv_recv_wr *recv_wr, struct ibv_recv_wr **bad_recv_wr)