From patchwork Thu Aug 20 22:49:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1348668 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=UXc77fUZ; dkim-atps=neutral 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 4BXfyx29x1z9sPB for ; Fri, 21 Aug 2020 08:51:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D54B623100; Thu, 20 Aug 2020 22:51:34 +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 M15HapD6iVnx; Thu, 20 Aug 2020 22:51:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 9C125230ED; Thu, 20 Aug 2020 22:50:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6F0EAC08A9; Thu, 20 Aug 2020 22:50:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4AC51C08A6 for ; Thu, 20 Aug 2020 22:50:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4513386C2C for ; Thu, 20 Aug 2020 22:50:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mEuw6BLx5QPe for ; Thu, 20 Aug 2020 22:50:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 1849D86BE1 for ; Thu, 20 Aug 2020 22:50:19 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id o5so68047pgb.2 for ; Thu, 20 Aug 2020 15:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TDN0bcfJCLtzAI5WBhcGbIkKsdcWnb9o9SHRo4FNm/4=; b=UXc77fUZY8outsbF0HTanixj7f3j/zpfMSOqWLguXAcXpsoQRkIDyKKPrngO4d3On2 MGMXkIFxBicST3iGlGgX9tMhDyjz5dQYaQAlHo7TB+gEv0Eb0p/67or0W8LsNad5T1Gj RKIBtVSy4/WJJvMBZbIgZc4qOl0NPXpM3JJ3UE3KwJoGtaYXuLlRqk4CyhWmq6/PAZJh BYrZvS7GUC94rJq/ajQw3jpnqbZ0ZRBaWTLAiJM3cUgu8g+k1tIQV1AA5JPu6Socy8ag xeLMy0doOwf10E3eQuQRCVo75FVyQ0ZRrRBqxE1XA2CkjLIxmcuuCiA101vvT8wZq7fA FIhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TDN0bcfJCLtzAI5WBhcGbIkKsdcWnb9o9SHRo4FNm/4=; b=rvuAnzp4AsF3Y7ImZg8qBn5Wtiw4ULK8wVxboitlPs8S/bhmaXtMN9iBwh+f0mL2cT UKEqRCEJq2B+A6p+5nH18sFkGRPHPfwe6jV8Dn3S9JyU9TPZXdB/HcgPT9YrjcTbnf9/ JQjQZlkIcVm2Dbsrc8M0tnFGXH1bWzT2wk8ApA61HHUZNUSF9oJgvGiUgah4Q8eIwJO4 XEa3W0POzcLiIm70xiIZORxNq99yq12bpsA2p6o1avRw/DE57xQ+RFfAHowNmms6lZXt bWutAZnsoITXEiI9v4wegk9ZscmCOWzXSjOgM8jETxNrMfHl+FZifEfRlSQnA21kHdmh 7RsA== X-Gm-Message-State: AOAM530sbc0BeqfYEvXhj3v88NwMdPyCT6UBgNdUY74GfLd3shP+9p/P SbRjzFfsHqb4NeBVoGOsL/TOxaeUrfPY3A== X-Google-Smtp-Source: ABdhPJwbOM/i20CWFQkYXFrQjt5B8DWxiQOSKhy0iZ+g6uXxKB2MitjclBuNDWc7Gi7kZXeSEJXIWg== X-Received: by 2002:a62:53c2:: with SMTP id h185mr57039pfb.53.1597963819009; Thu, 20 Aug 2020 15:50:19 -0700 (PDT) Received: from gizo.domain (97-115-99-106.ptld.qwest.net. [97.115.99.106]) by smtp.gmail.com with ESMTPSA id y6sm116866pfr.61.2020.08.20.15.50.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 15:50:18 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Thu, 20 Aug 2020 15:49:37 -0700 Message-Id: <1597963790-12362-11-git-send-email-gvrose8192@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> References: <1597963790-12362-1-git-send-email-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH 10/23] datapath: simplify the flow_hash 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" From: Tonghao Zhang Upstream commit: commit 515b65a4b99197ae062a795ab4de919e6d04be04 Author: Tonghao Zhang Date: Fri Nov 1 22:23:50 2019 +0800 net: openvswitch: simplify the flow_hash Simplify the code and remove the unnecessary BUILD_BUG_ON. Signed-off-by: Tonghao Zhang Tested-by: Greg Rose Acked-by: William Tu Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Cc: Tonghao Zhang Signed-off-by: Greg Rose Reviewed-by: Tonghao Zhang --- datapath/flow_table.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/datapath/flow_table.c b/datapath/flow_table.c index 62d726d..7efaa80 100644 --- a/datapath/flow_table.c +++ b/datapath/flow_table.c @@ -455,13 +455,10 @@ err_free_ti: static u32 flow_hash(const struct sw_flow_key *key, const struct sw_flow_key_range *range) { - int key_start = range->start; - int key_end = range->end; - const u32 *hash_key = (const u32 *)((const u8 *)key + key_start); - int hash_u32s = (key_end - key_start) >> 2; + const u32 *hash_key = (const u32 *)((const u8 *)key + range->start); /* Make sure number of hash bytes are multiple of u32. */ - BUILD_BUG_ON(sizeof(long) % sizeof(u32)); + int hash_u32s = range_n_bytes(range) >> 2; return jhash2(hash_key, hash_u32s, 0); }