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.
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);
60 check_links(struct app_params *app)
62 uint32_t n_links_port_mask = __builtin_popcountll(app->port_mask);
65 /* Check that number of links matches the port mask */
66 APP_CHECK((app->n_links == n_links_port_mask),
67 "Not enough links provided in the PORT_MASK\n");
69 for (i = 0; i < app->n_links; i++) {
70 struct app_link_params *link = &app->link_params[i];
71 uint32_t rxq_max, n_rxq, n_txq, link_id, i;
73 APP_PARAM_GET_ID(link, "LINK", link_id);
75 /* Check that link RXQs are contiguous */
77 if (link->arp_q > rxq_max)
78 rxq_max = link->arp_q;
79 if (link->tcp_syn_local_q > rxq_max)
80 rxq_max = link->tcp_syn_local_q;
81 if (link->ip_local_q > rxq_max)
82 rxq_max = link->ip_local_q;
83 if (link->tcp_local_q > rxq_max)
84 rxq_max = link->tcp_local_q;
85 if (link->udp_local_q > rxq_max)
86 rxq_max = link->udp_local_q;
87 if (link->sctp_local_q > rxq_max)
88 rxq_max = link->sctp_local_q;
90 for (i = 1; i <= rxq_max; i++)
91 APP_CHECK(((link->arp_q == i) ||
92 (link->tcp_syn_local_q == i) ||
93 (link->ip_local_q == i) ||
94 (link->tcp_local_q == i) ||
95 (link->udp_local_q == i) ||
96 (link->sctp_local_q == i)),
97 "%s RXQs are not contiguous (A)\n", link->name);
99 n_rxq = app_link_get_n_rxq(app, link);
101 APP_CHECK((n_rxq == rxq_max + 1),
102 "%s RXQs are not contiguous (B)\n", link->name);
104 for (i = 0; i < n_rxq; i++) {
105 char name[APP_PARAM_NAME_SIZE];
108 sprintf(name, "RXQ%" PRIu32 ".%" PRIu32,
110 pos = APP_PARAM_FIND(app->hwq_in_params, name);
111 APP_CHECK((pos >= 0),
112 "%s RXQs are not contiguous (C)\n", link->name);
115 /* Check that link RXQs are contiguous */
116 n_txq = app_link_get_n_txq(app, link);
118 for (i = 0; i < n_txq; i++) {
119 char name[APP_PARAM_NAME_SIZE];
122 sprintf(name, "TXQ%" PRIu32 ".%" PRIu32,
124 pos = APP_PARAM_FIND(app->hwq_out_params, name);
125 APP_CHECK((pos >= 0),
126 "%s TXQs are not contiguous\n", link->name);
132 check_rxqs(struct app_params *app)
136 for (i = 0; i < app->n_pktq_hwq_in; i++) {
137 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
138 uint32_t n_readers = app_rxq_get_readers(app, p);
140 APP_CHECK((p->size > 0),
141 "%s size is 0\n", p->name);
143 APP_CHECK((rte_is_power_of_2(p->size)),
144 "%s size is not a power of 2\n", p->name);
146 APP_CHECK((p->burst > 0),
147 "%s burst size is 0\n", p->name);
149 APP_CHECK((p->burst <= p->size),
150 "%s burst size is bigger than its size\n", p->name);
152 APP_CHECK((n_readers != 0),
153 "%s has no reader\n", p->name);
155 APP_CHECK((n_readers == 1),
156 "%s has more than one reader\n", p->name);
161 check_txqs(struct app_params *app)
165 for (i = 0; i < app->n_pktq_hwq_out; i++) {
166 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
167 uint32_t n_writers = app_txq_get_writers(app, p);
169 APP_CHECK((p->size > 0),
170 "%s size is 0\n", p->name);
172 APP_CHECK((rte_is_power_of_2(p->size)),
173 "%s size is not a power of 2\n", p->name);
175 APP_CHECK((p->burst > 0),
176 "%s burst size is 0\n", p->name);
178 APP_CHECK((p->burst <= p->size),
179 "%s burst size is bigger than its size\n", p->name);
181 APP_CHECK((n_writers != 0),
182 "%s has no writer\n", p->name);
184 APP_CHECK((n_writers == 1),
185 "%s has more than one writer\n", p->name);
190 check_swqs(struct app_params *app)
194 for (i = 0; i < app->n_pktq_swq; i++) {
195 struct app_pktq_swq_params *p = &app->swq_params[i];
196 uint32_t n_readers = app_swq_get_readers(app, p);
197 uint32_t n_writers = app_swq_get_writers(app, p);
200 APP_CHECK((p->size > 0),
201 "%s size is 0\n", p->name);
203 APP_CHECK((rte_is_power_of_2(p->size)),
204 "%s size is not a power of 2\n", p->name);
206 APP_CHECK((p->burst_read > 0),
207 "%s read burst size is 0\n", p->name);
209 APP_CHECK((p->burst_read <= p->size),
210 "%s read burst size is bigger than its size\n",
213 APP_CHECK((p->burst_write > 0),
214 "%s write burst size is 0\n", p->name);
216 APP_CHECK((p->burst_write <= p->size),
217 "%s write burst size is bigger than its size\n",
220 APP_CHECK((n_readers != 0),
221 "%s has no reader\n", p->name);
224 APP_LOG(app, LOW, "%s has more than one reader", p->name);
226 APP_CHECK((n_writers != 0),
227 "%s has no writer\n", p->name);
230 APP_LOG(app, LOW, "%s has more than one writer", p->name);
232 n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras;
234 APP_CHECK((n_flags < 2),
235 "%s has more than one fragmentation or reassembly mode enabled\n",
238 APP_CHECK((!((n_readers > 1) && (n_flags == 1))),
239 "%s has more than one reader when fragmentation or reassembly"
243 APP_CHECK((!((n_writers > 1) && (n_flags == 1))),
244 "%s has more than one writer when fragmentation or reassembly"
248 n_flags = p->ipv4_ras + p->ipv6_ras;
250 APP_CHECK((!((p->dropless == 1) && (n_flags == 1))),
251 "%s has dropless when reassembly mode enabled\n", p->name);
253 n_flags = p->ipv4_frag + p->ipv6_frag;
256 uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) :
257 sizeof(struct ipv6_hdr);
259 APP_CHECK((p->mtu > ip_hdr_size),
260 "%s mtu size is smaller than ip header\n", p->name);
262 APP_CHECK((!((p->mtu - ip_hdr_size) % 8)),
263 "%s mtu size is incorrect\n", p->name);
269 check_tms(struct app_params *app)
273 for (i = 0; i < app->n_pktq_tm; i++) {
274 struct app_pktq_tm_params *p = &app->tm_params[i];
275 uint32_t n_readers = app_tm_get_readers(app, p);
276 uint32_t n_writers = app_tm_get_writers(app, p);
278 APP_CHECK((n_readers != 0),
279 "%s has no reader\n", p->name);
281 APP_CHECK((n_readers == 1),
282 "%s has more than one reader\n", p->name);
284 APP_CHECK((n_writers != 0),
285 "%s has no writer\n", p->name);
287 APP_CHECK((n_writers == 1),
288 "%s has more than one writer\n", p->name);
293 check_sources(struct app_params *app)
297 for (i = 0; i < app->n_pktq_source; i++) {
298 struct app_pktq_source_params *p = &app->source_params[i];
299 uint32_t n_readers = app_source_get_readers(app, p);
301 APP_CHECK((n_readers != 0),
302 "%s has no reader\n", p->name);
304 APP_CHECK((n_readers == 1),
305 "%s has more than one reader\n", p->name);
310 check_sinks(struct app_params *app)
314 for (i = 0; i < app->n_pktq_sink; i++) {
315 struct app_pktq_sink_params *p = &app->sink_params[i];
316 uint32_t n_writers = app_sink_get_writers(app, p);
318 APP_CHECK((n_writers != 0),
319 "%s has no writer\n", p->name);
321 APP_CHECK((n_writers == 1),
322 "%s has more than one writer\n", p->name);
327 check_msgqs(struct app_params *app)
331 for (i = 0; i < app->n_msgq; i++) {
332 struct app_msgq_params *p = &app->msgq_params[i];
333 uint32_t n_readers = app_msgq_get_readers(app, p);
334 uint32_t n_writers = app_msgq_get_writers(app, p);
335 uint32_t msgq_req_pipeline, msgq_rsp_pipeline;
336 uint32_t msgq_req_core, msgq_rsp_core;
338 APP_CHECK((p->size > 0),
339 "%s size is 0\n", p->name);
341 APP_CHECK((rte_is_power_of_2(p->size)),
342 "%s size is not a power of 2\n", p->name);
344 msgq_req_pipeline = (strncmp(p->name, "MSGQ-REQ-PIPELINE",
345 strlen("MSGQ-REQ-PIPELINE")) == 0);
347 msgq_rsp_pipeline = (strncmp(p->name, "MSGQ-RSP-PIPELINE",
348 strlen("MSGQ-RSP-PIPELINE")) == 0);
350 msgq_req_core = (strncmp(p->name, "MSGQ-REQ-CORE",
351 strlen("MSGQ-REQ-CORE")) == 0);
353 msgq_rsp_core = (strncmp(p->name, "MSGQ-RSP-CORE",
354 strlen("MSGQ-RSP-CORE")) == 0);
356 if ((msgq_req_pipeline == 0) &&
357 (msgq_rsp_pipeline == 0) &&
358 (msgq_req_core == 0) &&
359 (msgq_rsp_core == 0)) {
360 APP_CHECK((n_readers != 0),
361 "%s has no reader\n", p->name);
363 APP_CHECK((n_readers == 1),
364 "%s has more than one reader\n", p->name);
366 APP_CHECK((n_writers != 0),
367 "%s has no writer\n", p->name);
369 APP_CHECK((n_writers == 1),
370 "%s has more than one writer\n", p->name);
373 if (msgq_req_pipeline) {
374 struct app_pipeline_params *pipeline;
375 uint32_t pipeline_id;
377 APP_PARAM_GET_ID(p, "MSGQ-REQ-PIPELINE", pipeline_id);
379 APP_PARAM_FIND_BY_ID(app->pipeline_params,
384 APP_CHECK((pipeline != NULL),
385 "%s is not associated with a valid pipeline\n",
389 if (msgq_rsp_pipeline) {
390 struct app_pipeline_params *pipeline;
391 uint32_t pipeline_id;
393 APP_PARAM_GET_ID(p, "MSGQ-RSP-PIPELINE", pipeline_id);
395 APP_PARAM_FIND_BY_ID(app->pipeline_params,
400 APP_CHECK((pipeline != NULL),
401 "%s is not associated with a valid pipeline\n",
408 check_pipelines(struct app_params *app)
412 for (i = 0; i < app->n_pipelines; i++) {
413 struct app_pipeline_params *p = &app->pipeline_params[i];
415 APP_CHECK((p->n_msgq_in == p->n_msgq_out),
416 "%s number of input MSGQs does not match "
417 "the number of output MSGQs\n", p->name);
422 app_config_check(struct app_params *app)
433 check_pipelines(app);