mlxsw: Use dscp_t in struct mlxsw_sp_fib4_entry
authorGuillaume Nault <gnault@redhat.com>
Fri, 8 Apr 2022 20:08:46 +0000 (22:08 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Apr 2022 00:38:01 +0000 (17:38 -0700)
Use the new dscp_t type to replace the tos field of struct
mlxsw_sp_fib4_entry. This ensures ECN bits are ignored and makes it
compatible with the dscp fields of fib_entry_notifier_info and
fib_rt_info.

This also allows sparse to flag potential incorrect uses of DSCP and
ECN bits.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 1c451d6..dc820d9 100644 (file)
@@ -508,7 +508,7 @@ struct mlxsw_sp_fib4_entry {
        struct mlxsw_sp_fib_entry common;
        struct fib_info *fi;
        u32 tb_id;
-       u8 tos;
+       dscp_t dscp;
        u8 type;
 };
 
@@ -5560,7 +5560,7 @@ mlxsw_sp_fib4_entry_should_offload(const struct mlxsw_sp_fib_entry *fib_entry)
 
        fib4_entry = container_of(fib_entry, struct mlxsw_sp_fib4_entry,
                                  common);
-       return !fib4_entry->tos;
+       return !fib4_entry->dscp;
 }
 
 static bool
@@ -5646,7 +5646,7 @@ mlxsw_sp_fib4_entry_hw_flags_set(struct mlxsw_sp *mlxsw_sp,
        fri.tb_id = fib4_entry->tb_id;
        fri.dst = cpu_to_be32(*p_dst);
        fri.dst_len = dst_len;
-       fri.dscp = inet_dsfield_to_dscp(fib4_entry->tos);
+       fri.dscp = fib4_entry->dscp;
        fri.type = fib4_entry->type;
        fri.offload = should_offload;
        fri.trap = !should_offload;
@@ -5669,7 +5669,7 @@ mlxsw_sp_fib4_entry_hw_flags_clear(struct mlxsw_sp *mlxsw_sp,
        fri.tb_id = fib4_entry->tb_id;
        fri.dst = cpu_to_be32(*p_dst);
        fri.dst_len = dst_len;
-       fri.dscp = inet_dsfield_to_dscp(fib4_entry->tos);
+       fri.dscp = fib4_entry->dscp;
        fri.type = fib4_entry->type;
        fri.offload = false;
        fri.trap = false;
@@ -6251,7 +6251,7 @@ mlxsw_sp_fib4_entry_create(struct mlxsw_sp *mlxsw_sp,
        fib_info_hold(fib4_entry->fi);
        fib4_entry->tb_id = fen_info->tb_id;
        fib4_entry->type = fen_info->type;
-       fib4_entry->tos = inet_dscp_to_dsfield(fen_info->dscp);
+       fib4_entry->dscp = fen_info->dscp;
 
        fib_entry->fib_node = fib_node;
 
@@ -6305,7 +6305,7 @@ mlxsw_sp_fib4_entry_lookup(struct mlxsw_sp *mlxsw_sp,
        fib4_entry = container_of(fib_node->fib_entry,
                                  struct mlxsw_sp_fib4_entry, common);
        if (fib4_entry->tb_id == fen_info->tb_id &&
-           fib4_entry->tos == inet_dscp_to_dsfield(fen_info->dscp) &&
+           fib4_entry->dscp == fen_info->dscp &&
            fib4_entry->type == fen_info->type &&
            fib4_entry->fi == fen_info->fi)
                return fib4_entry;