From patchwork Fri Oct 11 14:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1175240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.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.b="jQaT9cYI"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46qVSr43M0z9sP6 for ; Sat, 12 Oct 2019 01:19:24 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B857715B8; Fri, 11 Oct 2019 14:15:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3B11D15AE for ; Fri, 11 Oct 2019 14:05:59 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EE6D9709 for ; Fri, 11 Oct 2019 14:05:58 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id v4so6170556pff.6 for ; Fri, 11 Oct 2019 07:05:58 -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=bbwVTMUAZQTJCANcvOXtOltf12CCuf2zm8x25zYgp2s=; b=jQaT9cYINMGp2NE1qxiK361UDjGr0NTof9MDMVy+Np1nNgWYKETlaaVwn53PgKEZVO 0OIMMnH3mRm51vMrY57zZ1GmKf4e97VMxxz4D74kV0IOCMTLiU/yupnLjKlfXZ0jGjir OliSD5ATvcli8FMxM2VNqV7siJVLPR7H5Grcdolp8SXeDysScOH6hrpiiKm9dTglXb0G Hmv1rYDLwTFMcB0NgJb8Y0XhRwKdrVrVyH7mPXXsn3BNO+jR93T8Dm9K6mXcjZWI4gwT lUcQPr+Smo8ZwNk8n+/eLFx8QtouOL1Xii0kouFcPZn5LM3h0dk48b5haerbSqW+8IeI /9jw== 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=bbwVTMUAZQTJCANcvOXtOltf12CCuf2zm8x25zYgp2s=; b=EhBUXL73aL/TC7ozGMRKj/enTUgM6NbyHIol5PBpmW3HE67X0BcN3epvrSvoUHNYY7 e+f+wKXYEx8qWq83Yezz1a1r8tLC2r2BH7hlmE+wdoAGWYNpXKy0jaocbrvt7QfyFlO1 tvFkuHO2MgBmLXmGfqO8NJ+D+wC8/tsVKqC2AfZ9+IP1DFWR/VX2dCEL7YOYQwhBErGN ofnEVSvHEz0tcHvIvyFqzDltW+n7QWNC4DiBH90MYCqam14pCbhOqSWvc/PW+b4FodVI KcvYRbaN82IRzE4GuwxU6WHCmXHaAatjki6BINCsC16XbnL7zF4QJXXNU/Y8bdOg709U jxBg== X-Gm-Message-State: APjAAAURbk7K/lYMTI/0J1wB+OizAS3coG0k62kWJEKCZDtriKYa3vRj +V6neR8p2KSvy4YI6Apv9UcRKFuw X-Google-Smtp-Source: APXvYqwKEedgo7Bxb4cdznR2Ls/Y9bj5XzjZHYQR2OZc2clRp2Bac6FMzVtLFymV+29Fa7cPeAFTEw== X-Received: by 2002:a63:cf4a:: with SMTP id b10mr16313682pgj.86.1570802758624; Fri, 11 Oct 2019 07:05:58 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([219.143.130.165]) by smtp.gmail.com with ESMTPSA id p190sm11499392pfb.160.2019.10.11.07.05.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 07:05:58 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: gvrose8192@gmail.com, pshelar@ovn.org Date: Fri, 11 Oct 2019 22:00:43 +0800 Message-Id: <1570802447-8019-7-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1570802447-8019-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1570802447-8019-1-git-send-email-xiangxia.m.yue@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: dev@openvswitch.org, netdev@vger.kernel.org Subject: [ovs-dev] [PATCH net-next v3 06/10] net: openvswitch: simplify the flow_hash X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Tonghao Zhang Simplify the code and remove the unnecessary BUILD_BUG_ON. Signed-off-by: Tonghao Zhang --- net/openvswitch/flow_table.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 1b99f8e..7aba5b4 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -430,13 +430,9 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table) 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); }