From patchwork Thu Oct 19 14:41:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10017301 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 5FA42600CC for ; Thu, 19 Oct 2017 14:43:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52D8928D95 for ; Thu, 19 Oct 2017 14:43:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4804E28D96; Thu, 19 Oct 2017 14:43:04 +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 BC67A28D91 for ; Thu, 19 Oct 2017 14:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752687AbdJSOnA (ORCPT ); Thu, 19 Oct 2017 10:43:00 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:54864 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752590AbdJSOmu (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 v9JEggwa032334; 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 v9JEgg2t027413; 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 v9JEgg0F027412; 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 10/16] IB/uverbs: Add support for flow counter set Date: Thu, 19 Oct 2017 17:41:52 +0300 Message-Id: <1508424118-27205-11-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 The struct ib_uverbs_flow_spec_action_count associates a counter set with the flow. Use of ib_uverbs_flow_spec_action_count allows the consumer to associate an existing counter set to a flow on creation. Signed-off-by: Raed Salem Reviewed-by: Yishai Hadas --- drivers/infiniband/core/uverbs.h | 1 + drivers/infiniband/core/uverbs_cmd.c | 32 ++++++++++++++++++++++++++++++++ include/uapi/rdma/ib_user_verbs.h | 13 +++++++++++++ 3 files changed, 46 insertions(+) diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 50c4bb4..c87aca9 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -244,6 +244,7 @@ struct ib_uverbs_flow_spec { struct ib_uverbs_flow_spec_ipv6 ipv6; struct ib_uverbs_flow_spec_action_tag flow_tag; struct ib_uverbs_flow_spec_action_drop drop; + struct ib_uverbs_flow_spec_action_count flow_count; }; }; diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index bf2b95a..e05726f 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -2732,6 +2732,13 @@ static int kern_spec_to_ib_spec_action(struct ib_uverbs_flow_spec *kern_spec, ib_spec->drop.size = sizeof(struct ib_flow_spec_action_drop); break; + case IB_FLOW_SPEC_ACTION_COUNT: + if (kern_spec->flow_count.size != + sizeof(struct ib_uverbs_flow_spec_action_count)) + return -EINVAL; + ib_spec->flow_count.size = + sizeof(struct ib_flow_spec_action_count); + break; default: return -EINVAL; } @@ -3269,9 +3276,11 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, struct ib_uverbs_flow_attr *kern_flow_attr; struct ib_flow_attr *flow_attr; struct ib_qp *qp; + struct ib_counter_set *cs = NULL; int err = 0; void *kern_spec; void *ib_spec; + int cs_used = 0; int i; if (ucore->inlen < sizeof(cmd)) @@ -3366,6 +3375,25 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, flow_attr->size += ((union ib_flow_spec *) ib_spec)->size; cmd.flow_attr.size -= ((struct ib_uverbs_flow_spec *)kern_spec)->size; + if (((struct ib_uverbs_flow_spec *)kern_spec)->type == + IB_FLOW_SPEC_ACTION_COUNT) { + __u32 cs_handle = + ((struct ib_uverbs_flow_spec *)kern_spec)->flow_count.cs_handle; + cs_used++; + if (cs_used > 1) { + uobj_put_obj_read(cs); + err = -EINVAL; + goto err_free; + } + cs = uobj_get_obj_read(counter_set, + cs_handle, + file->ucontext); + if (!cs) { + err = -EINVAL; + goto err_free; + } + ((union ib_flow_spec *)ib_spec)->flow_count.counter_set = cs; + } kern_spec += ((struct ib_uverbs_flow_spec *) kern_spec)->size; ib_spec += ((union ib_flow_spec *) ib_spec)->size; } @@ -3376,6 +3404,10 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, goto err_free; } flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER); + + if (cs_used) + uobj_put_obj_read(cs); + if (IS_ERR(flow_id)) { err = PTR_ERR(flow_id); goto err_free; diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 49d9b2d..63f79d5 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -987,6 +987,19 @@ struct ib_uverbs_flow_spec_action_drop { }; }; +struct ib_uverbs_flow_spec_action_count { + union { + struct ib_uverbs_flow_spec_hdr hdr; + struct { + __u32 type; + __u16 size; + __u16 reserved; + }; + }; + __u32 cs_handle; + __u32 reserved1; +}; + struct ib_uverbs_flow_tunnel_filter { __be32 tunnel_id; };