1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
7 #include <rte_string_fns.h>
11 static struct rte_sched_subport_params
12 subport_profile[TMGR_SUBPORT_PROFILE_MAX];
14 static uint32_t n_subport_profiles;
16 static struct rte_sched_pipe_params
17 pipe_profile[TMGR_PIPE_PROFILE_MAX];
19 static uint32_t n_pipe_profiles;
21 static struct tmgr_port_list tmgr_port_list;
26 TAILQ_INIT(&tmgr_port_list);
32 tmgr_port_find(const char *name)
34 struct tmgr_port *tmgr_port;
39 TAILQ_FOREACH(tmgr_port, &tmgr_port_list, node)
40 if (strcmp(tmgr_port->name, name) == 0)
47 tmgr_subport_profile_add(struct rte_sched_subport_params *p)
49 /* Check input params */
54 memcpy(&subport_profile[n_subport_profiles],
64 tmgr_pipe_profile_add(struct rte_sched_pipe_params *p)
66 /* Check input params */
71 memcpy(&pipe_profile[n_pipe_profiles],
81 tmgr_port_create(const char *name, struct tmgr_port_params *params)
83 struct rte_sched_port_params p;
84 struct tmgr_port *tmgr_port;
85 struct rte_sched_port *s;
88 /* Check input params */
90 tmgr_port_find(name) ||
92 (params->n_subports_per_port == 0) ||
93 (params->n_pipes_per_subport == 0) ||
94 (params->cpu_id >= RTE_MAX_NUMA_NODES) ||
95 (n_subport_profiles == 0) ||
96 (n_pipe_profiles == 0))
101 p.socket = (int) params->cpu_id;
102 p.rate = params->rate;
104 p.frame_overhead = params->frame_overhead;
105 p.n_subports_per_port = params->n_subports_per_port;
106 p.n_pipes_per_subport = params->n_pipes_per_subport;
108 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
109 p.qsize[i] = params->qsize[i];
111 p.pipe_profiles = pipe_profile;
112 p.n_pipe_profiles = n_pipe_profiles;
114 s = rte_sched_port_config(&p);
118 for (i = 0; i < params->n_subports_per_port; i++) {
121 status = rte_sched_subport_config(
124 &subport_profile[0]);
127 rte_sched_port_free(s);
131 for (j = 0; j < params->n_pipes_per_subport; j++) {
132 status = rte_sched_pipe_config(
139 rte_sched_port_free(s);
145 /* Node allocation */
146 tmgr_port = calloc(1, sizeof(struct tmgr_port));
147 if (tmgr_port == NULL) {
148 rte_sched_port_free(s);
153 strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name));
155 tmgr_port->n_subports_per_port = params->n_subports_per_port;
156 tmgr_port->n_pipes_per_subport = params->n_pipes_per_subport;
158 /* Node add to list */
159 TAILQ_INSERT_TAIL(&tmgr_port_list, tmgr_port, node);
165 tmgr_subport_config(const char *port_name,
167 uint32_t subport_profile_id)
169 struct tmgr_port *port;
172 /* Check input params */
173 if (port_name == NULL)
176 port = tmgr_port_find(port_name);
177 if ((port == NULL) ||
178 (subport_id >= port->n_subports_per_port) ||
179 (subport_profile_id >= n_subport_profiles))
182 /* Resource config */
183 status = rte_sched_subport_config(
186 &subport_profile[subport_profile_id]);
192 tmgr_pipe_config(const char *port_name,
194 uint32_t pipe_id_first,
195 uint32_t pipe_id_last,
196 uint32_t pipe_profile_id)
198 struct tmgr_port *port;
201 /* Check input params */
202 if (port_name == NULL)
205 port = tmgr_port_find(port_name);
206 if ((port == NULL) ||
207 (subport_id >= port->n_subports_per_port) ||
208 (pipe_id_first >= port->n_pipes_per_subport) ||
209 (pipe_id_last >= port->n_pipes_per_subport) ||
210 (pipe_id_first > pipe_id_last) ||
211 (pipe_profile_id >= n_pipe_profiles))
214 /* Resource config */
215 for (i = pipe_id_first; i <= pipe_id_last; i++) {
218 status = rte_sched_pipe_config(
222 (int) pipe_profile_id);