1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(C) 2022 Marvell International Ltd.
*/
#include <stdint.h>
#include <rte_errno.h>
#include "rte_ethdev.h"
#include "ethdev_driver.h"
#include "ethdev_private.h"
#include "ethdev_trace.h"
/* Get congestion management information for a port */
int
rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info)
{
struct rte_eth_dev *dev;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
if (info == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "congestion management info is NULL");
return -EINVAL;
}
if (dev->dev_ops->cman_info_get == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "Function not implemented");
return -ENOTSUP;
}
memset(info, 0, sizeof(struct rte_eth_cman_info));
ret = eth_err(port_id, (*dev->dev_ops->cman_info_get)(dev, info));
rte_eth_trace_cman_info_get(port_id, info, ret);
return ret;
}
/* Initialize congestion management structure with default values */
int
rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config)
{
struct rte_eth_dev *dev;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
if (config == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "congestion management config is NULL");
return -EINVAL;
}
if (dev->dev_ops->cman_config_init == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "Function not implemented");
return -ENOTSUP;
}
memset(config, 0, sizeof(struct rte_eth_cman_config));
ret = eth_err(port_id, (*dev->dev_ops->cman_config_init)(dev, config));
rte_eth_trace_cman_config_init(port_id, config, ret);
return ret;
}
/* Configure congestion management on a port */
int
rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config)
{
struct rte_eth_dev *dev;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
if (config == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "congestion management config is NULL");
return -EINVAL;
}
if (dev->dev_ops->cman_config_set == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "Function not implemented");
return -ENOTSUP;
}
ret = eth_err(port_id, (*dev->dev_ops->cman_config_set)(dev, config));
rte_eth_trace_cman_config_set(port_id, config, ret);
return ret;
}
/* Retrieve congestion management configuration of a port */
int
rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config)
{
struct rte_eth_dev *dev;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
if (config == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "congestion management config is NULL");
return -EINVAL;
}
if (dev->dev_ops->cman_config_get == NULL) {
RTE_ETHDEV_LOG_LINE(ERR, "Function not implemented");
return -ENOTSUP;
}
memset(config, 0, sizeof(struct rte_eth_cman_config));
ret = eth_err(port_id, (*dev->dev_ops->cman_config_get)(dev, config));
rte_eth_trace_cman_config_get(port_id, config, ret);
return ret;
}
|