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 */
51 p->n_pipes_per_subport_enabled == 0)
55 memcpy(&subport_profile[n_subport_profiles],
65 tmgr_pipe_profile_add(struct rte_sched_pipe_params *p)
67 /* Check input params */
72 memcpy(&pipe_profile[n_pipe_profiles],
82 tmgr_port_create(const char *name, struct tmgr_port_params *params)
84 struct rte_sched_port_params p;
85 struct tmgr_port *tmgr_port;
86 struct rte_sched_port *s;
89 /* Check input params */
91 tmgr_port_find(name) ||
93 (params->n_subports_per_port == 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 = TMGR_PIPE_SUBPORT_MAX;
108 s = rte_sched_port_config(&p);
112 subport_profile[0].pipe_profiles = pipe_profile;
113 subport_profile[0].n_pipe_profiles = n_pipe_profiles;
114 subport_profile[0].n_max_pipe_profiles = TMGR_PIPE_PROFILE_MAX;
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 < subport_profile[0].n_pipes_per_subport_enabled; 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 strlcpy(tmgr_port->name, name, sizeof(tmgr_port->name));
153 tmgr_port->n_subports_per_port = params->n_subports_per_port;
155 /* Node add to list */
156 TAILQ_INSERT_TAIL(&tmgr_port_list, tmgr_port, node);
162 tmgr_subport_config(const char *port_name,
164 uint32_t subport_profile_id)
166 struct tmgr_port *port;
169 /* Check input params */
170 if (port_name == NULL)
173 port = tmgr_port_find(port_name);
174 if ((port == NULL) ||
175 (subport_id >= port->n_subports_per_port) ||
176 (subport_profile_id >= n_subport_profiles))
179 /* Resource config */
180 status = rte_sched_subport_config(
183 &subport_profile[subport_profile_id]);
189 tmgr_pipe_config(const char *port_name,
191 uint32_t pipe_id_first,
192 uint32_t pipe_id_last,
193 uint32_t pipe_profile_id)
195 struct tmgr_port *port;
198 /* Check input params */
199 if (port_name == NULL)
202 port = tmgr_port_find(port_name);
203 if ((port == NULL) ||
204 (subport_id >= port->n_subports_per_port) ||
206 subport_profile[subport_id].n_pipes_per_subport_enabled) ||
208 subport_profile[subport_id].n_pipes_per_subport_enabled) ||
209 (pipe_id_first > pipe_id_last) ||
210 (pipe_profile_id >= n_pipe_profiles))
213 /* Resource config */
214 for (i = pipe_id_first; i <= pipe_id_last; i++) {
217 status = rte_sched_pipe_config(
221 (int) pipe_profile_id);