Xen-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Ian Campbell <Ian.Campbell@eu.citrix.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Jeremy Fitzhardinge <Jeremy.Fitzhardinge@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH RESEND] net: convert xen-netfront to hw_features
Date: Thu, 31 Mar 2011 12:13:30 +0100
Message-ID: <1301570010.27123.172.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <20110331110136.03A1A13A6A@rere.qmqm.pl>

On Thu, 2011-03-31 at 12:01 +0100, Michał Mirosław wrote:
> Not tested in any way. The original code for offload setting seems broken
> as it resets the features on every netback reconnect.

Thanks, I've got a pending TODO item to test this and propagate similar
changes to netback. I hope to get to it soon...

Is this urgent (for 2.6.39) IYHO? I think it's been broken this way for
a long time now...

Ian.

> 
> This will set GSO_ROBUST at device creation time (earlier than connect time).
> 
> RX checksum offload is forced on - so advertise as it is.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> [I don't know Xen code enough to say this is correct. There is Xen netback
> driver coming in, that has similar changes to be made. Please match
> them up if you can.]
> 
>  drivers/net/xen-netfront.c |   57 +++++++++++++++++--------------------------
>  1 files changed, 23 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index 5c8d9c3..2a71c9f 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1148,6 +1148,8 @@ static const struct net_device_ops xennet_netdev_ops = {
>  	.ndo_change_mtu	     = xennet_change_mtu,
>  	.ndo_set_mac_address = eth_mac_addr,
>  	.ndo_validate_addr   = eth_validate_addr,
> +	.ndo_fix_features    = xennet_fix_features,
> +	.ndo_set_features    = xennet_set_features,
>  };
>  
>  static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
> @@ -1209,7 +1211,9 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
>  	netdev->netdev_ops	= &xennet_netdev_ops;
>  
>  	netif_napi_add(netdev, &np->napi, xennet_poll, 64);
> -	netdev->features        = NETIF_F_IP_CSUM;
> +	netdev->features        = NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
> +				  NETIF_F_GSO_ROBUST;
> +	netdev->hw_features	= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO;
>  
>  	SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops);
>  	SET_NETDEV_DEV(netdev, &dev->dev);
> @@ -1510,52 +1514,40 @@ again:
>  	return err;
>  }
>  
> -static int xennet_set_sg(struct net_device *dev, u32 data)
> +static u32 xennet_fix_features(struct net_device *dev, u32 features)
>  {
> -	if (data) {
> -		struct netfront_info *np = netdev_priv(dev);
> -		int val;
> +	struct netfront_info *np = netdev_priv(dev);
> +	int val;
>  
> +	if (features & NETIF_F_SG) {
>  		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg",
>  				 "%d", &val) < 0)
>  			val = 0;
> +
>  		if (!val)
> -			return -ENOSYS;
> -	} else if (dev->mtu > ETH_DATA_LEN)
> -		dev->mtu = ETH_DATA_LEN;
> -
> -	return ethtool_op_set_sg(dev, data);
> -}
> -
> -static int xennet_set_tso(struct net_device *dev, u32 data)
> -{
> -	if (data) {
> -		struct netfront_info *np = netdev_priv(dev);
> -		int val;
> +			features &= ~NETIF_F_SG;
> +	}
>  
> +	if (features & NETIF_F_TSO) {
>  		if (xenbus_scanf(XBT_NIL, np->xbdev->otherend,
>  				 "feature-gso-tcpv4", "%d", &val) < 0)
>  			val = 0;
> +
>  		if (!val)
> -			return -ENOSYS;
> +			features &= ~NETIF_F_TSO;
>  	}
>  
> -	return ethtool_op_set_tso(dev, data);
> +	return features;
>  }
>  
> -static void xennet_set_features(struct net_device *dev)
> +static int xennet_set_features(struct net_device *dev, u32 features)
>  {
> -	/* Turn off all GSO bits except ROBUST. */
> -	dev->features &= ~NETIF_F_GSO_MASK;
> -	dev->features |= NETIF_F_GSO_ROBUST;
> -	xennet_set_sg(dev, 0);
> +	if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) {
> +		netdev_info(dev, "Reducing MTU because no SG offload");
> +		dev->mtu = ETH_DATA_LEN;
> +	}
>  
> -	/* We need checksum offload to enable scatter/gather and TSO. */
> -	if (!(dev->features & NETIF_F_IP_CSUM))
> -		return;
> -
> -	if (!xennet_set_sg(dev, 1))
> -		xennet_set_tso(dev, 1);
> +	return 0;
>  }
>  
>  static int xennet_connect(struct net_device *dev)
> @@ -1582,7 +1574,7 @@ static int xennet_connect(struct net_device *dev)
>  	if (err)
>  		return err;
>  
> -	xennet_set_features(dev);
> +	netdev_update_features(dev);
>  
>  	spin_lock_bh(&np->rx_lock);
>  	spin_lock_irq(&np->tx_lock);
> @@ -1710,9 +1702,6 @@ static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)
>  
>  static const struct ethtool_ops xennet_ethtool_ops =
>  {
> -	.set_tx_csum = ethtool_op_set_tx_csum,
> -	.set_sg = xennet_set_sg,
> -	.set_tso = xennet_set_tso,
>  	.get_link = ethtool_op_get_link,
>  
>  	.get_sset_count = xennet_get_sset_count,



  reply index

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 11:01 Michał Mirosław
2011-03-31 11:13 ` Ian Campbell [this message]
2011-03-31 11:37   ` Michał Mirosław
2011-04-02  3:54 ` David Miller
2011-04-03 11:07   ` [PATCH] xen: netfront: fix declaration order Eric Dumazet
2011-04-03 17:35     ` Michał Mirosław
2011-04-04  0:24     ` David Miller
2011-04-04  9:55       ` [PATCH] xen: drop anti-dependency on X86_VISWS (Was: Re: [PATCH] xen: netfront: fix declaration order) Ian Campbell
2011-04-06 21:45         ` [PATCH] xen: drop anti-dependency on X86_VISWS David Miller
2011-04-07  6:58           ` Ian Campbell
2011-04-07 17:00             ` H. Peter Anvin
2011-04-08  6:46               ` Ian Campbell
2011-04-08 20:15                 ` H. Peter Anvin
2011-04-07 18:07             ` Jeremy Fitzhardinge
2011-04-08  6:38               ` Ian Campbell
2011-04-08 15:25                 ` Jeremy Fitzhardinge
2011-04-08 15:42                   ` Jan Beulich
2011-04-08 18:24                     ` Jeremy Fitzhardinge
2011-04-09 10:34                       ` Ian Campbell
2011-04-14  8:20                         ` Jeremy Fitzhardinge
2011-04-04 12:29   ` [PATCH RESEND] net: convert xen-netfront to hw_features Ian Campbell
2011-04-04 18:08     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301570010.27123.172.camel@zakaz.uk.xensource.com \
    --to=ian.campbell@eu.citrix.com \
    --cc=Jeremy.Fitzhardinge@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Xen-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/xen-devel/0 xen-devel/git/0.git
	git clone --mirror https://lore.kernel.org/xen-devel/1 xen-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 xen-devel xen-devel/ https://lore.kernel.org/xen-devel \
		xen-devel@lists.xenproject.org xen-devel@lists.xen.org
	public-inbox-index xen-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.xenproject.lists.xen-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git