From patchwork Mon Sep 14 12:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1363550 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BqlVs2dG3z9sTm for ; Mon, 14 Sep 2020 22:08:05 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 46DF785F94; Mon, 14 Sep 2020 12:08:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5izfDM6T-pdL; Mon, 14 Sep 2020 12:08:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9D69485FA4; Mon, 14 Sep 2020 12:08:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 71D11C089F; Mon, 14 Sep 2020 12:08:01 +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 02FE6C088B for ; Mon, 14 Sep 2020 12:07:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DF917869A2 for ; Mon, 14 Sep 2020 12:07:58 +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 4jd8u1gWTJT4 for ; Mon, 14 Sep 2020 12:07:57 +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 D42B1867F3 for ; Mon, 14 Sep 2020 12:07:56 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com) with SMTP; 14 Sep 2020 15:07:52 +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 08EC7l4m018898; Mon, 14 Sep 2020 15:07:51 +0300 From: Chris Mi To: dev@openvswitch.org Date: Mon, 14 Sep 2020 20:07:40 +0800 Message-Id: <20200914120745.16373-4-cmi@nvidia.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200914120745.16373-1-cmi@nvidia.com> References: <20200914120745.16373-1-cmi@nvidia.com> MIME-Version: 1.0 Cc: elibr@nvidia.com, Chris Mi Subject: [ovs-dev] [PATCH v2 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 }