From d38001d30d47051eec265d68378abca7f5109e97 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Fri, 15 Jan 2021 13:52:58 +0100 Subject: [PATCH 1/2] net: dsa: mv88e6xxx: Provide dummy implementations for trunk setters Support for Global 2 registers is build-time optional. In the case where it was not enabled the build would fail as no "dummy" implementation of these functions was available. Fixes: 57e661aae6a8 ("net: dsa: mv88e6xxx: Link aggregation support") Reported-by: kernel test robot Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean Signed-off-by: Tobias Waldekranz Signed-off-by: Jakub Kicinski --- drivers/net/dsa/mv88e6xxx/global2.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/global2.h b/drivers/net/dsa/mv88e6xxx/global2.h index 60febaf4da76..253a79582a1d 100644 --- a/drivers/net/dsa/mv88e6xxx/global2.h +++ b/drivers/net/dsa/mv88e6xxx/global2.h @@ -525,6 +525,18 @@ static inline int mv88e6xxx_g2_trunk_clear(struct mv88e6xxx_chip *chip) return -EOPNOTSUPP; } +static inline int mv88e6xxx_g2_trunk_mask_write(struct mv88e6xxx_chip *chip, + int num, bool hash, u16 mask) +{ + return -EOPNOTSUPP; +} + +static inline int mv88e6xxx_g2_trunk_mapping_write(struct mv88e6xxx_chip *chip, + int id, u16 map) +{ + return -EOPNOTSUPP; +} + static inline int mv88e6xxx_g2_device_mapping_write(struct mv88e6xxx_chip *chip, int target, int port) { From b80dc51b72e29318e02baace1e3c4cfe6e772904 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Fri, 15 Jan 2021 13:52:59 +0100 Subject: [PATCH 2/2] net: dsa: mv88e6xxx: Only allow LAG offload on supported hardware There are chips that do have Global 2 registers, and therefore trunk mapping/mask tables are not available. Refuse the offload as early as possible on those devices. Fixes: 57e661aae6a8 ("net: dsa: mv88e6xxx: Link aggregation support") Signed-off-by: Tobias Waldekranz Reviewed-by: Vladimir Oltean Signed-off-by: Jakub Kicinski --- drivers/net/dsa/mv88e6xxx/chip.c | 6 +++++- drivers/net/dsa/mv88e6xxx/chip.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index dcb1726b68cc..91286d7b12c7 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -5385,9 +5385,13 @@ static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds, struct net_device *lag, struct netdev_lag_upper_info *info) { + struct mv88e6xxx_chip *chip = ds->priv; struct dsa_port *dp; int id, members = 0; + if (!mv88e6xxx_has_lag(chip)) + return false; + id = dsa_lag_id(ds->dst, lag); if (id < 0 || id >= ds->num_lag_ids) return false; @@ -5727,7 +5731,7 @@ static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) * 5-bit port mode, which we do not support. 640k^W16 ought to * be enough for anyone. */ - ds->num_lag_ids = 16; + ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0; dev_set_drvdata(dev, ds); diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index 3543055bcb51..788b3f585ef3 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -662,6 +662,11 @@ static inline bool mv88e6xxx_has_pvt(struct mv88e6xxx_chip *chip) return chip->info->pvt; } +static inline bool mv88e6xxx_has_lag(struct mv88e6xxx_chip *chip) +{ + return !!chip->info->global2_addr; +} + static inline unsigned int mv88e6xxx_num_databases(struct mv88e6xxx_chip *chip) { return chip->info->num_databases;