From patchwork Mon Oct 30 14:09:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10032707 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 7E95D603B4 for ; Mon, 30 Oct 2017 14:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75FE320415 for ; Mon, 30 Oct 2017 14:09:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B0DC20499; Mon, 30 Oct 2017 14:09: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 00A7B20415 for ; Mon, 30 Oct 2017 14:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbdJ3OJi (ORCPT ); Mon, 30 Oct 2017 10:09:38 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:46746 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752354AbdJ3OJh (ORCPT ); Mon, 30 Oct 2017 10:09:37 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 30 Oct 2017 16:09:27 +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 v9UE9RqA009480; Mon, 30 Oct 2017 16:09:27 +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 v9UE9RVw026677; Mon, 30 Oct 2017 16:09:27 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v9UE9R45026676; Mon, 30 Oct 2017 16:09:27 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, yonatanc@mellanox.com, majd@mellanox.com, dledford@redhat.com Subject: [PATCH rdma-core 1/4] verbs: Expose CQ moderation capabilities Date: Mon, 30 Oct 2017 16:09:00 +0200 Message-Id: <1509372543-26603-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1509372543-26603-1-git-send-email-yishaih@mellanox.com> References: <1509372543-26603-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: Yonatan Cohen Extend ibv_query_device_ex to read from the kernel the CQ moderation capabilities as of cq_max_count and cq_max_period. Those CAPs represent the valid values that can be set to accumulate CQEs before the hardware generates an event. A returned value of 0 denotes that CQ moderation is not supported. Signed-off-by: Yonatan Cohen Reviewed-by: Yishai Hadas --- libibverbs/cmd.c | 10 ++++++++++ libibverbs/examples/devinfo.c | 11 +++++++++++ libibverbs/kern-abi.h | 7 +++++++ libibverbs/man/ibv_query_device_ex.3 | 6 ++++++ libibverbs/verbs.h | 6 ++++++ 5 files changed, 40 insertions(+) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 713a13c..b903ade 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -255,6 +255,16 @@ int ibv_cmd_query_device_ex(struct ibv_context *context, } } + if (attr_size >= offsetof(struct ibv_device_attr_ex, cq_mod_caps) + + sizeof(attr->cq_mod_caps)) { + if (resp->response_length >= + offsetof(struct ibv_query_device_resp_ex, cq_mod_caps) + + sizeof(resp->cq_mod_caps)) { + attr->cq_mod_caps.max_cq_count = resp->cq_mod_caps.cq_count; + attr->cq_mod_caps.max_cq_period = resp->cq_mod_caps.cq_period; + } + } + return 0; } diff --git a/libibverbs/examples/devinfo.c b/libibverbs/examples/devinfo.c index 33f7e95..169da2e 100644 --- a/libibverbs/examples/devinfo.c +++ b/libibverbs/examples/devinfo.c @@ -397,6 +397,16 @@ static void print_rss_caps(const struct ibv_rss_caps *caps) } } +static void print_cq_moderation_caps(const struct ibv_cq_moderation_caps *cq_caps) +{ + if (!cq_caps->max_cq_count || !cq_caps->max_cq_period) + return; + + printf("\n\tcq moderation caps:\n"); + printf("\t\tmax_cq_count:\t%u\n", cq_caps->max_cq_count); + printf("\t\tmax_cq_period:\t%u us\n\n", cq_caps->max_cq_period); +} + static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps) { uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET | @@ -538,6 +548,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) printf("\tmax_wq_type_rq:\t\t\t%u\n", device_attr.max_wq_type_rq); print_packet_pacing_caps(&device_attr.packet_pacing_caps); print_tm_caps(&device_attr.tm_caps); + print_cq_moderation_caps(&device_attr.cq_mod_caps); } for (port = 1; port <= device_attr.orig_attr.phys_port_cnt; ++port) { diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 6a16566..a80d2e6 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -289,6 +289,12 @@ struct ibv_tm_caps_resp { __u32 reserved; }; +struct ibv_cq_moderation_caps_resp { + __u16 cq_count; + __u16 cq_period; + __u32 reserved; +}; + struct ibv_query_device_resp_ex { struct ibv_query_device_resp base; __u32 comp_mask; @@ -301,6 +307,7 @@ struct ibv_query_device_resp_ex { __u32 max_wq_type_rq; __u32 raw_packet_caps; struct ibv_tm_caps_resp tm_caps; + struct ibv_cq_moderation_caps_resp cq_mod_caps; }; struct ibv_query_port { diff --git a/libibverbs/man/ibv_query_device_ex.3 b/libibverbs/man/ibv_query_device_ex.3 index c0cb77b..1a5c008 100644 --- a/libibverbs/man/ibv_query_device_ex.3 +++ b/libibverbs/man/ibv_query_device_ex.3 @@ -34,6 +34,7 @@ uint32_t max_wq_type_rq; /* Max Work Queue from type R struct ibv_packet_pacing_caps packet_pacing_caps; /* Packet pacing capabilities */ uint32_t raw_packet_caps; /* Raw packet capabilities, use enum ibv_raw_packet_caps */ struct ibv_tm_caps tm_caps; /* Tag matching capabilities */ +struct ibv_cq_moderation_caps cq_mod_caps; /* CQ moderation max capabilities */ .in -8 }; @@ -101,6 +102,11 @@ uint32_t max_sge; /* Max number of SGEs in a tagged buffer */ .in -8 }; +struct ibv_cq_moderation_caps { + uint16_t max_cq_count; + uint16_t max_cq_period; +}; + .fi .SH "RETURN VALUE" .B ibv_query_device_ex() diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 1ab747b..dbc95cb 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -286,6 +286,11 @@ struct ibv_tm_caps { uint32_t max_sge; }; +struct ibv_cq_moderation_caps { + uint16_t max_cq_count; + uint16_t max_cq_period; /* in micro seconds */ +}; + struct ibv_device_attr_ex { struct ibv_device_attr orig_attr; uint32_t comp_mask; @@ -299,6 +304,7 @@ struct ibv_device_attr_ex { struct ibv_packet_pacing_caps packet_pacing_caps; uint32_t raw_packet_caps; /* Use ibv_raw_packet_caps */ struct ibv_tm_caps tm_caps; + struct ibv_cq_moderation_caps cq_mod_caps; }; enum ibv_mtu {