From patchwork Wed Feb 24 09:41:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 8403351 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43818C0553 for ; Wed, 24 Feb 2016 09:43:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CEBB202EB for ; Wed, 24 Feb 2016 09:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D92B20303 for ; Wed, 24 Feb 2016 09:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbcBXJnM (ORCPT ); Wed, 24 Feb 2016 04:43:12 -0500 Received: from [193.47.165.129] ([193.47.165.129]:33145 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750871AbcBXJnJ (ORCPT ); Wed, 24 Feb 2016 04:43:09 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Feb 2016 11:42:46 +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 u1O9gjSL026417; Wed, 24 Feb 2016 11:42:45 +0200 Received: from vnc17.mtl.labs.mlnx (localhost.localdomain [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id u1O9gjmZ031491; Wed, 24 Feb 2016 11:42:45 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id u1O9gjoT031490; Wed, 24 Feb 2016 11:42:45 +0200 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, matanb@mellanox.com, majd@mellanox.com, talal@mellanox.com, ogerlitz@mellanox.com Subject: [PATCH V1 libibverbs 1/8] Add ibv_poll_cq_ex verb Date: Wed, 24 Feb 2016 11:41:57 +0200 Message-Id: <1456306924-31298-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1456306924-31298-1-git-send-email-yishaih@mellanox.com> References: <1456306924-31298-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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matan Barak This is an extension verb for ibv_poll_cq. It allows the user to poll the cq for specific wc fields only, while allowing to extend the wc. The verb calls the provider in order to fill the WC with the required information. Signed-off-by: Matan Barak Reviewed-by: Yishai Hadas --- include/infiniband/verbs.h | 107 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 6451d0f..99d6265 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -386,6 +386,79 @@ struct ibv_wc { uint8_t dlid_path_bits; }; +enum ibv_wc_flags_ex { + IBV_WC_EX_GRH = 1 << 0, + IBV_WC_EX_IMM = 1 << 1, + IBV_WC_EX_CSUM_OK = 1 << 2, + IBV_WC_EX_INV = 1 << 3, + IBV_WC_EX_WITH_BYTE_LEN = 1 << 4, + IBV_WC_EX_WITH_IMM = 1 << 5, + IBV_WC_EX_WITH_QP_NUM = 1 << 6, + IBV_WC_EX_WITH_SRC_QP = 1 << 7, + IBV_WC_EX_WITH_PKEY_INDEX = 1 << 8, + IBV_WC_EX_WITH_SLID = 1 << 9, + IBV_WC_EX_WITH_SL = 1 << 10, + IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 11, +}; + +enum { + IBV_WC_STANDARD_FLAGS = IBV_WC_EX_WITH_BYTE_LEN | + IBV_WC_EX_WITH_IMM | + IBV_WC_EX_WITH_QP_NUM | + IBV_WC_EX_WITH_SRC_QP | + IBV_WC_EX_WITH_PKEY_INDEX | + IBV_WC_EX_WITH_SLID | + IBV_WC_EX_WITH_SL | + IBV_WC_EX_WITH_DLID_PATH_BITS +}; + +/* fields order in wc_ex + * Note: To guarantee compatibility a new field will be added after fields + * of the same size. + * uint32_t byte_len, + * uint32_t imm_data; + * uint32_t qp_num; + * uint32_t src_qp; + * uint16_t pkey_index; + * uint16_t slid; + * uint8_t sl; + * uint8_t dlid_path_bits; + */ + +enum { + IBV_WC_EX_WITH_64BIT_FIELDS = 0 +}; + +enum { + IBV_WC_EX_WITH_32BIT_FIELDS = IBV_WC_EX_WITH_BYTE_LEN | + IBV_WC_EX_WITH_IMM | + IBV_WC_EX_WITH_QP_NUM | + IBV_WC_EX_WITH_SRC_QP +}; + +enum { + IBV_WC_EX_WITH_16BIT_FIELDS = IBV_WC_EX_WITH_PKEY_INDEX | + IBV_WC_EX_WITH_SLID +}; + +enum { + IBV_WC_EX_WITH_8BIT_FIELDS = IBV_WC_EX_WITH_SL | + IBV_WC_EX_WITH_DLID_PATH_BITS +}; + +struct ibv_wc_ex { + uint64_t wr_id; + /* wc_flags is a combination of ibv_wc_flags_ex flags. The IBV_WC_EX_WITH_XXX + * flags dynamically define the valid fields in buffer[0]. + */ + uint64_t wc_flags; + uint32_t status; + uint32_t opcode; + uint32_t vendor_err; + uint32_t reserved; + uint8_t buffer[0]; +}; + enum ibv_access_flags { IBV_ACCESS_LOCAL_WRITE = 1, IBV_ACCESS_REMOTE_WRITE = (1<<1), @@ -1052,8 +1125,16 @@ enum verbs_context_mask { VERBS_CONTEXT_RESERVED = 1 << 5 }; +struct ibv_poll_cq_ex_attr { + unsigned int max_entries; + uint32_t comp_mask; +}; + struct verbs_context { /* "grows up" - new fields go here */ + int (*poll_cq_ex)(struct ibv_cq *ibcq, + struct ibv_wc_ex *wc, + struct ibv_poll_cq_ex_attr *attr); int (*query_device_ex)(struct ibv_context *context, const struct ibv_query_device_ex_input *input, struct ibv_device_attr_ex *attr, @@ -1454,6 +1535,32 @@ ibv_create_srq_ex(struct ibv_context *context, } /** + * ibv_poll_cq_ex - Poll a CQ for work completions + * @cq:the CQ being polled + * @wc:array of @max_entries of &struct ibv_wc_ex where completions + * will be returned + * @attr: Poll cq attributs + * + * Poll a CQ for (possibly multiple) completions. If the return value + * is < 0, an error occurred. If the return value is >= 0, it is the + * number of completions returned. If the return value is + * non-negative and strictly less than max_entries, then the CQ was + * emptied. + */ + +static inline int ibv_poll_cq_ex(struct ibv_cq *ibcq, + struct ibv_wc_ex *wc, + struct ibv_poll_cq_ex_attr *attr) +{ + struct verbs_context *vctx = verbs_get_ctx_op(ibcq->context, + poll_cq_ex); + if (!vctx) + return ENOSYS; + + return vctx->poll_cq_ex(ibcq, wc, attr); +} + +/** * ibv_modify_srq - Modifies the attributes for the specified SRQ. * @srq: The SRQ to modify. * @srq_attr: On input, specifies the SRQ attributes to modify. On output,