From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Russell King <rmk+kernel@armlinux.org.uk>,
David Miller <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH net-next 3/5] ethtool: send EEE linkmode bitmaps to userspace
Date: Mon, 1 Jan 2024 22:25:22 +0100 [thread overview]
Message-ID: <d30cfde6-de90-4a64-b8e3-ebb142e08371@gmail.com> (raw)
In-Reply-To: <783d4a61-2f08-41fc-b91d-bd5f512586a2@gmail.com>
Fortunately, for sending EEE linkmode bitmaps to userspace, no changes
to the netlink attributes are needed. We just increase the size of the
sent bitmaps. For backward compatibility, if keee->use_link_modes is
false, copy the legacy bitmaps to keee->link_modes before sending
the linkmode bitmaps to userspace.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
net/ethtool/eee.c | 48 ++++++++++++++++++++++++++++++++++-------------
1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/net/ethtool/eee.c b/net/ethtool/eee.c
index 9b34d3310..38b151146 100644
--- a/net/ethtool/eee.c
+++ b/net/ethtool/eee.c
@@ -43,6 +43,15 @@ static int eee_prepare_data(const struct ethnl_req_info *req_base,
ret = dev->ethtool_ops->get_eee(dev, eee);
ethnl_ops_complete(dev);
+ if (!ret && !keee->use_link_modes) {
+ ethtool_convert_legacy_u32_to_link_mode(keee->link_modes.supported,
+ eee->supported);
+ ethtool_convert_legacy_u32_to_link_mode(keee->link_modes.advertising,
+ eee->advertised);
+ ethtool_convert_legacy_u32_to_link_mode(keee->link_modes.lp_advertising,
+ eee->lp_advertised);
+ }
+
return ret;
}
@@ -62,14 +71,17 @@ static int eee_reply_size(const struct ethnl_req_info *req_base,
EEE_MODES_COUNT);
/* MODES_OURS */
- ret = ethnl_bitset32_size(&eee->advertised, &eee->supported,
- EEE_MODES_COUNT, link_mode_names, compact);
+ ret = ethnl_bitset_size(keee->link_modes.advertising,
+ keee->link_modes.supported,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ link_mode_names, compact);
if (ret < 0)
return ret;
len += ret;
/* MODES_PEERS */
- ret = ethnl_bitset32_size(&eee->lp_advertised, NULL,
- EEE_MODES_COUNT, link_mode_names, compact);
+ ret = ethnl_bitset_size(keee->link_modes.lp_advertising, NULL,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ link_mode_names, compact);
if (ret < 0)
return ret;
len += ret;
@@ -92,14 +104,17 @@ static int eee_fill_reply(struct sk_buff *skb,
const struct ethtool_eee *eee = &keee->eee;
int ret;
- ret = ethnl_put_bitset32(skb, ETHTOOL_A_EEE_MODES_OURS,
- &eee->advertised, &eee->supported,
- EEE_MODES_COUNT, link_mode_names, compact);
+ ret = ethnl_put_bitset(skb, ETHTOOL_A_EEE_MODES_OURS,
+ keee->link_modes.advertising,
+ keee->link_modes.supported,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ link_mode_names, compact);
if (ret < 0)
return ret;
- ret = ethnl_put_bitset32(skb, ETHTOOL_A_EEE_MODES_PEER,
- &eee->lp_advertised, NULL, EEE_MODES_COUNT,
- link_mode_names, compact);
+ ret = ethnl_put_bitset(skb, ETHTOOL_A_EEE_MODES_PEER,
+ keee->link_modes.lp_advertising, NULL,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ link_mode_names, compact);
if (ret < 0)
return ret;
@@ -147,9 +162,16 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info)
if (ret < 0)
return ret;
- ret = ethnl_update_bitset32(&eee->advertised, EEE_MODES_COUNT,
- tb[ETHTOOL_A_EEE_MODES_OURS],
- link_mode_names, info->extack, &mod);
+ if (keee.use_link_modes) {
+ ret = ethnl_update_bitset(keee.link_modes.advertising,
+ __ETHTOOL_LINK_MODE_MASK_NBITS,
+ tb[ETHTOOL_A_EEE_MODES_OURS],
+ link_mode_names, info->extack, &mod);
+ } else {
+ ret = ethnl_update_bitset32(&eee->advertised, EEE_MODES_COUNT,
+ tb[ETHTOOL_A_EEE_MODES_OURS],
+ link_mode_names, info->extack, &mod);
+ }
if (ret < 0)
return ret;
ethnl_update_bool32(&eee->eee_enabled, tb[ETHTOOL_A_EEE_ENABLED], &mod);
--
2.43.0
next prev parent reply other threads:[~2024-01-01 21:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-01 21:22 [PATCH net-next 0/5] ethtool: add support for EEE linkmodes beyond bit 32 Heiner Kallweit
2024-01-01 21:23 ` [PATCH net-next 1/5] ethtool: add struct ethtool_keee and extend struct ethtool_eee Heiner Kallweit
2024-01-04 16:27 ` Marek Behún
2024-01-04 16:46 ` Heiner Kallweit
2024-01-04 17:16 ` Andrew Lunn
2024-01-04 20:30 ` Heiner Kallweit
2024-01-05 22:35 ` Heiner Kallweit
2024-01-05 23:15 ` Andrew Lunn
2024-01-08 15:38 ` Russell King (Oracle)
2024-01-01 21:24 ` [PATCH net-next 2/5] ethtool: add basic handling of struct ethtool_keee Heiner Kallweit
2024-01-01 21:25 ` Heiner Kallweit [this message]
2024-01-01 21:26 ` [PATCH net-next 4/5] net: phy: c45: prepare genphy_c45_ethtool_set_eee for follow-up extension Heiner Kallweit
2024-01-01 21:28 ` [PATCH net-next 5/5] net: phy: c45: extend genphy_c45_ethtool_[set|get]_eee Heiner Kallweit
2024-01-06 19:44 ` [PATCH net-next 0/5] ethtool: add support for EEE linkmodes beyond bit 32 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=d30cfde6-de90-4a64-b8e3-ebb142e08371@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).