From patchwork Mon Mar 21 06:14:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1607577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=JncEeGgB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KMPwr1Zl2z9s1l for ; Mon, 21 Mar 2022 17:34:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 21983405CE; Mon, 21 Mar 2022 06:34:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2S9LlnhLM_KC; Mon, 21 Mar 2022 06:34:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7EF7940877; Mon, 21 Mar 2022 06:34:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 81B5CC008C; Mon, 21 Mar 2022 06:34:29 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9A83BC000B for ; Mon, 21 Mar 2022 06:34:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8AEC2405CE for ; Mon, 21 Mar 2022 06:34:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 45OEvMHe6zzf for ; Mon, 21 Mar 2022 06:34:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp4.osuosl.org (Postfix) with ESMTPS id C945D402DD for ; Mon, 21 Mar 2022 06:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647844466; x=1679380466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d+gfsTFj5JKlayN1Yl+aHK9JX0Gb3SmVJFwsgVQy3JQ=; b=JncEeGgBMHqSND0SdqtCgl4iUSh4+kyLk17dTyG7TzqFWJeE/zxiQXiJ VS9RDo4n4CtFd2oZhWH1nytDhlJDL+F8VtwmejxX8bKthVPFpLINczBN9 ncoi0bNWqJCceA8v+fwPA0J6qzfMJioYviVXUzCgv1ayllRpsX7WXZq2B l6Z9teaCijxUjll1CCZkQFjJZg3HGsu9dcrbMTqv/7qvplmNzmuqNrPBe XobJXyrHaQG0O+5L+AN/hdkeK7FeGH08N800XRuIWySFc/jGiPAfRWqph T/sgRTS9kk21tE+wkTRyt4SVZPBgHSzr7fd0+r8qfd36BdqVXCkCgPEjF g==; X-IronPort-AV: E=McAfee;i="6200,9189,10292"; a="244953081" X-IronPort-AV: E=Sophos;i="5.90,197,1643702400"; d="scan'208";a="244953081" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2022 23:34:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,197,1643702400"; d="scan'208";a="518308628" Received: from unknown (HELO localhost.localdomain) ([10.190.213.111]) by orsmga006.jf.intel.com with ESMTP; 20 Mar 2022 23:34:23 -0700 From: Kumar Amber To: ovs-dev@openvswitch.org Date: Mon, 21 Mar 2022 11:44:32 +0530 Message-Id: <20220321061441.1833575-2-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220321061441.1833575-1-kumar.amber@intel.com> References: <20220321061441.1833575-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org, fbl@sysclose.org, Kumar Amber Subject: [ovs-dev] [PATCH v1 01/10] dpif-netdev: Refactor recirc data allocation and hash fn. 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" The patch removes static allocation of recirc_depth parameter and moves the hash function to dpcls to allow for re-use by avx512 dpif and others. Signed-off-by: Kumar Amber Signed-off-by: Cian Ferriter Co-authored-by: Cian Ferriter --- lib/dpif-netdev-private-dpcls.h | 23 +++++++++++++++++++++++ lib/dpif-netdev-private-dpif.c | 2 ++ lib/dpif-netdev-private-dpif.h | 9 +++++++++ lib/dpif-netdev.c | 29 ++--------------------------- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/lib/dpif-netdev-private-dpcls.h b/lib/dpif-netdev-private-dpcls.h index 0d5da73c7..a86ea449b 100644 --- a/lib/dpif-netdev-private-dpcls.h +++ b/lib/dpif-netdev-private-dpcls.h @@ -25,6 +25,7 @@ #include "cmap.h" #include "openvswitch/thread.h" +#include "dpif-netdev-private-dpif.h" #ifdef __cplusplus extern "C" { @@ -124,6 +125,28 @@ dpif_netdev_packet_get_rss_hash_orig_pkt(struct dp_packet *packet, return hash; } +static inline uint32_t +dpif_netdev_packet_get_rss_hash(struct dp_packet *packet, + const struct miniflow *mf) +{ + uint32_t hash; + + if (OVS_LIKELY(dp_packet_rss_valid(packet))) { + hash = dp_packet_get_rss_hash(packet); + } else { + hash = miniflow_hash_5tuple(mf, 0); + dp_packet_set_rss_hash(packet, hash); + } + + /* The RSS hash must account for the recirculation depth to avoid + * collisions in the exact match cache */ + uint32_t recirc_depth = *recirc_depth_get(); + if (OVS_UNLIKELY(recirc_depth)) { + hash = hash_finish(hash, recirc_depth); + } + return hash; +} + /* Allow other implementations to call dpcls_lookup() for subtable search. */ bool dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key *keys[], diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c index 84d4ec156..4fe67a3c5 100644 --- a/lib/dpif-netdev-private-dpif.c +++ b/lib/dpif-netdev-private-dpif.c @@ -153,3 +153,5 @@ dp_netdev_impl_set_default_by_name(const char *name) return err; } + +DEFINE_EXTERN_PER_THREAD_DATA(recirc_depth, 0); diff --git a/lib/dpif-netdev-private-dpif.h b/lib/dpif-netdev-private-dpif.h index 0da639c55..0e29a02db 100644 --- a/lib/dpif-netdev-private-dpif.h +++ b/lib/dpif-netdev-private-dpif.h @@ -18,6 +18,11 @@ #define DPIF_NETDEV_PRIVATE_DPIF_H 1 #include "openvswitch/types.h" +#include "ovs-thread.h" + + +#define MAX_RECIRC_DEPTH 6 +DECLARE_EXTERN_PER_THREAD_DATA(uint32_t, recirc_depth); /* Forward declarations to avoid including files. */ struct dp_netdev_pmd_thread; @@ -76,4 +81,8 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets, odp_port_t in_port); +int32_t +dp_netdev_recirculate(struct dp_netdev_pmd_thread *, + struct dp_packet_batch *); + #endif /* netdev-private.h */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 720818e30..829f1dedf 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -98,8 +98,6 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev); #define FLOW_DUMP_MAX_BATCH 50 /* Use per thread recirc_depth to prevent recirculation loop. */ -#define MAX_RECIRC_DEPTH 6 -DEFINE_STATIC_PER_THREAD_DATA(uint32_t, recirc_depth, 0) /* Use instant packet send by default. */ #define DEFAULT_TX_FLUSH_INTERVAL 0 @@ -547,8 +545,6 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, const struct flow *flow, const struct nlattr *actions, size_t actions_len); -static void dp_netdev_recirculate(struct dp_netdev_pmd_thread *, - struct dp_packet_batch *); static void dp_netdev_disable_upcall(struct dp_netdev *); static void dp_netdev_pmd_reload_done(struct dp_netdev_pmd_thread *pmd); @@ -7789,28 +7785,6 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_, actions, wc, put_actions, dp->upcall_aux); } -static inline uint32_t -dpif_netdev_packet_get_rss_hash(struct dp_packet *packet, - const struct miniflow *mf) -{ - uint32_t hash, recirc_depth; - - if (OVS_LIKELY(dp_packet_rss_valid(packet))) { - hash = dp_packet_get_rss_hash(packet); - } else { - hash = miniflow_hash_5tuple(mf, 0); - dp_packet_set_rss_hash(packet, hash); - } - - /* The RSS hash must account for the recirculation depth to avoid - * collisions in the exact match cache */ - recirc_depth = *recirc_depth_get_unsafe(); - if (OVS_UNLIKELY(recirc_depth)) { - hash = hash_finish(hash, recirc_depth); - } - return hash; -} - struct packet_batch_per_flow { unsigned int byte_count; uint16_t tcp_flags; @@ -8497,11 +8471,12 @@ dp_netdev_input(struct dp_netdev_pmd_thread *pmd, return 0; } -static void +int32_t dp_netdev_recirculate(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets) { dp_netdev_input__(pmd, packets, true, 0); + return 0; } struct dp_netdev_execute_aux {