4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 check_mempools(struct app_params *app)
43 for (i = 0; i < app->n_mempools; i++) {
44 struct app_mempool_params *p = &app->mempool_params[i];
46 APP_CHECK((p->pool_size > 0),
47 "Mempool %s size is 0\n", p->name);
49 APP_CHECK((p->cache_size > 0),
50 "Mempool %s cache size is 0\n", p->name);
52 APP_CHECK(rte_is_power_of_2(p->cache_size),
53 "Mempool %s cache size not a power of 2\n", p->name);
58 check_links(struct app_params *app)
60 uint32_t n_links_port_mask = __builtin_popcountll(app->port_mask);
63 /* Check that number of links matches the port mask */
64 APP_CHECK((app->n_links == n_links_port_mask),
65 "Not enough links provided in the PORT_MASK\n");
67 for (i = 0; i < app->n_links; i++) {
68 struct app_link_params *link = &app->link_params[i];
69 uint32_t rxq_max, n_rxq, n_txq, link_id, i;
71 APP_PARAM_GET_ID(link, "LINK", link_id);
73 /* Check that link RXQs are contiguous */
75 if (link->arp_q > rxq_max)
76 rxq_max = link->arp_q;
77 if (link->tcp_syn_local_q > rxq_max)
78 rxq_max = link->tcp_syn_local_q;
79 if (link->ip_local_q > rxq_max)
80 rxq_max = link->ip_local_q;
81 if (link->tcp_local_q > rxq_max)
82 rxq_max = link->tcp_local_q;
83 if (link->udp_local_q > rxq_max)
84 rxq_max = link->udp_local_q;
85 if (link->sctp_local_q > rxq_max)
86 rxq_max = link->sctp_local_q;
88 for (i = 1; i <= rxq_max; i++)
89 APP_CHECK(((link->arp_q == i) ||
90 (link->tcp_syn_local_q == i) ||
91 (link->ip_local_q == i) ||
92 (link->tcp_local_q == i) ||
93 (link->udp_local_q == i) ||
94 (link->sctp_local_q == i)),
95 "%s RXQs are not contiguous (A)\n", link->name);
97 n_rxq = app_link_get_n_rxq(app, link);
99 APP_CHECK((n_rxq == rxq_max + 1),
100 "%s RXQs are not contiguous (B)\n", link->name);
102 for (i = 0; i < n_rxq; i++) {
103 char name[APP_PARAM_NAME_SIZE];
106 sprintf(name, "RXQ%" PRIu32 ".%" PRIu32,
108 pos = APP_PARAM_FIND(app->hwq_in_params, name);
109 APP_CHECK((pos >= 0),
110 "%s RXQs are not contiguous (C)\n", link->name);
113 /* Check that link RXQs are contiguous */
114 n_txq = app_link_get_n_txq(app, link);
116 for (i = 0; i < n_txq; i++) {
117 char name[APP_PARAM_NAME_SIZE];
120 sprintf(name, "TXQ%" PRIu32 ".%" PRIu32,
122 pos = APP_PARAM_FIND(app->hwq_out_params, name);
123 APP_CHECK((pos >= 0),
124 "%s TXQs are not contiguous\n", link->name);
130 check_rxqs(struct app_params *app)
134 for (i = 0; i < app->n_pktq_hwq_in; i++) {
135 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
136 uint32_t n_readers = app_rxq_get_readers(app, p);
138 APP_CHECK((p->size > 0),
139 "%s size is 0\n", p->name);
141 APP_CHECK((rte_is_power_of_2(p->size)),
142 "%s size is not a power of 2\n", p->name);
144 APP_CHECK((p->burst > 0),
145 "%s burst size is 0\n", p->name);
147 APP_CHECK((p->burst <= p->size),
148 "%s burst size is bigger than its size\n", p->name);
150 APP_CHECK((n_readers != 0),
151 "%s has no reader\n", p->name);
153 APP_CHECK((n_readers == 1),
154 "%s has more than one reader\n", p->name);
159 check_txqs(struct app_params *app)
163 for (i = 0; i < app->n_pktq_hwq_out; i++) {
164 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
165 uint32_t n_writers = app_txq_get_writers(app, p);
167 APP_CHECK((p->size > 0),
168 "%s size is 0\n", p->name);
170 APP_CHECK((rte_is_power_of_2(p->size)),
171 "%s size is not a power of 2\n", p->name);
173 APP_CHECK((p->burst > 0),
174 "%s burst size is 0\n", p->name);
176 APP_CHECK((p->burst <= p->size),
177 "%s burst size is bigger than its size\n", p->name);
179 APP_CHECK((n_writers != 0),
180 "%s has no writer\n", p->name);
182 APP_CHECK((n_writers == 1),
183 "%s has more than one writer\n", p->name);
188 check_swqs(struct app_params *app)
192 for (i = 0; i < app->n_pktq_swq; i++) {
193 struct app_pktq_swq_params *p = &app->swq_params[i];
194 uint32_t n_readers = app_swq_get_readers(app, p);
195 uint32_t n_writers = app_swq_get_writers(app, p);
197 APP_CHECK((p->size > 0),
198 "%s size is 0\n", p->name);
200 APP_CHECK((rte_is_power_of_2(p->size)),
201 "%s size is not a power of 2\n", p->name);
203 APP_CHECK((p->burst_read > 0),
204 "%s read burst size is 0\n", p->name);
206 APP_CHECK((p->burst_read <= p->size),
207 "%s read burst size is bigger than its size\n",
210 APP_CHECK((p->burst_write > 0),
211 "%s write burst size is 0\n", p->name);
213 APP_CHECK((p->burst_write <= p->size),
214 "%s write burst size is bigger than its size\n",
217 APP_CHECK((n_readers != 0),
218 "%s has no reader\n", p->name);
220 APP_CHECK((n_readers == 1),
221 "%s has more than one reader\n", p->name);
223 APP_CHECK((n_writers != 0),
224 "%s has no writer\n", p->name);
226 APP_CHECK((n_writers == 1),
227 "%s has more than one writer\n", p->name);
232 check_tms(struct app_params *app)
236 for (i = 0; i < app->n_pktq_tm; i++) {
237 struct app_pktq_tm_params *p = &app->tm_params[i];
238 uint32_t n_readers = app_tm_get_readers(app, p);
239 uint32_t n_writers = app_tm_get_writers(app, p);
241 APP_CHECK((n_readers != 0),
242 "%s has no reader\n", p->name);
244 APP_CHECK((n_readers == 1),
245 "%s has more than one reader\n", p->name);
247 APP_CHECK((n_writers != 0),
248 "%s has no writer\n", p->name);
250 APP_CHECK((n_writers == 1),
251 "%s has more than one writer\n", p->name);
256 check_sources(struct app_params *app)
260 for (i = 0; i < app->n_pktq_source; i++) {
261 struct app_pktq_source_params *p = &app->source_params[i];
262 uint32_t n_readers = app_source_get_readers(app, p);
264 APP_CHECK((n_readers != 0),
265 "%s has no reader\n", p->name);
267 APP_CHECK((n_readers == 1),
268 "%s has more than one reader\n", p->name);
273 check_sinks(struct app_params *app)
277 for (i = 0; i < app->n_pktq_sink; i++) {
278 struct app_pktq_sink_params *p = &app->sink_params[i];
279 uint32_t n_writers = app_sink_get_writers(app, p);
281 APP_CHECK((n_writers != 0),
282 "%s has no writer\n", p->name);
284 APP_CHECK((n_writers == 1),
285 "%s has more than one writer\n", p->name);
290 check_msgqs(struct app_params *app)
294 for (i = 0; i < app->n_msgq; i++) {
295 struct app_msgq_params *p = &app->msgq_params[i];
296 uint32_t n_readers = app_msgq_get_readers(app, p);
297 uint32_t n_writers = app_msgq_get_writers(app, p);
298 uint32_t msgq_req_pipeline, msgq_rsp_pipeline;
299 uint32_t msgq_req_core, msgq_rsp_core;
301 APP_CHECK((p->size > 0),
302 "%s size is 0\n", p->name);
304 APP_CHECK((rte_is_power_of_2(p->size)),
305 "%s size is not a power of 2\n", p->name);
307 msgq_req_pipeline = (strncmp(p->name, "MSGQ-REQ-PIPELINE",
308 strlen("MSGQ-REQ-PIPELINE")) == 0);
310 msgq_rsp_pipeline = (strncmp(p->name, "MSGQ-RSP-PIPELINE",
311 strlen("MSGQ-RSP-PIPELINE")) == 0);
313 msgq_req_core = (strncmp(p->name, "MSGQ-REQ-CORE",
314 strlen("MSGQ-REQ-CORE")) == 0);
316 msgq_rsp_core = (strncmp(p->name, "MSGQ-RSP-CORE",
317 strlen("MSGQ-RSP-CORE")) == 0);
319 if ((msgq_req_pipeline == 0) &&
320 (msgq_rsp_pipeline == 0) &&
321 (msgq_req_core == 0) &&
322 (msgq_rsp_core == 0)) {
323 APP_CHECK((n_readers != 0),
324 "%s has no reader\n", p->name);
326 APP_CHECK((n_readers == 1),
327 "%s has more than one reader\n", p->name);
329 APP_CHECK((n_writers != 0),
330 "%s has no writer\n", p->name);
332 APP_CHECK((n_writers == 1),
333 "%s has more than one writer\n", p->name);
336 if (msgq_req_pipeline) {
337 struct app_pipeline_params *pipeline;
338 uint32_t pipeline_id;
340 APP_PARAM_GET_ID(p, "MSGQ-REQ-PIPELINE", pipeline_id);
342 APP_PARAM_FIND_BY_ID(app->pipeline_params,
347 APP_CHECK((pipeline != NULL),
348 "%s is not associated with a valid pipeline\n",
352 if (msgq_rsp_pipeline) {
353 struct app_pipeline_params *pipeline;
354 uint32_t pipeline_id;
356 APP_PARAM_GET_ID(p, "MSGQ-RSP-PIPELINE", pipeline_id);
358 APP_PARAM_FIND_BY_ID(app->pipeline_params,
363 APP_CHECK((pipeline != NULL),
364 "%s is not associated with a valid pipeline\n",
371 check_pipelines(struct app_params *app)
375 for (i = 0; i < app->n_pipelines; i++) {
376 struct app_pipeline_params *p = &app->pipeline_params[i];
378 APP_CHECK((p->n_msgq_in == p->n_msgq_out),
379 "%s number of input MSGQs does not match "
380 "the number of output MSGQs\n", p->name);
385 app_config_check(struct app_params *app)
396 check_pipelines(app);