4 * Copyright(c) 2010-2016 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.
41 check_mempools(struct app_params *app)
45 for (i = 0; i < app->n_mempools; i++) {
46 struct app_mempool_params *p = &app->mempool_params[i];
48 APP_CHECK((p->pool_size > 0),
49 "Mempool %s size is 0\n", p->name);
51 APP_CHECK((p->cache_size > 0),
52 "Mempool %s cache size is 0\n", p->name);
54 APP_CHECK(rte_is_power_of_2(p->cache_size),
55 "Mempool %s cache size not a power of 2\n", p->name);
59 static inline uint32_t
60 link_rxq_used(struct app_link_params *link, uint32_t q_id)
64 if ((link->arp_q == q_id) ||
65 (link->tcp_syn_q == q_id) ||
66 (link->ip_local_q == q_id) ||
67 (link->tcp_local_q == q_id) ||
68 (link->udp_local_q == q_id) ||
69 (link->sctp_local_q == q_id))
72 for (i = 0; i < link->n_rss_qs; i++)
73 if (link->rss_qs[i] == q_id)
80 check_links(struct app_params *app)
84 /* Check that number of links matches the port mask */
86 uint32_t n_links_port_mask =
87 __builtin_popcountll(app->port_mask);
89 APP_CHECK((app->n_links == n_links_port_mask),
90 "Not enough links provided in the PORT_MASK\n");
93 for (i = 0; i < app->n_links; i++) {
94 struct app_link_params *link = &app->link_params[i];
95 uint32_t rxq_max, n_rxq, n_txq, link_id, i;
97 APP_PARAM_GET_ID(link, "LINK", link_id);
99 /* Check that link RXQs are contiguous */
101 if (link->arp_q > rxq_max)
102 rxq_max = link->arp_q;
103 if (link->tcp_syn_q > rxq_max)
104 rxq_max = link->tcp_syn_q;
105 if (link->ip_local_q > rxq_max)
106 rxq_max = link->ip_local_q;
107 if (link->tcp_local_q > rxq_max)
108 rxq_max = link->tcp_local_q;
109 if (link->udp_local_q > rxq_max)
110 rxq_max = link->udp_local_q;
111 if (link->sctp_local_q > rxq_max)
112 rxq_max = link->sctp_local_q;
113 for (i = 0; i < link->n_rss_qs; i++)
114 if (link->rss_qs[i] > rxq_max)
115 rxq_max = link->rss_qs[i];
117 for (i = 1; i <= rxq_max; i++)
118 APP_CHECK((link_rxq_used(link, i)),
119 "%s RXQs are not contiguous (A)\n", link->name);
121 n_rxq = app_link_get_n_rxq(app, link);
123 APP_CHECK((n_rxq), "%s does not have any RXQ\n", link->name);
125 APP_CHECK((n_rxq == rxq_max + 1),
126 "%s RXQs are not contiguous (B)\n", link->name);
128 for (i = 0; i < n_rxq; i++) {
129 char name[APP_PARAM_NAME_SIZE];
132 sprintf(name, "RXQ%" PRIu32 ".%" PRIu32,
134 pos = APP_PARAM_FIND(app->hwq_in_params, name);
135 APP_CHECK((pos >= 0),
136 "%s RXQs are not contiguous (C)\n", link->name);
139 /* Check that link TXQs are contiguous */
140 n_txq = app_link_get_n_txq(app, link);
142 APP_CHECK((n_txq), "%s does not have any TXQ\n", link->name);
144 for (i = 0; i < n_txq; i++) {
145 char name[APP_PARAM_NAME_SIZE];
148 sprintf(name, "TXQ%" PRIu32 ".%" PRIu32,
150 pos = APP_PARAM_FIND(app->hwq_out_params, name);
151 APP_CHECK((pos >= 0),
152 "%s TXQs are not contiguous\n", link->name);
158 check_rxqs(struct app_params *app)
162 for (i = 0; i < app->n_pktq_hwq_in; i++) {
163 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
164 uint32_t n_readers = app_rxq_get_readers(app, p);
166 APP_CHECK((p->size > 0),
167 "%s size is 0\n", p->name);
169 APP_CHECK((rte_is_power_of_2(p->size)),
170 "%s size is not a power of 2\n", p->name);
172 APP_CHECK((p->burst > 0),
173 "%s burst size is 0\n", p->name);
175 APP_CHECK((p->burst <= p->size),
176 "%s burst size is bigger than its size\n", p->name);
178 APP_CHECK((n_readers != 0),
179 "%s has no reader\n", p->name);
181 APP_CHECK((n_readers == 1),
182 "%s has more than one reader\n", p->name);
187 check_txqs(struct app_params *app)
191 for (i = 0; i < app->n_pktq_hwq_out; i++) {
192 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
193 uint32_t n_writers = app_txq_get_writers(app, p);
195 APP_CHECK((p->size > 0),
196 "%s size is 0\n", p->name);
198 APP_CHECK((rte_is_power_of_2(p->size)),
199 "%s size is not a power of 2\n", p->name);
201 APP_CHECK((p->burst > 0),
202 "%s burst size is 0\n", p->name);
204 APP_CHECK((p->burst <= p->size),
205 "%s burst size is bigger than its size\n", p->name);
207 APP_CHECK((n_writers != 0),
208 "%s has no writer\n", p->name);
210 APP_CHECK((n_writers == 1),
211 "%s has more than one writer\n", p->name);
216 check_swqs(struct app_params *app)
220 for (i = 0; i < app->n_pktq_swq; i++) {
221 struct app_pktq_swq_params *p = &app->swq_params[i];
222 uint32_t n_readers = app_swq_get_readers(app, p);
223 uint32_t n_writers = app_swq_get_writers(app, p);
226 APP_CHECK((p->size > 0),
227 "%s size is 0\n", p->name);
229 APP_CHECK((rte_is_power_of_2(p->size)),
230 "%s size is not a power of 2\n", p->name);
232 APP_CHECK((p->burst_read > 0),
233 "%s read burst size is 0\n", p->name);
235 APP_CHECK((p->burst_read <= p->size),
236 "%s read burst size is bigger than its size\n",
239 APP_CHECK((p->burst_write > 0),
240 "%s write burst size is 0\n", p->name);
242 APP_CHECK((p->burst_write <= p->size),
243 "%s write burst size is bigger than its size\n",
246 APP_CHECK((n_readers != 0),
247 "%s has no reader\n", p->name);
250 APP_LOG(app, LOW, "%s has more than one reader", p->name);
252 APP_CHECK((n_writers != 0),
253 "%s has no writer\n", p->name);
256 APP_LOG(app, LOW, "%s has more than one writer", p->name);
258 n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras;
260 APP_CHECK((n_flags < 2),
261 "%s has more than one fragmentation or reassembly mode enabled\n",
264 APP_CHECK((!((n_readers > 1) && (n_flags == 1))),
265 "%s has more than one reader when fragmentation or reassembly"
269 APP_CHECK((!((n_writers > 1) && (n_flags == 1))),
270 "%s has more than one writer when fragmentation or reassembly"
274 n_flags = p->ipv4_ras + p->ipv6_ras;
276 APP_CHECK((!((p->dropless == 1) && (n_flags == 1))),
277 "%s has dropless when reassembly mode enabled\n", p->name);
279 n_flags = p->ipv4_frag + p->ipv6_frag;
282 uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) :
283 sizeof(struct ipv6_hdr);
285 APP_CHECK((p->mtu > ip_hdr_size),
286 "%s mtu size is smaller than ip header\n", p->name);
288 APP_CHECK((!((p->mtu - ip_hdr_size) % 8)),
289 "%s mtu size is incorrect\n", p->name);
295 check_tms(struct app_params *app)
299 for (i = 0; i < app->n_pktq_tm; i++) {
300 struct app_pktq_tm_params *p = &app->tm_params[i];
301 uint32_t n_readers = app_tm_get_readers(app, p);
302 uint32_t n_writers = app_tm_get_writers(app, p);
304 APP_CHECK((n_readers != 0),
305 "%s has no reader\n", p->name);
307 APP_CHECK((n_readers == 1),
308 "%s has more than one reader\n", p->name);
310 APP_CHECK((n_writers != 0),
311 "%s has no writer\n", p->name);
313 APP_CHECK((n_writers == 1),
314 "%s has more than one writer\n", p->name);
319 check_knis(struct app_params *app) {
322 for (i = 0; i < app->n_pktq_kni; i++) {
323 struct app_pktq_kni_params *p = &app->kni_params[i];
324 uint32_t n_readers = app_kni_get_readers(app, p);
325 uint32_t n_writers = app_kni_get_writers(app, p);
327 APP_CHECK((n_readers != 0),
328 "%s has no reader\n", p->name);
330 APP_CHECK((n_readers == 1),
331 "%s has more than one reader\n", p->name);
333 APP_CHECK((n_writers != 0),
334 "%s has no writer\n", p->name);
336 APP_CHECK((n_writers == 1),
337 "%s has more than one writer\n", p->name);
342 check_sources(struct app_params *app)
346 for (i = 0; i < app->n_pktq_source; i++) {
347 struct app_pktq_source_params *p = &app->source_params[i];
348 uint32_t n_readers = app_source_get_readers(app, p);
350 APP_CHECK((n_readers != 0),
351 "%s has no reader\n", p->name);
353 APP_CHECK((n_readers == 1),
354 "%s has more than one reader\n", p->name);
359 check_sinks(struct app_params *app)
363 for (i = 0; i < app->n_pktq_sink; i++) {
364 struct app_pktq_sink_params *p = &app->sink_params[i];
365 uint32_t n_writers = app_sink_get_writers(app, p);
367 APP_CHECK((n_writers != 0),
368 "%s has no writer\n", p->name);
370 APP_CHECK((n_writers == 1),
371 "%s has more than one writer\n", p->name);
376 check_msgqs(struct app_params *app)
380 for (i = 0; i < app->n_msgq; i++) {
381 struct app_msgq_params *p = &app->msgq_params[i];
382 uint32_t n_readers = app_msgq_get_readers(app, p);
383 uint32_t n_writers = app_msgq_get_writers(app, p);
384 uint32_t msgq_req_pipeline, msgq_rsp_pipeline;
385 uint32_t msgq_req_core, msgq_rsp_core;
387 APP_CHECK((p->size > 0),
388 "%s size is 0\n", p->name);
390 APP_CHECK((rte_is_power_of_2(p->size)),
391 "%s size is not a power of 2\n", p->name);
393 msgq_req_pipeline = (strncmp(p->name, "MSGQ-REQ-PIPELINE",
394 strlen("MSGQ-REQ-PIPELINE")) == 0);
396 msgq_rsp_pipeline = (strncmp(p->name, "MSGQ-RSP-PIPELINE",
397 strlen("MSGQ-RSP-PIPELINE")) == 0);
399 msgq_req_core = (strncmp(p->name, "MSGQ-REQ-CORE",
400 strlen("MSGQ-REQ-CORE")) == 0);
402 msgq_rsp_core = (strncmp(p->name, "MSGQ-RSP-CORE",
403 strlen("MSGQ-RSP-CORE")) == 0);
405 if ((msgq_req_pipeline == 0) &&
406 (msgq_rsp_pipeline == 0) &&
407 (msgq_req_core == 0) &&
408 (msgq_rsp_core == 0)) {
409 APP_CHECK((n_readers != 0),
410 "%s has no reader\n", p->name);
412 APP_CHECK((n_readers == 1),
413 "%s has more than one reader\n", p->name);
415 APP_CHECK((n_writers != 0),
416 "%s has no writer\n", p->name);
418 APP_CHECK((n_writers == 1),
419 "%s has more than one writer\n", p->name);
422 if (msgq_req_pipeline) {
423 struct app_pipeline_params *pipeline;
424 uint32_t pipeline_id;
426 APP_PARAM_GET_ID(p, "MSGQ-REQ-PIPELINE", pipeline_id);
428 APP_PARAM_FIND_BY_ID(app->pipeline_params,
433 APP_CHECK((pipeline != NULL),
434 "%s is not associated with a valid pipeline\n",
438 if (msgq_rsp_pipeline) {
439 struct app_pipeline_params *pipeline;
440 uint32_t pipeline_id;
442 APP_PARAM_GET_ID(p, "MSGQ-RSP-PIPELINE", pipeline_id);
444 APP_PARAM_FIND_BY_ID(app->pipeline_params,
449 APP_CHECK((pipeline != NULL),
450 "%s is not associated with a valid pipeline\n",
457 check_pipelines(struct app_params *app)
461 for (i = 0; i < app->n_pipelines; i++) {
462 struct app_pipeline_params *p = &app->pipeline_params[i];
464 APP_CHECK((p->n_msgq_in == p->n_msgq_out),
465 "%s number of input MSGQs does not match "
466 "the number of output MSGQs\n", p->name);
471 app_config_check(struct app_params *app)
483 check_pipelines(app);