2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
22 //uint8_t g_n_hwq_in = N_RXQ;
25 check_mempools(struct app_params *app)
29 for (i = 0; i < app->n_mempools; i++) {
30 struct app_mempool_params *p = &app->mempool_params[i];
32 APP_CHECK((p->pool_size > 0),
33 "Mempool %s size is 0\n", p->name);
35 APP_CHECK((p->cache_size > 0),
36 "Mempool %s cache size is 0\n", p->name);
38 APP_CHECK(rte_is_power_of_2(p->cache_size),
39 "Mempool %s cache size not a power of 2\n", p->name);
44 check_links(struct app_params *app)
48 /* Check that number of links matches the port mask */
50 uint32_t n_links_port_mask =
51 __builtin_popcountll(app->port_mask);
53 APP_CHECK((app->n_links == n_links_port_mask),
54 "Not enough links provided in the PORT_MASK\n");
57 for (i = 0; i < app->n_links; i++) {
58 struct app_link_params *link = &app->link_params[i];
59 uint32_t rxq_max, n_rxq, n_txq, link_id, i;
61 APP_PARAM_GET_ID(link, "LINK", link_id);
63 /* Check that link RXQs are contiguous */
65 if (link->arp_q > rxq_max)
66 rxq_max = link->arp_q;
67 if (link->tcp_syn_q > rxq_max)
68 rxq_max = link->tcp_syn_q;
69 if (link->ip_local_q > rxq_max)
70 rxq_max = link->ip_local_q;
71 if (link->tcp_local_q > rxq_max)
72 rxq_max = link->tcp_local_q;
73 if (link->udp_local_q > rxq_max)
74 rxq_max = link->udp_local_q;
75 if (link->sctp_local_q > rxq_max)
76 rxq_max = link->sctp_local_q;
78 if(enable_hwlb || enable_flow_dir){
79 g_n_hwq_in = app->n_hwlb_q;
80 rxq_max = (g_n_hwq_in - 1);
81 for (i = g_n_hwq_in; i <= rxq_max; i++)
82 APP_CHECK(((link->arp_q == i) ||
83 (link->tcp_syn_q == i) ||
84 (link->ip_local_q == i) ||
85 (link->tcp_local_q == i) ||
86 (link->udp_local_q == i) ||
87 (link->sctp_local_q == i)),
88 "%s RXQs are not contiguous (A)\n", link->name);
92 for (i = 1; i <= rxq_max; i++)
93 APP_CHECK(((link->arp_q == i) ||
94 (link->tcp_syn_q == i) ||
95 (link->ip_local_q == i) ||
96 (link->tcp_local_q == i) ||
97 (link->udp_local_q == i) ||
98 (link->sctp_local_q == i)),
99 "%s RXQs are not contiguous (A)\n", link->name);
101 n_rxq = app_link_get_n_rxq(app, link);
103 APP_CHECK((n_rxq), "%s does not have any RXQ\n", link->name);
104 printf("n_rxq = %d\n",n_rxq);
105 printf("rxq_max = %d\n",rxq_max);
106 //APP_CHECK((n_rxq == rxq_max + 1),
107 // "%s RXQs are not contiguous (B)\n", link->name);
109 for (i = 0; i < n_rxq; i++) {
110 char name[APP_PARAM_NAME_SIZE];
113 sprintf(name, "RXQ%" PRIu32 ".%" PRIu32,
115 pos = APP_PARAM_FIND(app->hwq_in_params, name);
116 APP_CHECK((pos >= 0),
117 "%s RXQs are not contiguous (C)\n", link->name);
120 /* Check that link RXQs are contiguous */
121 n_txq = app_link_get_n_txq(app, link);
123 APP_CHECK((n_txq), "%s does not have any TXQ\n", link->name);
125 for (i = 0; i < n_txq; i++) {
126 char name[APP_PARAM_NAME_SIZE];
129 sprintf(name, "TXQ%" PRIu32 ".%" PRIu32,
131 pos = APP_PARAM_FIND(app->hwq_out_params, name);
132 APP_CHECK((pos >= 0),
133 "%s TXQs are not contiguous\n", link->name);
139 check_rxqs(struct app_params *app)
143 for (i = 0; i < app->n_pktq_hwq_in; i++) {
144 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
145 uint32_t n_readers = app_rxq_get_readers(app, p);
147 APP_CHECK((p->size > 0),
148 "%s size is 0\n", p->name);
150 APP_CHECK((rte_is_power_of_2(p->size)),
151 "%s size is not a power of 2\n", p->name);
153 APP_CHECK((p->burst > 0),
154 "%s burst size is 0\n", p->name);
156 APP_CHECK((p->burst <= p->size),
157 "%s burst size is bigger than its size\n", p->name);
159 APP_CHECK((n_readers != 0),
160 "%s has no reader\n", p->name);
162 APP_CHECK((n_readers == 1),
163 "%s has more than one reader\n", p->name);
168 check_txqs(struct app_params *app)
172 for (i = 0; i < app->n_pktq_hwq_out; i++) {
173 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
174 uint32_t n_writers = app_txq_get_writers(app, p);
176 APP_CHECK((p->size > 0),
177 "%s size is 0\n", p->name);
179 APP_CHECK((rte_is_power_of_2(p->size)),
180 "%s size is not a power of 2\n", p->name);
182 APP_CHECK((p->burst > 0),
183 "%s burst size is 0\n", p->name);
185 APP_CHECK((p->burst <= p->size),
186 "%s burst size is bigger than its size\n", p->name);
188 APP_CHECK((n_writers != 0),
189 "%s has no writer\n", p->name);
191 APP_CHECK((n_writers == 1),
192 "%s has more than one writer\n", p->name);
197 check_swqs(struct app_params *app)
201 for (i = 0; i < app->n_pktq_swq; i++) {
202 struct app_pktq_swq_params *p = &app->swq_params[i];
203 uint32_t n_readers = app_swq_get_readers(app, p);
204 uint32_t n_writers = app_swq_get_writers(app, p);
207 APP_CHECK((p->size > 0),
208 "%s size is 0\n", p->name);
210 APP_CHECK((rte_is_power_of_2(p->size)),
211 "%s size is not a power of 2\n", p->name);
213 APP_CHECK((p->burst_read > 0),
214 "%s read burst size is 0\n", p->name);
216 APP_CHECK((p->burst_read <= p->size),
217 "%s read burst size is bigger than its size\n",
220 APP_CHECK((p->burst_write > 0),
221 "%s write burst size is 0\n", p->name);
223 APP_CHECK((p->burst_write <= p->size),
224 "%s write burst size is bigger than its size\n",
227 APP_CHECK((n_readers != 0),
228 "%s has no reader\n", p->name);
231 APP_LOG(app, LOW, "%s has more than one reader", p->name);
233 APP_CHECK((n_writers != 0),
234 "%s has no writer\n", p->name);
237 APP_LOG(app, LOW, "%s has more than one writer", p->name);
239 n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras;
241 APP_CHECK((n_flags < 2),
242 "%s has more than one fragmentation or reassembly mode enabled\n",
245 APP_CHECK((!((n_readers > 1) && (n_flags == 1))),
246 "%s has more than one reader when fragmentation or reassembly"
250 APP_CHECK((!((n_writers > 1) && (n_flags == 1))),
251 "%s has more than one writer when fragmentation or reassembly"
255 n_flags = p->ipv4_ras + p->ipv6_ras;
257 APP_CHECK((!((p->dropless == 1) && (n_flags == 1))),
258 "%s has dropless when reassembly mode enabled\n", p->name);
260 n_flags = p->ipv4_frag + p->ipv6_frag;
263 uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) :
264 sizeof(struct ipv6_hdr);
266 APP_CHECK((p->mtu > ip_hdr_size),
267 "%s mtu size is smaller than ip header\n", p->name);
269 APP_CHECK((!((p->mtu - ip_hdr_size) % 8)),
270 "%s mtu size is incorrect\n", p->name);
276 check_tms(struct app_params *app)
280 for (i = 0; i < app->n_pktq_tm; i++) {
281 struct app_pktq_tm_params *p = &app->tm_params[i];
282 uint32_t n_readers = app_tm_get_readers(app, p);
283 uint32_t n_writers = app_tm_get_writers(app, p);
285 APP_CHECK((n_readers != 0),
286 "%s has no reader\n", p->name);
288 APP_CHECK((n_readers == 1),
289 "%s has more than one reader\n", p->name);
291 APP_CHECK((n_writers != 0),
292 "%s has no writer\n", p->name);
294 APP_CHECK((n_writers == 1),
295 "%s has more than one writer\n", p->name);
300 check_sources(struct app_params *app)
304 for (i = 0; i < app->n_pktq_source; i++) {
305 struct app_pktq_source_params *p = &app->source_params[i];
306 uint32_t n_readers = app_source_get_readers(app, p);
308 APP_CHECK((n_readers != 0),
309 "%s has no reader\n", p->name);
311 APP_CHECK((n_readers == 1),
312 "%s has more than one reader\n", p->name);
317 check_sinks(struct app_params *app)
321 for (i = 0; i < app->n_pktq_sink; i++) {
322 struct app_pktq_sink_params *p = &app->sink_params[i];
323 uint32_t n_writers = app_sink_get_writers(app, p);
325 APP_CHECK((n_writers != 0),
326 "%s has no writer\n", p->name);
328 APP_CHECK((n_writers == 1),
329 "%s has more than one writer\n", p->name);
334 check_msgqs(struct app_params *app)
338 for (i = 0; i < app->n_msgq; i++) {
339 struct app_msgq_params *p = &app->msgq_params[i];
340 uint32_t n_readers = app_msgq_get_readers(app, p);
341 uint32_t n_writers = app_msgq_get_writers(app, p);
342 uint32_t msgq_req_pipeline, msgq_rsp_pipeline;
343 uint32_t msgq_req_core, msgq_rsp_core;
345 APP_CHECK((p->size > 0),
346 "%s size is 0\n", p->name);
348 APP_CHECK((rte_is_power_of_2(p->size)),
349 "%s size is not a power of 2\n", p->name);
351 msgq_req_pipeline = (strncmp(p->name, "MSGQ-REQ-PIPELINE",
352 strlen("MSGQ-REQ-PIPELINE")) == 0);
354 msgq_rsp_pipeline = (strncmp(p->name, "MSGQ-RSP-PIPELINE",
355 strlen("MSGQ-RSP-PIPELINE")) == 0);
357 msgq_req_core = (strncmp(p->name, "MSGQ-REQ-CORE",
358 strlen("MSGQ-REQ-CORE")) == 0);
360 msgq_rsp_core = (strncmp(p->name, "MSGQ-RSP-CORE",
361 strlen("MSGQ-RSP-CORE")) == 0);
363 if ((msgq_req_pipeline == 0) &&
364 (msgq_rsp_pipeline == 0) &&
365 (msgq_req_core == 0) &&
366 (msgq_rsp_core == 0)) {
367 APP_CHECK((n_readers != 0),
368 "%s has no reader\n", p->name);
370 APP_CHECK((n_readers == 1),
371 "%s has more than one reader\n", p->name);
373 APP_CHECK((n_writers != 0),
374 "%s has no writer\n", p->name);
376 APP_CHECK((n_writers == 1),
377 "%s has more than one writer\n", p->name);
380 if (msgq_req_pipeline) {
381 struct app_pipeline_params *pipeline;
382 uint32_t pipeline_id;
384 APP_PARAM_GET_ID(p, "MSGQ-REQ-PIPELINE", pipeline_id);
386 APP_PARAM_FIND_BY_ID(app->pipeline_params,
391 APP_CHECK((pipeline != NULL),
392 "%s is not associated with a valid pipeline\n",
396 if (msgq_rsp_pipeline) {
397 struct app_pipeline_params *pipeline;
398 uint32_t pipeline_id;
400 APP_PARAM_GET_ID(p, "MSGQ-RSP-PIPELINE", pipeline_id);
402 APP_PARAM_FIND_BY_ID(app->pipeline_params,
407 APP_CHECK((pipeline != NULL),
408 "%s is not associated with a valid pipeline\n",
415 check_pipelines(struct app_params *app)
419 for (i = 0; i < app->n_pipelines; i++) {
420 struct app_pipeline_params *p = &app->pipeline_params[i];
422 APP_CHECK((p->n_msgq_in == p->n_msgq_out),
423 "%s number of input MSGQs does not match "
424 "the number of output MSGQs\n", p->name);
429 app_config_check(struct app_params *app)
440 check_pipelines(app);