+#include "mlx5_flow.h"
+
+/**
+ * Callback to get MTR capabilities.
+ *
+ * @param[in] dev
+ * Pointer to Ethernet device.
+ * @param[out] cap
+ * Pointer to save MTR capabilities.
+ * @param[out] error
+ * Pointer to the error structure.
+ *
+ * @return
+ * 0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+static int
+mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,
+ struct rte_mtr_capabilities *cap,
+ struct rte_mtr_error *error __rte_unused)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+ struct mlx5_hca_qos_attr *qattr = &priv->config.hca_attr.qos;
+
+ if (!priv->mtr_en)
+ return -rte_mtr_error_set(error, ENOTSUP,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "Meter is not support");
+ memset(cap, 0, sizeof(*cap));
+ cap->n_max = 1 << qattr->log_max_flow_meter;
+ cap->n_shared_max = cap->n_max;
+ cap->identical = 1;
+ cap->shared_identical = 1;
+ cap->shared_n_flows_per_mtr_max = 4 << 20;
+ /* 2M flows can share the same meter. */
+ cap->chaining_n_mtrs_per_flow_max = 1; /* Chaining is not supported. */
+ cap->meter_srtcm_rfc2697_n_max = qattr->srtcm_sup ? cap->n_max : 0;
+ cap->meter_rate_max = 1ULL << 40; /* 1 Tera tokens per sec. */
+ cap->policer_action_drop_supported = 1;
+ cap->stats_mask = RTE_MTR_STATS_N_BYTES_DROPPED |
+ RTE_MTR_STATS_N_PKTS_DROPPED;
+ return 0;
+}