From patchwork Fri Jan 22 06:44:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1430194 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=) 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 4DMVBP4Nbwz9sVm for ; Fri, 22 Jan 2021 17:45:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 33F9D87370; Fri, 22 Jan 2021 06:45:16 +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 7kCJNEhmdn9f; Fri, 22 Jan 2021 06:45:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 5040B8730F; Fri, 22 Jan 2021 06:45:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2A1F9C1E74; Fri, 22 Jan 2021 06:45:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 62568C1DA7 for ; Fri, 22 Jan 2021 06:45:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4BE6886885 for ; Fri, 22 Jan 2021 06:45:08 +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 MK5apdu62bqk for ; Fri, 22 Jan 2021 06:45:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8350D86868 for ; Fri, 22 Jan 2021 06:45:06 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com) with SMTP; 22 Jan 2021 08:45:00 +0200 Received: from dev-r630-03.mtbc.labs.mlnx (dev-r630-03.mtbc.labs.mlnx [10.75.205.13]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10M6io6i028591; Fri, 22 Jan 2021 08:44:59 +0200 From: Chris Mi To: dev@openvswitch.org Date: Fri, 22 Jan 2021 14:44:42 +0800 Message-Id: <20210122064448.183230-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210122064448.183230-1-cmi@nvidia.com> References: <20210122064448.183230-1-cmi@nvidia.com> MIME-Version: 1.0 Cc: elibr@nvidia.com, roniba@nvidia.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v11 05/11] netdev-offload: Introduce register sFlow upcall callback 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" Introduce register sFlow upcall callback API as a pre-step towards saving the upcall callback. Signed-off-by: Chris Mi Reviewed-by: Eli Britstein --- lib/dpif-netlink.h | 4 ++++ lib/netdev-offload-provider.h | 3 +++ lib/netdev-offload.c | 12 ++++++++++++ lib/netdev-offload.h | 3 +++ 4 files changed, 22 insertions(+) diff --git a/lib/dpif-netlink.h b/lib/dpif-netlink.h index 24294bc42..318a4c71f 100644 --- a/lib/dpif-netlink.h +++ b/lib/dpif-netlink.h @@ -21,6 +21,7 @@ #include #include +#include "dpif.h" #include "flow.h" struct ofpbuf; @@ -60,4 +61,7 @@ bool dpif_netlink_is_internal_device(const char *name); enum ovs_vport_type netdev_to_ovs_vport_type(const char *type); +typedef int dpif_netlink_sflow_upcall_callback(struct dpif_upcall_sflow + *dupcall); + #endif /* dpif-netlink.h */ diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index cf859d1b4..feeb3b458 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -87,6 +87,9 @@ struct netdev_flow_api { * Return 0 if successful, otherwise returns a positive errno value. */ int (*flow_get_n_flows)(struct netdev *, uint64_t *n_flows); + /* Registers an upcall callback to process sFlow packet */ + void (*register_nl_sflow_upcall_cb)(dpif_netlink_sflow_upcall_callback *); + /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 6237667c3..99b2704f6 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -693,3 +693,15 @@ netdev_set_flow_api_enabled(const struct smap *ovs_other_config) } } } + +void +netdev_regsiter_nl_sflow_upcall_cb(struct netdev *netdev, + dpif_netlink_sflow_upcall_callback *cb) +{ + const struct netdev_flow_api *flow_api = + ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api); + + if (flow_api && flow_api->register_nl_sflow_upcall_cb) { + flow_api->register_nl_sflow_upcall_cb(cb); + } +} diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 18b48790f..5ad5463ff 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -22,6 +22,7 @@ #include "openvswitch/types.h" #include "packets.h" #include "flow.h" +#include "dpif-netlink.h" #ifdef __cplusplus extern "C" { @@ -127,6 +128,8 @@ int netdev_ports_flow_get(const char *dpif_type, struct match *match, struct ofpbuf *buf); int netdev_ports_get_n_flows(const char *dpif_type, odp_port_t port_no, uint64_t *n_flows); +void netdev_regsiter_nl_sflow_upcall_cb(struct netdev *netdev, + dpif_netlink_sflow_upcall_callback *cb); #ifdef __cplusplus }