From patchwork Wed Sep 9 19:20:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Rose X-Patchwork-Id: 1360983 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.137; helo=fraxinus.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=uf8F1rDG; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmsMc1PxDz9sTN for ; Thu, 10 Sep 2020 05:21:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id ADD8786F04; Wed, 9 Sep 2020 19:21:46 +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 gxtHUga73vXG; Wed, 9 Sep 2020 19:21:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8FA1386F80; Wed, 9 Sep 2020 19:21:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 60C7BC0051; Wed, 9 Sep 2020 19:21:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9B6CBC0859 for ; Wed, 9 Sep 2020 19:21:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6F9292E243 for ; Wed, 9 Sep 2020 19:21:15 +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 rZooxptSmgQB for ; Wed, 9 Sep 2020 19:21:07 +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 silver.osuosl.org (Postfix) with ESMTPS id B68A42E157 for ; Wed, 9 Sep 2020 19:20:36 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id u13so2801827pgh.1 for ; Wed, 09 Sep 2020 12:20:36 -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=SpwRwdc8GRf/bNpGJm+51hL05PPN6W8I4zPpCZiS/Es=; b=uf8F1rDGTRRbBpbeYL8sNUQpXyEWM5OeF8Y0nDAOiF1oOF7WZZJu295SKryyowMufn kK8eRS3LSWFhEHvdodYzZ2+GCnaVmRoHVSEgWtGfTli6pn3QC6KAaoSX2R+OK8+99YRw VzYPCHzza+e6NOdnS7kTe1f1VYZd8p8DybGsZT5Fb0LQo035VOLqALdX5yhPdOKpQBgY KLkqJE2d8Gc7Hy1vaZ0ibG0Lt22Bn076HmWwuLe5WCsazbm2Z4u5ACBm48ktQiTQn20f cKhSb8DuBq+WWCYhQ/ZfnE7jpBPjYhoCetTqXag08V6Bf6akBlYyhJI0X+LI5V99Ba3c DjeA== 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=SpwRwdc8GRf/bNpGJm+51hL05PPN6W8I4zPpCZiS/Es=; b=oV0miZUTk/lqQOOXM9ghLQzziSXutdoKNjjlR0gBklFIUP0qo4i02MKORD83gS/PaY yuo+G9x0iM+zGPzSumliVhi+iJ9KCXO0CmxrvowCJ71RPiuTFLwbo6nNkByiKf5mWS9a E9gOM18YSyVd6ERZA39aNBMOFBgdDOeX7ZkFLYRez7alqmtciNi1gN/TUxsL20G7iJ7t EaRLbMLv+ZRY4HfmhKDjGm/86iU2l3DvDnELQluKGkGEIICTksk5cGo6Jc6HDtMOZ4mg /28DL4knaglO/n8wxTZ35Vbe9nr3mg9gUzRWtn+Vo8viVhlIpdjEpcrjCTym3i/jZZee kxvw== X-Gm-Message-State: AOAM532OQ+FdOBbdftzCCM55HXEDjw2ThpI0+fC9qsskOUCo9ATRPOe3 YUNWvG9k9ev25MXOwEAQKSW/NYb73tQ90g== X-Google-Smtp-Source: ABdhPJzuOeHr7Mo4ESVKyPzXc7Iosm4nZ+PVQ3ImhbVZEUAmANl6RNnYsbxLCpVTtDq/Bme2RxiIbA== X-Received: by 2002:a05:6a00:1507:b029:13e:d13d:a13c with SMTP id q7-20020a056a001507b029013ed13da13cmr2093215pfu.36.1599679235915; Wed, 09 Sep 2020 12:20:35 -0700 (PDT) Received: from VMware-box.domain ([97.115.183.169]) by smtp.googlemail.com with ESMTPSA id x29sm2866338pga.23.2020.09.09.12.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 12:20:34 -0700 (PDT) From: Greg Rose To: dev@openvswitch.org Date: Wed, 9 Sep 2020 12:20:06 -0700 Message-Id: <20200909192021.9545-10-gvrose8192@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200909192021.9545-1-gvrose8192@gmail.com> References: <20200909192021.9545-1-gvrose8192@gmail.com> Subject: [ovs-dev] [PATCH v2 09/24] 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 Reviewed-by: Tonghao Zhang Signed-off-by: Greg Rose --- 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 62d726ddd..7efaa8044 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); }