All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: netdev@vger.kernel.org
Cc: Ben Hutchings <bhutchings@solarflare.com>
Subject: [PATCH v2 10/16] vlan: convert VLAN devices to use ndo_fix_features()
Date: Sat, 22 Jan 2011 23:14:13 +0100 (CET)	[thread overview]
Message-ID: <cd588125add36235f392019452c13a9130cb76b6.1295734271.git.mirq-linux@rere.qmqm.pl> (raw)
In-Reply-To: <cover.1295734270.git.mirq-linux@rere.qmqm.pl>

Note: get_flags was actually broken, because it should return the
flags capped with vlan_features. This is now done implicitly by
limiting netdev->hw_features.

RX checksumming offload control is (and was) broken, as there was no way
before to say whether it's done for tagged packets.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 net/8021q/vlan.c     |    3 +--
 net/8021q/vlan_dev.c |   50 ++++++++++++++------------------------------------
 2 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 7850412..4b575de 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -329,8 +329,7 @@ static void vlan_transfer_features(struct net_device *dev,
 {
 	u32 old_features = vlandev->features;
 
-	vlandev->features &= ~dev->vlan_features;
-	vlandev->features |= dev->features & dev->vlan_features;
+	netdev_update_features(vlandev);
 	vlandev->gso_max_size = dev->gso_max_size;
 
 	if (dev->features & NETIF_F_HW_VLAN_TX)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index be73753..6cfca22 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -691,8 +691,8 @@ static int vlan_dev_init(struct net_device *dev)
 					  (1<<__LINK_STATE_DORMANT))) |
 		      (1<<__LINK_STATE_PRESENT);
 
-	dev->features |= real_dev->features & real_dev->vlan_features;
-	dev->features |= NETIF_F_LLTX;
+	dev->hw_features = real_dev->vlan_features & NETIF_F_ALL_TX_OFFLOADS;
+	dev->features |= real_dev->vlan_features | NETIF_F_LLTX;
 	dev->gso_max_size = real_dev->gso_max_size;
 
 	/* ipv6 shared card related stuff */
@@ -745,6 +745,17 @@ static void vlan_dev_uninit(struct net_device *dev)
 	}
 }
 
+static u32 vlan_dev_fix_features(struct net_device *dev, u32 features)
+{
+	struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
+
+	features &= (real_dev->features | NETIF_F_LLTX);
+	if (dev_ethtool_get_rx_csum(real_dev))
+		features |= NETIF_F_RXCSUM;
+
+	return features;
+}
+
 static int vlan_ethtool_get_settings(struct net_device *dev,
 				     struct ethtool_cmd *cmd)
 {
@@ -760,18 +771,6 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
 	strcpy(info->fw_version, "N/A");
 }
 
-static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
-{
-	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
-	return dev_ethtool_get_rx_csum(vlan->real_dev);
-}
-
-static u32 vlan_ethtool_get_flags(struct net_device *dev)
-{
-	const struct vlan_dev_info *vlan = vlan_dev_info(dev);
-	return dev_ethtool_get_flags(vlan->real_dev);
-}
-
 static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 
@@ -809,32 +808,10 @@ static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, st
 	return stats;
 }
 
-static int vlan_ethtool_set_tso(struct net_device *dev, u32 data)
-{
-       if (data) {
-		struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
-
-		/* Underlying device must support TSO for VLAN-tagged packets
-		 * and must have TSO enabled now.
-		 */
-		if (!(real_dev->vlan_features & NETIF_F_TSO))
-			return -EOPNOTSUPP;
-		if (!(real_dev->features & NETIF_F_TSO))
-			return -EINVAL;
-		dev->features |= NETIF_F_TSO;
-	} else {
-		dev->features &= ~NETIF_F_TSO;
-	}
-	return 0;
-}
-
 static const struct ethtool_ops vlan_ethtool_ops = {
 	.get_settings	        = vlan_ethtool_get_settings,
 	.get_drvinfo	        = vlan_ethtool_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
-	.get_rx_csum		= vlan_ethtool_get_rx_csum,
-	.get_flags		= vlan_ethtool_get_flags,
-	.set_tso                = vlan_ethtool_set_tso,
 };
 
 static const struct net_device_ops vlan_netdev_ops = {
@@ -859,6 +836,7 @@ static const struct net_device_ops vlan_netdev_ops = {
 	.ndo_fcoe_disable	= vlan_dev_fcoe_disable,
 	.ndo_fcoe_get_wwn	= vlan_dev_fcoe_get_wwn,
 #endif
+	.ndo_fix_features	= vlan_dev_fix_features,
 };
 
 void vlan_setup(struct net_device *dev)
-- 
1.7.2.3


  parent reply	other threads:[~2011-01-22 22:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22 22:14 [PATCH v2 00/16] net: Unified offload configuration Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 03/16] net: reduce and unify printk level in netdev_fix_features() Michał Mirosław
2011-01-22 23:12   ` Joe Perches
2011-01-22 23:40     ` Michał Mirosław
2011-01-23 12:44       ` [PATCH] " Michał Mirosław
2011-01-22 23:48   ` [PATCH v2 03/16] " Michał Mirosław
2011-01-24 23:45   ` David Miller
2011-01-22 22:14 ` [PATCH v2 01/16] net: Move check of checksum features to netdev_fix_features() Michał Mirosław
2011-01-24 23:29   ` David Miller
2011-01-22 22:14 ` [PATCH v2 02/16] net: change netdev->features to u32 Michał Mirosław
2011-01-23 10:35   ` Eric Dumazet
2011-01-23 12:44     ` [PATCH] " Michał Mirosław
2011-01-24 23:30   ` [PATCH v2 02/16] " David Miller
2011-01-25 11:07     ` Michał Mirosław
2011-01-25 20:37       ` David Miller
2011-01-22 22:14 ` [PATCH v2 08/16] loopback: convert to hw_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 12/16] jme: convert offload constraints to ndo_fix_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 05/16] net: ethtool: use ndo_fix_features for offload setting Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 11/16] bonding: convert to ndo_fix_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 06/16] net: use ndo_fix_features for ethtool_ops->set_flags Michał Mirosław
2011-01-22 22:14 ` Michał Mirosław [this message]
2011-01-22 22:14 ` [PATCH v2 09/16] bridge: convert br_features_recompute() to ndo_fix_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 04/16] net: Introduce new feature setting ops Michał Mirosław
2011-01-24 23:51   ` David Miller
2011-01-25  1:26     ` Ben Hutchings
2011-01-22 22:14 ` [PATCH v2 07/16] net: introduce NETIF_F_RXCSUM Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 13/16] virtio_net: convert to ndo_fix_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 15/16] veth: convert to hw_features Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 16/16] skge: " Michał Mirosław
2011-01-31 16:45   ` Stephen Hemminger
2011-01-31 21:53     ` Michał Mirosław
2011-01-31 22:40       ` Michał Mirosław
2011-01-31 23:08       ` Michał Mirosław
2011-01-22 22:14 ` [PATCH v2 14/16] Intel net drivers: convert to ndo_fix_features Michał Mirosław
2011-01-24  7:06   ` Jeff Kirsher
2011-01-26  9:47   ` Jeff Kirsher
2011-04-07 12:51     ` Michał Mirosław
2011-04-07 15:00       ` Jeff Kirsher

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=cd588125add36235f392019452c13a9130cb76b6.1295734271.git.mirq-linux@rere.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=bhutchings@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.