From patchwork Thu Oct 19 14:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10017305 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 BBB10600CC for ; Thu, 19 Oct 2017 14:43:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFD0E28D91 for ; Thu, 19 Oct 2017 14:43:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4C7928D95; Thu, 19 Oct 2017 14:43:05 +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 4BCF528D91 for ; Thu, 19 Oct 2017 14:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbdJSOnB (ORCPT ); Thu, 19 Oct 2017 10:43:01 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54850 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752513AbdJSOmu (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 v9JEggGg032316; 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 v9JEggbU027407; 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 v9JEggfg027405; 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 09/16] IB/core: Add support for flow counter set Date: Thu, 19 Oct 2017 17:41:51 +0300 Message-Id: <1508424118-27205-10-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 A counter set object could be attached to flow on creation by providing the counter specification action. Signed-off-by: Raed Salem Reviewed-by: Yishai Hadas --- drivers/infiniband/core/verbs.c | 8 +++++++- include/rdma/ib_verbs.h | 14 +++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index ffe51fd..8e82249 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1941,6 +1941,8 @@ struct ib_flow *ib_create_flow(struct ib_qp *qp, if (!IS_ERR(flow_id)) { atomic_inc(&qp->usecnt); flow_id->qp = qp; + if (flow_id->counter_set) + atomic_inc(&flow_id->counter_set->usecnt); } return flow_id; } @@ -1950,10 +1952,14 @@ int ib_destroy_flow(struct ib_flow *flow_id) { int err; struct ib_qp *qp = flow_id->qp; + struct ib_counter_set *counter_set = flow_id->counter_set; err = qp->device->destroy_flow(flow_id); - if (!err) + if (!err) { atomic_dec(&qp->usecnt); + if (counter_set) + atomic_dec(&counter_set->usecnt); + } return err; } EXPORT_SYMBOL(ib_destroy_flow); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index bc33bc2..d394e24 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1811,6 +1811,7 @@ enum ib_flow_spec_type { /* Actions */ IB_FLOW_SPEC_ACTION_TAG = 0x1000, IB_FLOW_SPEC_ACTION_DROP = 0x1001, + IB_FLOW_SPEC_ACTION_COUNT = 0x1002, }; #define IB_FLOW_SPEC_LAYER_MASK 0xF0 #define IB_FLOW_SPEC_SUPPORT_LAYERS 8 @@ -1944,6 +1945,12 @@ struct ib_flow_spec_action_drop { u16 size; }; +struct ib_flow_spec_action_count { + enum ib_flow_spec_type type; + u16 size; + struct ib_counter_set *counter_set; +}; + union ib_flow_spec { struct { u32 type; @@ -1957,6 +1964,7 @@ struct ib_flow_spec_action_drop { struct ib_flow_spec_tunnel tunnel; struct ib_flow_spec_action_tag flow_tag; struct ib_flow_spec_action_drop drop; + struct ib_flow_spec_action_count flow_count; }; struct ib_flow_attr { @@ -1975,6 +1983,7 @@ struct ib_flow_attr { struct ib_flow { struct ib_qp *qp; struct ib_uobject *uobject; + struct ib_counter_set *counter_set; }; struct ib_mad_hdr; @@ -3671,6 +3680,8 @@ 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_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, + unsigned int *sg_offset, unsigned int page_size); int ib_describe_counter_set(struct ib_device *device, u16 cs_id, struct ib_counter_set_describe_attr *cs_describe_attr); @@ -3680,9 +3691,6 @@ struct ib_counter_set *ib_create_counter_set(struct ib_device *device, 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); - static inline int ib_map_mr_sg_zbva(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset, unsigned int page_size)