From patchwork Thu May 17 10:39:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10406311 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 2CC9360230 for ; Thu, 17 May 2018 10:40:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1029728AA0 for ; Thu, 17 May 2018 10:40:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DB8628A5F; Thu, 17 May 2018 10:40:09 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 33DF528AA0 for ; Thu, 17 May 2018 10:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751280AbeEQKkF (ORCPT ); Thu, 17 May 2018 06:40:05 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:44998 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751626AbeEQKkD (ORCPT ); Thu, 17 May 2018 06:40:03 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 May 2018 13:41:47 +0300 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 w4HAdu2V002339; Thu, 17 May 2018 13:39:56 +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 w4HAdu9f032409; Thu, 17 May 2018 13:39:56 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w4HAducQ032408; Thu, 17 May 2018 13:39:56 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, raeds@mellanox.com Subject: [PATCH rdma-core 07/11] verbs: Add counters flow_spec Date: Thu, 17 May 2018 13:39:33 +0300 Message-Id: <1526553577-32273-8-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1526553577-32273-1-git-send-email-yishaih@mellanox.com> References: <1526553577-32273-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 flow counter specification is used to bind an ibv_counters to a new flow. This feature allows an application to request to add an action to count events that match this flow rule. The ibv_counters object used must be created beforehand. Signed-off-by: Raed Salem Signed-off-by: Yishai Hadas --- libibverbs/cmd.c | 9 +++++++++ libibverbs/kern-abi.h | 1 + libibverbs/man/ibv_create_flow.3 | 1 + libibverbs/verbs.h | 8 ++++++++ 4 files changed, 19 insertions(+) diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index 9cd1ba5..bb07af5 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -1795,6 +1795,15 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, kern_spec->handle.handle = vaction->handle; break; } + case IBV_FLOW_SPEC_ACTION_COUNT: { + const struct verbs_counters *vcounters = + container_of(ib_spec->flow_count.counters, + const struct verbs_counters, counters); + kern_spec->flow_count.size = + sizeof(struct ib_uverbs_flow_spec_action_count); + kern_spec->flow_count.handle = vcounters->handle; + break; + } default: return EINVAL; } diff --git a/libibverbs/kern-abi.h b/libibverbs/kern-abi.h index 23dd104..3b9e7e5 100644 --- a/libibverbs/kern-abi.h +++ b/libibverbs/kern-abi.h @@ -271,6 +271,7 @@ struct ibv_kern_spec { struct ib_uverbs_flow_spec_action_tag flow_tag; struct ib_uverbs_flow_spec_action_drop drop; struct ib_uverbs_flow_spec_action_handle handle; + struct ib_uverbs_flow_spec_action_count flow_count; }; }; diff --git a/libibverbs/man/ibv_create_flow.3 b/libibverbs/man/ibv_create_flow.3 index 65de08b..efa145c 100644 --- a/libibverbs/man/ibv_create_flow.3 +++ b/libibverbs/man/ibv_create_flow.3 @@ -73,6 +73,7 @@ IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specif IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */ IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */ IBV_FLOW_SPEC_ACTION_HANDLE = 0x1002, /* Carry out an action created by ibv_create_flow_action_xxxx verb */ +IBV_FLOW_SPEC_ACTION_COUNT = 0x1003, /* Action count matched packet with a ibv_counters handle */ .in -8 }; .br diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index bcb1af0..4175347 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -1404,6 +1404,7 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_ACTION_TAG = 0x1000, IBV_FLOW_SPEC_ACTION_DROP = 0x1001, IBV_FLOW_SPEC_ACTION_HANDLE = 0x1002, + IBV_FLOW_SPEC_ACTION_COUNT = 0x1003, }; struct ibv_flow_eth_filter { @@ -1519,6 +1520,12 @@ struct ibv_flow_spec_action_handle { const struct ibv_flow_action *action; }; +struct ibv_flow_spec_counter_action { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_counters *counters; +}; + struct ibv_flow_spec { union { struct { @@ -1535,6 +1542,7 @@ struct ibv_flow_spec { struct ibv_flow_spec_action_tag flow_tag; struct ibv_flow_spec_action_drop drop; struct ibv_flow_spec_action_handle handle; + struct ibv_flow_spec_counter_action flow_count; }; };