199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson * Copyright(c) 2017 Intel Corporation
399a2dd95SBruce Richardson */
499a2dd95SBruce Richardson
599a2dd95SBruce Richardson #include <stdint.h>
699a2dd95SBruce Richardson
799a2dd95SBruce Richardson #include <rte_errno.h>
848e48fceSAnkur Dwivedi #include "ethdev_trace.h"
999a2dd95SBruce Richardson #include "rte_ethdev.h"
1099a2dd95SBruce Richardson #include "rte_mtr_driver.h"
1199a2dd95SBruce Richardson #include "rte_mtr.h"
1299a2dd95SBruce Richardson
1399a2dd95SBruce Richardson /* Get generic traffic metering & policing operations structure from a port. */
1499a2dd95SBruce Richardson const struct rte_mtr_ops *
rte_mtr_ops_get(uint16_t port_id,struct rte_mtr_error * error)1599a2dd95SBruce Richardson rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error)
1699a2dd95SBruce Richardson {
1799a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1899a2dd95SBruce Richardson const struct rte_mtr_ops *ops;
1999a2dd95SBruce Richardson
2099a2dd95SBruce Richardson if (!rte_eth_dev_is_valid_port(port_id)) {
2199a2dd95SBruce Richardson rte_mtr_error_set(error,
2299a2dd95SBruce Richardson ENODEV,
2399a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_UNSPECIFIED,
2499a2dd95SBruce Richardson NULL,
2599a2dd95SBruce Richardson rte_strerror(ENODEV));
2699a2dd95SBruce Richardson return NULL;
2799a2dd95SBruce Richardson }
2899a2dd95SBruce Richardson
2999a2dd95SBruce Richardson if ((dev->dev_ops->mtr_ops_get == NULL) ||
3099a2dd95SBruce Richardson (dev->dev_ops->mtr_ops_get(dev, &ops) != 0) ||
3199a2dd95SBruce Richardson (ops == NULL)) {
3299a2dd95SBruce Richardson rte_mtr_error_set(error,
3399a2dd95SBruce Richardson ENOSYS,
3499a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_UNSPECIFIED,
3599a2dd95SBruce Richardson NULL,
3699a2dd95SBruce Richardson rte_strerror(ENOSYS));
3799a2dd95SBruce Richardson return NULL;
3899a2dd95SBruce Richardson }
3999a2dd95SBruce Richardson
4099a2dd95SBruce Richardson return ops;
4199a2dd95SBruce Richardson }
4299a2dd95SBruce Richardson
4399a2dd95SBruce Richardson #define RTE_MTR_FUNC(port_id, func) \
44*93998f3cSTyler Retzlaff __extension__ ({ \
4599a2dd95SBruce Richardson const struct rte_mtr_ops *ops = \
4699a2dd95SBruce Richardson rte_mtr_ops_get(port_id, error); \
4799a2dd95SBruce Richardson if (ops == NULL) \
4899a2dd95SBruce Richardson return -rte_errno; \
4999a2dd95SBruce Richardson \
5099a2dd95SBruce Richardson if (ops->func == NULL) \
5199a2dd95SBruce Richardson return -rte_mtr_error_set(error, \
5299a2dd95SBruce Richardson ENOSYS, \
5399a2dd95SBruce Richardson RTE_MTR_ERROR_TYPE_UNSPECIFIED, \
5499a2dd95SBruce Richardson NULL, \
5599a2dd95SBruce Richardson rte_strerror(ENOSYS)); \
5699a2dd95SBruce Richardson \
5799a2dd95SBruce Richardson ops->func; \
5899a2dd95SBruce Richardson })
5999a2dd95SBruce Richardson
60ece19ccaSAlexander Kozyrev #define RTE_MTR_HNDL_FUNC(port_id, func) \
61*93998f3cSTyler Retzlaff __extension__ ({ \
62ece19ccaSAlexander Kozyrev const struct rte_mtr_ops *ops = \
63ece19ccaSAlexander Kozyrev rte_mtr_ops_get(port_id, error); \
64ece19ccaSAlexander Kozyrev if (ops == NULL) \
65ece19ccaSAlexander Kozyrev return NULL; \
66ece19ccaSAlexander Kozyrev \
67ece19ccaSAlexander Kozyrev if (ops->func == NULL) { \
68ece19ccaSAlexander Kozyrev rte_mtr_error_set(error, \
69ece19ccaSAlexander Kozyrev ENOSYS, \
70ece19ccaSAlexander Kozyrev RTE_MTR_ERROR_TYPE_UNSPECIFIED, \
71ece19ccaSAlexander Kozyrev NULL, \
72ece19ccaSAlexander Kozyrev rte_strerror(ENOSYS)); \
73ece19ccaSAlexander Kozyrev return NULL; \
74ece19ccaSAlexander Kozyrev } \
75ece19ccaSAlexander Kozyrev \
76ece19ccaSAlexander Kozyrev ops->func; \
77ece19ccaSAlexander Kozyrev })
78ece19ccaSAlexander Kozyrev
7999a2dd95SBruce Richardson /* MTR capabilities get */
8099a2dd95SBruce Richardson int
rte_mtr_capabilities_get(uint16_t port_id,struct rte_mtr_capabilities * cap,struct rte_mtr_error * error)8199a2dd95SBruce Richardson rte_mtr_capabilities_get(uint16_t port_id,
8299a2dd95SBruce Richardson struct rte_mtr_capabilities *cap,
8399a2dd95SBruce Richardson struct rte_mtr_error *error)
8499a2dd95SBruce Richardson {
8599a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
8648e48fceSAnkur Dwivedi int ret;
8748e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, capabilities_get)(dev,
8899a2dd95SBruce Richardson cap, error);
8948e48fceSAnkur Dwivedi
9048e48fceSAnkur Dwivedi rte_mtr_trace_capabilities_get(port_id, cap, ret);
9148e48fceSAnkur Dwivedi
9248e48fceSAnkur Dwivedi return ret;
9399a2dd95SBruce Richardson }
9499a2dd95SBruce Richardson
9599a2dd95SBruce Richardson /* MTR meter profile add */
9699a2dd95SBruce Richardson int
rte_mtr_meter_profile_add(uint16_t port_id,uint32_t meter_profile_id,struct rte_mtr_meter_profile * profile,struct rte_mtr_error * error)9799a2dd95SBruce Richardson rte_mtr_meter_profile_add(uint16_t port_id,
9899a2dd95SBruce Richardson uint32_t meter_profile_id,
9999a2dd95SBruce Richardson struct rte_mtr_meter_profile *profile,
10099a2dd95SBruce Richardson struct rte_mtr_error *error)
10199a2dd95SBruce Richardson {
10299a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
10348e48fceSAnkur Dwivedi int ret;
10448e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_profile_add)(dev,
10599a2dd95SBruce Richardson meter_profile_id, profile, error);
10648e48fceSAnkur Dwivedi
10748e48fceSAnkur Dwivedi rte_mtr_trace_meter_profile_add(port_id, meter_profile_id, profile,
10848e48fceSAnkur Dwivedi ret);
10948e48fceSAnkur Dwivedi
11048e48fceSAnkur Dwivedi return ret;
11199a2dd95SBruce Richardson }
11299a2dd95SBruce Richardson
11399a2dd95SBruce Richardson /** MTR meter profile delete */
11499a2dd95SBruce Richardson int
rte_mtr_meter_profile_delete(uint16_t port_id,uint32_t meter_profile_id,struct rte_mtr_error * error)11599a2dd95SBruce Richardson rte_mtr_meter_profile_delete(uint16_t port_id,
11699a2dd95SBruce Richardson uint32_t meter_profile_id,
11799a2dd95SBruce Richardson struct rte_mtr_error *error)
11899a2dd95SBruce Richardson {
11999a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
12048e48fceSAnkur Dwivedi int ret;
12148e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_profile_delete)(dev,
12299a2dd95SBruce Richardson meter_profile_id, error);
12348e48fceSAnkur Dwivedi
12448e48fceSAnkur Dwivedi rte_mtr_trace_meter_profile_delete(port_id, meter_profile_id, ret);
12548e48fceSAnkur Dwivedi
12648e48fceSAnkur Dwivedi return ret;
12799a2dd95SBruce Richardson }
12899a2dd95SBruce Richardson
129ece19ccaSAlexander Kozyrev /** MTR meter profile get */
130ece19ccaSAlexander Kozyrev struct rte_flow_meter_profile *
rte_mtr_meter_profile_get(uint16_t port_id,uint32_t meter_profile_id,struct rte_mtr_error * error)131ece19ccaSAlexander Kozyrev rte_mtr_meter_profile_get(uint16_t port_id,
132ece19ccaSAlexander Kozyrev uint32_t meter_profile_id,
133ece19ccaSAlexander Kozyrev struct rte_mtr_error *error)
134ece19ccaSAlexander Kozyrev {
135ece19ccaSAlexander Kozyrev struct rte_eth_dev *dev = &rte_eth_devices[port_id];
13648e48fceSAnkur Dwivedi struct rte_flow_meter_profile *ret;
13748e48fceSAnkur Dwivedi ret = RTE_MTR_HNDL_FUNC(port_id, meter_profile_get)(dev,
138ece19ccaSAlexander Kozyrev meter_profile_id, error);
13948e48fceSAnkur Dwivedi
14048e48fceSAnkur Dwivedi rte_mtr_trace_meter_profile_get(port_id, meter_profile_id, ret);
14148e48fceSAnkur Dwivedi
14248e48fceSAnkur Dwivedi return ret;
143ece19ccaSAlexander Kozyrev }
144ece19ccaSAlexander Kozyrev
1455f0d54f3SLi Zhang /* MTR meter policy validate */
1465f0d54f3SLi Zhang int
rte_mtr_meter_policy_validate(uint16_t port_id,struct rte_mtr_meter_policy_params * policy,struct rte_mtr_error * error)1475f0d54f3SLi Zhang rte_mtr_meter_policy_validate(uint16_t port_id,
1485f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy,
1495f0d54f3SLi Zhang struct rte_mtr_error *error)
1505f0d54f3SLi Zhang {
1515f0d54f3SLi Zhang struct rte_eth_dev *dev = &rte_eth_devices[port_id];
15248e48fceSAnkur Dwivedi int ret;
15348e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_policy_validate)(dev,
1545f0d54f3SLi Zhang policy, error);
15548e48fceSAnkur Dwivedi
15648e48fceSAnkur Dwivedi rte_mtr_trace_meter_policy_validate(port_id, policy, ret);
15748e48fceSAnkur Dwivedi
15848e48fceSAnkur Dwivedi return ret;
1595f0d54f3SLi Zhang }
1605f0d54f3SLi Zhang
1615f0d54f3SLi Zhang /* MTR meter policy add */
1625f0d54f3SLi Zhang int
rte_mtr_meter_policy_add(uint16_t port_id,uint32_t policy_id,struct rte_mtr_meter_policy_params * policy,struct rte_mtr_error * error)1635f0d54f3SLi Zhang rte_mtr_meter_policy_add(uint16_t port_id,
1645f0d54f3SLi Zhang uint32_t policy_id,
1655f0d54f3SLi Zhang struct rte_mtr_meter_policy_params *policy,
1665f0d54f3SLi Zhang struct rte_mtr_error *error)
1675f0d54f3SLi Zhang {
1685f0d54f3SLi Zhang struct rte_eth_dev *dev = &rte_eth_devices[port_id];
16948e48fceSAnkur Dwivedi int ret;
17048e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_policy_add)(dev,
1715f0d54f3SLi Zhang policy_id, policy, error);
17248e48fceSAnkur Dwivedi
17348e48fceSAnkur Dwivedi rte_mtr_trace_meter_policy_add(port_id, policy_id, policy, ret);
17448e48fceSAnkur Dwivedi
17548e48fceSAnkur Dwivedi return ret;
1765f0d54f3SLi Zhang }
1775f0d54f3SLi Zhang
1785f0d54f3SLi Zhang /** MTR meter policy delete */
1795f0d54f3SLi Zhang int
rte_mtr_meter_policy_delete(uint16_t port_id,uint32_t policy_id,struct rte_mtr_error * error)1805f0d54f3SLi Zhang rte_mtr_meter_policy_delete(uint16_t port_id,
1815f0d54f3SLi Zhang uint32_t policy_id,
1825f0d54f3SLi Zhang struct rte_mtr_error *error)
1835f0d54f3SLi Zhang {
1845f0d54f3SLi Zhang struct rte_eth_dev *dev = &rte_eth_devices[port_id];
18548e48fceSAnkur Dwivedi int ret;
18648e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_policy_delete)(dev,
1875f0d54f3SLi Zhang policy_id, error);
18848e48fceSAnkur Dwivedi
18948e48fceSAnkur Dwivedi rte_mtr_trace_meter_policy_delete(port_id, policy_id, ret);
19048e48fceSAnkur Dwivedi
19148e48fceSAnkur Dwivedi return ret;
1925f0d54f3SLi Zhang }
1935f0d54f3SLi Zhang
194ece19ccaSAlexander Kozyrev /** MTR meter policy get */
195ece19ccaSAlexander Kozyrev struct rte_flow_meter_policy *
rte_mtr_meter_policy_get(uint16_t port_id,uint32_t policy_id,struct rte_mtr_error * error)196ece19ccaSAlexander Kozyrev rte_mtr_meter_policy_get(uint16_t port_id,
197ece19ccaSAlexander Kozyrev uint32_t policy_id,
198ece19ccaSAlexander Kozyrev struct rte_mtr_error *error)
199ece19ccaSAlexander Kozyrev {
200ece19ccaSAlexander Kozyrev struct rte_eth_dev *dev = &rte_eth_devices[port_id];
20148e48fceSAnkur Dwivedi struct rte_flow_meter_policy *ret;
20248e48fceSAnkur Dwivedi ret = RTE_MTR_HNDL_FUNC(port_id, meter_policy_get)(dev,
203ece19ccaSAlexander Kozyrev policy_id, error);
20448e48fceSAnkur Dwivedi
20548e48fceSAnkur Dwivedi rte_mtr_trace_meter_policy_get(port_id, policy_id, ret);
20648e48fceSAnkur Dwivedi
20748e48fceSAnkur Dwivedi return ret;
208ece19ccaSAlexander Kozyrev }
209ece19ccaSAlexander Kozyrev
21099a2dd95SBruce Richardson /** MTR object create */
21199a2dd95SBruce Richardson int
rte_mtr_create(uint16_t port_id,uint32_t mtr_id,struct rte_mtr_params * params,int shared,struct rte_mtr_error * error)21299a2dd95SBruce Richardson rte_mtr_create(uint16_t port_id,
21399a2dd95SBruce Richardson uint32_t mtr_id,
21499a2dd95SBruce Richardson struct rte_mtr_params *params,
21599a2dd95SBruce Richardson int shared,
21699a2dd95SBruce Richardson struct rte_mtr_error *error)
21799a2dd95SBruce Richardson {
21899a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
21948e48fceSAnkur Dwivedi int ret;
22048e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, create)(dev,
22199a2dd95SBruce Richardson mtr_id, params, shared, error);
22248e48fceSAnkur Dwivedi
22348e48fceSAnkur Dwivedi rte_mtr_trace_create(port_id, mtr_id, params, shared, ret);
22448e48fceSAnkur Dwivedi
22548e48fceSAnkur Dwivedi return ret;
22699a2dd95SBruce Richardson }
22799a2dd95SBruce Richardson
22899a2dd95SBruce Richardson /** MTR object destroy */
22999a2dd95SBruce Richardson int
rte_mtr_destroy(uint16_t port_id,uint32_t mtr_id,struct rte_mtr_error * error)23099a2dd95SBruce Richardson rte_mtr_destroy(uint16_t port_id,
23199a2dd95SBruce Richardson uint32_t mtr_id,
23299a2dd95SBruce Richardson struct rte_mtr_error *error)
23399a2dd95SBruce Richardson {
23499a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
23548e48fceSAnkur Dwivedi int ret;
23648e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, destroy)(dev,
23799a2dd95SBruce Richardson mtr_id, error);
23848e48fceSAnkur Dwivedi
23948e48fceSAnkur Dwivedi rte_mtr_trace_destroy(port_id, mtr_id, ret);
24048e48fceSAnkur Dwivedi
24148e48fceSAnkur Dwivedi return ret;
24299a2dd95SBruce Richardson }
24399a2dd95SBruce Richardson
24499a2dd95SBruce Richardson /** MTR object meter enable */
24599a2dd95SBruce Richardson int
rte_mtr_meter_enable(uint16_t port_id,uint32_t mtr_id,struct rte_mtr_error * error)24699a2dd95SBruce Richardson rte_mtr_meter_enable(uint16_t port_id,
24799a2dd95SBruce Richardson uint32_t mtr_id,
24899a2dd95SBruce Richardson struct rte_mtr_error *error)
24999a2dd95SBruce Richardson {
25099a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
25148e48fceSAnkur Dwivedi int ret;
25248e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_enable)(dev,
25399a2dd95SBruce Richardson mtr_id, error);
25448e48fceSAnkur Dwivedi
25548e48fceSAnkur Dwivedi rte_mtr_trace_meter_enable(port_id, mtr_id, ret);
25648e48fceSAnkur Dwivedi
25748e48fceSAnkur Dwivedi return ret;
25899a2dd95SBruce Richardson }
25999a2dd95SBruce Richardson
26099a2dd95SBruce Richardson /** MTR object meter disable */
26199a2dd95SBruce Richardson int
rte_mtr_meter_disable(uint16_t port_id,uint32_t mtr_id,struct rte_mtr_error * error)26299a2dd95SBruce Richardson rte_mtr_meter_disable(uint16_t port_id,
26399a2dd95SBruce Richardson uint32_t mtr_id,
26499a2dd95SBruce Richardson struct rte_mtr_error *error)
26599a2dd95SBruce Richardson {
26699a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
26748e48fceSAnkur Dwivedi int ret;
26848e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_disable)(dev,
26999a2dd95SBruce Richardson mtr_id, error);
27048e48fceSAnkur Dwivedi
27148e48fceSAnkur Dwivedi rte_mtr_trace_meter_disable(port_id, mtr_id, ret);
27248e48fceSAnkur Dwivedi
27348e48fceSAnkur Dwivedi return ret;
27499a2dd95SBruce Richardson }
27599a2dd95SBruce Richardson
27699a2dd95SBruce Richardson /** MTR object meter profile update */
27799a2dd95SBruce Richardson int
rte_mtr_meter_profile_update(uint16_t port_id,uint32_t mtr_id,uint32_t meter_profile_id,struct rte_mtr_error * error)27899a2dd95SBruce Richardson rte_mtr_meter_profile_update(uint16_t port_id,
27999a2dd95SBruce Richardson uint32_t mtr_id,
28099a2dd95SBruce Richardson uint32_t meter_profile_id,
28199a2dd95SBruce Richardson struct rte_mtr_error *error)
28299a2dd95SBruce Richardson {
28399a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
28448e48fceSAnkur Dwivedi int ret;
28548e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_profile_update)(dev,
28699a2dd95SBruce Richardson mtr_id, meter_profile_id, error);
28748e48fceSAnkur Dwivedi
28848e48fceSAnkur Dwivedi rte_mtr_trace_meter_profile_update(port_id, mtr_id, meter_profile_id, ret);
28948e48fceSAnkur Dwivedi
29048e48fceSAnkur Dwivedi return ret;
29199a2dd95SBruce Richardson }
29299a2dd95SBruce Richardson
2935f0d54f3SLi Zhang /** MTR object meter policy update */
2945f0d54f3SLi Zhang int
rte_mtr_meter_policy_update(uint16_t port_id,uint32_t mtr_id,uint32_t meter_policy_id,struct rte_mtr_error * error)2955f0d54f3SLi Zhang rte_mtr_meter_policy_update(uint16_t port_id,
2965f0d54f3SLi Zhang uint32_t mtr_id,
2975f0d54f3SLi Zhang uint32_t meter_policy_id,
2985f0d54f3SLi Zhang struct rte_mtr_error *error)
2995f0d54f3SLi Zhang {
3005f0d54f3SLi Zhang struct rte_eth_dev *dev = &rte_eth_devices[port_id];
30148e48fceSAnkur Dwivedi int ret;
30248e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_policy_update)(dev,
3035f0d54f3SLi Zhang mtr_id, meter_policy_id, error);
30448e48fceSAnkur Dwivedi
30548e48fceSAnkur Dwivedi rte_mtr_trace_meter_policy_update(port_id, mtr_id, meter_policy_id, ret);
30648e48fceSAnkur Dwivedi
30748e48fceSAnkur Dwivedi return ret;
3085f0d54f3SLi Zhang }
3095f0d54f3SLi Zhang
31099a2dd95SBruce Richardson /** MTR object meter DSCP table update */
31199a2dd95SBruce Richardson int
rte_mtr_meter_dscp_table_update(uint16_t port_id,uint32_t mtr_id,enum rte_mtr_color_in_protocol proto,enum rte_color * dscp_table,struct rte_mtr_error * error)31299a2dd95SBruce Richardson rte_mtr_meter_dscp_table_update(uint16_t port_id,
313204daeeaSSunil Kumar Kori uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
31499a2dd95SBruce Richardson enum rte_color *dscp_table,
31599a2dd95SBruce Richardson struct rte_mtr_error *error)
31699a2dd95SBruce Richardson {
31799a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
31848e48fceSAnkur Dwivedi int ret;
31948e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_dscp_table_update)(dev,
320204daeeaSSunil Kumar Kori mtr_id, proto, dscp_table, error);
32148e48fceSAnkur Dwivedi
32248e48fceSAnkur Dwivedi rte_mtr_trace_meter_dscp_table_update(port_id, mtr_id, dscp_table, ret);
32348e48fceSAnkur Dwivedi
32448e48fceSAnkur Dwivedi return ret;
32599a2dd95SBruce Richardson }
32699a2dd95SBruce Richardson
327d04fb3b5SJerin Jacob /** MTR object meter VLAN table update */
328d04fb3b5SJerin Jacob int
rte_mtr_meter_vlan_table_update(uint16_t port_id,uint32_t mtr_id,enum rte_mtr_color_in_protocol proto,enum rte_color * vlan_table,struct rte_mtr_error * error)329d04fb3b5SJerin Jacob rte_mtr_meter_vlan_table_update(uint16_t port_id,
330204daeeaSSunil Kumar Kori uint32_t mtr_id, enum rte_mtr_color_in_protocol proto,
331d04fb3b5SJerin Jacob enum rte_color *vlan_table,
332d04fb3b5SJerin Jacob struct rte_mtr_error *error)
333d04fb3b5SJerin Jacob {
334d04fb3b5SJerin Jacob struct rte_eth_dev *dev = &rte_eth_devices[port_id];
33548e48fceSAnkur Dwivedi int ret;
33648e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
337204daeeaSSunil Kumar Kori mtr_id, proto, vlan_table, error);
33848e48fceSAnkur Dwivedi
33948e48fceSAnkur Dwivedi rte_mtr_trace_meter_vlan_table_update(port_id, mtr_id, vlan_table, ret);
34048e48fceSAnkur Dwivedi
34148e48fceSAnkur Dwivedi return ret;
342d04fb3b5SJerin Jacob }
343d04fb3b5SJerin Jacob
344d04fb3b5SJerin Jacob /** Set the input color protocol on MTR object */
345d04fb3b5SJerin Jacob int
rte_mtr_color_in_protocol_set(uint16_t port_id,uint32_t mtr_id,enum rte_mtr_color_in_protocol proto,uint32_t priority,struct rte_mtr_error * error)346d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_set(uint16_t port_id,
347d04fb3b5SJerin Jacob uint32_t mtr_id,
348d04fb3b5SJerin Jacob enum rte_mtr_color_in_protocol proto,
349d04fb3b5SJerin Jacob uint32_t priority,
350d04fb3b5SJerin Jacob struct rte_mtr_error *error)
351d04fb3b5SJerin Jacob {
352d04fb3b5SJerin Jacob struct rte_eth_dev *dev = &rte_eth_devices[port_id];
35348e48fceSAnkur Dwivedi int ret;
35448e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, in_proto_set)(dev,
355d04fb3b5SJerin Jacob mtr_id, proto, priority, error);
35648e48fceSAnkur Dwivedi
35748e48fceSAnkur Dwivedi rte_mtr_trace_color_in_protocol_set(port_id, mtr_id, proto, priority, ret);
35848e48fceSAnkur Dwivedi
35948e48fceSAnkur Dwivedi return ret;
360d04fb3b5SJerin Jacob }
361d04fb3b5SJerin Jacob
362d04fb3b5SJerin Jacob /** Get input color protocols of MTR object */
363d04fb3b5SJerin Jacob int
rte_mtr_color_in_protocol_get(uint16_t port_id,uint32_t mtr_id,uint64_t * proto_mask,struct rte_mtr_error * error)364d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_get(uint16_t port_id,
365d04fb3b5SJerin Jacob uint32_t mtr_id,
366d04fb3b5SJerin Jacob uint64_t *proto_mask,
367d04fb3b5SJerin Jacob struct rte_mtr_error *error)
368d04fb3b5SJerin Jacob {
369d04fb3b5SJerin Jacob struct rte_eth_dev *dev = &rte_eth_devices[port_id];
37048e48fceSAnkur Dwivedi int ret;
37148e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, in_proto_get)(dev,
372d04fb3b5SJerin Jacob mtr_id, proto_mask, error);
37348e48fceSAnkur Dwivedi
37448e48fceSAnkur Dwivedi rte_mtr_trace_color_in_protocol_get(port_id, mtr_id, ret);
37548e48fceSAnkur Dwivedi
37648e48fceSAnkur Dwivedi return ret;
377d04fb3b5SJerin Jacob }
378d04fb3b5SJerin Jacob
379d04fb3b5SJerin Jacob /** Get input color protocol priority of MTR object */
380d04fb3b5SJerin Jacob int
rte_mtr_color_in_protocol_priority_get(uint16_t port_id,uint32_t mtr_id,enum rte_mtr_color_in_protocol proto,uint32_t * priority,struct rte_mtr_error * error)381d04fb3b5SJerin Jacob rte_mtr_color_in_protocol_priority_get(uint16_t port_id,
382d04fb3b5SJerin Jacob uint32_t mtr_id,
383d04fb3b5SJerin Jacob enum rte_mtr_color_in_protocol proto,
384d04fb3b5SJerin Jacob uint32_t *priority,
385d04fb3b5SJerin Jacob struct rte_mtr_error *error)
386d04fb3b5SJerin Jacob {
387d04fb3b5SJerin Jacob struct rte_eth_dev *dev = &rte_eth_devices[port_id];
38848e48fceSAnkur Dwivedi int ret;
38948e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, in_proto_prio_get)(dev,
390d04fb3b5SJerin Jacob mtr_id, proto, priority, error);
39148e48fceSAnkur Dwivedi
39248e48fceSAnkur Dwivedi rte_mtr_trace_color_in_protocol_priority_get(port_id, mtr_id, proto, ret);
39348e48fceSAnkur Dwivedi
39448e48fceSAnkur Dwivedi return ret;
395d04fb3b5SJerin Jacob }
396d04fb3b5SJerin Jacob
39799a2dd95SBruce Richardson /** MTR object enabled stats update */
39899a2dd95SBruce Richardson int
rte_mtr_stats_update(uint16_t port_id,uint32_t mtr_id,uint64_t stats_mask,struct rte_mtr_error * error)39999a2dd95SBruce Richardson rte_mtr_stats_update(uint16_t port_id,
40099a2dd95SBruce Richardson uint32_t mtr_id,
40199a2dd95SBruce Richardson uint64_t stats_mask,
40299a2dd95SBruce Richardson struct rte_mtr_error *error)
40399a2dd95SBruce Richardson {
40499a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
40548e48fceSAnkur Dwivedi int ret;
40648e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, stats_update)(dev,
40799a2dd95SBruce Richardson mtr_id, stats_mask, error);
40848e48fceSAnkur Dwivedi
40948e48fceSAnkur Dwivedi rte_mtr_trace_stats_update(port_id, mtr_id, stats_mask, ret);
41048e48fceSAnkur Dwivedi
41148e48fceSAnkur Dwivedi return ret;
41299a2dd95SBruce Richardson }
41399a2dd95SBruce Richardson
41499a2dd95SBruce Richardson /** MTR object stats read */
41599a2dd95SBruce Richardson int
rte_mtr_stats_read(uint16_t port_id,uint32_t mtr_id,struct rte_mtr_stats * stats,uint64_t * stats_mask,int clear,struct rte_mtr_error * error)41699a2dd95SBruce Richardson rte_mtr_stats_read(uint16_t port_id,
41799a2dd95SBruce Richardson uint32_t mtr_id,
41899a2dd95SBruce Richardson struct rte_mtr_stats *stats,
41999a2dd95SBruce Richardson uint64_t *stats_mask,
42099a2dd95SBruce Richardson int clear,
42199a2dd95SBruce Richardson struct rte_mtr_error *error)
42299a2dd95SBruce Richardson {
42399a2dd95SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[port_id];
42448e48fceSAnkur Dwivedi int ret;
42548e48fceSAnkur Dwivedi ret = RTE_MTR_FUNC(port_id, stats_read)(dev,
42699a2dd95SBruce Richardson mtr_id, stats, stats_mask, clear, error);
42748e48fceSAnkur Dwivedi
42848e48fceSAnkur Dwivedi rte_mtr_trace_stats_read(port_id, mtr_id, stats, *stats_mask, clear,
42948e48fceSAnkur Dwivedi ret);
43048e48fceSAnkur Dwivedi
43148e48fceSAnkur Dwivedi return ret;
43299a2dd95SBruce Richardson }
433