]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: spectrum_router: Update hardware flags on nexthop buckets
authorIdo Schimmel <idosch@nvidia.com>
Wed, 24 Mar 2021 20:14:19 +0000 (22:14 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Mar 2021 23:34:57 +0000 (16:34 -0700)
So far, mlxsw only updated hardware flags ('offload' / 'trap') on
nexthop objects. For resilient nexthop groups, these flags need to be
updated on individual nexthop buckets as well.

Update these flags whenever updating the flags of the encapsulating
nexthop object and whenever a nexthop bucket is replaced.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index d6e91f1f48cc6eeaf065c2d766a7130ed211d60a..862c8667813bf0a0647f26ecf7cd14b3183fca8c 100644 (file)
@@ -3762,10 +3762,30 @@ mlxsw_sp_nexthop6_group_offload_refresh(struct mlxsw_sp *mlxsw_sp,
                __mlxsw_sp_nexthop6_group_offload_refresh(nh_grp, fib6_entry);
 }
 
+static void
+mlxsw_sp_nexthop_bucket_offload_refresh(struct mlxsw_sp *mlxsw_sp,
+                                       const struct mlxsw_sp_nexthop *nh,
+                                       u16 bucket_index)
+{
+       struct mlxsw_sp_nexthop_group *nh_grp = nh->nhgi->nh_grp;
+       bool offload = false, trap = false;
+
+       if (nh->offloaded) {
+               if (nh->action == MLXSW_SP_NEXTHOP_ACTION_TRAP)
+                       trap = true;
+               else
+                       offload = true;
+       }
+       nexthop_bucket_set_hw_flags(mlxsw_sp_net(mlxsw_sp), nh_grp->obj.id,
+                                   bucket_index, offload, trap);
+}
+
 static void
 mlxsw_sp_nexthop_obj_group_offload_refresh(struct mlxsw_sp *mlxsw_sp,
                                           struct mlxsw_sp_nexthop_group *nh_grp)
 {
+       int i;
+
        /* Do not update the flags if the nexthop group is being destroyed
         * since:
         * 1. The nexthop objects is being deleted, in which case the flags are
@@ -3779,6 +3799,18 @@ mlxsw_sp_nexthop_obj_group_offload_refresh(struct mlxsw_sp *mlxsw_sp,
 
        nexthop_set_hw_flags(mlxsw_sp_net(mlxsw_sp), nh_grp->obj.id,
                             nh_grp->nhgi->adj_index_valid, false);
+
+       /* Update flags of individual nexthop buckets in case of a resilient
+        * nexthop group.
+        */
+       if (!nh_grp->nhgi->is_resilient)
+               return;
+
+       for (i = 0; i < nh_grp->nhgi->count; i++) {
+               struct mlxsw_sp_nexthop *nh = &nh_grp->nhgi->nexthops[i];
+
+               mlxsw_sp_nexthop_bucket_offload_refresh(mlxsw_sp, nh, i);
+       }
 }
 
 static void
@@ -3832,6 +3864,10 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
                        dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n");
                        goto set_trap;
                }
+               /* Flags of individual nexthop buckets might need to be
+                * updated.
+                */
+               mlxsw_sp_nexthop_group_offload_refresh(mlxsw_sp, nh_grp);
                return 0;
        }
        mlxsw_sp_nexthop_group_normalize(nhgi);
@@ -4881,6 +4917,7 @@ mlxsw_sp_nexthop_obj_bucket_adj_update(struct mlxsw_sp *mlxsw_sp,
 
        nh->update = 0;
        nh->offloaded = 1;
+       mlxsw_sp_nexthop_bucket_offload_refresh(mlxsw_sp, nh, bucket_index);
 
        return 0;
 }