From patchwork Tue Sep 26 14:06:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 1839723 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ActSV0vL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rw1lF6C2Nz1ynX for ; Wed, 27 Sep 2023 00:07:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E755E8238B; Tue, 26 Sep 2023 14:07:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E755E8238B Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ActSV0vL X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oLTsDVfYN2Nb; Tue, 26 Sep 2023 14:07:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0D9CB82350; Tue, 26 Sep 2023 14:06:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0D9CB82350 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C3392C0071; Tue, 26 Sep 2023 14:06:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CE5CC0032 for ; Tue, 26 Sep 2023 14:06:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4AAC2409BD for ; Tue, 26 Sep 2023 14:06:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4AAC2409BD Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ActSV0vL X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wTFLy-Ja8TZY for ; Tue, 26 Sep 2023 14:06:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0487040198 for ; Tue, 26 Sep 2023 14:06:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0487040198 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695737213; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v07XZ45PX4ePat/lVyPk/Xb9z2q4PbvPoViouAW/3MQ=; b=ActSV0vL0MTiT2FPGYFQknipBMs+B+tpV0flxydm4vpOhWCDCySxoAviJcG21xlmi/5EOh FPe64G3uH05BK0YvLqEhSwFNwu9mOH1m4pjeeUUAepTPiiIZ44XuUOfJShY5PxeAeUFsNI LJNZJvlvlW3bgt270tStXXe5YvYm7jA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-7yG7gah0PH-WOnaO4-d4VA-1; Tue, 26 Sep 2023 10:06:52 -0400 X-MC-Unique: 7yG7gah0PH-WOnaO4-d4VA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EEC3B101B045; Tue, 26 Sep 2023 14:06:45 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82F071054FC2; Tue, 26 Sep 2023 14:06:44 +0000 (UTC) From: David Marchand To: dev@openvswitch.org Date: Tue, 26 Sep 2023 16:06:41 +0200 Message-ID: <20230926140641.493252-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Eli Britstein , Ilya Maximets Subject: [ovs-dev] [dpdk-latest] netdev-offload: Use per packet tunnel metadata restore flag. 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" Since v23.07, DPDK provides a per packet flag that indicates if a call to the optional rte_flow_restore_tunnel_info() is necessary. There is, then, no need at runtime to discover if a driver supports this feature. Link: https://git.dpdk.org/dpdk/commit/?id=fca8cba4f1f1 Signed-off-by: David Marchand --- lib/dpif-netdev.c | 15 +++++---------- lib/netdev-dpdk.c | 10 ++++++++++ lib/netdev-offload.c | 18 +----------------- lib/netdev-offload.h | 1 - lib/netdev.c | 1 - 5 files changed, 16 insertions(+), 29 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 157694bcf0..aa51e0a67d 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -8207,16 +8207,11 @@ dp_netdev_hw_flow(const struct dp_netdev_pmd_thread *pmd, #ifdef ALLOW_EXPERIMENTAL_API /* Packet restoration API required. */ /* Restore the packet if HW processing was terminated before completion. */ struct dp_netdev_rxq *rxq = pmd->ctx.last_rxq; - bool miss_api_supported; - - atomic_read_relaxed(&rxq->port->netdev->hw_info.miss_api_supported, - &miss_api_supported); - if (miss_api_supported) { - int err = netdev_hw_miss_packet_recover(rxq->port->netdev, packet); - if (err && err != EOPNOTSUPP) { - COVERAGE_INC(datapath_drop_hw_miss_recover); - return -1; - } + int err = netdev_hw_miss_packet_recover(rxq->port->netdev, packet); + + if (err && err != EOPNOTSUPP) { + COVERAGE_INC(datapath_drop_hw_miss_recover); + return -1; } #endif diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 55700250df..379c50399d 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1223,6 +1223,10 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex) } } +#ifdef ALLOW_EXPERIMENTAL_API +static uint64_t netdev_dpdk_restore_info_flag; +#endif + static void dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev) { @@ -1251,6 +1255,8 @@ dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev) if (!(rx_metadata & RTE_ETH_RX_METADATA_TUNNEL_ID)) { VLOG_DBG("%s: The NIC will not provide per-packet TUNNEL_ID", netdev_get_name(&dev->up)); + } else if (!netdev_dpdk_restore_info_flag) { + netdev_dpdk_restore_info_flag = rte_flow_restore_info_dynflag(); } #endif /* ALLOW_EXPERIMENTAL_API */ } else { @@ -6230,6 +6236,10 @@ netdev_dpdk_rte_flow_get_restore_info(struct netdev *netdev, return -1; } + if (!(p->mbuf.ol_flags & netdev_dpdk_restore_info_flag)) { + return -EOPNOTSUPP; + } + dev = netdev_dpdk_cast(netdev); ovs_mutex_lock(&dev->mutex); ret = rte_flow_get_restore_info(dev->port_id, m, info, error); diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index a5fa624875..fce09565dd 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -183,7 +183,6 @@ netdev_assign_flow_api(struct netdev *netdev) CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { if (!rfa->flow_api->init_flow_api(netdev)) { ovs_refcount_ref(&rfa->refcnt); - atomic_store_relaxed(&netdev->hw_info.miss_api_supported, true); ovsrcu_set(&netdev->flow_api, rfa->flow_api); VLOG_INFO("%s: Assigned flow API '%s'.", netdev_get_name(netdev), rfa->flow_api->type); @@ -192,7 +191,6 @@ netdev_assign_flow_api(struct netdev *netdev) VLOG_DBG("%s: flow API '%s' is not suitable.", netdev_get_name(netdev), rfa->flow_api->type); } - atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false); VLOG_INFO("%s: No suitable flow API found.", netdev_get_name(netdev)); return -1; @@ -325,27 +323,13 @@ netdev_hw_miss_packet_recover(struct netdev *netdev, struct dp_packet *packet) { const struct netdev_flow_api *flow_api; - bool miss_api_supported; - int rv; - - atomic_read_relaxed(&netdev->hw_info.miss_api_supported, - &miss_api_supported); - if (!miss_api_supported) { - return EOPNOTSUPP; - } flow_api = ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api); if (!flow_api || !flow_api->hw_miss_packet_recover) { return EOPNOTSUPP; } - rv = flow_api->hw_miss_packet_recover(netdev, packet); - if (rv == EOPNOTSUPP) { - /* API unsupported by the port; avoid subsequent calls. */ - atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false); - } - - return rv; + return flow_api->hw_miss_packet_recover(netdev, packet); } int diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 47f8e6f48b..ba5f203562 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -47,7 +47,6 @@ struct ovs_action_push_tnl; /* Offload-capable (HW) netdev information */ struct netdev_hw_info { bool oor; /* Out of Offload Resources ? */ - atomic_bool miss_api_supported; /* hw_miss_packet_recover() supported.*/ int offload_count; /* Pending (non-offloaded) flow count */ int pending_count; /* Offloaded flow count */ OVSRCU_TYPE(void *) offload_data; /* Offload metadata. */ diff --git a/lib/netdev.c b/lib/netdev.c index e5ac7713d2..5945aacae4 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -432,7 +432,6 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp) seq_read(netdev->reconfigure_seq); ovsrcu_set(&netdev->flow_api, NULL); netdev->hw_info.oor = false; - atomic_init(&netdev->hw_info.miss_api_supported, false); netdev->node = shash_add(&netdev_shash, name, netdev); /* By default enable one tx and rx queue per netdev. */