From patchwork Thu Apr 30 21:53:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 466742 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1B4EC14076B for ; Fri, 1 May 2015 07:53:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751781AbbD3Vxv (ORCPT ); Thu, 30 Apr 2015 17:53:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35197 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbbD3Vxt (ORCPT ); Thu, 30 Apr 2015 17:53:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 4787A8E665; Thu, 30 Apr 2015 21:53:49 +0000 (UTC) Received: from [192.168.122.149] (vpn-225-10.phx2.redhat.com [10.3.225.10]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3ULrmXb016908; Thu, 30 Apr 2015 17:53:49 -0400 Subject: [PATCH 1/3] etherdev: Avoid unnecessary byte swap in check for Ethertype From: Alexander Duyck To: netdev@vger.kernel.org Cc: davem@davemloft.net Date: Thu, 30 Apr 2015 14:53:48 -0700 Message-ID: <20150430215348.1798.15509.stgit@ahduyck-vm-fedora22> In-Reply-To: <20150430214917.1798.49769.stgit@ahduyck-vm-fedora22> References: <20150430214917.1798.49769.stgit@ahduyck-vm-fedora22> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This change takes advantage of the fact that ETH_P_802_3_MIN is aligned to 512 so as a result we can actually ignore the lower 8b when comparing the Ethertype to ETH_P_802_3_MIN. This allows us to avoid a byte swap by simply masking the value and comparing it to the byte swapped value for ETH_P_802_3_MIN. Signed-off-by: Alexander Duyck --- net/ethernet/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index f3bad41d725f..60069318d5d1 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -178,7 +178,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) if (unlikely(netdev_uses_dsa(dev))) return htons(ETH_P_XDSA); - if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN)) + if (likely((eth->h_proto & htons(0xFF00)) >= htons(ETH_P_802_3_MIN))) return eth->h_proto; /*