From patchwork Thu Dec 19 11:54:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1213264 X-Patchwork-Delegate: i.maximets@samsung.com 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.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47dr263MdPz9sQp for ; Thu, 19 Dec 2019 22:56:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id C2BFE24D41; Thu, 19 Dec 2019 11:56:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zfvGGZ9JquFw; Thu, 19 Dec 2019 11:56:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 311682341A; Thu, 19 Dec 2019 11:55:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 125AFC1D8D; Thu, 19 Dec 2019 11:55:09 +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 9D8EEC1D81 for ; Thu, 19 Dec 2019 11:54:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 810B08865B for ; Thu, 19 Dec 2019 11:54:51 +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 k4NF7Vqy87DL for ; Thu, 19 Dec 2019 11:54:49 +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 hemlock.osuosl.org (Postfix) with ESMTP id 5D492885C4 for ; Thu, 19 Dec 2019 11:54:47 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Dec 2019 13:54:41 +0200 Received: from dev-r-vrt-215.mtr.labs.mlnx. (dev-r-vrt-215.mtr.labs.mlnx [10.212.215.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xBJBserQ014710; Thu, 19 Dec 2019 13:54:41 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Thu, 19 Dec 2019 11:54:26 +0000 Message-Id: <20191219115436.10354-9-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191219115436.10354-1-elibr@mellanox.com> References: <20191219115436.10354-1-elibr@mellanox.com> Cc: Oz Shlomo , Simon Horman , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V6 08/18] netdev-offload-dpdk: Implement flow get method 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Implement the flow get method for DPDK, to get the statistics of the provided ufid, towards reading statistics of fully offloaded flows. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 12da62a10..e2fce2ee4 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -57,6 +57,7 @@ struct ufid_to_rte_flow_data { ovs_u128 ufid; struct rte_flow *rte_flow; bool actions_offloaded; + struct dpif_flow_stats stats; }; /* Find rte_flow with @ufid. */ @@ -964,9 +965,55 @@ netdev_offload_dpdk_init_flow_api(struct netdev *netdev) return netdev_dpdk_flow_api_supported(netdev) ? 0 : EOPNOTSUPP; } +static int +netdev_offload_dpdk_flow_get(struct netdev *netdev, + struct match *match OVS_UNUSED, + struct nlattr **actions OVS_UNUSED, + const ovs_u128 *ufid, + struct dpif_flow_stats *stats, + struct dpif_flow_attrs *attrs, + struct ofpbuf *buf OVS_UNUSED) +{ + struct rte_flow_query_count query = { .reset = 1 }; + struct ufid_to_rte_flow_data *rte_flow_data; + struct rte_flow_error error; + int ret = 0; + + rte_flow_data = ufid_to_rte_flow_data_find(ufid); + if (!rte_flow_data || !rte_flow_data->rte_flow) { + ret = -1; + goto out; + } + + attrs->offloaded = true; + if (!rte_flow_data->actions_offloaded) { + attrs->dp_layer = "ovs"; + memset(stats, 0, sizeof *stats); + goto out; + } + attrs->dp_layer = "dpdk"; + ret = netdev_dpdk_rte_flow_query_count(netdev, rte_flow_data->rte_flow, + &query, &error); + if (ret) { + VLOG_DBG_RL(&rl, "%s: Failed to query ufid "UUID_FMT" flow: %p\n", + netdev_get_name(netdev), UUID_ARGS((struct uuid *)ufid), + rte_flow_data->rte_flow); + goto out; + } + rte_flow_data->stats.n_packets += (query.hits_set) ? query.hits : 0; + rte_flow_data->stats.n_bytes += (query.bytes_set) ? query.bytes : 0; + if (query.hits_set && query.hits) { + rte_flow_data->stats.used = time_msec(); + } + memcpy(stats, &rte_flow_data->stats, sizeof *stats); +out: + return ret; +} + const struct netdev_flow_api netdev_offload_dpdk = { .type = "dpdk_flow_api", .flow_put = netdev_offload_dpdk_flow_put, .flow_del = netdev_offload_dpdk_flow_del, .init_flow_api = netdev_offload_dpdk_init_flow_api, + .flow_get = netdev_offload_dpdk_flow_get, };