From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Russell King <rmk+kernel@armlinux.org.uk>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH v2 RFC 2/5] ethtool: switch back from ethtool_keee to ethtool_eee for ioctl
Date: Sat, 6 Jan 2024 23:20:04 +0100 [thread overview]
Message-ID: <ba3105df-74ae-4883-b9e9-d517036a73b3@gmail.com> (raw)
In-Reply-To: <8d8700c8-75b2-49ba-b303-b8d619008e45@gmail.com>
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
net/ethtool/ioctl.c | 49 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 099d02e7d..9222fbeeb 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1505,22 +1505,51 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
return 0;
}
+static void eee_to_keee(struct ethtool_keee *keee,
+ const struct ethtool_eee *eee)
+{
+ memset(keee, 0, sizeof(*keee));
+
+ keee->supported = eee->supported;
+ keee->advertised = eee->advertised;
+ keee->lp_advertised = eee->lp_advertised;
+ keee->eee_active = eee->eee_active;
+ keee->eee_enabled = eee->eee_enabled;
+ keee->tx_lpi_enabled = eee->tx_lpi_enabled;
+ keee->tx_lpi_timer = eee->tx_lpi_timer;
+}
+
+static void keee_to_eee(struct ethtool_eee *eee,
+ const struct ethtool_keee *keee)
+{
+ memset(eee, 0, sizeof(*eee));
+
+ eee->supported = keee->supported;
+ eee->advertised = keee->advertised;
+ eee->lp_advertised = keee->lp_advertised;
+ eee->eee_active = keee->eee_active;
+ eee->eee_enabled = keee->eee_enabled;
+ eee->tx_lpi_enabled = keee->tx_lpi_enabled;
+ eee->tx_lpi_timer = keee->tx_lpi_timer;
+}
+
static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
{
- struct ethtool_keee edata;
+ struct ethtool_keee keee;
+ struct ethtool_eee eee;
int rc;
if (!dev->ethtool_ops->get_eee)
return -EOPNOTSUPP;
- memset(&edata, 0, sizeof(struct ethtool_keee));
- edata.cmd = ETHTOOL_GEEE;
- rc = dev->ethtool_ops->get_eee(dev, &edata);
-
+ memset(&keee, 0, sizeof(keee));
+ rc = dev->ethtool_ops->get_eee(dev, &keee);
if (rc)
return rc;
- if (copy_to_user(useraddr, &edata, sizeof(edata)))
+ keee_to_eee(&eee, &keee);
+ eee.cmd = ETHTOOL_GEEE;
+ if (copy_to_user(useraddr, &eee, sizeof(eee)))
return -EFAULT;
return 0;
@@ -1528,16 +1557,18 @@ static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
{
- struct ethtool_keee edata;
+ struct ethtool_keee keee;
+ struct ethtool_eee eee;
int ret;
if (!dev->ethtool_ops->set_eee)
return -EOPNOTSUPP;
- if (copy_from_user(&edata, useraddr, sizeof(edata)))
+ if (copy_from_user(&eee, useraddr, sizeof(eee)))
return -EFAULT;
- ret = dev->ethtool_ops->set_eee(dev, &edata);
+ eee_to_keee(&keee, &eee);
+ ret = dev->ethtool_ops->set_eee(dev, &keee);
if (!ret)
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
return ret;
--
2.43.0
next prev parent reply other threads:[~2024-01-06 22:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-06 22:17 [PATCH v2 RFC 0/5] ethtool: switch EEE netlink interface to use EEE linkmode bitmaps Heiner Kallweit
2024-01-06 22:19 ` [PATCH v2 RFC 1/5] ethtool: replace struct ethtool_eee with a new struct ethtool_keee on kernel side Heiner Kallweit
2024-01-06 22:20 ` Heiner Kallweit [this message]
2024-01-07 16:23 ` [PATCH v2 RFC 2/5] ethtool: switch back from ethtool_keee to ethtool_eee for ioctl Andrew Lunn
2024-01-07 17:10 ` Heiner Kallweit
2024-01-07 16:28 ` Andrew Lunn
2024-01-06 22:20 ` [PATCH v2 RFC 3/5] ethtool: adjust struct ethtool_keee to kernel needs Heiner Kallweit
2024-01-07 16:40 ` Andrew Lunn
2024-01-06 22:21 ` [PATCH v2 RFC 4/5] ethtool: add linkmode bitmap support to struct ethtool_keee Heiner Kallweit
2024-01-07 17:14 ` Andrew Lunn
2024-01-07 17:50 ` Heiner Kallweit
2024-01-06 22:22 ` [PATCH v2 RFC 5/5] net: phy: c45: change genphy_c45_ethtool_[get|set]_eee to use EEE linkmode bitmaps Heiner Kallweit
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=ba3105df-74ae-4883-b9e9-d517036a73b3@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).