net/mlx5: Add flow counter bulk allocation hardware bits and command
authorGavi Teitz <gavi@mellanox.com>
Mon, 29 Jul 2019 21:12:54 +0000 (21:12 +0000)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 1 Aug 2019 18:14:24 +0000 (11:14 -0700)
Add a handle to invoke the new FW capability of allocating a bulk of
flow counters.

Signed-off-by: Gavi Teitz <gavi@mellanox.com>
Reviewed-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.h
include/linux/mlx5/mlx5_ifc.h

index 51f6972f4c70cfd16eafd65f36852e2f0f5f151e..b84a225bbe86cfe0a50b85caa645eb5da516e3bc 100644 (file)
@@ -566,7 +566,9 @@ static int mlx5_cmd_delete_fte(struct mlx5_flow_root_namespace *ns,
        return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
 }
 
-int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id)
+int mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev,
+                          enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask,
+                          u32 *id)
 {
        u32 in[MLX5_ST_SZ_DW(alloc_flow_counter_in)]   = {0};
        u32 out[MLX5_ST_SZ_DW(alloc_flow_counter_out)] = {0};
@@ -574,6 +576,7 @@ int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id)
 
        MLX5_SET(alloc_flow_counter_in, in, opcode,
                 MLX5_CMD_OP_ALLOC_FLOW_COUNTER);
+       MLX5_SET(alloc_flow_counter_in, in, flow_counter_bulk, alloc_bitmask);
 
        err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
        if (!err)
@@ -581,6 +584,11 @@ int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id)
        return err;
 }
 
+int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id)
+{
+       return mlx5_cmd_fc_bulk_alloc(dev, 0, id);
+}
+
 int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id)
 {
        u32 in[MLX5_ST_SZ_DW(dealloc_flow_counter_in)]   = {0};
index db49eabba98d377fc99e0649651785101ed9bfb8..bc4606306009843a3f9e6dba5e94d5f4b8c4d6e4 100644 (file)
@@ -78,6 +78,9 @@ struct mlx5_flow_cmds {
 };
 
 int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id);
+int mlx5_cmd_fc_bulk_alloc(struct mlx5_core_dev *dev,
+                          enum mlx5_fc_bulk_alloc_bitmask alloc_bitmask,
+                          u32 *id);
 int mlx5_cmd_fc_free(struct mlx5_core_dev *dev, u32 id);
 int mlx5_cmd_fc_query(struct mlx5_core_dev *dev, u32 id,
                      u64 *packets, u64 *bytes);
index b3d5752657d9893fbc83bdaf577d872ed9bde5a4..196987f14a3ff1da2c3b9a09ff7a4bf6e5b18b75 100644 (file)
@@ -1040,6 +1040,21 @@ enum {
        MLX5_UCTX_CAP_INTERNAL_DEV_RES = 1UL << 1,
 };
 
+#define MLX5_FC_BULK_SIZE_FACTOR 128
+
+enum mlx5_fc_bulk_alloc_bitmask {
+       MLX5_FC_BULK_128   = (1 << 0),
+       MLX5_FC_BULK_256   = (1 << 1),
+       MLX5_FC_BULK_512   = (1 << 2),
+       MLX5_FC_BULK_1024  = (1 << 3),
+       MLX5_FC_BULK_2048  = (1 << 4),
+       MLX5_FC_BULK_4096  = (1 << 5),
+       MLX5_FC_BULK_8192  = (1 << 6),
+       MLX5_FC_BULK_16384 = (1 << 7),
+};
+
+#define MLX5_FC_BULK_NUM_FCS(fc_enum) (MLX5_FC_BULK_SIZE_FACTOR * (fc_enum))
+
 struct mlx5_ifc_cmd_hca_cap_bits {
        u8         reserved_at_0[0x30];
        u8         vhca_id[0x10];
@@ -1244,7 +1259,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {
        u8         reserved_at_2e0[0x7];
        u8         max_qp_mcg[0x19];
 
-       u8         reserved_at_300[0x18];
+       u8         reserved_at_300[0x10];
+       u8         flow_counter_bulk_alloc[0x8];
        u8         log_max_mcg[0x8];
 
        u8         reserved_at_320[0x3];
@@ -7815,7 +7831,8 @@ struct mlx5_ifc_alloc_flow_counter_in_bits {
        u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_at_40[0x40];
+       u8         reserved_at_40[0x38];
+       u8         flow_counter_bulk[0x8];
 };
 
 struct mlx5_ifc_add_vxlan_udp_dport_out_bits {