From patchwork Sat Dec 5 14:21:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaetan Rivet X-Patchwork-Id: 1411443 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=none (p=none dis=none) header.from=u256.net 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 4CpBcP2J87z9sWQ for ; Sun, 6 Dec 2020 01:22:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 35EFE871A1; Sat, 5 Dec 2020 14:22:41 +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 JV1H7Hk3Z3aK; Sat, 5 Dec 2020 14:22:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 0DB7687136; Sat, 5 Dec 2020 14:22:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D724FC0FA7; Sat, 5 Dec 2020 14:22:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7B816C013B for ; Sat, 5 Dec 2020 14:22:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 779B987159 for ; Sat, 5 Dec 2020 14:22:37 +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 Ola9bY1jH+Kf for ; Sat, 5 Dec 2020 14:22:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by hemlock.osuosl.org (Postfix) with ESMTPS id 994D587120 for ; Sat, 5 Dec 2020 14:22:35 +0000 (UTC) X-Originating-IP: 90.78.4.16 Received: from inocybe.home (lfbn-poi-1-1343-16.w90-78.abo.wanadoo.fr [90.78.4.16]) (Authenticated sender: grive@u256.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 5323A40006 for ; Sat, 5 Dec 2020 14:22:33 +0000 (UTC) From: Gaetan Rivet To: dev@openvswitch.org Date: Sat, 5 Dec 2020 15:21:58 +0100 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Subject: [ovs-dev] [RFC PATCH 03/26] netdev-offload: Add function to read hardware offload stats 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" Add a function for an offload provider to report a device hardware offload count. It is not for reporting offload usage statistics, i.e. in terms of packets or bytes matched by offloads, but only to know how many offloads are currently programmed into the device. Because it is not related to any specific flow, this count is not integrated with the more general flow statistics. Signed-off-by: Gaetan Rivet --- lib/netdev-offload-provider.h | 3 +++ lib/netdev-offload.c | 11 +++++++++++ lib/netdev-offload.h | 1 + 3 files changed, 15 insertions(+) diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index f6e8b009c..fd38cea66 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -83,6 +83,9 @@ struct netdev_flow_api { int (*flow_del)(struct netdev *, const ovs_u128 *ufid, struct dpif_flow_stats *); + /* Queries an offload provider hardware statistics. */ + int (*hw_offload_stats_get)(struct netdev *netdev, uint64_t *counter); + /* 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 f748fcf0d..4a8403ead 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -280,6 +280,17 @@ netdev_flow_del(struct netdev *netdev, const ovs_u128 *ufid, : EOPNOTSUPP; } +int +netdev_hw_offload_stats_get(struct netdev *netdev, uint64_t *counter) +{ + const struct netdev_flow_api *flow_api = + ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api); + + return (flow_api && flow_api->hw_offload_stats_get) + ? flow_api->hw_offload_stats_get(netdev, counter) + : EOPNOTSUPP; +} + int netdev_init_flow_api(struct netdev *netdev) { diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 49b893190..5ed561d13 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -95,6 +95,7 @@ int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions, struct dpif_flow_attrs *, struct ofpbuf *wbuffer); int netdev_flow_del(struct netdev *, const ovs_u128 *, struct dpif_flow_stats *); +int netdev_hw_offload_stats_get(struct netdev *, uint64_t *counter); int netdev_init_flow_api(struct netdev *); void netdev_uninit_flow_api(struct netdev *); uint32_t netdev_get_block_id(struct netdev *);