net/mlx5: prepare meter flow tables
[dpdk.git] / drivers / net / mlx5 / mlx5.h
index fab58c9..8f2c541 100644 (file)
@@ -169,6 +169,17 @@ struct mlx5_devx_mkey_attr {
        uint32_t pd;
 };
 
+/* HCA qos attributes. */
+struct mlx5_hca_qos_attr {
+       uint32_t sup:1; /* Whether QOS is supported. */
+       uint32_t srtcm_sup:1; /* Whether srTCM mode is supported. */
+       uint8_t log_max_flow_meter;
+       /* Power of the maximum supported meters. */
+       uint8_t flow_meter_reg_c_ids;
+       /* Bitmap of the reg_Cs available for flow meter to use. */
+
+};
+
 /* HCA supports this number of time periods for LRO. */
 #define MLX5_LRO_NUM_SUPP_PERIODS 4
 
@@ -195,6 +206,7 @@ struct mlx5_hca_attr {
        uint32_t log_max_hairpin_wq_data_sz:5;
        uint32_t log_max_hairpin_num_packets:5;
        uint32_t vhca_id:16;
+       struct mlx5_hca_qos_attr qos;
 };
 
 /* Flow list . */
@@ -566,6 +578,8 @@ struct mlx5_flow_tbl_resource {
 };
 
 #define MLX5_MAX_TABLES UINT16_MAX
+#define MLX5_FLOW_TABLE_LEVEL_METER (UINT16_MAX - 3)
+#define MLX5_FLOW_TABLE_LEVEL_SUFFIX (UINT16_MAX - 2)
 #define MLX5_HAIRPIN_TX_TABLE (UINT16_MAX - 1)
 /* Reserve the last two tables for metadata register copy. */
 #define MLX5_FLOW_MREG_ACT_TABLE_GROUP (MLX5_MAX_TABLES - 1)
@@ -632,12 +646,18 @@ struct mlx5_ibv_shared {
        void *fdb_domain; /* FDB Direct Rules name space handle. */
        struct mlx5_flow_tbl_resource fdb_tbl[MLX5_MAX_TABLES_FDB];
        /* FDB Direct Rules tables. */
+       struct mlx5_flow_tbl_resource *fdb_mtr_sfx_tbl;
+       /* FDB meter suffix rules table. */
        void *rx_domain; /* RX Direct Rules name space handle. */
        struct mlx5_flow_tbl_resource rx_tbl[MLX5_MAX_TABLES];
        /* RX Direct Rules tables. */
+       struct mlx5_flow_tbl_resource *rx_mtr_sfx_tbl;
+       /* RX meter suffix rules table. */
        void *tx_domain; /* TX Direct Rules name space handle. */
        struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
        /* TX Direct Rules tables. */
+       struct mlx5_flow_tbl_resource *tx_mtr_sfx_tbl;
+       /* TX meter suffix rules table. */
        void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
        void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
        /* TX Direct Rules tables/ */
@@ -672,6 +692,9 @@ struct mlx5_proc_priv {
        /* Table of UAR registers for each process. */
 };
 
+/* MTR profile list. */
+TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);
+
 #define MLX5_PROC_PRIV(port_id) \
        ((struct mlx5_proc_priv *)rte_eth_devices[port_id].process_private)
 
@@ -692,6 +715,7 @@ struct mlx5_priv {
        unsigned int master:1; /* Device is a E-Switch master. */
        unsigned int dr_shared:1; /* DV/DR data is shared. */
        unsigned int counter_fallback:1; /* Use counter fallback management. */
+       unsigned int mtr_en:1; /* Whether support meter. */
        uint16_t domain_id; /* Switch domain identifier. */
        uint16_t vport_id; /* Associated VF vport index (if any). */
        uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
@@ -739,6 +763,9 @@ struct mlx5_priv {
        struct mlx5_flow_id_pool *qrss_id_pool;
        struct mlx5_hlist *mreg_cp_tbl;
        /* Hash table of Rx metadata register copy table. */
+       uint8_t mtr_sfx_reg; /* Meter prefix-suffix flow match REG_C. */
+       uint8_t mtr_color_reg; /* Meter color match REG_C. */
+       struct mlx5_mtr_profiles flow_meter_profiles; /* MTR profile list. */
 #ifndef RTE_ARCH_64
        rte_spinlock_t uar_lock_cq; /* CQs share a common distinct UAR */
        rte_spinlock_t uar_lock[MLX5_UAR_PAGE_NUM_MAX];
@@ -1001,4 +1028,8 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_tis
        (struct ibv_context *ctx, struct mlx5_devx_tis_attr *tis_attr);
 struct mlx5_devx_obj *mlx5_devx_cmd_create_td(struct ibv_context *ctx);
 
+/* mlx5_flow_meter.c */
+
+int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);
+
 #endif /* RTE_PMD_MLX5_H_ */