From patchwork Fri May 6 05:23:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1627396 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=OTX1dNXR; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kvfh00j3Rz9sG6 for ; Fri, 6 May 2022 15:46:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 81F84840A5; Fri, 6 May 2022 05:46:21 +0000 (UTC) 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 bITZ1CDaFXFu; Fri, 6 May 2022 05:46:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 998D483FBB; Fri, 6 May 2022 05:46:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C61BDC0083; Fri, 6 May 2022 05:46:17 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5EA54C002D for ; Fri, 6 May 2022 05:46:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5A58483F91 for ; Fri, 6 May 2022 05:46:16 +0000 (UTC) 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 FFxuR2yIjVA3 for ; Fri, 6 May 2022 05:46:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by smtp1.osuosl.org (Postfix) with ESMTPS id C5A5283F86 for ; Fri, 6 May 2022 05:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651815975; x=1683351975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PZby0D+USv0YyrQmhJedatKX7pRMrjfEuDu6pxxbyqQ=; b=OTX1dNXR/shaCJuDDaPp1TwQj9Lp0BV+km9OMDmezvhYN9Pd7FBYK5bw 574yo03KV72++fZSgVpvqBa98t40NhsyU0l9z49f4kbZxhRQ0P7MVYdiV 1rIgxt4/XFRDipT51OXeUq5bZZPQMxbnNv8dvamUxb1t8OY74SXZovGBO HOrWmYKfXRn5AYAUDc0h1z+4IJTTDP8Bsr/PDfsvMuZ2T2gW/s0m6Oga5 hIlJlwJIwzoFEmfxaHP5x84l3pQi02iYALVJjWCTWIwNQg4JxA+bTqs01 Myzotf9KjH1g8eRazHa8ct1VNDZoZiwBu2Sse2PH2x0TAjphAhHfrWn8v g==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="268503767" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="268503767" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 22:46:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="537727376" Received: from unknown (HELO localhost.localdomain) ([10.190.213.111]) by orsmga006.jf.intel.com with ESMTP; 05 May 2022 22:46:12 -0700 From: Kumar Amber To: ovs-dev@openvswitch.org Date: Fri, 6 May 2022 10:53:23 +0530 Message-Id: <20220506052326.3191931-2-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220506052326.3191931-1-kumar.amber@intel.com> References: <20220506052326.3191931-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org, fbl@sysclose.org, Kumar Amber , david.marchand@redhat.com Subject: [ovs-dev] [PATCH v7 1/4] mfex_avx512: Calculate pkt offsets at compile time. 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 magic numbers pkt offsets and minimum packet lenght and instead calculate it at compile time. Signed-off-by: Kumar Amber --- lib/dpif-netdev-extract-avx512.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index 6b6fe07db..6ae15a4db 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -246,6 +246,16 @@ _mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) NC, NC, NC, NC, 0xBF, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, \ NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC +#define PKT_OFFSET_L2 (ETH_HEADER_LEN) +#define PKT_OFFSET_L3_VLAN (ETH_HEADER_LEN + VLAN_HEADER_LEN) +#define PKT_OFFSET_L4_IPv4 (ETH_HEADER_LEN + IP_HEADER_LEN) +#define PKT_OFFSET_L4_VLAN_IPv4 (PKT_OFFSET_L4_IPv4 + VLAN_HEADER_LEN) + +#define PKT_MIN_ETH_IPv4_UDP (PKT_OFFSET_L4_IPv4 + UDP_HEADER_LEN) +#define PKT_MIN_ETH_VLAN_IPv4_UDP (PKT_OFFSET_L4_VLAN_IPv4 + UDP_HEADER_LEN) +#define PKT_MIN_ETH_IPv4_TCP (PKT_OFFSET_L4_IPv4 + TCP_HEADER_LEN) +#define PKT_MIN_ETH_VLAN_IPv4_TCP (PKT_OFFSET_L4_VLAN_IPv4 + TCP_HEADER_LEN) + /* This union allows initializing static data as u8, but easily loading it * into AVX512 registers too. The union ensures proper alignment for the zmm. */ @@ -345,9 +355,9 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .mf_bits = { 0x18a0000000000000, 0x0000000000040401}, .dp_pkt_offs = { - 0, UINT16_MAX, 14, 34, + 0, UINT16_MAX, PKT_OFFSET_L2, PKT_OFFSET_L4_IPv4, }, - .dp_pkt_min_size = 42, + .dp_pkt_min_size = PKT_MIN_ETH_IPv4_UDP, }, [PROFILE_ETH_IPV4_TCP] = { @@ -368,9 +378,9 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .mf_bits = { 0x18a0000000000000, 0x0000000000044401}, .dp_pkt_offs = { - 0, UINT16_MAX, 14, 34, + 0, UINT16_MAX, PKT_OFFSET_L2, PKT_OFFSET_L4_IPv4, }, - .dp_pkt_min_size = 54, + .dp_pkt_min_size = PKT_MIN_ETH_IPv4_TCP, }, [PROFILE_ETH_VLAN_IPV4_UDP] = { @@ -387,9 +397,10 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .mf_bits = { 0x38a0000000000000, 0x0000000000040401}, .dp_pkt_offs = { - 14, UINT16_MAX, 18, 38, + PKT_OFFSET_L2, UINT16_MAX, PKT_OFFSET_L3_VLAN, + PKT_OFFSET_L4_VLAN_IPv4, }, - .dp_pkt_min_size = 46, + .dp_pkt_min_size = PKT_MIN_ETH_VLAN_IPv4_UDP, }, [PROFILE_ETH_VLAN_IPV4_TCP] = { @@ -412,9 +423,10 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = .mf_bits = { 0x38a0000000000000, 0x0000000000044401}, .dp_pkt_offs = { - 14, UINT16_MAX, 18, 38, + PKT_OFFSET_L2, UINT16_MAX, PKT_OFFSET_L3_VLAN, + PKT_OFFSET_L4_VLAN_IPv4, }, - .dp_pkt_min_size = 58, + .dp_pkt_min_size = PKT_MIN_ETH_VLAN_IPv4_TCP, }, };