OSDN Git Service

net: dsa: mv88e6xxx: Only allow LAG offload on supported hardware
authorTobias Waldekranz <tobias@waldekranz.com>
Fri, 15 Jan 2021 12:52:59 +0000 (13:52 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 16 Jan 2021 00:08:51 +0000 (16:08 -0800)
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 <tobias@waldekranz.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/chip.h

index dcb1726..91286d7 100644 (file)
@@ -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);
 
index 3543055..788b3f5 100644 (file)
@@ -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;