net/mlx5: add flex parser DevX object management
[dpdk.git] / drivers / net / mlx5 / mlx5.h
index 5768b82..63de652 100644 (file)
@@ -50,6 +50,9 @@
 #define MLX5_MAX_MODIFY_NUM                    32
 #define MLX5_ROOT_TBL_MODIFY_NUM               16
 
+/* Maximal number of flex items created on the port.*/
+#define MLX5_PORT_FLEX_ITEM_NUM                        4
+
 enum mlx5_ipool_index {
 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
        MLX5_IPOOL_DECAP_ENCAP = 0, /* Pool for encap/decap resource. */
@@ -270,9 +273,6 @@ struct mlx5_dev_config {
                /* Rx queue count threshold to enable MPRQ. */
        } mprq; /* Configurations for Multi-Packet RQ. */
        int mps; /* Multi-packet send supported mode. */
-       unsigned int flow_prio; /* Number of flow priorities. */
-       enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM];
-       /* Availibility of mreg_c's. */
        unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
        unsigned int ind_table_max_size; /* Maximum indirection table size. */
        unsigned int max_dump_files_num; /* Maximum dump files per queue. */
@@ -552,7 +552,7 @@ struct mlx5_aso_age_mng {
        struct mlx5_aso_age_pool **pools;
        uint16_t n; /* Total number of pools. */
        uint16_t next; /* Number of pools in use, index of next free pool. */
-       rte_spinlock_t resize_sl; /* Lock for resize objects. */
+       rte_rwlock_t resize_rwl; /* Lock for resize objects. */
        rte_spinlock_t free_sl; /* Lock for free list access. */
        struct aso_age_list free; /* Free age actions list - ready to use. */
        struct mlx5_aso_sq aso_sq; /* ASO queue objects. */
@@ -898,6 +898,7 @@ struct mlx5_aso_mtr_pools_mng {
        volatile uint16_t n_valid; /* Number of valid pools. */
        uint16_t n; /* Number of pools. */
        rte_spinlock_t mtrsl; /* The ASO flow meter free list lock. */
+       rte_rwlock_t resize_mtrwl; /* Lock for resize objects. */
        struct aso_meter_list meters; /* Free ASO flow meter list. */
        struct mlx5_aso_sq sq; /*SQ using by ASO flow meter. */
        struct mlx5_aso_mtr_pool **pools; /* ASO flow meter pool array. */
@@ -1015,14 +1016,8 @@ struct mlx5_dev_txpp {
        uint64_t err_ts_future; /* Timestamp in the distant future. */
 };
 
-/* Supported flex parser profile ID. */
-enum mlx5_flex_parser_profile_id {
-       MLX5_FLEX_PARSER_ECPRI_0 = 0,
-       MLX5_FLEX_PARSER_MAX = 8,
-};
-
-/* Sample ID information of flex parser structure. */
-struct mlx5_flex_parser_profiles {
+/* Sample ID information of eCPRI flex parser structure. */
+struct mlx5_ecpri_parser_profile {
        uint32_t num;           /* Actual number of samples. */
        uint32_t ids[8];        /* Sample IDs for this profile. */
        uint8_t offset[8];      /* Bytes offset of each parser. */
@@ -1104,6 +1099,21 @@ struct mlx5_lag {
        uint8_t affinity_mode; /* TIS or hash based affinity */
 };
 
+/* DevX flex parser context. */
+struct mlx5_flex_parser_devx {
+       struct mlx5_list_entry entry;  /* List element at the beginning. */
+       uint32_t num_samples;
+       void *devx_obj;
+       struct mlx5_devx_graph_node_attr devx_conf;
+       uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
+};
+
+/* Port flex item context. */
+struct mlx5_flex_item {
+       struct mlx5_flex_parser_devx *devx_fp; /* DevX flex parser object. */
+       uint32_t refcnt; /* Atomically accessed refcnt by flows. */
+};
+
 /*
  * Shared Infiniband device context for Master/Representors
  * which belong to same IB device with multiple IB ports.
@@ -1120,6 +1130,10 @@ struct mlx5_dev_ctx_shared {
        uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */
        uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */
        uint32_t reclaim_mode:1; /* Reclaim memory. */
+       uint32_t dr_drop_action_en:1; /* Use DR drop action. */
+       uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */
+       uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */
+       uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */
        uint32_t max_port; /* Maximal IB device port index. */
        struct mlx5_bond_info bond; /* Bonding information. */
        struct mlx5_common_device *cdev; /* Backend mlx5 device. */
@@ -1154,6 +1168,7 @@ struct mlx5_dev_ctx_shared {
        struct mlx5_list *push_vlan_action_list; /* Push VLAN actions. */
        struct mlx5_list *sample_action_list; /* List of sample actions. */
        struct mlx5_list *dest_array_list;
+       struct mlx5_list *flex_parsers_dv; /* Flex Item parsers. */
        /* List of destination array actions. */
        struct mlx5_flow_counter_mng cmng; /* Counters management structure. */
        void *default_miss_action; /* Default miss action. */
@@ -1167,7 +1182,7 @@ struct mlx5_dev_ctx_shared {
        struct mlx5_devx_obj *td; /* Transport domain. */
        struct mlx5_lag lag; /* LAG attributes */
        void *tx_uar; /* Tx/packet pacing shared UAR. */
-       struct mlx5_flex_parser_profiles fp[MLX5_FLEX_PARSER_MAX];
+       struct mlx5_ecpri_parser_profile ecpri_parser;
        /* Flex parser profiles information. */
        void *devx_rx_uar; /* DevX UAR for Rx. */
        struct mlx5_aso_age_mng *aso_age_mng;
@@ -1180,6 +1195,9 @@ struct mlx5_dev_ctx_shared {
        struct mlx5_aso_ct_pools_mng *ct_mng;
        /* Management data for ASO connection tracking. */
        struct mlx5_lb_ctx self_lb; /* QP to enable self loopback for Devx. */
+       unsigned int flow_max_priority;
+       enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM];
+       /* Availability of mreg_c's. */
        struct mlx5_dev_shared_port port[]; /* per device port data array. */
 };
 
@@ -1426,6 +1444,10 @@ struct mlx5_priv {
        struct mlx5_devx_obj *q_counters; /* DevX queue counter object. */
        uint32_t counter_set_id; /* Queue counter ID to set in DevX objects. */
        uint32_t lag_affinity_idx; /* LAG mode queue 0 affinity starting. */
+       rte_spinlock_t flex_item_sl; /* Flex item list spinlock. */
+       struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM];
+       /* Flex items have been created on the port. */
+       uint32_t flex_item_map; /* Map of allocated flex item elements. */
 };
 
 #define PORT_ID(priv) ((priv)->dev_data->port_id)
@@ -1685,7 +1707,7 @@ int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt,
 int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow,
                        FILE *file, struct rte_flow_error *error);
 int save_dump_file(const unsigned char *data, uint32_t size,
-               uint32_t type, uint32_t id, void *arg, FILE *file);
+               uint32_t type, uint64_t id, void *arg, FILE *file);
 int mlx5_flow_query_counter(struct rte_eth_dev *dev, struct rte_flow *flow,
        struct rte_flow_query_count *count, struct rte_flow_error *error);
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
@@ -1805,4 +1827,25 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);
 uint32_t
 mlx5_get_supported_tunneling_offloads(const struct mlx5_hca_attr *attr);
 
+/* mlx5_flow_flex.c */
+
+struct rte_flow_item_flex_handle *
+flow_dv_item_create(struct rte_eth_dev *dev,
+                   const struct rte_flow_item_flex_conf *conf,
+                   struct rte_flow_error *error);
+int flow_dv_item_release(struct rte_eth_dev *dev,
+                   const struct rte_flow_item_flex_handle *flex_handle,
+                   struct rte_flow_error *error);
+int mlx5_flex_item_port_init(struct rte_eth_dev *dev);
+void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);
+/* Flex parser list callbacks. */
+struct mlx5_list_entry *mlx5_flex_parser_create_cb(void *list_ctx, void *ctx);
+int mlx5_flex_parser_match_cb(void *list_ctx,
+                             struct mlx5_list_entry *iter, void *ctx);
+void mlx5_flex_parser_remove_cb(void *list_ctx,        struct mlx5_list_entry *entry);
+struct mlx5_list_entry *mlx5_flex_parser_clone_cb(void *list_ctx,
+                                                 struct mlx5_list_entry *entry,
+                                                 void *ctx);
+void mlx5_flex_parser_clone_free_cb(void *tool_ctx,
+                                   struct mlx5_list_entry *entry);
 #endif /* RTE_PMD_MLX5_H_ */