From patchwork Thu Oct 19 14:41:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10017291 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 8BBBB600CC for ; Thu, 19 Oct 2017 14:42:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FBFA28D90 for ; Thu, 19 Oct 2017 14:42:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7484528D92; Thu, 19 Oct 2017 14:42:54 +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 0DE1828D90 for ; Thu, 19 Oct 2017 14:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750902AbdJSOmv (ORCPT ); Thu, 19 Oct 2017 10:42:51 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54782 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752411AbdJSOmt (ORCPT ); Thu, 19 Oct 2017 10:42:49 -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 v9JEgg4J032298; 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 v9JEgf8j027357; Thu, 19 Oct 2017 17:42:41 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v9JEgf1Y027356; Thu, 19 Oct 2017 17:42:41 +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 03/16] IB/core: Introduce counter set describe verb Date: Thu, 19 Oct 2017 17:41:45 +0300 Message-Id: <1508424118-27205-4-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 In order to work with a counter set object, first need to get various information on the counter set, hence the describe verb is introduced. The following info is exposed by the describe verb: - Type of counter set: Which type of verb object this counter set could count, for example Flow. - Number of instances of this counter-set that are available in the hardware (i.e. num_of_cs). - Additional attributes about the counter set, for example is cache supported ? if yes, application can choose upon query to read the data from the cache. - Number of counters in the counter set i.e. entries_count. - An array of null terminated counters names strings within this counter set, each name is 64 bytes aligned. The user must allocate sufficient buffer size to get this data. In case buffer is NULL all other metadata is returned, except of the array. Based on the returned metadata, user can know the required buffer size needed to hold the counters names, which is 64 * entries_count. Signed-off-by: Raed Salem Reviewed-by: Yishai Hadas --- drivers/infiniband/core/verbs.c | 20 ++++++++++++++++++++ include/rdma/ib_verbs.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index d8f1a5d..eda389a 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -2290,3 +2290,23 @@ void ib_drain_qp(struct ib_qp *qp) ib_drain_rq(qp); } EXPORT_SYMBOL(ib_drain_qp); + +/** + * ib_describe_counter_set - Describes a Counter Set + * @device: The device on which to describe a counter set. + * @cs_id: the counter set id to be described + * @cs_describe_attr: A list of description attributes + * required to get the outcome. + */ +int ib_describe_counter_set(struct ib_device *device, + u16 cs_id, + struct ib_counter_set_describe_attr *cs_describe_attr) +{ + if (!device->describe_counter_set) + return -ENOSYS; + + return device->describe_counter_set(device, cs_id, + cs_describe_attr, + NULL); +} +EXPORT_SYMBOL(ib_describe_counter_set); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 0cc880d..44f92c3 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2053,6 +2053,30 @@ struct ib_port_pkey_list { struct list_head pkey_list; }; +enum ib_counter_set_type { + IB_COUNTER_SET_FLOW, +}; + +enum ib_counter_set_attributes { + /* Is cache supported */ + IB_COUNTER_SET_ATTR_CACHED = 1 << 0, +}; + +#define IB_COUNTER_NAME_LEN 64 +struct ib_counter_set_describe_attr { + /* Type that this set refers to, use enum ib_counter_set_type */ + u8 counted_type; + /* Number of instances of this counter-set available in the hardware */ + u64 num_of_cs; + /* Attributes of the set, use enum ib_counter_set_attributes */ + u32 attributes; + /* Number of counters in this set */ + u8 entries_count; + /* Counters_names_buff length */ + u16 counters_names_len; + char *counters_names_buff; +}; + struct ib_device { /* Do not access @dma_device directly from ULP nor from HW drivers. */ struct device *dma_device; @@ -2308,6 +2332,11 @@ struct ib_device { struct ib_rwq_ind_table_init_attr *init_attr, struct ib_udata *udata); int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table); + int (*describe_counter_set)(struct ib_device *device, + u16 cs_id, + struct ib_counter_set_describe_attr *cs_describe_attr, + struct ib_udata *udata); + /** * rdma netdev operation * @@ -3615,6 +3644,10 @@ struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device, wq_ind_table_init_attr); int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table); +int ib_describe_counter_set(struct ib_device *device, + u16 cs_id, + struct ib_counter_set_describe_attr *cs_describe_attr); + int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset, unsigned int page_size);