From patchwork Thu Oct 19 14:41:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10017317 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 59133600CC for ; Thu, 19 Oct 2017 14:43:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CF7928D90 for ; Thu, 19 Oct 2017 14:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41D0828D94; Thu, 19 Oct 2017 14:43:29 +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 B984228D90 for ; Thu, 19 Oct 2017 14:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752124AbdJSOn0 (ORCPT ); Thu, 19 Oct 2017 10:43:26 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54806 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752437AbdJSOmu (ORCPT ); Thu, 19 Oct 2017 10:42:50 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Oct 2017 16:42:42 +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 v9JEggG7032310; Thu, 19 Oct 2017 17:42:42 +0300 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 v9JEggIt027391; Thu, 19 Oct 2017 17:42:42 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v9JEggMY027374; Thu, 19 Oct 2017 17:42:42 +0300 From: Yishai Hadas To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, yishaih@mellanox.com, raeds@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-next 07/16] IB/core: Introduce counter set query verb Date: Thu, 19 Oct 2017 17:41:49 +0300 Message-Id: <1508424118-27205-8-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1508424118-27205-1-git-send-email-yishaih@mellanox.com> References: <1508424118-27205-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: Raed Salem This patch adds the query counter set verb, enabling the user to read the hardware counters which are associated with the counter set. The user supplies counter set instance and an output address. The hardware queries the counter set and writes statistics to the output address as an array of uint64_t, each entry in the uint64_t array represents a single counter. Note: A counter set must be first attached to an IB object in order to be queried for its underlay counters, downstream patches will present bind and query methods for flow counters. The user has an option as part of the query verb to force reading the up-to-date hardware values instead of reading some cached values by using the IB_COUNTER_SET_FORCE_UPDATE flag. Signed-off-by: Raed Salem Reviewed-by: Yishai Hadas --- drivers/infiniband/core/verbs.c | 21 +++++++++++++++++++++ include/rdma/ib_verbs.h | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index ea71393..ffe51fd 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -2352,3 +2352,24 @@ int ib_destroy_counter_set(struct ib_counter_set *cs) return cs->device->destroy_counter_set(cs); } EXPORT_SYMBOL(ib_destroy_counter_set); + +/** + * ib_query_counter_set - Queries a Counter Set + * @cs: The counter set to query. + * @cs_query_attr: A list of query attributes + * required to get the outcome. + */ +int ib_query_counter_set(struct ib_counter_set *cs, + struct ib_counter_set_query_attr *cs_query_attr) +{ + if (!cs->device->query_counter_set) + return -ENOSYS; + + if (!atomic_read(&cs->usecnt)) + return -EINVAL; + + return cs->device->query_counter_set(cs, + cs_query_attr, + NULL); +} +EXPORT_SYMBOL(ib_query_counter_set); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 1c78db7..bc33bc2 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2085,6 +2085,18 @@ struct ib_counter_set { atomic_t usecnt; }; +enum ib_query_counter_set_flags { + /* force hardware query instead of cached value */ + IB_COUNTER_SET_FORCE_UPDATE = 1 << 0, +}; + +struct ib_counter_set_query_attr { + u32 query_flags; /* Use enum ib_query_counter_set_flags */ + u64 *out_buff; + u32 buff_len; + u32 outlen; +}; + struct ib_device { /* Do not access @dma_device directly from ULP nor from HW drivers. */ struct device *dma_device; @@ -2348,6 +2360,9 @@ struct ib_device { u16 cs_id, struct ib_udata *udata); int (*destroy_counter_set)(struct ib_counter_set *cs); + int (*query_counter_set)(struct ib_counter_set *cs, + struct ib_counter_set_query_attr *cs_query_attr, + struct ib_udata *udata); /** * rdma netdev operation @@ -3662,6 +3677,8 @@ int ib_describe_counter_set(struct ib_device *device, struct ib_counter_set *ib_create_counter_set(struct ib_device *device, u16 cs_id); int ib_destroy_counter_set(struct ib_counter_set *cs); +int ib_query_counter_set(struct ib_counter_set *cs, + struct ib_counter_set_query_attr *cs_query_attr); int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset, unsigned int page_size);