1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
9 static struct rte_sched_subport_params
10 subport_profile[TMGR_SUBPORT_PROFILE_MAX];
12 static uint32_t n_subport_profiles;
14 static struct rte_sched_pipe_params
15 pipe_profile[TMGR_PIPE_PROFILE_MAX];
17 static uint32_t n_pipe_profiles;
19 static struct tmgr_port_list tmgr_port_list;
24 TAILQ_INIT(&tmgr_port_list);
30 tmgr_port_find(const char *name)
32 struct tmgr_port *tmgr_port;
37 TAILQ_FOREACH(tmgr_port, &tmgr_port_list, node)
38 if (strcmp(tmgr_port->name, name) == 0)
45 tmgr_subport_profile_add(struct rte_sched_subport_params *p)
47 /* Check input params */
52 memcpy(&subport_profile[n_subport_profiles],
62 tmgr_pipe_profile_add(struct rte_sched_pipe_params *p)
64 /* Check input params */
69 memcpy(&pipe_profile[n_pipe_profiles],
79 tmgr_port_create(const char *name, struct tmgr_port_params *params)
81 struct rte_sched_port_params p;
82 struct tmgr_port *tmgr_port;
83 struct rte_sched_port *s;
86 /* Check input params */
88 tmgr_port_find(name) ||
90 (params->n_subports_per_port == 0) ||
91 (params->n_pipes_per_subport == 0) ||
92 (params->cpu_id >= RTE_MAX_NUMA_NODES) ||
93 (n_subport_profiles == 0) ||
94 (n_pipe_profiles == 0))
99 p.socket = (int) params->cpu_id;
100 p.rate = params->rate;
102 p.frame_overhead = params->frame_overhead;
103 p.n_subports_per_port = params->n_subports_per_port;
104 p.n_pipes_per_subport = params->n_pipes_per_subport;
106 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
107 p.qsize[i] = params->qsize[i];
109 p.pipe_profiles = pipe_profile;
110 p.n_pipe_profiles = n_pipe_profiles;
112 s = rte_sched_port_config(&p);
116 for (i = 0; i < params->n_subports_per_port; i++) {
119 status = rte_sched_subport_config(
122 &subport_profile[0]);
125 rte_sched_port_free(s);
129 for (j = 0; j < params->n_pipes_per_subport; j++) {
130 status = rte_sched_pipe_config(
137 rte_sched_port_free(s);
143 /* Node allocation */
144 tmgr_port = calloc(1, sizeof(struct tmgr_port));
145 if (tmgr_port == NULL) {
146 rte_sched_port_free(s);
151 strncpy(tmgr_port->name, name, sizeof(tmgr_port->name));
153 tmgr_port->n_subports_per_port = params->n_subports_per_port;
154 tmgr_port->n_pipes_per_subport = params->n_pipes_per_subport;
156 /* Node add to list */
157 TAILQ_INSERT_TAIL(&tmgr_port_list, tmgr_port, node);
163 tmgr_subport_config(const char *port_name,
165 uint32_t subport_profile_id)
167 struct tmgr_port *port;
170 /* Check input params */
171 if (port_name == NULL)
174 port = tmgr_port_find(port_name);
175 if ((port == NULL) ||
176 (subport_id >= port->n_subports_per_port) ||
177 (subport_profile_id >= n_subport_profiles))
180 /* Resource config */
181 status = rte_sched_subport_config(
184 &subport_profile[subport_profile_id]);
190 tmgr_pipe_config(const char *port_name,
192 uint32_t pipe_id_first,
193 uint32_t pipe_id_last,
194 uint32_t pipe_profile_id)
196 struct tmgr_port *port;
199 /* Check input params */
200 if (port_name == NULL)
203 port = tmgr_port_find(port_name);
204 if ((port == NULL) ||
205 (subport_id >= port->n_subports_per_port) ||
206 (pipe_id_first >= port->n_pipes_per_subport) ||
207 (pipe_id_last >= port->n_pipes_per_subport) ||
208 (pipe_id_first > pipe_id_last) ||
209 (pipe_profile_id >= n_pipe_profiles))
212 /* Resource config */
213 for (i = pipe_id_first; i <= pipe_id_last; i++) {
216 status = rte_sched_pipe_config(
220 (int) pipe_profile_id);