net/mlx5: share tag between meter and metadata
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index 672552b..bbce63d 100644 (file)
@@ -201,6 +201,7 @@ enum mlx5_feature_name {
 #define MLX5_FLOW_ACTION_SET_TAG (1ull << 32)
 #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 33)
 #define MLX5_FLOW_ACTION_SET_META (1ull << 34)
+#define MLX5_FLOW_ACTION_METER (1ull << 35)
 
 #define MLX5_FLOW_FATE_ACTIONS \
        (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
@@ -519,7 +520,10 @@ struct mlx5_flow {
 #endif
                struct mlx5_flow_verbs verbs;
        };
-       uint32_t qrss_id; /**< Uniqie Q/RSS suffix subflow tag. */
+       union {
+               uint32_t qrss_id; /**< Uniqie Q/RSS suffix subflow tag. */
+               uint32_t mtr_flow_id; /**< Unique meter match flow id. */
+       };
        bool external; /**< true if the flow is created external to PMD. */
 };
 
@@ -531,6 +535,14 @@ struct mlx5_flow {
 /* Modify this value if enum rte_mtr_color changes. */
 #define RTE_MTR_DROPPED RTE_COLORS
 
+/* Meter policer statistics */
+struct mlx5_flow_policer_stats {
+       struct mlx5_flow_counter *cnt[RTE_COLORS + 1];
+       /**< Color counter, extra for drop. */
+       uint64_t stats_mask;
+       /**< Statistics mask for the colors. */
+};
+
 /* Meter table structure. */
 struct mlx5_meter_domain_info {
        struct mlx5_flow_tbl_resource *tbl;
@@ -557,6 +569,8 @@ struct mlx5_meter_domains_infos {
        /**< FDB meter table. */
        void *drop_actn;
        /**< Drop action as not matched. */
+       void *count_actns[RTE_MTR_DROPPED + 1];
+       /**< Counters for match and unmatched statistics. */
        uint32_t fmp[MLX5_ST_SZ_DW(flow_meter_parameters)];
        /**< Flow meter parameter. */
        size_t fmp_size;
@@ -575,8 +589,12 @@ struct mlx5_flow_meter {
        /**< Meter rule parameters. */
        struct mlx5_flow_meter_profile *profile;
        /**< Meter profile parameters. */
+       struct rte_flow_attr attr;
+       /**< Flow attributes. */
        struct mlx5_meter_domains_infos *mfts;
        /**< Flow table created for this meter. */
+       struct mlx5_flow_policer_stats policer_stats;
+       /**< Meter policer statistics. */
        uint32_t ref_cnt;
        /**< Use count. */
        uint32_t active_state:1;
@@ -619,6 +637,7 @@ struct rte_flow {
        struct mlx5_flow_counter *counter; /**< Holds flow counter. */
        struct mlx5_flow_mreg_copy_resource *mreg_copy;
        /**< pointer to metadata register copy table resource. */
+       struct mlx5_flow_meter *meter; /**< Holds flow meter. */
        LIST_HEAD(dev_flows, mlx5_flow) dev_flows;
        /**< Device flows that are part of the flow. */
        struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */
@@ -653,7 +672,8 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,
                                 void *data,
                                 struct rte_flow_error *error);
 typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t)
-                                           (struct rte_eth_dev *dev);
+                                           (struct rte_eth_dev *dev,
+                                            const struct mlx5_flow_meter *fm);
 typedef int (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,
                                        struct mlx5_meter_domains_infos *tbls);
 typedef int (*mlx5_flow_create_policer_rules_t)
@@ -664,6 +684,14 @@ typedef int (*mlx5_flow_destroy_policer_rules_t)
                                        (struct rte_eth_dev *dev,
                                         const struct mlx5_flow_meter *fm,
                                         const struct rte_flow_attr *attr);
+typedef struct mlx5_flow_counter * (*mlx5_flow_counter_alloc_t)
+                                  (struct rte_eth_dev *dev);
+typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
+                                        struct mlx5_flow_counter *cnt);
+typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
+                                        struct mlx5_flow_counter *cnt,
+                                        bool clear, uint64_t *pkts,
+                                        uint64_t *bytes);
 struct mlx5_flow_driver_ops {
        mlx5_flow_validate_t validate;
        mlx5_flow_prepare_t prepare;
@@ -676,6 +704,9 @@ struct mlx5_flow_driver_ops {
        mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;
        mlx5_flow_create_policer_rules_t create_policer_rules;
        mlx5_flow_destroy_policer_rules_t destroy_policer_rules;
+       mlx5_flow_counter_alloc_t counter_alloc;
+       mlx5_flow_counter_free_t counter_free;
+       mlx5_flow_counter_query_t counter_query;
 };
 
 
@@ -803,7 +834,8 @@ int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
                                   struct rte_eth_dev *dev,
                                   struct rte_flow_error *error);
 struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls
-                                       (struct rte_eth_dev *dev);
+                                       (struct rte_eth_dev *dev,
+                                        const struct mlx5_flow_meter *fm);
 int mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,
                               struct mlx5_meter_domains_infos *tbl);
 int mlx5_flow_create_policer_rules(struct rte_eth_dev *dev,