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