From patchwork Mon Feb 2 02:20:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: FengYu LeiDian X-Patchwork-Id: 435317 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 729B214028E for ; Mon, 2 Feb 2015 13:24:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754644AbbBBCY1 (ORCPT ); Sun, 1 Feb 2015 21:24:27 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:57316 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbbBBCYZ (ORCPT ); Sun, 1 Feb 2015 21:24:25 -0500 Received: by mail-pa0-f42.google.com with SMTP id bj1so76174817pad.1 for ; Sun, 01 Feb 2015 18:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Luxbg364t9kKwSVABM30UWa1fimMQrj+lYIFJQ2UlzM=; b=M2EM1nOgYrCI9VZEY4bTvHVl50xzJ1qR3rO8FPLYjVoWtbV39SBPXJsCShqAf8p8W7 inmLLmc+A3ARO0jJ30OjGzF1U/F5uvtX5b12jen/WLvmhN4UMecFVmNVd0TuanMzo9Yu Z79c56URl+t6u61eQ1MfnsXQ1tTTxkwpq9I0O0+w40bAEKFTNNTvS4UiTgauS4VSiByd kJCHmBvCDVLG2cNocCQR9HjFioNpkosfU+qxI3hvA7UyB+oaaBPjd0InlMyfxqpvBduH LEBD53fubc5mYkLvdeO4SDuOb+pJf2XcVSu7FEpMP7pZ6m0fKYgu1Hn583vK96IIW8vr dFPA== X-Received: by 10.66.178.198 with SMTP id da6mr25913381pac.126.1422843864900; Sun, 01 Feb 2015 18:24:24 -0800 (PST) Received: from [134.134.139.70] (jfdmzpr01-ext.jf.intel.com. [134.134.139.70]) by mx.google.com with ESMTPSA id i3sm17125234pdf.39.2015.02.01.18.24.20 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Feb 2015 18:24:24 -0800 (PST) Message-ID: <54CEDEDC.7060507@gmail.com> Date: Mon, 02 Feb 2015 10:20:12 +0800 From: Fan Du User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Alexander Duyck CC: Fan Du , bhutchings@solarflare.com, davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCHv2 net] net: restore lro after device detached from bridge References: <1422621209-23222-1-git-send-email-fan.du@intel.com> <54CBEE24.8000603@redhat.com> In-Reply-To: <54CBEE24.8000603@redhat.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 于 2015年01月31日 04:48, Alexander Duyck 写道: > On 01/30/2015 04:33 AM, Fan Du wrote: >> Either detaching a device from bridge or switching a device >> out of FORWARDING state, the original lro feature should >> possibly be enabled for good reason, e.g. hw feature like >> receive side coalescing could come into play. >> >> BEFORE: >> echo 1 > /proc/sys/net/ipv4/conf/ens806f0/forwarding && ethtool -k ens806f0 | grep large >> large-receive-offload: off >> >> echo 0 > /proc/sys/net/ipv4/conf/ens806f0/forwarding && ethtool -k ens806f0 | grep large >> large-receive-offload: off >> >> AFTER: >> echo 1 > /proc/sys/net/ipv4/conf/ens806f0/forwarding && ethtool -k ens806f0 | grep large >> large-receive-offload: off >> >> echo 0 > /proc/sys/net/ipv4/conf/ens806f0/forwarding && ethtool -k ens806f0 | grep large >> large-receive-offload: on >> >> Signed-off-by: Fan Du >> Fixes: 0187bdfb0567 ("net: Disable LRO on devices that are forwarding") > > First off this isn't a "fix". This is going to likely break more than > it fixes. The main reason why LRO is disabled is because it can cause > more harm then it helps. Since GRO is available we should err on the > side of caution since enabling LRO/RSC can have undesirable side effects > in a number of cases. I think you are talking about bad scenarios when net device is attached to a bridge. Then what's the good reason user has to pay extra cpu power for using GRO, instead of using hw capable LRO/RSC when this net device is detached from bridge acting as a standalone NIC? Note, SRC is defaulted to *ON* in practice for ALL ixgbe NICs, as same other RSC capable NICs. Attaching net device to a bridge _once_ should not changed its default configuration, moreover it's a subtle change without any message that user won't noticed at all. From 1e76b2625b3e6aa239b5ef8399fe441a587c6646 Mon Sep 17 00:00:00 2001 From: Fan Du Date: Mon, 2 Feb 2015 05:02:11 -0500 Subject: [PATCH] net: restore lro after device detached from bridge When detached net device from a bridge, the original lro feature should possibly be enabled for good reason, e.g. hw feature like receive side coalescing could come into play. Signed-off-by: Fan Du Fixes: 0187bdfb0567 ("net: Disable LRO on devices that are forwarding") --- ChangeLog: v2: - Restore lro only when device detached from bridge --- include/linux/netdevice.h | 1 + net/bridge/br_if.c | 1 + net/core/dev.c | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 642d426..904b1a4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2153,6 +2153,7 @@ int dev_alloc_name(struct net_device *dev, const char *name); int dev_open(struct net_device *dev); int dev_close(struct net_device *dev); void dev_disable_lro(struct net_device *dev); +void dev_enable_lro(struct net_device *dev); int dev_loopback_xmit(struct sk_buff *newskb); int dev_queue_xmit(struct sk_buff *skb); int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv); diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 81e49fb..4236f3a 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -565,6 +565,7 @@ int br_del_if(struct net_bridge *br, struct net_device *dev) call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev); netdev_update_features(br->dev); + dev_enable_lro(dev); return 0; } diff --git a/net/core/dev.c b/net/core/dev.c index 1e325ad..76f2ed7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1451,6 +1451,29 @@ void dev_disable_lro(struct net_device *dev) } EXPORT_SYMBOL(dev_disable_lro); +/** + * dev_enable_lro - enable Large Receive Offload on a device + * @dev: device + * + * Enable Large Receive Offload (LRO) on a net device. + * This is needed if device is not attached to a bridge. + */ +void dev_enable_lro(struct net_device *dev) +{ + struct net_device *lower_dev; + struct list_head *iter; + + dev->wanted_features |= NETIF_F_LRO; + netdev_update_features(dev); + + if (unlikely(!(dev->features & NETIF_F_LRO))) + netdev_WARN(dev, "failed to enable LRO!\n"); + + netdev_for_each_lower_dev(dev, lower_dev, iter) + dev_enable_lro(lower_dev); +} +EXPORT_SYMBOL(dev_enable_lro); + static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val, struct net_device *dev) {