Commit 96b6fcc0 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-dsa-cleanup-eee-part-1'

Russell King says:

====================
net: dsa: cleanup EEE (part 1)

First part of DSA EEE cleanups.

Patch 1 removes a useless test that is always false. dp->pl will always
be set for user ports, so !dp->pl in the EEE methods will always be
false.

Patch 2 adds support for a new DSA support_eee() method, which tells
DSA whether the DSA driver supports EEE, and thus whether the ethtool
set_eee() and get_eee() methods should return -EOPNOTSUPP.

Patch 3 adds a trivial implementation for this new method which
indicates that EEE is supported.

Patches 4..8 adds implementations for .supports_eee() to all drivers
that support EEE in some form.

Patch 9 switches the core DSA code to require a .supports_eee()
implementation if DSA is supported. Any DSA driver that doesn't
implement this method after this patch will not support the ethtool
EEE methods.

Part 2 will remove the (now) useless .get_mac_eee() DSA operation.
====================

Link: https://patch.msgid.link/Z1hNkEb13FMuDQiY@shell.armlinux.org.uk


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 3fa2540d 88325a29
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -2224,13 +2224,16 @@ int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy)
}
EXPORT_SYMBOL(b53_eee_init);

int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
bool b53_support_eee(struct dsa_switch *ds, int port)
{
	struct b53_device *dev = ds->priv;

	if (is5325(dev) || is5365(dev))
		return -EOPNOTSUPP;
	return !is5325(dev) && !is5365(dev);
}
EXPORT_SYMBOL(b53_support_eee);

int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
{
	return 0;
}
EXPORT_SYMBOL(b53_get_mac_eee);
@@ -2240,9 +2243,6 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e)
	struct b53_device *dev = ds->priv;
	struct ethtool_keee *p = &dev->ports[port].eee;

	if (is5325(dev) || is5365(dev))
		return -EOPNOTSUPP;

	p->eee_enabled = e->eee_enabled;
	b53_eee_enable_set(ds, port, e->eee_enabled);

@@ -2298,6 +2298,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
	.phylink_get_caps	= b53_phylink_get_caps,
	.port_enable		= b53_enable_port,
	.port_disable		= b53_disable_port,
	.support_eee		= b53_support_eee,
	.get_mac_eee		= b53_get_mac_eee,
	.set_mac_eee		= b53_set_mac_eee,
	.port_bridge_join	= b53_br_join,
+1 −0
Original line number Diff line number Diff line
@@ -384,6 +384,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
void b53_disable_port(struct dsa_switch *ds, int port);
void b53_brcm_hdr_setup(struct dsa_switch *ds, int port);
int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
bool b53_support_eee(struct dsa_switch *ds, int port);
int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);
int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e);

+1 −0
Original line number Diff line number Diff line
@@ -1232,6 +1232,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
	.set_wol		= bcm_sf2_sw_set_wol,
	.port_enable		= bcm_sf2_port_setup,
	.port_disable		= bcm_sf2_port_disable,
	.support_eee		= b53_support_eee,
	.get_mac_eee		= b53_get_mac_eee,
	.set_mac_eee		= b53_set_mac_eee,
	.port_bridge_join	= b53_br_join,
+5 −15
Original line number Diff line number Diff line
@@ -3454,12 +3454,12 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)
	return -EOPNOTSUPP;
}

static int ksz_validate_eee(struct dsa_switch *ds, int port)
static bool ksz_support_eee(struct dsa_switch *ds, int port)
{
	struct ksz_device *dev = ds->priv;

	if (!dev->info->internal_phy[port])
		return -EOPNOTSUPP;
		return false;

	switch (dev->chip_id) {
	case KSZ8563_CHIP_ID:
@@ -3471,21 +3471,15 @@ static int ksz_validate_eee(struct dsa_switch *ds, int port)
	case KSZ9896_CHIP_ID:
	case KSZ9897_CHIP_ID:
	case LAN9646_CHIP_ID:
		return 0;
		return true;
	}

	return -EOPNOTSUPP;
	return false;
}

static int ksz_get_mac_eee(struct dsa_switch *ds, int port,
			   struct ethtool_keee *e)
{
	int ret;

	ret = ksz_validate_eee(ds, port);
	if (ret)
		return ret;

	/* There is no documented control of Tx LPI configuration. */
	e->tx_lpi_enabled = true;

@@ -3501,11 +3495,6 @@ static int ksz_set_mac_eee(struct dsa_switch *ds, int port,
			   struct ethtool_keee *e)
{
	struct ksz_device *dev = ds->priv;
	int ret;

	ret = ksz_validate_eee(ds, port);
	if (ret)
		return ret;

	if (!e->tx_lpi_enabled) {
		dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n");
@@ -4651,6 +4640,7 @@ static const struct dsa_switch_ops ksz_switch_ops = {
	.cls_flower_add		= ksz_cls_flower_add,
	.cls_flower_del		= ksz_cls_flower_del,
	.port_setup_tc		= ksz_setup_tc,
	.support_eee		= ksz_support_eee,
	.get_mac_eee		= ksz_get_mac_eee,
	.set_mac_eee		= ksz_set_mac_eee,
	.port_get_default_prio	= ksz_port_get_default_prio,
+1 −0
Original line number Diff line number Diff line
@@ -3238,6 +3238,7 @@ const struct dsa_switch_ops mt7530_switch_ops = {
	.port_mirror_add	= mt753x_port_mirror_add,
	.port_mirror_del	= mt753x_port_mirror_del,
	.phylink_get_caps	= mt753x_phylink_get_caps,
	.support_eee		= dsa_supports_eee,
	.get_mac_eee		= mt753x_get_mac_eee,
	.set_mac_eee		= mt753x_set_mac_eee,
	.conduit_state_change	= mt753x_conduit_state_change,
Loading