Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 122718
b: refs/heads/master
c: b240a0e
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Dec 16, 2008
1 parent 2e76a6d commit 27e5cf1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bf296b125b21b8d558ceb6ec30bb4eba2730cd6b
refs/heads/master: b240a0e5644eb817c4a397098a40e1ad42a615bc
2 changes: 2 additions & 0 deletions trunk/include/linux/ethtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ struct ethtool_ops {

#define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */
#define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */
#define ETHTOOL_GGRO 0x0000002b /* Get GRO enable (ethtool_value) */
#define ETHTOOL_SGRO 0x0000002c /* Set GRO enable (ethtool_value) */

/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
Expand Down
53 changes: 51 additions & 2 deletions trunk/net/core/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,22 @@ static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
return dev->ethtool_ops->set_tx_csum(dev, edata.data);
}

static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
{
struct ethtool_value edata;

if (!dev->ethtool_ops->set_rx_csum)
return -EOPNOTSUPP;

if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;

if (!edata.data && dev->ethtool_ops->set_sg)
dev->features &= ~NETIF_F_GRO;

return dev->ethtool_ops->set_rx_csum(dev, edata.data);
}

static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
{
struct ethtool_value edata;
Expand Down Expand Up @@ -599,6 +615,34 @@ static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
return 0;
}

static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
{
struct ethtool_value edata = { ETHTOOL_GGRO };

edata.data = dev->features & NETIF_F_GRO;
if (copy_to_user(useraddr, &edata, sizeof(edata)))
return -EFAULT;
return 0;
}

static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
{
struct ethtool_value edata;

if (copy_from_user(&edata, useraddr, sizeof(edata)))
return -EFAULT;

if (edata.data) {
if (!dev->ethtool_ops->get_rx_csum ||
!dev->ethtool_ops->get_rx_csum(dev))
return -EINVAL;
dev->features |= NETIF_F_GRO;
} else
dev->features &= ~NETIF_F_GRO;

return 0;
}

static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
{
struct ethtool_test test;
Expand Down Expand Up @@ -932,8 +976,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
dev->ethtool_ops->get_rx_csum);
break;
case ETHTOOL_SRXCSUM:
rc = ethtool_set_value(dev, useraddr,
dev->ethtool_ops->set_rx_csum);
rc = ethtool_set_rx_csum(dev, useraddr);
break;
case ETHTOOL_GTXCSUM:
rc = ethtool_get_value(dev, useraddr, ethcmd,
Expand Down Expand Up @@ -1014,6 +1057,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
case ETHTOOL_SRXFH:
rc = ethtool_set_rxhash(dev, useraddr);
break;
case ETHTOOL_GGRO:
rc = ethtool_get_gro(dev, useraddr);
break;
case ETHTOOL_SGRO:
rc = ethtool_set_gro(dev, useraddr);
break;
default:
rc = -EOPNOTSUPP;
}
Expand Down

0 comments on commit 27e5cf1

Please sign in to comment.