net/mlx5e: reduce stack usage in mlx5_eswitch_termtbl_create
authorArnd Bergmann <arnd@arndb.de>
Tue, 18 Jun 2019 11:15:06 +0000 (13:15 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 28 Jun 2019 23:03:59 +0000 (16:03 -0700)
Putting an empty 'mlx5_flow_spec' structure on the stack is a bit
wasteful and causes a warning on 32-bit architectures when building
with clang -fsanitize-coverage:

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c: In function 'mlx5_eswitch_termtbl_create':
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c:90:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Since the structure is never written to, we can statically allocate
it to avoid the stack usage. To be on the safe side, mark all
subsequent function arguments that we pass it into as 'const'
as well.

Fixes: 10caabdaad5a ("net/mlx5e: Use termination table for VLAN push actions")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
include/linux/mlx5/fs.h

index cb7d8ebe2c95a36ef3f1c81ba16647ad1fcab058..1d55a324a17e3d00b779d8fce3ad77b914471bdb 100644 (file)
@@ -49,8 +49,8 @@ mlx5_eswitch_termtbl_create(struct mlx5_core_dev *dev,
                            struct mlx5_termtbl_handle *tt,
                            struct mlx5_flow_act *flow_act)
 {
+       static const struct mlx5_flow_spec spec = {};
        struct mlx5_flow_namespace *root_ns;
-       struct mlx5_flow_spec spec = {};
        int prio, flags;
        int err;
 
index 585e7adcbf9969cd30a39bd17a0dfe3e4adc9800..a68a51c5011aac14cc9252db770335e92ac75213 100644 (file)
@@ -584,7 +584,7 @@ err_ida_remove:
 }
 
 static struct fs_fte *alloc_fte(struct mlx5_flow_table *ft,
-                               struct mlx5_flow_spec *spec,
+                               const struct mlx5_flow_spec *spec,
                                struct mlx5_flow_act *flow_act)
 {
        struct mlx5_flow_steering *steering = get_steering(&ft->node);
@@ -613,7 +613,7 @@ static void dealloc_flow_group(struct mlx5_flow_steering *steering,
 
 static struct mlx5_flow_group *alloc_flow_group(struct mlx5_flow_steering *steering,
                                                u8 match_criteria_enable,
-                                               void *match_criteria,
+                                               const void *match_criteria,
                                                int start_index,
                                                int end_index)
 {
@@ -643,7 +643,7 @@ static struct mlx5_flow_group *alloc_flow_group(struct mlx5_flow_steering *steer
 
 static struct mlx5_flow_group *alloc_insert_flow_group(struct mlx5_flow_table *ft,
                                                       u8 match_criteria_enable,
-                                                      void *match_criteria,
+                                                      const void *match_criteria,
                                                       int start_index,
                                                       int end_index,
                                                       struct list_head *prev)
@@ -1286,7 +1286,7 @@ free_handle:
 }
 
 static struct mlx5_flow_group *alloc_auto_flow_group(struct mlx5_flow_table  *ft,
-                                                    struct mlx5_flow_spec *spec)
+                                                    const struct mlx5_flow_spec *spec)
 {
        struct list_head *prev = &ft->node.children;
        struct mlx5_flow_group *fg;
@@ -1454,7 +1454,7 @@ static int check_conflicting_ftes(struct fs_fte *fte,
 }
 
 static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg,
-                                           struct mlx5_flow_spec *spec,
+                                           const struct mlx5_flow_spec *spec,
                                            struct mlx5_flow_act *flow_act,
                                            struct mlx5_flow_destination *dest,
                                            int dest_num,
@@ -1539,7 +1539,7 @@ static void free_match_list(struct match_list_head *head)
 
 static int build_match_list(struct match_list_head *match_head,
                            struct mlx5_flow_table *ft,
-                           struct mlx5_flow_spec *spec)
+                           const struct mlx5_flow_spec *spec)
 {
        struct rhlist_head *tmp, *list;
        struct mlx5_flow_group *g;
@@ -1592,7 +1592,7 @@ static u64 matched_fgs_get_version(struct list_head *match_head)
 
 static struct fs_fte *
 lookup_fte_locked(struct mlx5_flow_group *g,
-                 u32 *match_value,
+                 const u32 *match_value,
                  bool take_write)
 {
        struct fs_fte *fte_tmp;
@@ -1625,7 +1625,7 @@ out:
 static struct mlx5_flow_handle *
 try_add_to_existing_fg(struct mlx5_flow_table *ft,
                       struct list_head *match_head,
-                      struct mlx5_flow_spec *spec,
+                      const struct mlx5_flow_spec *spec,
                       struct mlx5_flow_act *flow_act,
                       struct mlx5_flow_destination *dest,
                       int dest_num,
@@ -1716,7 +1716,7 @@ out:
 
 static struct mlx5_flow_handle *
 _mlx5_add_flow_rules(struct mlx5_flow_table *ft,
-                    struct mlx5_flow_spec *spec,
+                    const struct mlx5_flow_spec *spec,
                     struct mlx5_flow_act *flow_act,
                     struct mlx5_flow_destination *dest,
                     int dest_num)
@@ -1823,7 +1823,7 @@ static bool fwd_next_prio_supported(struct mlx5_flow_table *ft)
 
 struct mlx5_flow_handle *
 mlx5_add_flow_rules(struct mlx5_flow_table *ft,
-                   struct mlx5_flow_spec *spec,
+                   const struct mlx5_flow_spec *spec,
                    struct mlx5_flow_act *flow_act,
                    struct mlx5_flow_destination *dest,
                    int num_dest)
index dc7e7aa53a132337302665807b2fb990672aae9f..04a569568eacb738bcc52a9389f96eb4fcafdd7f 100644 (file)
@@ -208,7 +208,7 @@ struct mlx5_flow_act {
  */
 struct mlx5_flow_handle *
 mlx5_add_flow_rules(struct mlx5_flow_table *ft,
-                   struct mlx5_flow_spec *spec,
+                   const struct mlx5_flow_spec *spec,
                    struct mlx5_flow_act *flow_act,
                    struct mlx5_flow_destination *dest,
                    int num_dest);