net/mlx5: support flow counters using devx
[dpdk.git] / drivers / net / mlx5 / mlx5_prm.h
index 29742b1..da1219e 100644 (file)
@@ -280,8 +280,14 @@ struct mlx5_cqe {
 /* CQE format value. */
 #define MLX5_COMPRESSED 0x3
 
+/* Write a specific data value to a field. */
+#define MLX5_MODIFICATION_TYPE_SET 1
+
+/* Add a specific data value to a field. */
+#define MLX5_MODIFICATION_TYPE_ADD 2
+
 /* The field of packet to be modified. */
-enum mlx5_modificaiton_field {
+enum mlx5_modification_field {
        MLX5_MODI_OUT_SMAC_47_16 = 1,
        MLX5_MODI_OUT_SMAC_15_0,
        MLX5_MODI_OUT_ETHERTYPE,
@@ -337,23 +343,17 @@ struct mlx5_modification_cmd {
        union {
                uint32_t data0;
                struct {
-                       unsigned int bits:5;
+                       unsigned int length:5;
                        unsigned int rsvd0:3;
-                       unsigned int src_offset:5; /* Start bit offset. */
+                       unsigned int offset:5;
                        unsigned int rsvd1:3;
-                       unsigned int src_field:12;
-                       unsigned int type:4;
+                       unsigned int field:12;
+                       unsigned int action_type:4;
                };
        };
        union {
                uint32_t data1;
                uint8_t data[4];
-               struct {
-                       unsigned int rsvd2:8;
-                       unsigned int dst_offset:8;
-                       unsigned int dst_field:12;
-                       unsigned int rsvd3:4;
-               };
        };
 };
 
@@ -368,6 +368,7 @@ typedef uint8_t u8;
 #define __mlx5_dw_bit_off(typ, fld) (32 - __mlx5_bit_sz(typ, fld) - \
                                    (__mlx5_bit_off(typ, fld) & 0x1f))
 #define __mlx5_dw_off(typ, fld) (__mlx5_bit_off(typ, fld) / 32)
+#define __mlx5_64_off(typ, fld) (__mlx5_bit_off(typ, fld) / 64)
 #define __mlx5_dw_mask(typ, fld) (__mlx5_mask(typ, fld) << \
                                  __mlx5_dw_bit_off(typ, fld))
 #define __mlx5_mask(typ, fld) ((u32)((1ull << __mlx5_bit_sz(typ, fld)) - 1))
@@ -375,6 +376,7 @@ typedef uint8_t u8;
 #define __mlx5_16_bit_off(typ, fld) (16 - __mlx5_bit_sz(typ, fld) - \
                                    (__mlx5_bit_off(typ, fld) & 0xf))
 #define __mlx5_mask16(typ, fld) ((u16)((1ull << __mlx5_bit_sz(typ, fld)) - 1))
+#define MLX5_ST_SZ_BYTES(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 8)
 #define MLX5_ST_SZ_DW(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 32)
 #define MLX5_ST_SZ_DB(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 8)
 #define MLX5_BYTE_OFF(typ, fld) (__mlx5_bit_off(typ, fld) / 8)
@@ -391,10 +393,16 @@ typedef uint8_t u8;
                                 (((_v) & __mlx5_mask(typ, fld)) << \
                                   __mlx5_dw_bit_off(typ, fld))); \
        } while (0)
+#define MLX5_GET(typ, p, fld) \
+       ((rte_be_to_cpu_32(*((__be32 *)(p) +\
+       __mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
+       __mlx5_mask(typ, fld))
 #define MLX5_GET16(typ, p, fld) \
        ((rte_be_to_cpu_16(*((__be16 *)(p) + \
          __mlx5_16_off(typ, fld))) >> __mlx5_16_bit_off(typ, fld)) & \
         __mlx5_mask16(typ, fld))
+#define MLX5_GET64(typ, p, fld) rte_be_to_cpu_64(*((__be64 *)(p) + \
+                                                  __mlx5_64_off(typ, fld)))
 #define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
 
 struct mlx5_ifc_fte_match_set_misc_bits {
@@ -500,6 +508,69 @@ enum {
        MLX5_MATCH_CRITERIA_ENABLE_MISC2_BIT
 };
 
+enum {
+       MLX5_CMD_OP_ALLOC_FLOW_COUNTER = 0x939,
+       MLX5_CMD_OP_QUERY_FLOW_COUNTER = 0x93b,
+};
+
+/* Flow counters. */
+struct mlx5_ifc_alloc_flow_counter_out_bits {
+       u8         status[0x8];
+       u8         reserved_at_8[0x18];
+       u8         syndrome[0x20];
+       u8         flow_counter_id[0x20];
+       u8         reserved_at_60[0x20];
+};
+
+struct mlx5_ifc_alloc_flow_counter_in_bits {
+       u8         opcode[0x10];
+       u8         reserved_at_10[0x10];
+       u8         reserved_at_20[0x10];
+       u8         op_mod[0x10];
+       u8         reserved_at_40[0x40];
+};
+
+struct mlx5_ifc_dealloc_flow_counter_out_bits {
+       u8         status[0x8];
+       u8         reserved_at_8[0x18];
+       u8         syndrome[0x20];
+       u8         reserved_at_40[0x40];
+};
+
+struct mlx5_ifc_dealloc_flow_counter_in_bits {
+       u8         opcode[0x10];
+       u8         reserved_at_10[0x10];
+       u8         reserved_at_20[0x10];
+       u8         op_mod[0x10];
+       u8         flow_counter_id[0x20];
+       u8         reserved_at_60[0x20];
+};
+
+struct mlx5_ifc_traffic_counter_bits {
+       u8         packets[0x40];
+       u8         octets[0x40];
+};
+
+struct mlx5_ifc_query_flow_counter_out_bits {
+       u8         status[0x8];
+       u8         reserved_at_8[0x18];
+       u8         syndrome[0x20];
+       u8         reserved_at_40[0x40];
+       struct mlx5_ifc_traffic_counter_bits flow_statistics[];
+};
+
+struct mlx5_ifc_query_flow_counter_in_bits {
+       u8         opcode[0x10];
+       u8         reserved_at_10[0x10];
+       u8         reserved_at_20[0x10];
+       u8         op_mod[0x10];
+       u8         reserved_at_40[0x80];
+       u8         clear[0x1];
+       u8         reserved_at_c1[0xf];
+       u8         num_of_counters[0x10];
+       u8         flow_counter_id[0x20];
+};
+
 /* CQE format mask. */
 #define MLX5E_CQE_FORMAT_MASK 0xc