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.
21 #include <rte_cycles.h>
22 #include <rte_ethdev.h>
23 #include <rte_ether.h>
26 #include <rte_malloc.h>
27 #include <rte_version.h>
31 #include "pipeline_common_fe.h"
32 #include "pipeline_master.h"
33 #include "thread_fe.h"
34 #include "pipeline_cgnapt.h"
35 #include "pipeline_loadb.h"
36 #include "pipeline_timer.h"
37 #include "pipeline_txrx.h"
38 #include "pipeline_arpicmp.h"
39 #include "interface.h"
40 #include "l3fwd_common.h"
41 #include "l3fwd_lpm4.h"
42 #include "l3fwd_lpm6.h"
45 #define APP_NAME_SIZE 32
46 port_config_t *port_config;
49 app_init_core_map(struct app_params *app)
51 APP_LOG(app, HIGH, "Initializing CPU core map ...");
52 app->core_map = cpu_core_map_init(4, 32, 4, 0);
54 if (app->core_map == NULL)
55 rte_panic("Cannot create CPU core map\n");
57 if (app->log_level >= APP_LOG_LEVEL_LOW)
58 cpu_core_map_print(app->core_map);
61 /* Core Mask String in Hex Representation */
62 #define APP_CORE_MASK_STRING_SIZE ((64 * APP_CORE_MASK_SIZE) / 8 * 2 + 1)
65 app_init_core_mask(struct app_params *app)
67 char core_mask_str[APP_CORE_MASK_STRING_SIZE];
70 for (i = 0; i < app->n_pipelines; i++) {
71 struct app_pipeline_params *p = &app->pipeline_params[i];
74 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
80 rte_panic("Cannot create CPU core mask\n");
82 app_core_enable_in_core_mask(app, lcore_id);
85 app_core_build_core_mask_string(app, core_mask_str);
86 APP_LOG(app, HIGH, "CPU core mask = 0x%s", core_mask_str);
91 app_init_eal(struct app_params *app)
94 char core_mask_str[APP_CORE_MASK_STRING_SIZE];
95 struct app_eal_params *p = &app->eal_params;
100 app->eal_argv[n_args++] = strdup(app->app_name);
102 app_core_build_core_mask_string(app, core_mask_str);
103 snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str);
104 app->eal_argv[n_args++] = strdup(buffer);
107 snprintf(buffer, sizeof(buffer), "--lcores=%s", p->coremap);
108 app->eal_argv[n_args++] = strdup(buffer);
111 if (p->master_lcore_present) {
114 "--master-lcore=%" PRIu32,
116 app->eal_argv[n_args++] = strdup(buffer);
119 snprintf(buffer, sizeof(buffer), "-n%" PRIu32, p->channels);
120 app->eal_argv[n_args++] = strdup(buffer);
122 if (p->memory_present) {
123 snprintf(buffer, sizeof(buffer), "-m%" PRIu32, p->memory);
124 app->eal_argv[n_args++] = strdup(buffer);
127 if (p->ranks_present) {
128 snprintf(buffer, sizeof(buffer), "-r%" PRIu32, p->ranks);
129 app->eal_argv[n_args++] = strdup(buffer);
132 for (i = 0; i < APP_MAX_LINKS; i++) {
133 if (p->pci_blacklist[i] == NULL)
138 "--pci-blacklist=%s",
139 p->pci_blacklist[i]);
140 app->eal_argv[n_args++] = strdup(buffer);
143 if (app->port_mask != 0)
144 for (i = 0; i < APP_MAX_LINKS; i++) {
145 if (p->pci_whitelist[i] == NULL)
150 "--pci-whitelist=%s",
151 p->pci_whitelist[i]);
153 app->eal_argv[n_args++] = strdup(buffer);
156 for (i = 0; i < app->n_links; i++) {
157 char *pci_bdf = app->link_params[i].pci_bdf;
161 "--pci-whitelist=%s",
163 app->eal_argv[n_args++] = strdup(buffer);
166 for (i = 0; i < APP_MAX_LINKS; i++) {
167 if (p->vdev[i] == NULL)
174 app->eal_argv[n_args++] = strdup(buffer);
177 if ((p->vmware_tsc_map_present) && p->vmware_tsc_map) {
178 snprintf(buffer, sizeof(buffer), "--vmware-tsc-map");
179 app->eal_argv[n_args++] = strdup(buffer);
187 app->eal_argv[n_args++] = strdup(buffer);
191 snprintf(buffer, sizeof(buffer), "--syslog=%s", p->syslog);
192 app->eal_argv[n_args++] = strdup(buffer);
195 if (p->log_level_present) {
198 "--log-level=%" PRIu32,
200 app->eal_argv[n_args++] = strdup(buffer);
203 if ((p->version_present) && p->version) {
204 snprintf(buffer, sizeof(buffer), "-v");
205 app->eal_argv[n_args++] = strdup(buffer);
208 if ((p->help_present) && p->help) {
209 snprintf(buffer, sizeof(buffer), "--help");
210 app->eal_argv[n_args++] = strdup(buffer);
213 if ((p->no_huge_present) && p->no_huge) {
214 snprintf(buffer, sizeof(buffer), "--no-huge");
215 app->eal_argv[n_args++] = strdup(buffer);
218 if ((p->no_pci_present) && p->no_pci) {
219 snprintf(buffer, sizeof(buffer), "--no-pci");
220 app->eal_argv[n_args++] = strdup(buffer);
223 if ((p->no_hpet_present) && p->no_hpet) {
224 snprintf(buffer, sizeof(buffer), "--no-hpet");
225 app->eal_argv[n_args++] = strdup(buffer);
228 if ((p->no_shconf_present) && p->no_shconf) {
229 snprintf(buffer, sizeof(buffer), "--no-shconf");
230 app->eal_argv[n_args++] = strdup(buffer);
234 snprintf(buffer, sizeof(buffer), "-d=%s", p->add_driver);
235 app->eal_argv[n_args++] = strdup(buffer);
243 app->eal_argv[n_args++] = strdup(buffer);
247 snprintf(buffer, sizeof(buffer), "--huge-dir=%s", p->huge_dir);
248 app->eal_argv[n_args++] = strdup(buffer);
251 if (p->file_prefix) {
256 app->eal_argv[n_args++] = strdup(buffer);
259 if (p->base_virtaddr) {
262 "--base-virtaddr=%s",
264 app->eal_argv[n_args++] = strdup(buffer);
267 if ((p->create_uio_dev_present) && p->create_uio_dev) {
268 snprintf(buffer, sizeof(buffer), "--create-uio-dev");
269 app->eal_argv[n_args++] = strdup(buffer);
277 app->eal_argv[n_args++] = strdup(buffer);
280 if ((p->xen_dom0_present) && (p->xen_dom0)) {
281 snprintf(buffer, sizeof(buffer), "--xen-dom0");
282 app->eal_argv[n_args++] = strdup(buffer);
285 snprintf(buffer, sizeof(buffer), "--");
286 app->eal_argv[n_args++] = strdup(buffer);
288 app->eal_argc = n_args;
290 APP_LOG(app, HIGH, "Initializing EAL ...");
291 if (app->log_level >= APP_LOG_LEVEL_LOW) {
294 fprintf(stdout, "[APP] EAL arguments: \"");
295 for (i = 1; i < app->eal_argc; i++)
296 fprintf(stdout, "%s ", app->eal_argv[i]);
297 fprintf(stdout, "\"\n");
300 status = rte_eal_init(app->eal_argc, app->eal_argv);
302 rte_panic("EAL init error\n");
306 app_init_mempool(struct app_params *app)
310 for (i = 0; i < app->n_mempools; i++) {
311 struct app_mempool_params *p = &app->mempool_params[i];
313 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
314 app->mempool[i] = rte_mempool_create(
319 sizeof(struct rte_pktmbuf_pool_private),
320 rte_pktmbuf_pool_init, NULL,
321 rte_pktmbuf_init, NULL,
325 if (app->mempool[i] == NULL)
326 rte_panic("%s init error\n", p->name);
331 app_link_filter_arp_add(struct app_link_params *link)
333 struct rte_eth_ethertype_filter filter = {
334 .ether_type = ETHER_TYPE_ARP,
336 .queue = link->arp_q,
339 return rte_eth_dev_filter_ctrl(link->pmd_id,
340 RTE_ETH_FILTER_ETHERTYPE,
346 app_link_filter_tcp_syn_add(struct app_link_params *link)
348 struct rte_eth_syn_filter filter = {
350 .queue = link->tcp_syn_q,
353 return rte_eth_dev_filter_ctrl(link->pmd_id,
360 app_link_filter_ip_add(struct app_link_params *l1, struct app_link_params *l2)
362 struct rte_eth_ntuple_filter filter = {
363 .flags = RTE_5TUPLE_FLAGS,
364 .dst_ip = rte_bswap32(l2->ip),
365 .dst_ip_mask = UINT32_MAX, /* Enable */
367 .src_ip_mask = 0, /* Disable */
369 .dst_port_mask = 0, /* Disable */
371 .src_port_mask = 0, /* Disable */
373 .proto_mask = 0, /* Disable */
375 .priority = 1, /* Lowest */
376 .queue = l1->ip_local_q,
379 return rte_eth_dev_filter_ctrl(l1->pmd_id,
380 RTE_ETH_FILTER_NTUPLE,
386 app_link_filter_ip_del(struct app_link_params *l1, struct app_link_params *l2)
388 struct rte_eth_ntuple_filter filter = {
389 .flags = RTE_5TUPLE_FLAGS,
390 .dst_ip = rte_bswap32(l2->ip),
391 .dst_ip_mask = UINT32_MAX, /* Enable */
393 .src_ip_mask = 0, /* Disable */
395 .dst_port_mask = 0, /* Disable */
397 .src_port_mask = 0, /* Disable */
399 .proto_mask = 0, /* Disable */
401 .priority = 1, /* Lowest */
402 .queue = l1->ip_local_q,
405 return rte_eth_dev_filter_ctrl(l1->pmd_id,
406 RTE_ETH_FILTER_NTUPLE,
407 RTE_ETH_FILTER_DELETE,
412 app_link_filter_tcp_add(struct app_link_params *l1, struct app_link_params *l2)
414 struct rte_eth_ntuple_filter filter = {
415 .flags = RTE_5TUPLE_FLAGS,
416 .dst_ip = rte_bswap32(l2->ip),
417 .dst_ip_mask = UINT32_MAX, /* Enable */
419 .src_ip_mask = 0, /* Disable */
421 .dst_port_mask = 0, /* Disable */
423 .src_port_mask = 0, /* Disable */
424 .proto = IPPROTO_TCP,
425 .proto_mask = UINT8_MAX, /* Enable */
427 .priority = 2, /* Higher priority than IP */
428 .queue = l1->tcp_local_q,
431 return rte_eth_dev_filter_ctrl(l1->pmd_id,
432 RTE_ETH_FILTER_NTUPLE,
438 app_link_filter_tcp_del(struct app_link_params *l1, struct app_link_params *l2)
440 struct rte_eth_ntuple_filter filter = {
441 .flags = RTE_5TUPLE_FLAGS,
442 .dst_ip = rte_bswap32(l2->ip),
443 .dst_ip_mask = UINT32_MAX, /* Enable */
445 .src_ip_mask = 0, /* Disable */
447 .dst_port_mask = 0, /* Disable */
449 .src_port_mask = 0, /* Disable */
450 .proto = IPPROTO_TCP,
451 .proto_mask = UINT8_MAX, /* Enable */
453 .priority = 2, /* Higher priority than IP */
454 .queue = l1->tcp_local_q,
457 return rte_eth_dev_filter_ctrl(l1->pmd_id,
458 RTE_ETH_FILTER_NTUPLE,
459 RTE_ETH_FILTER_DELETE,
464 app_link_filter_udp_add(struct app_link_params *l1, struct app_link_params *l2)
466 struct rte_eth_ntuple_filter filter = {
467 .flags = RTE_5TUPLE_FLAGS,
468 .dst_ip = rte_bswap32(l2->ip),
469 .dst_ip_mask = UINT32_MAX, /* Enable */
471 .src_ip_mask = 0, /* Disable */
473 .dst_port_mask = 0, /* Disable */
475 .src_port_mask = 0, /* Disable */
476 .proto = IPPROTO_UDP,
477 .proto_mask = UINT8_MAX, /* Enable */
479 .priority = 2, /* Higher priority than IP */
480 .queue = l1->udp_local_q,
483 return rte_eth_dev_filter_ctrl(l1->pmd_id,
484 RTE_ETH_FILTER_NTUPLE,
490 app_link_filter_udp_del(struct app_link_params *l1, struct app_link_params *l2)
492 struct rte_eth_ntuple_filter filter = {
493 .flags = RTE_5TUPLE_FLAGS,
494 .dst_ip = rte_bswap32(l2->ip),
495 .dst_ip_mask = UINT32_MAX, /* Enable */
497 .src_ip_mask = 0, /* Disable */
499 .dst_port_mask = 0, /* Disable */
501 .src_port_mask = 0, /* Disable */
502 .proto = IPPROTO_UDP,
503 .proto_mask = UINT8_MAX, /* Enable */
505 .priority = 2, /* Higher priority than IP */
506 .queue = l1->udp_local_q,
509 return rte_eth_dev_filter_ctrl(l1->pmd_id,
510 RTE_ETH_FILTER_NTUPLE,
511 RTE_ETH_FILTER_DELETE,
516 app_link_filter_sctp_add(struct app_link_params *l1, struct app_link_params *l2)
518 struct rte_eth_ntuple_filter filter = {
519 .flags = RTE_5TUPLE_FLAGS,
520 .dst_ip = rte_bswap32(l2->ip),
521 .dst_ip_mask = UINT32_MAX, /* Enable */
523 .src_ip_mask = 0, /* Disable */
525 .dst_port_mask = 0, /* Disable */
527 .src_port_mask = 0, /* Disable */
528 .proto = IPPROTO_SCTP,
529 .proto_mask = UINT8_MAX, /* Enable */
531 .priority = 2, /* Higher priority than IP */
532 .queue = l1->sctp_local_q,
535 return rte_eth_dev_filter_ctrl(l1->pmd_id,
536 RTE_ETH_FILTER_NTUPLE,
542 app_link_filter_sctp_del(struct app_link_params *l1, struct app_link_params *l2)
544 struct rte_eth_ntuple_filter filter = {
545 .flags = RTE_5TUPLE_FLAGS,
546 .dst_ip = rte_bswap32(l2->ip),
547 .dst_ip_mask = UINT32_MAX, /* Enable */
549 .src_ip_mask = 0, /* Disable */
551 .dst_port_mask = 0, /* Disable */
553 .src_port_mask = 0, /* Disable */
554 .proto = IPPROTO_SCTP,
555 .proto_mask = UINT8_MAX, /* Enable */
557 .priority = 2, /* Higher priority than IP */
558 .queue = l1->sctp_local_q,
561 return rte_eth_dev_filter_ctrl(l1->pmd_id,
562 RTE_ETH_FILTER_NTUPLE,
563 RTE_ETH_FILTER_DELETE,
568 app_link_set_arp_filter(struct app_params *app, struct app_link_params *cp)
570 if (cp->arp_q != 0) {
571 int status = app_link_filter_arp_add(cp);
573 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
574 "Adding ARP filter (queue = %" PRIu32 ")",
575 cp->name, cp->pmd_id, cp->arp_q);
578 rte_panic("%s (%" PRIu32 "): "
579 "Error adding ARP filter "
580 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
581 cp->name, cp->pmd_id, cp->arp_q, status);
586 app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
588 if (cp->tcp_syn_q != 0) {
589 int status = app_link_filter_tcp_syn_add(cp);
591 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
592 "Adding TCP SYN filter (queue = %" PRIu32 ")",
593 cp->name, cp->pmd_id, cp->tcp_syn_q);
596 rte_panic("%s (%" PRIu32 "): "
597 "Error adding TCP SYN filter "
598 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
599 cp->name, cp->pmd_id, cp->tcp_syn_q,
604 /* rte_eth_dev is removed in DPDK version 16.11 and onwards */
605 #if RTE_VERSION < 0x100b0000
607 app_link_is_virtual(__rte_unused struct app_link_params *p)
609 uint32_t pmd_id = p->pmd_id;
610 struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
611 if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
620 app_link_up_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
625 struct rte_eth_link link;
627 #if RTE_VERSION < 0x100b0000
628 if (app_link_is_virtual(cp)) {
634 /* For each link, add filters for IP of current link */
636 for (i = 0; i < app->n_links; i++) {
637 struct app_link_params *p = &app->link_params[i];
640 if (p->ip_local_q != 0) {
641 int status = app_link_filter_ip_add(p, cp);
643 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
644 "Adding IP filter (queue= %" PRIu32
645 ", IP = 0x%08" PRIx32 ")",
646 p->name, p->pmd_id, p->ip_local_q,
650 rte_panic("%s (%" PRIu32 "): "
652 "filter (queue= %" PRIu32 ", "
656 p->ip_local_q, cp->ip, status);
660 if (p->tcp_local_q != 0) {
661 int status = app_link_filter_tcp_add(p, cp);
663 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
666 ", IP = 0x%08" PRIx32 ")",
667 p->name, p->pmd_id, p->tcp_local_q,
671 rte_panic("%s (%" PRIu32 "): "
673 "filter (queue = %" PRIu32 ", "
677 p->tcp_local_q, cp->ip, status);
681 if (p->udp_local_q != 0) {
682 int status = app_link_filter_udp_add(p, cp);
684 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
687 ", IP = 0x%08" PRIx32 ")",
688 p->name, p->pmd_id, p->udp_local_q,
692 rte_panic("%s (%" PRIu32 "): "
694 "filter (queue = %" PRIu32 ", "
698 p->udp_local_q, cp->ip, status);
702 if (p->sctp_local_q != 0) {
703 int status = app_link_filter_sctp_add(p, cp);
705 APP_LOG(app, LOW, "%s (%" PRIu32
706 "): Adding SCTP filter "
708 ", IP = 0x%08" PRIx32 ")",
709 p->name, p->pmd_id, p->sctp_local_q,
713 rte_panic("%s (%" PRIu32 "): "
715 "filter (queue = %" PRIu32 ", "
719 p->sctp_local_q, cp->ip,
725 rte_eth_link_get(cp->pmd_id, &link);
726 if (!link.link_status) {
728 status = rte_eth_dev_set_link_up(cp->pmd_id);
730 rte_panic("%s (%" PRIu32 "): PMD set link up error %"
731 PRId32 "\n", cp->name, cp->pmd_id, status);
734 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_UP);
736 /* Mark link as UP */
741 app_link_down_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
746 struct rte_eth_link link;
748 #if RTE_VERSION < 0x100b0000
749 if (app_link_is_virtual(cp)) {
755 rte_eth_link_get(cp->pmd_id, &link);
756 if (link.link_status) {
758 status = rte_eth_dev_set_link_down(cp->pmd_id);
760 rte_panic("%s (%" PRIu32 "): PMD set link down error %"
761 PRId32 "\n", cp->name, cp->pmd_id, status);
764 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_DOWN);
765 /* Mark link as DOWN */
768 /* Return if current link IP is not valid */
772 /* For each link, remove filters for IP of current link */
773 for (i = 0; i < app->n_links; i++) {
774 struct app_link_params *p = &app->link_params[i];
777 if (p->ip_local_q != 0) {
778 int status = app_link_filter_ip_del(p, cp);
780 APP_LOG(app, LOW, "%s (%" PRIu32
781 "): Deleting IP filter "
782 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
783 p->name, p->pmd_id, p->ip_local_q, cp->ip);
786 rte_panic("%s (%" PRIu32
787 "): Error deleting IP filter "
791 p->name, p->pmd_id, p->ip_local_q,
796 if (p->tcp_local_q != 0) {
797 int status = app_link_filter_tcp_del(p, cp);
799 APP_LOG(app, LOW, "%s (%" PRIu32
800 "): Deleting TCP filter "
802 ", IP = 0x%" PRIx32 ")",
803 p->name, p->pmd_id, p->tcp_local_q, cp->ip);
806 rte_panic("%s (%" PRIu32
807 "): Error deleting TCP filter "
811 p->name, p->pmd_id, p->tcp_local_q,
816 if (p->udp_local_q != 0) {
817 int status = app_link_filter_udp_del(p, cp);
819 APP_LOG(app, LOW, "%s (%" PRIu32
820 "): Deleting UDP filter "
821 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
822 p->name, p->pmd_id, p->udp_local_q, cp->ip);
825 rte_panic("%s (%" PRIu32
826 "): Error deleting UDP filter "
830 p->name, p->pmd_id, p->udp_local_q,
835 if (p->sctp_local_q != 0) {
836 int status = app_link_filter_sctp_del(p, cp);
838 APP_LOG(app, LOW, "%s (%" PRIu32
839 "): Deleting SCTP filter "
841 ", IP = 0x%" PRIx32 ")",
842 p->name, p->pmd_id, p->sctp_local_q, cp->ip);
845 rte_panic("%s (%" PRIu32
846 "): Error deleting SCTP filter "
850 p->name, p->pmd_id, p->sctp_local_q,
858 app_check_link(struct app_params *app)
860 uint32_t all_links_up, i;
864 for (i = 0; i < app->n_links; i++) {
865 struct app_link_params *p = &app->link_params[i];
866 struct rte_eth_link link_params;
868 memset(&link_params, 0, sizeof(link_params));
869 rte_eth_link_get(p->pmd_id, &link_params);
871 APP_LOG(app, HIGH, "%s (%" PRIu32 ") (%" PRIu32 " Gbps) %s",
874 link_params.link_speed / 1000,
875 link_params.link_status ? "UP" : "DOWN");
877 if (link_params.link_status == ETH_LINK_DOWN)
881 if (all_links_up == 0)
882 rte_panic("Some links are DOWN\n");
886 is_any_swq_frag_or_ras(struct app_params *app)
890 for (i = 0; i < app->n_pktq_swq; i++) {
891 struct app_pktq_swq_params *p = &app->swq_params[i];
893 if ((p->ipv4_frag == 1) || (p->ipv6_frag == 1) ||
894 (p->ipv4_ras == 1) || (p->ipv6_ras == 1))
902 app_init_link_frag_ras(struct app_params *app)
906 if (is_any_swq_frag_or_ras(app)) {
907 for (i = 0; i < app->n_pktq_hwq_out; i++) {
908 struct app_pktq_hwq_out_params *p_txq =
909 &app->hwq_out_params[i];
911 p_txq->conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
917 app_get_cpu_socket_id(uint32_t pmd_id)
919 int status = rte_eth_dev_socket_id(pmd_id);
921 return (status != SOCKET_ID_ANY) ? status : 0;
924 struct rte_eth_rxmode rx_mode = {
925 .max_rx_pkt_len = ETHER_MAX_LEN, /**< Default maximum frame length. */
927 .header_split = 0, /**< Header Split disabled. */
928 .hw_ip_checksum = 0, /**< IP checksum offload disabled. */
929 .hw_vlan_filter = 1, /**< VLAN filtering enabled. */
930 .hw_vlan_strip = 1, /**< VLAN strip enabled. */
931 .hw_vlan_extend = 0, /**< Extended VLAN disabled. */
932 .jumbo_frame = 0, /**< Jumbo Frame Support disabled. */
933 .hw_strip_crc = 0, /**< CRC stripping by hardware disabled. */
935 struct rte_fdir_conf fdir_conf = {
936 .mode = RTE_FDIR_MODE_NONE,
937 .pballoc = RTE_FDIR_PBALLOC_64K,
938 .status = RTE_FDIR_REPORT_STATUS,
940 .vlan_tci_mask = 0x0,
942 .src_ip = 0xFFFFFFFF,
943 .dst_ip = 0xFFFFFFFF,
946 .src_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
947 .dst_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
949 .src_port_mask = 0xFFFF,
950 .dst_port_mask = 0xFFFF,
951 .mac_addr_byte_mask = 0xFF,
952 .tunnel_type_mask = 1,
953 .tunnel_id_mask = 0xFFFFFFFF,
959 app_init_link(struct app_params *app)
963 app_init_link_frag_ras(app);
966 *Configuring port_config_t structure for interface manager initialization
968 size = RTE_CACHE_LINE_ROUNDUP(sizeof(port_config_t));
969 port_config = rte_zmalloc(NULL, (app->n_links * size), RTE_CACHE_LINE_SIZE);
970 if (port_config == NULL)
971 rte_panic("port_config is NULL: Memory Allocation failure\n");
973 for (i = 0; i < app->n_links; i++) {
974 struct app_link_params *p_link = &app->link_params[i];
975 uint32_t link_id, n_hwq_in, n_hwq_out;
978 status = sscanf(p_link->name, "LINK%" PRIu32, &link_id);
980 rte_panic("%s (%" PRId32 "): "
981 "init error (%" PRId32 ")\n",
982 p_link->name, link_id, status);
984 n_hwq_in = app_link_get_n_rxq(app, p_link);
985 n_hwq_out = app_link_get_n_txq(app, p_link);
987 printf("\n\nn_hwq_in %d\n", n_hwq_in);
988 struct rte_eth_conf *My_local_conf = &p_link->conf;
991 My_local_conf->rxmode = rx_mode;
992 My_local_conf->fdir_conf = fdir_conf;
993 My_local_conf->rxmode.mq_mode = ETH_MQ_RX_RSS;
994 My_local_conf->rx_adv_conf.rss_conf.rss_key = NULL;
995 My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
996 //My_local_conf->rx_adv_conf.rss_conf.rss_hf |= ETH_RSS_UDP;
997 //My_local_conf->rx_adv_conf.rss_conf.rss_hf |= ETH_RSS_IP;
998 // My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_TCP;
1000 //#else /*for FDIR Filter*/
1003 My_local_conf->rx_adv_conf.rss_conf.rss_hf = 0;
1004 /* pkt-filter-mode is perfect */
1005 My_local_conf->fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
1008 /* Set the hardware CRC stripping to avoid double stripping of FCS in VM */
1009 p_link->conf.rxmode.hw_strip_crc=1;
1011 APP_LOG(app, HIGH, "Initializing %s (%" PRIu32") "
1012 "(%" PRIu32 " RXQ, %" PRIu32 " TXQ) ...",
1018 port_config[i].port_id = p_link->pmd_id;
1019 port_config[i].nrx_queue = n_hwq_in;
1020 port_config[i].ntx_queue = n_hwq_out;
1021 port_config[i].state = 1;
1022 port_config[i].promisc = p_link->promisc;
1023 port_config[i].mempool.pool_size = app->mempool_params[0].pool_size;
1024 port_config[i].mempool.buffer_size = app->mempool_params[0].buffer_size;
1025 port_config[i].mempool.cache_size = app->mempool_params[0].cache_size;
1026 port_config[i].mempool.cpu_socket_id = app->mempool_params[0].cpu_socket_id;
1027 memcpy (&port_config[i].port_conf, &p_link->conf, sizeof(struct rte_eth_conf));
1028 memcpy (&port_config[i].rx_conf, &app->hwq_in_params[0].conf, sizeof(struct rte_eth_rxconf));
1029 memcpy (&port_config[i].tx_conf, &app->hwq_out_params[0].conf, sizeof(struct rte_eth_txconf));
1031 if(app->header_csum_req) {
1032 /* Enable TCP and UDP HW Checksum */
1033 port_config[i].tx_conf.txq_flags &=
1034 ~(ETH_TXQ_FLAGS_NOXSUMTCP|ETH_TXQ_FLAGS_NOXSUMUDP);
1037 if (ifm_port_setup (p_link->pmd_id, &port_config[i])) {
1038 printf("Failed to configure port %s - %"PRIu32
1039 ".\n", p_link->name, p_link->pmd_id);
1040 printf("Try again with offload disabled....\n");
1041 port_config[i].tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOOFFLOADS;
1042 if (ifm_port_setup (p_link->pmd_id, &port_config[i]))
1043 rte_panic ("Port Setup Failed: %s - %"PRIu32"\n", p_link->name, p_link->pmd_id);
1048 status = rte_eth_dev_configure(
1054 rte_panic("%s (%" PRId32 "): "
1055 "init error (%" PRId32 ")\n",
1056 p_link->name, p_link->pmd_id, status);
1058 rte_eth_macaddr_get(p_link->pmd_id,
1059 (struct ether_addr *) &p_link->mac_addr);
1061 if (p_link->promisc)
1062 rte_eth_promiscuous_enable(p_link->pmd_id);
1065 for (j = 0; j < app->n_pktq_hwq_in; j++) {
1066 struct app_pktq_hwq_in_params *p_rxq =
1067 &app->hwq_in_params[j];
1068 uint32_t rxq_link_id, rxq_queue_id;
1071 sscanf(p_rxq->name, "RXQ%" PRIu32 ".%" PRIu32,
1072 &rxq_link_id, &rxq_queue_id);
1074 rte_panic("%s (%" PRId32 "): "
1075 "init error (%" PRId32 ")\n",
1076 p_rxq->name, rxq_queue_id, status);
1078 if (rxq_link_id != link_id)
1081 status = rte_eth_rx_queue_setup(
1085 app_get_cpu_socket_id(p_link->pmd_id),
1087 app->mempool[p_rxq->mempool_id]);
1089 rte_panic("%s (%" PRIu32 "): "
1090 "%s init error (%" PRId32 ")\n",
1098 for (j = 0; j < app->n_pktq_hwq_out; j++) {
1099 struct app_pktq_hwq_out_params *p_txq =
1100 &app->hwq_out_params[j];
1101 uint32_t txq_link_id, txq_queue_id;
1104 sscanf(p_txq->name, "TXQ%" PRIu32 ".%" PRIu32,
1105 &txq_link_id, &txq_queue_id);
1108 rte_panic("%s (%" PRId32 "): "
1109 "init error (%" PRId32 ")\n",
1110 p_txq->name, txq_link_id, status);
1112 if (txq_link_id != link_id)
1115 if (app->header_csum_req) {
1116 /* Enable TCP and UDP HW Checksum */
1117 p_txq->conf.txq_flags &=
1118 ~(ETH_TXQ_FLAGS_NOXSUMTCP|
1119 ETH_TXQ_FLAGS_NOXSUMUDP);
1122 status = rte_eth_tx_queue_setup(
1126 app_get_cpu_socket_id(p_link->pmd_id),
1130 rte_panic("%s (%" PRIu32 "): "
1131 "%s init error (%" PRId32 ")\n",
1139 status = rte_eth_dev_start(p_link->pmd_id);
1141 rte_panic("Cannot start %s (error %" PRId32 ")\n",
1142 p_link->name, status);
1145 app_link_set_arp_filter(app, p_link);
1146 app_link_set_tcp_syn_filter(app, p_link);
1148 app_link_up_internal(app, p_link);
1151 app_check_link(app);
1155 app_init_swq(struct app_params *app)
1159 for (i = 0; i < app->n_pktq_swq; i++) {
1160 struct app_pktq_swq_params *p = &app->swq_params[i];
1161 unsigned int flags = 0;
1163 if (app_swq_get_readers(app, p) == 1)
1164 flags |= RING_F_SC_DEQ;
1165 if (app_swq_get_writers(app, p) == 1)
1166 flags |= RING_F_SP_ENQ;
1168 APP_LOG(app, HIGH, "Initializing %s...", p->name);
1169 app->swq[i] = rte_ring_create(
1175 if (app->swq[i] == NULL)
1176 rte_panic("%s init error\n", p->name);
1181 app_init_tm(struct app_params *app)
1185 for (i = 0; i < app->n_pktq_tm; i++) {
1186 struct app_pktq_tm_params *p_tm = &app->tm_params[i];
1187 struct app_link_params *p_link;
1188 struct rte_eth_link link_eth_params;
1189 struct rte_sched_port *sched;
1190 uint32_t n_subports, subport_id;
1193 p_link = app_get_link_for_tm(app, p_tm);
1195 rte_eth_link_get(p_link->pmd_id, &link_eth_params);
1198 p_tm->sched_port_params.name = p_tm->name;
1199 p_tm->sched_port_params.socket =
1200 app_get_cpu_socket_id(p_link->pmd_id);
1201 p_tm->sched_port_params.rate =
1202 (uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;
1204 APP_LOG(app, HIGH, "Initializing %s ...", p_tm->name);
1205 sched = rte_sched_port_config(&p_tm->sched_port_params);
1207 rte_panic("%s init error\n", p_tm->name);
1211 n_subports = p_tm->sched_port_params.n_subports_per_port;
1212 for (subport_id = 0; subport_id < n_subports; subport_id++) {
1213 uint32_t n_pipes_per_subport, pipe_id;
1215 status = rte_sched_subport_config(sched,
1217 &p_tm->sched_subport_params[subport_id]);
1219 rte_panic("%s subport %" PRIu32
1220 " init error (%" PRId32 ")\n",
1221 p_tm->name, subport_id, status);
1224 n_pipes_per_subport =
1225 p_tm->sched_port_params.n_pipes_per_subport;
1227 pipe_id < n_pipes_per_subport;
1229 int profile_id = p_tm->sched_pipe_to_profile[
1230 subport_id * APP_MAX_SCHED_PIPES +
1233 if (profile_id == -1)
1236 status = rte_sched_pipe_config(sched,
1241 rte_panic("%s subport %" PRIu32
1243 " (profile %" PRId32 ") "
1244 "init error (% " PRId32 ")\n",
1245 p_tm->name, subport_id, pipe_id,
1246 profile_id, status);
1253 app_init_msgq(struct app_params *app)
1257 for (i = 0; i < app->n_msgq; i++) {
1258 struct app_msgq_params *p = &app->msgq_params[i];
1260 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
1261 app->msgq[i] = rte_ring_create(
1265 RING_F_SP_ENQ | RING_F_SC_DEQ);
1267 if (app->msgq[i] == NULL)
1268 rte_panic("%s init error\n", p->name);
1272 static void app_pipeline_params_get(struct app_params *app,
1273 struct app_pipeline_params *p_in,
1274 struct pipeline_params *p_out)
1277 uint32_t mempool_id;
1279 snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
1281 p_out->socket_id = (int) p_in->socket_id;
1283 p_out->log_level = app->log_level;
1286 p_out->n_ports_in = p_in->n_pktq_in;
1287 for (i = 0; i < p_in->n_pktq_in; i++) {
1288 struct app_pktq_in_params *in = &p_in->pktq_in[i];
1289 struct pipeline_port_in_params *out = &p_out->port_in[i];
1292 case APP_PKTQ_IN_HWQ:
1294 struct app_pktq_hwq_in_params *p_hwq_in =
1295 &app->hwq_in_params[in->id];
1296 struct app_link_params *p_link =
1297 app_get_link_for_rxq(app, p_hwq_in);
1298 uint32_t rxq_link_id, rxq_queue_id;
1301 sscanf(p_hwq_in->name, "RXQ%" SCNu32 ".%" SCNu32,
1305 rte_panic("%s (%" PRId32 "): "
1306 "init error (%" PRId32 ")\n",
1307 p_hwq_in->name, rxq_link_id, status);
1309 out->type = PIPELINE_PORT_IN_ETHDEV_READER;
1310 out->params.ethdev.port_id = p_link->pmd_id;
1311 out->params.ethdev.queue_id = rxq_queue_id;
1312 out->burst_size = p_hwq_in->burst;
1315 case APP_PKTQ_IN_SWQ:
1317 struct app_pktq_swq_params *swq_params =
1318 &app->swq_params[in->id];
1320 if ((swq_params->ipv4_frag == 0) &&
1321 (swq_params->ipv6_frag == 0)) {
1322 if (app_swq_get_readers(app,
1325 PIPELINE_PORT_IN_RING_READER;
1326 out->params.ring.ring =
1329 app->swq_params[in->id].
1332 out->type = PIPELINE_PORT_IN_RING_MULTI_READER;
1333 out->params.ring_multi.ring = app->swq[in->id];
1334 out->burst_size = swq_params->burst_read;
1337 if (swq_params->ipv4_frag == 1) {
1338 struct rte_port_ring_reader_ipv4_frag_params
1340 &out->params.ring_ipv4_frag;
1343 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG;
1344 params->ring = app->swq[in->id];
1345 params->mtu = swq_params->mtu;
1346 params->metadata_size =
1347 swq_params->metadata_size;
1348 params->pool_direct =
1350 [swq_params->mempool_direct_id];
1351 params->pool_indirect =
1353 [swq_params->mempool_indirect_id];
1354 out->burst_size = swq_params->burst_read;
1356 struct rte_port_ring_reader_ipv6_frag_params
1358 &out->params.ring_ipv6_frag;
1361 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG;
1362 params->ring = app->swq[in->id];
1363 params->mtu = swq_params->mtu;
1364 params->metadata_size =
1365 swq_params->metadata_size;
1366 params->pool_direct =
1368 [swq_params->mempool_direct_id];
1369 params->pool_indirect =
1371 [swq_params->mempool_indirect_id];
1372 out->burst_size = swq_params->burst_read;
1377 case APP_PKTQ_IN_TM:
1378 out->type = PIPELINE_PORT_IN_SCHED_READER;
1379 out->params.sched.sched = app->tm[in->id];
1380 out->burst_size = app->tm_params[in->id].burst_read;
1382 case APP_PKTQ_IN_SOURCE:
1383 mempool_id = app->source_params[in->id].mempool_id;
1384 out->type = PIPELINE_PORT_IN_SOURCE;
1385 out->params.source.mempool = app->mempool[mempool_id];
1386 out->burst_size = app->source_params[in->id].burst;
1389 if (app->source_params[in->id].file_name
1391 out->params.source.file_name = strdup(
1392 app->source_params[in->id].
1394 if (out->params.source.file_name == NULL) {
1396 n_bytes_per_pkt = 0;
1399 out->params.source.n_bytes_per_pkt =
1400 app->source_params[in->id].
1412 p_out->n_ports_out = p_in->n_pktq_out;
1413 for (i = 0; i < p_in->n_pktq_out; i++) {
1414 struct app_pktq_out_params *in = &p_in->pktq_out[i];
1415 struct pipeline_port_out_params *out = &p_out->port_out[i];
1418 case APP_PKTQ_OUT_HWQ:
1420 struct app_pktq_hwq_out_params *p_hwq_out =
1421 &app->hwq_out_params[in->id];
1422 struct app_link_params *p_link =
1423 app_get_link_for_txq(app, p_hwq_out);
1424 uint32_t txq_link_id, txq_queue_id;
1427 sscanf(p_hwq_out->name,
1428 "TXQ%" SCNu32 ".%" SCNu32,
1432 rte_panic("%s (%" PRId32 "): "
1433 "init error (%" PRId32 ")\n",
1434 p_hwq_out->name, txq_link_id, status);
1436 if (p_hwq_out->dropless == 0) {
1437 struct rte_port_ethdev_writer_params *params =
1438 &out->params.ethdev;
1440 out->type = PIPELINE_PORT_OUT_ETHDEV_WRITER;
1441 params->port_id = p_link->pmd_id;
1442 params->queue_id = txq_queue_id;
1443 params->tx_burst_sz =
1444 app->hwq_out_params[in->id].burst;
1446 struct rte_port_ethdev_writer_nodrop_params
1447 *params = &out->params.ethdev_nodrop;
1450 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP;
1451 params->port_id = p_link->pmd_id;
1452 params->queue_id = txq_queue_id;
1453 params->tx_burst_sz = p_hwq_out->burst;
1454 params->n_retries = p_hwq_out->n_retries;
1458 case APP_PKTQ_OUT_SWQ:
1460 struct app_pktq_swq_params *swq_params =
1461 &app->swq_params[in->id];
1463 if ((swq_params->ipv4_ras == 0) &&
1464 (swq_params->ipv6_ras == 0)) {
1465 if (app_swq_get_writers(app, swq_params) == 1) {
1466 if (app->swq_params[in->id].dropless == 0) {
1467 struct rte_port_ring_writer_params *params =
1470 out->type = PIPELINE_PORT_OUT_RING_WRITER;
1471 params->ring = app->swq[in->id];
1472 params->tx_burst_sz =
1473 app->swq_params[in->id].burst_write;
1475 struct rte_port_ring_writer_nodrop_params
1476 *params = &out->params.ring_nodrop;
1479 PIPELINE_PORT_OUT_RING_WRITER_NODROP;
1480 params->ring = app->swq[in->id];
1481 params->tx_burst_sz =
1482 app->swq_params[in->id].burst_write;
1484 app->swq_params[in->id].n_retries;
1487 if (swq_params->dropless == 0) {
1488 struct rte_port_ring_multi_writer_params
1490 &out->params.ring_multi;
1493 PIPELINE_PORT_OUT_RING_MULTI_WRITER;
1494 params->ring = app->swq[in->id];
1495 params->tx_burst_sz = swq_params->burst_write;
1497 struct rte_port_ring_multi_writer_nodrop_params
1499 &out->params.ring_multi_nodrop;
1502 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP;
1504 params->ring = app->swq[in->id];
1505 params->tx_burst_sz = swq_params->burst_write;
1506 params->n_retries = swq_params->n_retries;
1510 if (swq_params->ipv4_ras == 1) {
1511 struct rte_port_ring_writer_ipv4_ras_params
1513 &out->params.ring_ipv4_ras;
1516 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS;
1517 params->ring = app->swq[in->id];
1518 params->tx_burst_sz = swq_params->burst_write;
1520 struct rte_port_ring_writer_ipv6_ras_params
1522 &out->params.ring_ipv6_ras;
1525 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS;
1526 params->ring = app->swq[in->id];
1527 params->tx_burst_sz = swq_params->burst_write;
1532 case APP_PKTQ_OUT_TM: {
1533 struct rte_port_sched_writer_params *params =
1536 out->type = PIPELINE_PORT_OUT_SCHED_WRITER;
1537 params->sched = app->tm[in->id];
1538 params->tx_burst_sz =
1539 app->tm_params[in->id].burst_write;
1542 case APP_PKTQ_OUT_SINK:
1543 out->type = PIPELINE_PORT_OUT_SINK;
1544 if (app->sink_params[in->id].file_name != NULL) {
1545 out->params.sink.file_name = strdup(
1546 app->sink_params[in->id].
1548 if (out->params.sink.file_name == NULL) {
1549 out->params.sink.max_n_pkts = 0;
1552 out->params.sink.max_n_pkts =
1553 app->sink_params[in->id].
1556 out->params.sink.file_name = NULL;
1557 out->params.sink.max_n_pkts = 0;
1566 p_out->n_msgq = p_in->n_msgq_in;
1568 for (i = 0; i < p_in->n_msgq_in; i++)
1569 p_out->msgq_in[i] = app->msgq[p_in->msgq_in[i]];
1571 for (i = 0; i < p_in->n_msgq_out; i++)
1572 p_out->msgq_out[i] = app->msgq[p_in->msgq_out[i]];
1575 p_out->n_args = p_in->n_args;
1576 for (i = 0; i < p_in->n_args; i++) {
1577 p_out->args_name[i] = p_in->args_name[i];
1578 p_out->args_value[i] = p_in->args_value[i];
1583 app_init_pipelines(struct app_params *app)
1587 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1588 struct app_pipeline_params *params =
1589 &app->pipeline_params[p_id];
1590 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1591 struct pipeline_type *ptype;
1592 struct pipeline_params pp;
1594 APP_LOG(app, HIGH, "Initializing %s ...", params->name);
1596 ptype = app_pipeline_type_find(app, params->type);
1598 rte_panic("Init error: Unknown pipeline type \"%s\"\n",
1601 app_pipeline_params_get(app, params, &pp);
1605 if (ptype->be_ops->f_init) {
1606 data->be = ptype->be_ops->f_init(&pp, (void *) app);
1608 if (data->be == NULL)
1609 rte_panic("Pipeline instance \"%s\" back-end "
1610 "init error\n", params->name);
1615 if (ptype->fe_ops->f_init) {
1616 data->fe = ptype->fe_ops->f_init(&pp, (void *) app);
1618 if (data->fe == NULL)
1619 rte_panic("Pipeline instance \"%s\" front-end "
1620 "init error\n", params->name);
1623 data->ptype = ptype;
1625 data->timer_period = (rte_get_tsc_hz() *
1626 params->timer_period) / 100;
1631 app_init_threads(struct app_params *app)
1633 uint64_t time = rte_get_tsc_cycles();
1636 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1637 struct app_pipeline_params *params =
1638 &app->pipeline_params[p_id];
1639 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1640 struct pipeline_type *ptype;
1641 struct app_thread_data *t;
1642 struct app_thread_pipeline_data *p;
1645 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
1648 params->hyper_th_id);
1651 rte_panic("Invalid core s%" PRIu32 "c%" PRIu32 "%s\n",
1654 (params->hyper_th_id) ? "h" : "");
1656 t = &app->thread_data[lcore_id];
1658 t->timer_period = (rte_get_tsc_hz() *
1659 APP_THREAD_TIMER_PERIOD) / 1000;
1660 t->thread_req_deadline = time + t->timer_period;
1662 t->headroom_cycles = 0;
1663 t->headroom_time = rte_get_tsc_cycles();
1664 t->headroom_ratio = 0.0;
1666 t->msgq_in = app_thread_msgq_in_get(app,
1669 params->hyper_th_id);
1670 if (t->msgq_in == NULL)
1671 rte_panic("Init error: Cannot find MSGQ_IN "
1672 "for thread %" PRId32, lcore_id);
1674 t->msgq_out = app_thread_msgq_out_get(app,
1677 params->hyper_th_id);
1678 if (t->msgq_out == NULL)
1679 rte_panic("Init error: Cannot find MSGQ_OUT "
1680 "for thread %" PRId32, lcore_id);
1682 ptype = app_pipeline_type_find(app, params->type);
1684 rte_panic("Init error: Unknown pipeline "
1685 "type \"%s\"\n", params->type);
1687 p = (ptype->be_ops->f_run == NULL) ?
1688 &t->regular[t->n_regular] :
1689 &t->custom[t->n_custom];
1691 p->pipeline_id = p_id;
1693 p->f_run = ptype->be_ops->f_run;
1694 p->f_timer = ptype->be_ops->f_timer;
1695 p->timer_period = data->timer_period;
1696 p->deadline = time + data->timer_period;
1700 if (ptype->be_ops->f_run == NULL)
1707 int app_init(struct app_params *app)
1709 app_init_core_map(app);
1710 app_init_core_mask(app);
1714 //app_init_mempool(app);
1720 app_pipeline_common_cmd_push(app);
1721 app_pipeline_thread_cmd_push(app);
1722 app_pipeline_type_register(app, &pipeline_master);
1723 app_pipeline_type_register(app, &pipeline_cgnapt);
1724 app_pipeline_type_register(app, &pipeline_loadb);
1725 app_pipeline_type_register(app, &pipeline_timer);
1726 app_pipeline_type_register(app, &pipeline_txrx);
1727 app_pipeline_type_register(app, &pipeline_arpicmp);
1729 app_init_pipelines(app);
1730 app_init_threads(app);
1735 populate_lpm_routes();
1736 print_interface_details();
1742 app_pipeline_type_cmd_push(struct app_params *app,
1743 struct pipeline_type *ptype)
1745 cmdline_parse_ctx_t *cmds;
1748 /* Check input arguments */
1749 if ((app == NULL) ||
1753 n_cmds = pipeline_type_cmds_count(ptype);
1757 cmds = ptype->fe_ops->cmds;
1759 /* Check for available slots in the application commands array */
1760 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1763 /* Push pipeline commands into the application */
1764 memcpy(&app->cmds[app->n_cmds],
1766 n_cmds * sizeof(cmdline_parse_ctx_t));
1768 for (i = 0; i < n_cmds; i++)
1769 app->cmds[app->n_cmds + i]->data = app;
1771 app->n_cmds += n_cmds;
1772 app->cmds[app->n_cmds] = NULL;
1778 app_pipeline_type_register(struct app_params *app, struct pipeline_type *ptype)
1782 /* Check input arguments */
1783 if ((app == NULL) ||
1785 (ptype->name == NULL) ||
1786 (strlen(ptype->name) == 0) ||
1787 (ptype->be_ops->f_init == NULL) ||
1788 (ptype->be_ops->f_timer == NULL))
1791 /* Check for duplicate entry */
1792 for (i = 0; i < app->n_pipeline_types; i++)
1793 if (strcmp(app->pipeline_type[i].name, ptype->name) == 0)
1796 /* Check for resource availability */
1797 n_cmds = pipeline_type_cmds_count(ptype);
1798 if ((app->n_pipeline_types == APP_MAX_PIPELINE_TYPES) ||
1799 (n_cmds > APP_MAX_CMDS - app->n_cmds))
1802 /* Copy pipeline type */
1803 memcpy(&app->pipeline_type[app->n_pipeline_types++],
1805 sizeof(struct pipeline_type));
1807 /* Copy CLI commands */
1809 app_pipeline_type_cmd_push(app, ptype);
1815 pipeline_type *app_pipeline_type_find(struct app_params *app, char *name)
1819 for (i = 0; i < app->n_pipeline_types; i++)
1820 if (strcmp(app->pipeline_type[i].name, name) == 0)
1821 return &app->pipeline_type[i];