Skip to content

Commit 0b3100b

Browse files
hkallweitdavem330
authored andcommitted
ethtool: switch back from ethtool_keee to ethtool_eee for ioctl
In order to later extend struct ethtool_keee, we have to decouple it from the userspace format represented by struct ethtool_eee. Therefore switch back to struct ethtool_eee, representing the userspace format, and add conversion between ethtool_eee and ethtool_keee. Struct ethtool_keee will be changed in follow-up patches, therefore don't do a *keee = *eee here. Member cmd isn't copied, because it's not used, and we'll remove it in the next patch of this series. In addition omit setting cmd to ETHTOOL_GEEE in the ioctl response, userspace ethtool isn't interested in it. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d80a523 commit 0b3100b

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

net/ethtool/ioctl.c

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,39 +1508,69 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
15081508
return 0;
15091509
}
15101510

1511+
static void eee_to_keee(struct ethtool_keee *keee,
1512+
const struct ethtool_eee *eee)
1513+
{
1514+
memset(keee, 0, sizeof(*keee));
1515+
1516+
keee->supported = eee->supported;
1517+
keee->advertised = eee->advertised;
1518+
keee->lp_advertised = eee->lp_advertised;
1519+
keee->eee_active = eee->eee_active;
1520+
keee->eee_enabled = eee->eee_enabled;
1521+
keee->tx_lpi_enabled = eee->tx_lpi_enabled;
1522+
keee->tx_lpi_timer = eee->tx_lpi_timer;
1523+
}
1524+
1525+
static void keee_to_eee(struct ethtool_eee *eee,
1526+
const struct ethtool_keee *keee)
1527+
{
1528+
memset(eee, 0, sizeof(*eee));
1529+
1530+
eee->supported = keee->supported;
1531+
eee->advertised = keee->advertised;
1532+
eee->lp_advertised = keee->lp_advertised;
1533+
eee->eee_active = keee->eee_active;
1534+
eee->eee_enabled = keee->eee_enabled;
1535+
eee->tx_lpi_enabled = keee->tx_lpi_enabled;
1536+
eee->tx_lpi_timer = keee->tx_lpi_timer;
1537+
}
1538+
15111539
static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
15121540
{
1513-
struct ethtool_keee edata;
1541+
struct ethtool_keee keee;
1542+
struct ethtool_eee eee;
15141543
int rc;
15151544

15161545
if (!dev->ethtool_ops->get_eee)
15171546
return -EOPNOTSUPP;
15181547

1519-
memset(&edata, 0, sizeof(struct ethtool_keee));
1520-
edata.cmd = ETHTOOL_GEEE;
1521-
rc = dev->ethtool_ops->get_eee(dev, &edata);
1522-
1548+
memset(&keee, 0, sizeof(keee));
1549+
rc = dev->ethtool_ops->get_eee(dev, &keee);
15231550
if (rc)
15241551
return rc;
15251552

1526-
if (copy_to_user(useraddr, &edata, sizeof(edata)))
1553+
keee_to_eee(&eee, &keee);
1554+
if (copy_to_user(useraddr, &eee, sizeof(eee)))
15271555
return -EFAULT;
15281556

15291557
return 0;
15301558
}
15311559

15321560
static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
15331561
{
1534-
struct ethtool_keee edata;
1562+
struct ethtool_keee keee;
1563+
struct ethtool_eee eee;
15351564
int ret;
15361565

15371566
if (!dev->ethtool_ops->set_eee)
15381567
return -EOPNOTSUPP;
15391568

1540-
if (copy_from_user(&edata, useraddr, sizeof(edata)))
1569+
if (copy_from_user(&eee, useraddr, sizeof(eee)))
15411570
return -EFAULT;
15421571

1543-
ret = dev->ethtool_ops->set_eee(dev, &edata);
1572+
eee_to_keee(&keee, &eee);
1573+
ret = dev->ethtool_ops->set_eee(dev, &keee);
15441574
if (!ret)
15451575
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
15461576
return ret;

0 commit comments

Comments
 (0)