From patchwork Mon Sep 14 10:05:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1363492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bqhxb6plpz9sTS for ; Mon, 14 Sep 2020 20:12:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4892D85803; Mon, 14 Sep 2020 10:12:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fOgiOPv2qmrf; Mon, 14 Sep 2020 10:12:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id F33DD87203; Mon, 14 Sep 2020 10:12:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D8E14C0864; Mon, 14 Sep 2020 10:12:32 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id DD39EC0051 for ; Mon, 14 Sep 2020 10:12:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D797A869C1 for ; Mon, 14 Sep 2020 10:12:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e2ssH2R+BHvK for ; Mon, 14 Sep 2020 10:12:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by whitealder.osuosl.org (Postfix) with ESMTP id CE99B8694B for ; Mon, 14 Sep 2020 10:12:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com) with SMTP; 14 Sep 2020 13:05:42 +0300 Received: from dev-r630-04.mtbc.labs.mlnx (dev-r630-04.mtbc.labs.mlnx [10.75.205.14]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 08EA5b6t022527; Mon, 14 Sep 2020 13:05:41 +0300 From: Chris Mi To: dev@openvswitch.org Date: Mon, 14 Sep 2020 18:05:28 +0800 Message-Id: <20200914100533.9395-4-cmi@nvidia.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200914100533.9395-1-cmi@nvidia.com> References: <20200914100533.9395-1-cmi@nvidia.com> MIME-Version: 1.0 Cc: elibr@nvidia.com, Chris Mi Subject: [ovs-dev] [PATCH 3/8] netdev-offload: Introduce sFlow attributes query by group ID API X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" OVS maintains a group ID to sFlow attribute mapping when offloading sFlow action to TC. Introduce sFlow attributes query by group ID API. Signed-off-by: Chris Mi Reviewed-by: Eli Britstein --- lib/netdev-offload-provider.h | 5 +++++ lib/netdev-offload.c | 11 +++++++++++ lib/netdev-offload.h | 1 + 3 files changed, 17 insertions(+) diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 0bed7bf61..8edffcbbd 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -86,6 +86,11 @@ struct netdev_flow_api { /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); + + /* Query sFlow attribute by group ID. + * + * On success returns a const pointer, on failure returns NULL */ + const struct dpif_sflow_attr *(*sflow_attr_get)(uint32_t gid); }; int netdev_register_flow_api_provider(const struct netdev_flow_api *); diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 2da3bc701..084ce25a9 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -666,3 +666,14 @@ netdev_set_flow_api_enabled(const struct smap *ovs_other_config) } } } + +const struct dpif_sflow_attr * +netdev_sflow_attr_get(struct netdev *netdev, uint32_t gid) +{ + const struct netdev_flow_api *flow_api = + ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api); + + return (flow_api && flow_api->sflow_attr_get) + ? flow_api->sflow_attr_get(gid) + : NULL; +} diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 4c0ed2ae8..9f167e1a5 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -124,6 +124,7 @@ int netdev_ports_flow_get(const char *dpif_type, struct match *match, struct dpif_flow_stats *stats, struct dpif_flow_attrs *attrs, struct ofpbuf *buf); +const struct dpif_sflow_attr *netdev_sflow_attr_get(struct netdev *, uint32_t); #ifdef __cplusplus }