Skip to content

Commit

Permalink
net: ethtool: eee: Remove legacy _u32 from keee
Browse files Browse the repository at this point in the history
All MAC drivers have been converted to use the link mode members of
keee. So remove the _u32 values, and the code in the ethtool core to
convert the legacy _u32 values to link modes.

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Feb 28, 2024
1 parent 1e45b5f commit 292fac4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 49 deletions.
3 changes: 0 additions & 3 deletions include/linux/ethtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ struct ethtool_keee {
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
__ETHTOOL_DECLARE_LINK_MODE_MASK(advertised);
__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertised);
u32 supported_u32;
u32 advertised_u32;
u32 lp_advertised_u32;
u32 tx_lpi_timer;
bool tx_lpi_enabled;
bool eee_active;
Expand Down
31 changes: 4 additions & 27 deletions net/ethtool/eee.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include "common.h"
#include "bitset.h"

#define EEE_MODES_COUNT \
(sizeof_field(struct ethtool_keee, supported_u32) * BITS_PER_BYTE)

struct eee_req_info {
struct ethnl_req_info base;
};
Expand Down Expand Up @@ -41,15 +38,6 @@ 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 && !ethtool_eee_use_linkmodes(eee)) {
ethtool_convert_legacy_u32_to_link_mode(eee->supported,
eee->supported_u32);
ethtool_convert_legacy_u32_to_link_mode(eee->advertised,
eee->advertised_u32);
ethtool_convert_legacy_u32_to_link_mode(eee->lp_advertised,
eee->lp_advertised_u32);
}

return ret;
}

Expand All @@ -62,11 +50,6 @@ static int eee_reply_size(const struct ethnl_req_info *req_base,
int len = 0;
int ret;

BUILD_BUG_ON(sizeof(eee->advertised_u32) * BITS_PER_BYTE !=
EEE_MODES_COUNT);
BUILD_BUG_ON(sizeof(eee->lp_advertised_u32) * BITS_PER_BYTE !=
EEE_MODES_COUNT);

/* MODES_OURS */
ret = ethnl_bitset_size(eee->advertised, eee->supported,
__ETHTOOL_LINK_MODE_MASK_NBITS,
Expand Down Expand Up @@ -154,16 +137,10 @@ ethnl_set_eee(struct ethnl_req_info *req_info, struct genl_info *info)
if (ret < 0)
return ret;

if (ethtool_eee_use_linkmodes(&eee)) {
ret = ethnl_update_bitset(eee.advertised,
__ETHTOOL_LINK_MODE_MASK_NBITS,
tb[ETHTOOL_A_EEE_MODES_OURS],
link_mode_names, info->extack, &mod);
} else {
ret = ethnl_update_bitset32(&eee.advertised_u32, EEE_MODES_COUNT,
tb[ETHTOOL_A_EEE_MODES_OURS],
link_mode_names, info->extack, &mod);
}
ret = ethnl_update_bitset(eee.advertised,
__ETHTOOL_LINK_MODE_MASK_NBITS,
tb[ETHTOOL_A_EEE_MODES_OURS],
link_mode_names, info->extack, &mod);
if (ret < 0)
return ret;
ethnl_update_bool(&eee.eee_enabled, tb[ETHTOOL_A_EEE_ENABLED], &mod);
Expand Down
29 changes: 10 additions & 19 deletions net/ethtool/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1514,9 +1514,6 @@ static void eee_to_keee(struct ethtool_keee *keee,
{
memset(keee, 0, sizeof(*keee));

keee->supported_u32 = eee->supported;
keee->advertised_u32 = eee->advertised;
keee->lp_advertised_u32 = eee->lp_advertised;
keee->eee_active = eee->eee_active;
keee->eee_enabled = eee->eee_enabled;
keee->tx_lpi_enabled = eee->tx_lpi_enabled;
Expand All @@ -1533,29 +1530,23 @@ static void eee_to_keee(struct ethtool_keee *keee,
static void keee_to_eee(struct ethtool_eee *eee,
const struct ethtool_keee *keee)
{
bool overflow;

memset(eee, 0, sizeof(*eee));

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;

if (ethtool_eee_use_linkmodes(keee)) {
bool overflow;

overflow = !ethtool_convert_link_mode_to_legacy_u32(&eee->supported,
keee->supported);
ethtool_convert_link_mode_to_legacy_u32(&eee->advertised,
keee->advertised);
ethtool_convert_link_mode_to_legacy_u32(&eee->lp_advertised,
keee->lp_advertised);
if (overflow)
pr_warn("Ethtool ioctl interface doesn't support passing EEE linkmodes beyond bit 32\n");
} else {
eee->supported = keee->supported_u32;
eee->advertised = keee->advertised_u32;
eee->lp_advertised = keee->lp_advertised_u32;
}
overflow = !ethtool_convert_link_mode_to_legacy_u32(&eee->supported,
keee->supported);
ethtool_convert_link_mode_to_legacy_u32(&eee->advertised,
keee->advertised);
ethtool_convert_link_mode_to_legacy_u32(&eee->lp_advertised,
keee->lp_advertised);
if (overflow)
pr_warn("Ethtool ioctl interface doesn't support passing EEE linkmodes beyond bit 32\n");
}

static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
Expand Down

0 comments on commit 292fac4

Please sign in to comment.