aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q/vlan_dev.c
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2011-04-03 01:49:12 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-03 01:49:12 -0400
commit8a0427bb688eae86a8bb939b6a74e5aa00aa035a (patch)
treea2c8361f6eba3d97e2053e559c9f6b81693aa9aa /net/8021q/vlan_dev.c
parent6cb6a27c45cec9184302c2e350b3593c64bc7f6c (diff)
vlan: convert VLAN devices to use ndo_fix_features()
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q/vlan_dev.c')
-rw-r--r--net/8021q/vlan_dev.c50
1 files changed, 14 insertions, 36 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index e34ea9e5e28b..b84a46b30c0c 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -704,8 +704,8 @@ static int vlan_dev_init(struct net_device *dev)
704 (1<<__LINK_STATE_DORMANT))) | 704 (1<<__LINK_STATE_DORMANT))) |
705 (1<<__LINK_STATE_PRESENT); 705 (1<<__LINK_STATE_PRESENT);
706 706
707 dev->features |= real_dev->features & real_dev->vlan_features; 707 dev->hw_features = real_dev->vlan_features & NETIF_F_ALL_TX_OFFLOADS;
708 dev->features |= NETIF_F_LLTX; 708 dev->features |= real_dev->vlan_features | NETIF_F_LLTX;
709 dev->gso_max_size = real_dev->gso_max_size; 709 dev->gso_max_size = real_dev->gso_max_size;
710 710
711 /* ipv6 shared card related stuff */ 711 /* ipv6 shared card related stuff */
@@ -759,6 +759,17 @@ static void vlan_dev_uninit(struct net_device *dev)
759 } 759 }
760} 760}
761 761
762static u32 vlan_dev_fix_features(struct net_device *dev, u32 features)
763{
764 struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
765
766 features &= (real_dev->features | NETIF_F_LLTX);
767 if (dev_ethtool_get_rx_csum(real_dev))
768 features |= NETIF_F_RXCSUM;
769
770 return features;
771}
772
762static int vlan_ethtool_get_settings(struct net_device *dev, 773static int vlan_ethtool_get_settings(struct net_device *dev,
763 struct ethtool_cmd *cmd) 774 struct ethtool_cmd *cmd)
764{ 775{
@@ -774,18 +785,6 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
774 strcpy(info->fw_version, "N/A"); 785 strcpy(info->fw_version, "N/A");
775} 786}
776 787
777static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
778{
779 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
780 return dev_ethtool_get_rx_csum(vlan->real_dev);
781}
782
783static u32 vlan_ethtool_get_flags(struct net_device *dev)
784{
785 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
786 return dev_ethtool_get_flags(vlan->real_dev);
787}
788
789static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) 788static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
790{ 789{
791 790
@@ -823,32 +822,10 @@ static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, st
823 return stats; 822 return stats;
824} 823}
825 824
826static int vlan_ethtool_set_tso(struct net_device *dev, u32 data)
827{
828 if (data) {
829 struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
830
831 /* Underlying device must support TSO for VLAN-tagged packets
832 * and must have TSO enabled now.
833 */
834 if (!(real_dev->vlan_features & NETIF_F_TSO))
835 return -EOPNOTSUPP;
836 if (!(real_dev->features & NETIF_F_TSO))
837 return -EINVAL;
838 dev->features |= NETIF_F_TSO;
839 } else {
840 dev->features &= ~NETIF_F_TSO;
841 }
842 return 0;
843}
844
845static const struct ethtool_ops vlan_ethtool_ops = { 825static const struct ethtool_ops vlan_ethtool_ops = {
846 .get_settings = vlan_ethtool_get_settings, 826 .get_settings = vlan_ethtool_get_settings,
847 .get_drvinfo = vlan_ethtool_get_drvinfo, 827 .get_drvinfo = vlan_ethtool_get_drvinfo,
848 .get_link = ethtool_op_get_link, 828 .get_link = ethtool_op_get_link,
849 .get_rx_csum = vlan_ethtool_get_rx_csum,
850 .get_flags = vlan_ethtool_get_flags,
851 .set_tso = vlan_ethtool_set_tso,
852}; 829};
853 830
854static const struct net_device_ops vlan_netdev_ops = { 831static const struct net_device_ops vlan_netdev_ops = {
@@ -874,6 +851,7 @@ static const struct net_device_ops vlan_netdev_ops = {
874 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn, 851 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
875 .ndo_fcoe_ddp_target = vlan_dev_fcoe_ddp_target, 852 .ndo_fcoe_ddp_target = vlan_dev_fcoe_ddp_target,
876#endif 853#endif
854 .ndo_fix_features = vlan_dev_fix_features,
877}; 855};
878 856
879void vlan_setup(struct net_device *dev) 857void vlan_setup(struct net_device *dev)