common/mlx5: add flex parser DevX structures
[dpdk.git] / drivers / net / mlx5 / mlx5.h
index 93bde5a..61abe4a 100644 (file)
@@ -210,10 +210,13 @@ struct mlx5_dev_config {
        unsigned int dv_esw_en:1; /* Enable E-Switch DV flow. */
        unsigned int dv_flow_en:1; /* Enable DV flow. */
        unsigned int dv_xmeta_en:2; /* Enable extensive flow metadata. */
+       unsigned int lacp_by_user:1;
+       /* Enable user to manage LACP traffic. */
        unsigned int swp:1; /* Tx generic tunnel checksum and TSO offload. */
        unsigned int devx:1; /* Whether devx interface is available or not. */
        unsigned int dest_tir:1; /* Whether advanced DR API is available. */
        unsigned int reclaim_mode:2; /* Memory reclaim mode. */
+       unsigned int rt_timestamp:1; /* realtime timestamp format. */
        struct {
                unsigned int enabled:1; /* Whether MPRQ is enabled. */
                unsigned int stride_num_n; /* Number of strides. */
@@ -238,6 +241,8 @@ struct mlx5_dev_config {
        int txq_inline_min; /* Minimal amount of data bytes to inline. */
        int txq_inline_max; /* Max packet size for inlining with SEND. */
        int txq_inline_mpw; /* Max packet size for inlining with eMPW. */
+       int tx_pp; /* Timestamp scheduling granularity in nanoseconds. */
+       int tx_skew; /* Tx scheduling skew between WQE and data on wire. */
        struct mlx5_hca_attr hca_attr; /* HCA attributes. */
        struct mlx5_lro_config lro; /* LRO configuration. */
 };
@@ -527,6 +532,78 @@ struct mlx5_flow_id_pool {
        uint32_t max_id; /**< Maximum id can be allocated from the pool. */
 };
 
+/* Tx pacing queue structure - for Clock and Rearm queues. */
+struct mlx5_txpp_wq {
+       /* Completion Queue related data.*/
+       struct mlx5_devx_obj *cq;
+       struct mlx5dv_devx_umem *cq_umem;
+       union {
+               volatile void *cq_buf;
+               volatile struct mlx5_cqe *cqes;
+       };
+       volatile uint32_t *cq_dbrec;
+       uint32_t cq_ci:24;
+       uint32_t arm_sn:2;
+       /* Send Queue related data.*/
+       struct mlx5_devx_obj *sq;
+       struct mlx5dv_devx_umem *sq_umem;
+       union {
+               volatile void *sq_buf;
+               volatile struct mlx5_wqe *wqes;
+       };
+       uint16_t sq_size; /* Number of WQEs in the queue. */
+       uint16_t sq_ci; /* Next WQE to execute. */
+       volatile uint32_t *sq_dbrec;
+};
+
+/* Tx packet pacing internal timestamp. */
+struct mlx5_txpp_ts {
+       rte_atomic64_t ci_ts;
+       rte_atomic64_t ts;
+};
+
+/* Tx packet pacing structure. */
+struct mlx5_dev_txpp {
+       pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
+       uint32_t refcnt; /* Pacing reference counter. */
+       uint32_t freq; /* Timestamp frequency, Hz. */
+       uint32_t tick; /* Completion tick duration in nanoseconds. */
+       uint32_t test; /* Packet pacing test mode. */
+       int32_t skew; /* Scheduling skew. */
+       uint32_t eqn; /* Event Queue number. */
+       struct rte_intr_handle intr_handle; /* Periodic interrupt. */
+       struct mlx5dv_devx_event_channel *echan; /* Event Channel. */
+       struct mlx5_txpp_wq clock_queue; /* Clock Queue. */
+       struct mlx5_txpp_wq rearm_queue; /* Clock Queue. */
+       struct mlx5dv_pp *pp; /* Packet pacing context. */
+       uint16_t pp_id; /* Packet pacing context index. */
+       uint16_t ts_n; /* Number of captured timestamps. */
+       uint16_t ts_p; /* Pointer to statisticks timestamp. */
+       struct mlx5_txpp_ts *tsa; /* Timestamps sliding window stats. */
+       struct mlx5_txpp_ts ts; /* Cached completion id/timestamp. */
+       uint32_t sync_lost:1; /* ci/timestamp synchronization lost. */
+       /* Statistics counters. */
+       rte_atomic32_t err_miss_int; /* Missed service interrupt. */
+       rte_atomic32_t err_rearm_queue; /* Rearm Queue errors. */
+       rte_atomic32_t err_clock_queue; /* Clock Queue errors. */
+       rte_atomic32_t err_ts_past; /* Timestamp in the past. */
+       rte_atomic32_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 {
+       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. */
+       void *obj;              /* Flex parser node object. */
+};
+
 /*
  * Shared Infiniband device context for Master/Representors
  * which belong to same IB device with multiple IB ports.
@@ -543,9 +620,12 @@ struct mlx5_dev_ctx_shared {
        char ibdev_name[DEV_SYSFS_NAME_MAX]; /* SYSFS dev name. */
        char ibdev_path[DEV_SYSFS_PATH_MAX]; /* SYSFS dev path for secondary */
        struct mlx5_dev_attr device_attr; /* Device properties. */
+       int numa_node; /* Numa node of backing physical device. */
        LIST_ENTRY(mlx5_dev_ctx_shared) mem_event_cb;
        /**< Called by memory event callback. */
        struct mlx5_mr_share_cache share_cache;
+       /* Packet pacing related structure. */
+       struct mlx5_dev_txpp txpp;
        /* Shared DV/DR flow data section. */
        pthread_mutex_t dv_mutex; /* DV context mutex. */
        uint32_t dv_meta_mask; /* flow META metadata supported mask. */
@@ -555,6 +635,11 @@ struct mlx5_dev_ctx_shared {
        void *fdb_domain; /* FDB Direct Rules name space handle. */
        void *rx_domain; /* RX Direct Rules name space handle. */
        void *tx_domain; /* TX Direct Rules name space handle. */
+#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];
+       /* UAR same-page access control required in 32bit implementations. */
+#endif
        struct mlx5_hlist *flow_tbls;
        /* Direct Rules tables for FDB, NIC TX+RX */
        void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
@@ -577,6 +662,9 @@ struct mlx5_dev_ctx_shared {
        struct mlx5_devx_obj *tis; /* TIS object. */
        struct mlx5_devx_obj *td; /* Transport domain. */
        struct mlx5_flow_id_pool *flow_id_pool; /* Flow ID pool. */
+       struct mlx5dv_devx_uar *tx_uar; /* Tx/packer pacing shared UAR. */
+       struct mlx5_flex_parser_profiles fp[MLX5_FLEX_PARSER_MAX];
+       /* Flex parser profiles information. */
        struct mlx5_dev_shared_port port[]; /* per device port data array. */
 };
 
@@ -612,6 +700,7 @@ struct mlx5_priv {
        unsigned int representor:1; /* Device is a port representor. */
        unsigned int master:1; /* Device is a E-Switch master. */
        unsigned int dr_shared:1; /* DV/DR data is shared. */
+       unsigned int txpp_en:1; /* Tx packet pacing enabled. */
        unsigned int counter_fallback:1; /* Use counter fallback management. */
        unsigned int mtr_en:1; /* Whether support meter. */
        unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */
@@ -669,11 +758,6 @@ struct mlx5_priv {
        uint8_t mtr_color_reg; /* Meter color match REG_C. */
        struct mlx5_mtr_profiles flow_meter_profiles; /* MTR profile list. */
        struct mlx5_flow_meters flow_meters; /* MTR 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];
-       /* UAR same-page access control required in 32bit implementations. */
-#endif
        uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */
        uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
        struct mlx5_mp_id mp_id; /* ID of a multi-process process */
@@ -716,6 +800,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
                         struct rte_eth_hairpin_cap *cap);
+bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);
+int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);
 
 /* mlx5_ethdev.c */
 
@@ -939,4 +1025,18 @@ int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
 void mlx5_os_stats_init(struct rte_eth_dev *dev);
 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
                           mlx5_dereg_mr_t *dereg_mr_cb);
+/* mlx5_txpp.c */
+
+int mlx5_txpp_start(struct rte_eth_dev *dev);
+void mlx5_txpp_stop(struct rte_eth_dev *dev);
+int mlx5_txpp_read_clock(struct rte_eth_dev *dev, uint64_t *timestamp);
+int mlx5_txpp_xstats_get(struct rte_eth_dev *dev,
+                        struct rte_eth_xstat *stats,
+                        unsigned int n, unsigned int n_used);
+int mlx5_txpp_xstats_reset(struct rte_eth_dev *dev);
+int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,
+                              struct rte_eth_xstat_name *xstats_names,
+                              unsigned int n, unsigned int n_used);
+void mlx5_txpp_interrupt_handler(void *cb_arg);
+
 #endif /* RTE_PMD_MLX5_H_ */