net/mlx5: add table management
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
index 125d858..1579036 100644 (file)
@@ -452,6 +452,7 @@ enum mlx5_flow_drv_type {
        MLX5_FLOW_TYPE_MIN,
        MLX5_FLOW_TYPE_DV,
        MLX5_FLOW_TYPE_VERBS,
+       MLX5_FLOW_TYPE_HW,
        MLX5_FLOW_TYPE_MAX,
 };
 
@@ -697,7 +698,6 @@ struct mlx5_flow_handle {
        void *drv_flow; /**< pointer to driver flow object. */
        uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */
        uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */
-       uint32_t mark:1; /**< Metadata rxq mark flag. */
        uint32_t fate_action:3; /**< Fate action type. */
        uint32_t flex_item; /**< referenced Flex Item bitmask. */
        union {
@@ -964,7 +964,7 @@ is_tunnel_offload_active(const struct rte_eth_dev *dev)
 {
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
        const struct mlx5_priv *priv = dev->data->dev_private;
-       return !!priv->config.dv_miss_info;
+       return !!priv->sh->config.dv_miss_info;
 #else
        RTE_SET_USED(dev);
        return false;
@@ -1015,6 +1015,78 @@ struct rte_flow {
        uint32_t geneve_tlv_option; /**< Holds Geneve TLV option id. > */
 } __rte_packed;
 
+#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
+
+/* Flow item template struct. */
+struct rte_flow_pattern_template {
+       LIST_ENTRY(rte_flow_pattern_template) next;
+       /* Template attributes. */
+       struct rte_flow_pattern_template_attr attr;
+       struct mlx5dr_match_template *mt; /* mlx5 match template. */
+       uint32_t refcnt;  /* Reference counter. */
+};
+
+/* Flow action template struct. */
+struct rte_flow_actions_template {
+       LIST_ENTRY(rte_flow_actions_template) next;
+       /* Template attributes. */
+       struct rte_flow_actions_template_attr attr;
+       struct rte_flow_action *actions; /* Cached flow actions. */
+       struct rte_flow_action *masks; /* Cached action masks.*/
+       uint32_t refcnt; /* Reference counter. */
+};
+
+/* Jump action struct. */
+struct mlx5_hw_jump_action {
+       /* Action jump from root. */
+       struct mlx5dr_action *root_action;
+       /* HW steering jump action. */
+       struct mlx5dr_action *hws_action;
+};
+
+/* DR action set struct. */
+struct mlx5_hw_actions {
+       struct mlx5dr_action *drop; /* Drop action. */
+};
+
+/* mlx5 action template struct. */
+struct mlx5_hw_action_template {
+       /* Action template pointer. */
+       struct rte_flow_actions_template *action_template;
+       struct mlx5_hw_actions acts; /* Template actions. */
+};
+
+/* mlx5 flow group struct. */
+struct mlx5_flow_group {
+       struct mlx5_list_entry entry;
+       struct mlx5dr_table *tbl; /* HWS table object. */
+       struct mlx5_hw_jump_action jump; /* Jump action. */
+       enum mlx5dr_table_type type; /* Table type. */
+       uint32_t group_id; /* Group id. */
+       uint32_t idx; /* Group memory index. */
+};
+
+
+#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2
+#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32
+
+struct rte_flow_template_table {
+       LIST_ENTRY(rte_flow_template_table) next;
+       struct mlx5_flow_group *grp; /* The group rte_flow_template_table uses. */
+       struct mlx5dr_matcher *matcher; /* Template matcher. */
+       /* Item templates bind to the table. */
+       struct rte_flow_pattern_template *its[MLX5_HW_TBL_MAX_ITEM_TEMPLATE];
+       /* Action templates bind to the table. */
+       struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
+       struct mlx5_indexed_pool *flow; /* The table's flow ipool. */
+       uint32_t type; /* Flow table type RX/TX/FDB. */
+       uint8_t nb_item_templates; /* Item template number. */
+       uint8_t nb_action_templates; /* Action template number. */
+       uint32_t refcnt; /* Table reference counter. */
+};
+
+#endif
+
 /*
  * Define list of valid combinations of RX Hash fields
  * (see enum ibv_rx_hash_fields).
@@ -1108,6 +1180,7 @@ struct mlx5_flow_workspace {
        /* The final policy when meter policy is hierarchy. */
        uint32_t skip_matcher_reg:1;
        /* Indicates if need to skip matcher register in translate. */
+       uint32_t mark:1; /* Indicates if flow contains mark action. */
 };
 
 struct mlx5_flow_split_info {
@@ -1180,7 +1253,7 @@ typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
 typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
                                         uint32_t cnt,
                                         bool clear, uint64_t *pkts,
-                                        uint64_t *bytes);
+                                        uint64_t *bytes, void **action);
 typedef int (*mlx5_flow_get_aged_flows_t)
                                        (struct rte_eth_dev *dev,
                                         void **context,
@@ -1256,6 +1329,48 @@ typedef int (*mlx5_flow_item_update_t)
                         const struct rte_flow_item_flex_handle *handle,
                         const struct rte_flow_item_flex_conf *conf,
                         struct rte_flow_error *error);
+typedef int (*mlx5_flow_info_get_t)
+                       (struct rte_eth_dev *dev,
+                        struct rte_flow_port_info *port_info,
+                        struct rte_flow_queue_info *queue_info,
+                        struct rte_flow_error *error);
+typedef int (*mlx5_flow_port_configure_t)
+                       (struct rte_eth_dev *dev,
+                        const struct rte_flow_port_attr *port_attr,
+                        uint16_t nb_queue,
+                        const struct rte_flow_queue_attr *queue_attr[],
+                        struct rte_flow_error *err);
+typedef struct rte_flow_pattern_template *(*mlx5_flow_pattern_template_create_t)
+                       (struct rte_eth_dev *dev,
+                        const struct rte_flow_pattern_template_attr *attr,
+                        const struct rte_flow_item items[],
+                        struct rte_flow_error *error);
+typedef int (*mlx5_flow_pattern_template_destroy_t)
+                       (struct rte_eth_dev *dev,
+                        struct rte_flow_pattern_template *template,
+                        struct rte_flow_error *error);
+typedef struct rte_flow_actions_template *(*mlx5_flow_actions_template_create_t)
+                       (struct rte_eth_dev *dev,
+                        const struct rte_flow_actions_template_attr *attr,
+                        const struct rte_flow_action actions[],
+                        const struct rte_flow_action masks[],
+                        struct rte_flow_error *error);
+typedef int (*mlx5_flow_actions_template_destroy_t)
+                       (struct rte_eth_dev *dev,
+                        struct rte_flow_actions_template *template,
+                        struct rte_flow_error *error);
+typedef struct rte_flow_template_table *(*mlx5_flow_table_create_t)
+               (struct rte_eth_dev *dev,
+                const struct rte_flow_template_table_attr *attr,
+                struct rte_flow_pattern_template *item_templates[],
+                uint8_t nb_item_templates,
+                struct rte_flow_actions_template *action_templates[],
+                uint8_t nb_action_templates,
+                struct rte_flow_error *error);
+typedef int (*mlx5_flow_table_destroy_t)
+                       (struct rte_eth_dev *dev,
+                        struct rte_flow_template_table *table,
+                        struct rte_flow_error *error);
 
 struct mlx5_flow_driver_ops {
        mlx5_flow_validate_t validate;
@@ -1294,6 +1409,14 @@ struct mlx5_flow_driver_ops {
        mlx5_flow_item_create_t item_create;
        mlx5_flow_item_release_t item_release;
        mlx5_flow_item_update_t item_update;
+       mlx5_flow_info_get_t info_get;
+       mlx5_flow_port_configure_t configure;
+       mlx5_flow_pattern_template_create_t pattern_template_create;
+       mlx5_flow_pattern_template_destroy_t pattern_template_destroy;
+       mlx5_flow_actions_template_create_t actions_template_create;
+       mlx5_flow_actions_template_destroy_t actions_template_destroy;
+       mlx5_flow_table_create_t template_table_create;
+       mlx5_flow_table_destroy_t template_table_destroy;
 };
 
 /* mlx5_flow.c */
@@ -1723,11 +1846,16 @@ struct mlx5_list_entry *flow_dv_dest_array_clone_cb(void *tool_ctx,
                                   struct mlx5_list_entry *entry, void *cb_ctx);
 void flow_dv_dest_array_clone_free_cb(void *tool_ctx,
                                      struct mlx5_list_entry *entry);
-int flow_dv_query_count_ptr(struct rte_eth_dev *dev, uint32_t cnt_idx,
-                               void **action, struct rte_flow_error *error);
-int
-flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data,
-                   struct rte_flow_error *error);
+
+struct mlx5_list_entry *flow_hw_grp_create_cb(void *tool_ctx, void *cb_ctx);
+void flow_hw_grp_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
+int flow_hw_grp_match_cb(void *tool_ctx,
+                        struct mlx5_list_entry *entry,
+                        void *cb_ctx);
+struct mlx5_list_entry *flow_hw_grp_clone_cb(void *tool_ctx,
+                                            struct mlx5_list_entry *oentry,
+                                            void *cb_ctx);
+void flow_hw_grp_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
 
 struct mlx5_aso_age_action *flow_aso_age_get_by_idx(struct rte_eth_dev *dev,
                                                    uint32_t age_idx);
@@ -1766,4 +1894,6 @@ const struct mlx5_flow_tunnel *
 mlx5_get_tof(const struct rte_flow_item *items,
             const struct rte_flow_action *actions,
             enum mlx5_tof_rule_type *rule_type);
+void
+flow_hw_resource_release(struct rte_eth_dev *dev);
 #endif /* RTE_PMD_MLX5_FLOW_H_ */