]> err.no Git - linux-2.6/blobdiff - net/core/ethtool.c
[PATCH] inotify: fix one-shot support
[linux-2.6] / net / core / ethtool.c
index 289c1b5a8e4a0bf4c497f999d35d5c4f9ea797e4..e6f76106a99b3929c8c56ec5a62a64103b9d0c6b 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/ethtool.h>
 #include <linux/netdevice.h>
@@ -93,6 +94,20 @@ int ethtool_op_get_perm_addr(struct net_device *dev, struct ethtool_perm_addr *a
 }
  
 
+u32 ethtool_op_get_ufo(struct net_device *dev)
+{
+       return (dev->features & NETIF_F_UFO) != 0;
+}
+
+int ethtool_op_set_ufo(struct net_device *dev, u32 data)
+{
+       if (data)
+               dev->features |= NETIF_F_UFO;
+       else
+               dev->features &= ~NETIF_F_UFO;
+       return 0;
+}
+
 /* Handlers for each ethtool command */
 
 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
@@ -483,6 +498,11 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
                        return err;
        }
 
+       if (!data && dev->ethtool_ops->set_ufo) {
+               err = dev->ethtool_ops->set_ufo(dev, 0);
+               if (err)
+                       return err;
+       }
        return dev->ethtool_ops->set_sg(dev, data);
 }
 
@@ -569,6 +589,32 @@ static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
        return dev->ethtool_ops->set_tso(dev, edata.data);
 }
 
+static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
+{
+       struct ethtool_value edata = { ETHTOOL_GTSO };
+
+       if (!dev->ethtool_ops->get_ufo)
+               return -EOPNOTSUPP;
+       edata.data = dev->ethtool_ops->get_ufo(dev);
+       if (copy_to_user(useraddr, &edata, sizeof(edata)))
+                return -EFAULT;
+       return 0;
+}
+static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
+{
+       struct ethtool_value edata;
+
+       if (!dev->ethtool_ops->set_ufo)
+               return -EOPNOTSUPP;
+       if (copy_from_user(&edata, useraddr, sizeof(edata)))
+               return -EFAULT;
+       if (edata.data && !(dev->features & NETIF_F_SG))
+               return -EINVAL;
+       if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
+               return -EINVAL;
+       return dev->ethtool_ops->set_ufo(dev, edata.data);
+}
+
 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
 {
        struct ethtool_test test;
@@ -695,7 +741,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
        return ret;
 }
 
-static int ethtool_get_perm_addr(struct net_device *dev, void *useraddr)
+static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
 {
        struct ethtool_perm_addr epaddr;
        u8 *data;
@@ -854,6 +900,12 @@ int dev_ethtool(struct ifreq *ifr)
        case ETHTOOL_GPERMADDR:
                rc = ethtool_get_perm_addr(dev, useraddr);
                break;
+       case ETHTOOL_GUFO:
+               rc = ethtool_get_ufo(dev, useraddr);
+               break;
+       case ETHTOOL_SUFO:
+               rc = ethtool_set_ufo(dev, useraddr);
+               break;
        default:
                rc =  -EOPNOTSUPP;
        }
@@ -882,3 +934,5 @@ EXPORT_SYMBOL(ethtool_op_set_sg);
 EXPORT_SYMBOL(ethtool_op_set_tso);
 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
+EXPORT_SYMBOL(ethtool_op_set_ufo);
+EXPORT_SYMBOL(ethtool_op_get_ufo);