1 // SPDX-License-Identifier: BSD-3-Clause
3 * Copyright 2018 Mellanox Technologies, Ltd
8 #include <rte_mtr_driver.h>
11 #include "mlx5_flow.h"
14 * Callback to get MTR capabilities.
17 * Pointer to Ethernet device.
19 * Pointer to save MTR capabilities.
21 * Pointer to the error structure.
24 * 0 on success, a negative errno value otherwise and rte_errno is set.
27 mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,
28 struct rte_mtr_capabilities *cap,
29 struct rte_mtr_error *error __rte_unused)
31 struct mlx5_priv *priv = dev->data->dev_private;
32 struct mlx5_hca_qos_attr *qattr = &priv->config.hca_attr.qos;
35 return -rte_mtr_error_set(error, ENOTSUP,
36 RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
37 "Meter is not support");
38 memset(cap, 0, sizeof(*cap));
39 cap->n_max = 1 << qattr->log_max_flow_meter;
40 cap->n_shared_max = cap->n_max;
42 cap->shared_identical = 1;
43 cap->shared_n_flows_per_mtr_max = 4 << 20;
44 /* 2M flows can share the same meter. */
45 cap->chaining_n_mtrs_per_flow_max = 1; /* Chaining is not supported. */
46 cap->meter_srtcm_rfc2697_n_max = qattr->srtcm_sup ? cap->n_max : 0;
47 cap->meter_rate_max = 1ULL << 40; /* 1 Tera tokens per sec. */
48 cap->policer_action_drop_supported = 1;
49 cap->stats_mask = RTE_MTR_STATS_N_BYTES_DROPPED |
50 RTE_MTR_STATS_N_PKTS_DROPPED;
54 static const struct rte_mtr_ops mlx5_flow_mtr_ops = {
55 .capabilities_get = mlx5_flow_mtr_cap_get,
56 .meter_profile_add = NULL,
57 .meter_profile_delete = NULL,
61 .meter_disable = NULL,
62 .meter_profile_update = NULL,
63 .meter_dscp_table_update = NULL,
64 .policer_actions_update = NULL,
70 * Get meter operations.
73 * Pointer to Ethernet device structure.
75 * Pointer to set the mtr operations.
81 mlx5_flow_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg)
83 *(const struct rte_mtr_ops **)arg = &mlx5_flow_mtr_ops;