Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jakub Kicinski <kuba@kernel.org>

+45 -23
+7 -6
drivers/net/dsa/b53/b53_common.c
··· 2224 2224 } 2225 2225 EXPORT_SYMBOL(b53_eee_init); 2226 2226 2227 - int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) 2227 + bool b53_support_eee(struct dsa_switch *ds, int port) 2228 2228 { 2229 2229 struct b53_device *dev = ds->priv; 2230 2230 2231 - if (is5325(dev) || is5365(dev)) 2232 - return -EOPNOTSUPP; 2231 + return !is5325(dev) && !is5365(dev); 2232 + } 2233 + EXPORT_SYMBOL(b53_support_eee); 2233 2234 2235 + int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e) 2236 + { 2234 2237 return 0; 2235 2238 } 2236 2239 EXPORT_SYMBOL(b53_get_mac_eee); ··· 2242 2239 { 2243 2240 struct b53_device *dev = ds->priv; 2244 2241 struct ethtool_keee *p = &dev->ports[port].eee; 2245 - 2246 - if (is5325(dev) || is5365(dev)) 2247 - return -EOPNOTSUPP; 2248 2242 2249 2243 p->eee_enabled = e->eee_enabled; 2250 2244 b53_eee_enable_set(ds, port, e->eee_enabled); ··· 2298 2298 .phylink_get_caps = b53_phylink_get_caps, 2299 2299 .port_enable = b53_enable_port, 2300 2300 .port_disable = b53_disable_port, 2301 + .support_eee = b53_support_eee, 2301 2302 .get_mac_eee = b53_get_mac_eee, 2302 2303 .set_mac_eee = b53_set_mac_eee, 2303 2304 .port_bridge_join = b53_br_join,
+1
drivers/net/dsa/b53/b53_priv.h
··· 384 384 void b53_disable_port(struct dsa_switch *ds, int port); 385 385 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port); 386 386 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy); 387 + bool b53_support_eee(struct dsa_switch *ds, int port); 387 388 int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e); 388 389 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_keee *e); 389 390
+1
drivers/net/dsa/bcm_sf2.c
··· 1232 1232 .set_wol = bcm_sf2_sw_set_wol, 1233 1233 .port_enable = bcm_sf2_port_setup, 1234 1234 .port_disable = bcm_sf2_port_disable, 1235 + .support_eee = b53_support_eee, 1235 1236 .get_mac_eee = b53_get_mac_eee, 1236 1237 .set_mac_eee = b53_set_mac_eee, 1237 1238 .port_bridge_join = b53_br_join,
+5 -15
drivers/net/dsa/microchip/ksz_common.c
··· 3454 3454 return -EOPNOTSUPP; 3455 3455 } 3456 3456 3457 - static int ksz_validate_eee(struct dsa_switch *ds, int port) 3457 + static bool ksz_support_eee(struct dsa_switch *ds, int port) 3458 3458 { 3459 3459 struct ksz_device *dev = ds->priv; 3460 3460 3461 3461 if (!dev->info->internal_phy[port]) 3462 - return -EOPNOTSUPP; 3462 + return false; 3463 3463 3464 3464 switch (dev->chip_id) { 3465 3465 case KSZ8563_CHIP_ID: ··· 3471 3471 case KSZ9896_CHIP_ID: 3472 3472 case KSZ9897_CHIP_ID: 3473 3473 case LAN9646_CHIP_ID: 3474 - return 0; 3474 + return true; 3475 3475 } 3476 3476 3477 - return -EOPNOTSUPP; 3477 + return false; 3478 3478 } 3479 3479 3480 3480 static int ksz_get_mac_eee(struct dsa_switch *ds, int port, 3481 3481 struct ethtool_keee *e) 3482 3482 { 3483 - int ret; 3484 - 3485 - ret = ksz_validate_eee(ds, port); 3486 - if (ret) 3487 - return ret; 3488 - 3489 3483 /* There is no documented control of Tx LPI configuration. */ 3490 3484 e->tx_lpi_enabled = true; 3491 3485 ··· 3495 3501 struct ethtool_keee *e) 3496 3502 { 3497 3503 struct ksz_device *dev = ds->priv; 3498 - int ret; 3499 - 3500 - ret = ksz_validate_eee(ds, port); 3501 - if (ret) 3502 - return ret; 3503 3504 3504 3505 if (!e->tx_lpi_enabled) { 3505 3506 dev_err(dev->dev, "Disabling EEE Tx LPI is not supported\n"); ··· 4640 4651 .cls_flower_add = ksz_cls_flower_add, 4641 4652 .cls_flower_del = ksz_cls_flower_del, 4642 4653 .port_setup_tc = ksz_setup_tc, 4654 + .support_eee = ksz_support_eee, 4643 4655 .get_mac_eee = ksz_get_mac_eee, 4644 4656 .set_mac_eee = ksz_set_mac_eee, 4645 4657 .port_get_default_prio = ksz_port_get_default_prio,
+1
drivers/net/dsa/mt7530.c
··· 3238 3238 .port_mirror_add = mt753x_port_mirror_add, 3239 3239 .port_mirror_del = mt753x_port_mirror_del, 3240 3240 .phylink_get_caps = mt753x_phylink_get_caps, 3241 + .support_eee = dsa_supports_eee, 3241 3242 .get_mac_eee = mt753x_get_mac_eee, 3242 3243 .set_mac_eee = mt753x_set_mac_eee, 3243 3244 .conduit_state_change = mt753x_conduit_state_change,
+1
drivers/net/dsa/mv88e6xxx/chip.c
··· 7099 7099 .get_sset_count = mv88e6xxx_get_sset_count, 7100 7100 .port_max_mtu = mv88e6xxx_get_max_mtu, 7101 7101 .port_change_mtu = mv88e6xxx_change_mtu, 7102 + .support_eee = dsa_supports_eee, 7102 7103 .get_mac_eee = mv88e6xxx_get_mac_eee, 7103 7104 .set_mac_eee = mv88e6xxx_set_mac_eee, 7104 7105 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
+1
drivers/net/dsa/qca/qca8k-8xxx.c
··· 2016 2016 .get_ethtool_stats = qca8k_get_ethtool_stats, 2017 2017 .get_sset_count = qca8k_get_sset_count, 2018 2018 .set_ageing_time = qca8k_set_ageing_time, 2019 + .support_eee = dsa_supports_eee, 2019 2020 .get_mac_eee = qca8k_get_mac_eee, 2020 2021 .set_mac_eee = qca8k_set_mac_eee, 2021 2022 .port_enable = qca8k_port_enable,
+2
include/net/dsa.h
··· 988 988 /* 989 989 * Port's MAC EEE settings 990 990 */ 991 + bool (*support_eee)(struct dsa_switch *ds, int port); 991 992 int (*set_mac_eee)(struct dsa_switch *ds, int port, 992 993 struct ethtool_keee *e); 993 994 int (*get_mac_eee)(struct dsa_switch *ds, int port, ··· 1384 1383 1385 1384 netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev); 1386 1385 void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up); 1386 + bool dsa_supports_eee(struct dsa_switch *ds, int port); 1387 1387 1388 1388 #endif
+16
net/dsa/port.c
··· 1575 1575 cpu_dp->tag_ops = tag_ops; 1576 1576 } 1577 1577 1578 + /* dsa_supports_eee - indicate that EEE is supported 1579 + * @ds: pointer to &struct dsa_switch 1580 + * @port: port index 1581 + * 1582 + * A default implementation for the .support_eee() DSA operations member, 1583 + * which drivers can use to indicate that they support EEE on all of their 1584 + * user ports. 1585 + * 1586 + * Returns: true 1587 + */ 1588 + bool dsa_supports_eee(struct dsa_switch *ds, int port) 1589 + { 1590 + return true; 1591 + } 1592 + EXPORT_SYMBOL_GPL(dsa_supports_eee); 1593 + 1578 1594 static void dsa_port_phylink_mac_config(struct phylink_config *config, 1579 1595 unsigned int mode, 1580 1596 const struct phylink_link_state *state)
+10 -2
net/dsa/user.c
··· 1229 1229 struct dsa_switch *ds = dp->ds; 1230 1230 int ret; 1231 1231 1232 + /* Check whether the switch supports EEE */ 1233 + if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index)) 1234 + return -EOPNOTSUPP; 1235 + 1232 1236 /* Port's PHY and MAC both need to be EEE capable */ 1233 - if (!dev->phydev || !dp->pl) 1237 + if (!dev->phydev) 1234 1238 return -ENODEV; 1235 1239 1236 1240 if (!ds->ops->set_mac_eee) ··· 1253 1249 struct dsa_switch *ds = dp->ds; 1254 1250 int ret; 1255 1251 1252 + /* Check whether the switch supports EEE */ 1253 + if (!ds->ops->support_eee || !ds->ops->support_eee(ds, dp->index)) 1254 + return -EOPNOTSUPP; 1255 + 1256 1256 /* Port's PHY and MAC both need to be EEE capable */ 1257 - if (!dev->phydev || !dp->pl) 1257 + if (!dev->phydev) 1258 1258 return -ENODEV; 1259 1259 1260 1260 if (!ds->ops->get_mac_eee)