]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5: Enlarge the NIC TC offload table size
authorOr Gerlitz <ogerlitz@mellanox.com>
Thu, 12 Jan 2017 14:19:29 +0000 (16:19 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Sun, 5 Nov 2017 04:27:01 +0000 (21:27 -0700)
The NIC TC offload table size was hard coded to 1k. Change it to be

      min(max NIC RX table size,
  min(max flow counters, 64k) * num flow groups)

where the max values are read from the firmware and the number of
flow groups is hard-coded as before this change.

We don't know upfront the division of flows to groups (== different masks).
This setup allows each group to be of size up to the where we want to go
(when supported, all offloaded flows use counters). Thus, we don't expect
multiple occurences for a group which in turn would add steering hops.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index 9ba1f72060aae4c57a55c9d7a4c049e1a6f8a69b..55979ec2e88a14f7123ad164769feefe9c730618 100644 (file)
@@ -90,8 +90,8 @@ enum {
        MLX5_HEADER_TYPE_NVGRE = 0x1,
 };
 
-#define MLX5E_TC_TABLE_NUM_ENTRIES 1024
 #define MLX5E_TC_TABLE_NUM_GROUPS 4
+#define MLX5E_TC_TABLE_MAX_GROUP_SIZE (1 << 16)
 
 struct mod_hdr_key {
        int num_actions;
@@ -263,10 +263,21 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
        }
 
        if (IS_ERR_OR_NULL(priv->fs.tc.t)) {
+               int tc_grp_size, tc_tbl_size;
+               u32 max_flow_counter;
+
+               max_flow_counter = (MLX5_CAP_GEN(dev, max_flow_counter_31_16) << 16) |
+                                   MLX5_CAP_GEN(dev, max_flow_counter_15_0);
+
+               tc_grp_size = min_t(int, max_flow_counter, MLX5E_TC_TABLE_MAX_GROUP_SIZE);
+
+               tc_tbl_size = min_t(int, tc_grp_size * MLX5E_TC_TABLE_NUM_GROUPS,
+                                   BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev, log_max_ft_size)));
+
                priv->fs.tc.t =
                        mlx5_create_auto_grouped_flow_table(priv->fs.ns,
                                                            MLX5E_TC_PRIO,
-                                                           MLX5E_TC_TABLE_NUM_ENTRIES,
+                                                           tc_tbl_size,
                                                            MLX5E_TC_TABLE_NUM_GROUPS,
                                                            0, 0);
                if (IS_ERR(priv->fs.tc.t)) {