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,
78 printf("lcore_id:%d\n", lcore_id);
81 rte_panic("Cannot create CPU core mask\n");
83 app_core_enable_in_core_mask(app, lcore_id);
86 app_core_build_core_mask_string(app, core_mask_str);
87 APP_LOG(app, HIGH, "CPU core mask = 0x%s", core_mask_str);
92 app_init_eal(struct app_params *app)
95 char core_mask_str[APP_CORE_MASK_STRING_SIZE];
96 struct app_eal_params *p = &app->eal_params;
101 app->eal_argv[n_args++] = strdup(app->app_name);
103 app_core_build_core_mask_string(app, core_mask_str);
104 snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str);
105 app->eal_argv[n_args++] = strdup(buffer);
108 snprintf(buffer, sizeof(buffer), "--lcores=%s", p->coremap);
109 app->eal_argv[n_args++] = strdup(buffer);
112 if (p->master_lcore_present) {
115 "--master-lcore=%" PRIu32,
117 app->eal_argv[n_args++] = strdup(buffer);
120 snprintf(buffer, sizeof(buffer), "-n%" PRIu32, p->channels);
121 app->eal_argv[n_args++] = strdup(buffer);
123 if (p->memory_present) {
124 snprintf(buffer, sizeof(buffer), "-m%" PRIu32, p->memory);
125 app->eal_argv[n_args++] = strdup(buffer);
128 if (p->ranks_present) {
129 snprintf(buffer, sizeof(buffer), "-r%" PRIu32, p->ranks);
130 app->eal_argv[n_args++] = strdup(buffer);
133 for (i = 0; i < APP_MAX_LINKS; i++) {
134 if (p->pci_blacklist[i] == NULL)
139 "--pci-blacklist=%s",
140 p->pci_blacklist[i]);
141 app->eal_argv[n_args++] = strdup(buffer);
144 if (app->port_mask != 0)
145 for (i = 0; i < APP_MAX_LINKS; i++) {
146 if (p->pci_whitelist[i] == NULL)
151 "--pci-whitelist=%s",
152 p->pci_whitelist[i]);
154 app->eal_argv[n_args++] = strdup(buffer);
157 for (i = 0; i < app->n_links; i++) {
158 char *pci_bdf = app->link_params[i].pci_bdf;
162 "--pci-whitelist=%s",
164 app->eal_argv[n_args++] = strdup(buffer);
167 for (i = 0; i < APP_MAX_LINKS; i++) {
168 if (p->vdev[i] == NULL)
175 app->eal_argv[n_args++] = strdup(buffer);
178 if ((p->vmware_tsc_map_present) && p->vmware_tsc_map) {
179 snprintf(buffer, sizeof(buffer), "--vmware-tsc-map");
180 app->eal_argv[n_args++] = strdup(buffer);
188 app->eal_argv[n_args++] = strdup(buffer);
192 snprintf(buffer, sizeof(buffer), "--syslog=%s", p->syslog);
193 app->eal_argv[n_args++] = strdup(buffer);
196 if (p->log_level_present) {
199 "--log-level=%" PRIu32,
201 app->eal_argv[n_args++] = strdup(buffer);
204 if ((p->version_present) && p->version) {
205 snprintf(buffer, sizeof(buffer), "-v");
206 app->eal_argv[n_args++] = strdup(buffer);
209 if ((p->help_present) && p->help) {
210 snprintf(buffer, sizeof(buffer), "--help");
211 app->eal_argv[n_args++] = strdup(buffer);
214 if ((p->no_huge_present) && p->no_huge) {
215 snprintf(buffer, sizeof(buffer), "--no-huge");
216 app->eal_argv[n_args++] = strdup(buffer);
219 if ((p->no_pci_present) && p->no_pci) {
220 snprintf(buffer, sizeof(buffer), "--no-pci");
221 app->eal_argv[n_args++] = strdup(buffer);
224 if ((p->no_hpet_present) && p->no_hpet) {
225 snprintf(buffer, sizeof(buffer), "--no-hpet");
226 app->eal_argv[n_args++] = strdup(buffer);
229 if ((p->no_shconf_present) && p->no_shconf) {
230 snprintf(buffer, sizeof(buffer), "--no-shconf");
231 app->eal_argv[n_args++] = strdup(buffer);
235 snprintf(buffer, sizeof(buffer), "-d=%s", p->add_driver);
236 app->eal_argv[n_args++] = strdup(buffer);
244 app->eal_argv[n_args++] = strdup(buffer);
248 snprintf(buffer, sizeof(buffer), "--huge-dir=%s", p->huge_dir);
249 app->eal_argv[n_args++] = strdup(buffer);
252 if (p->file_prefix) {
257 app->eal_argv[n_args++] = strdup(buffer);
260 if (p->base_virtaddr) {
263 "--base-virtaddr=%s",
265 app->eal_argv[n_args++] = strdup(buffer);
268 if ((p->create_uio_dev_present) && p->create_uio_dev) {
269 snprintf(buffer, sizeof(buffer), "--create-uio-dev");
270 app->eal_argv[n_args++] = strdup(buffer);
278 app->eal_argv[n_args++] = strdup(buffer);
281 if ((p->xen_dom0_present) && (p->xen_dom0)) {
282 snprintf(buffer, sizeof(buffer), "--xen-dom0");
283 app->eal_argv[n_args++] = strdup(buffer);
286 snprintf(buffer, sizeof(buffer), "--");
287 app->eal_argv[n_args++] = strdup(buffer);
289 app->eal_argc = n_args;
291 APP_LOG(app, HIGH, "Initializing EAL ...");
292 if (app->log_level >= APP_LOG_LEVEL_LOW) {
295 fprintf(stdout, "[APP] EAL arguments: \"");
296 for (i = 1; i < app->eal_argc; i++)
297 fprintf(stdout, "%s ", app->eal_argv[i]);
298 fprintf(stdout, "\"\n");
301 status = rte_eal_init(app->eal_argc, app->eal_argv);
303 rte_panic("EAL init error\n");
307 app_init_mempool(struct app_params *app)
311 for (i = 0; i < app->n_mempools; i++) {
312 struct app_mempool_params *p = &app->mempool_params[i];
314 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
315 app->mempool[i] = rte_mempool_create(
320 sizeof(struct rte_pktmbuf_pool_private),
321 rte_pktmbuf_pool_init, NULL,
322 rte_pktmbuf_init, NULL,
326 if (app->mempool[i] == NULL)
327 rte_panic("%s init error\n", p->name);
332 app_link_filter_arp_add(struct app_link_params *link)
334 struct rte_eth_ethertype_filter filter = {
335 .ether_type = ETHER_TYPE_ARP,
337 .queue = link->arp_q,
340 return rte_eth_dev_filter_ctrl(link->pmd_id,
341 RTE_ETH_FILTER_ETHERTYPE,
347 app_link_filter_tcp_syn_add(struct app_link_params *link)
349 struct rte_eth_syn_filter filter = {
351 .queue = link->tcp_syn_q,
354 return rte_eth_dev_filter_ctrl(link->pmd_id,
361 app_link_filter_ip_add(struct app_link_params *l1, struct app_link_params *l2)
363 struct rte_eth_ntuple_filter filter = {
364 .flags = RTE_5TUPLE_FLAGS,
365 .dst_ip = rte_bswap32(l2->ip),
366 .dst_ip_mask = UINT32_MAX, /* Enable */
368 .src_ip_mask = 0, /* Disable */
370 .dst_port_mask = 0, /* Disable */
372 .src_port_mask = 0, /* Disable */
374 .proto_mask = 0, /* Disable */
376 .priority = 1, /* Lowest */
377 .queue = l1->ip_local_q,
380 return rte_eth_dev_filter_ctrl(l1->pmd_id,
381 RTE_ETH_FILTER_NTUPLE,
387 app_link_filter_ip_del(struct app_link_params *l1, struct app_link_params *l2)
389 struct rte_eth_ntuple_filter filter = {
390 .flags = RTE_5TUPLE_FLAGS,
391 .dst_ip = rte_bswap32(l2->ip),
392 .dst_ip_mask = UINT32_MAX, /* Enable */
394 .src_ip_mask = 0, /* Disable */
396 .dst_port_mask = 0, /* Disable */
398 .src_port_mask = 0, /* Disable */
400 .proto_mask = 0, /* Disable */
402 .priority = 1, /* Lowest */
403 .queue = l1->ip_local_q,
406 return rte_eth_dev_filter_ctrl(l1->pmd_id,
407 RTE_ETH_FILTER_NTUPLE,
408 RTE_ETH_FILTER_DELETE,
413 app_link_filter_tcp_add(struct app_link_params *l1, struct app_link_params *l2)
415 struct rte_eth_ntuple_filter filter = {
416 .flags = RTE_5TUPLE_FLAGS,
417 .dst_ip = rte_bswap32(l2->ip),
418 .dst_ip_mask = UINT32_MAX, /* Enable */
420 .src_ip_mask = 0, /* Disable */
422 .dst_port_mask = 0, /* Disable */
424 .src_port_mask = 0, /* Disable */
425 .proto = IPPROTO_TCP,
426 .proto_mask = UINT8_MAX, /* Enable */
428 .priority = 2, /* Higher priority than IP */
429 .queue = l1->tcp_local_q,
432 return rte_eth_dev_filter_ctrl(l1->pmd_id,
433 RTE_ETH_FILTER_NTUPLE,
439 app_link_filter_tcp_del(struct app_link_params *l1, struct app_link_params *l2)
441 struct rte_eth_ntuple_filter filter = {
442 .flags = RTE_5TUPLE_FLAGS,
443 .dst_ip = rte_bswap32(l2->ip),
444 .dst_ip_mask = UINT32_MAX, /* Enable */
446 .src_ip_mask = 0, /* Disable */
448 .dst_port_mask = 0, /* Disable */
450 .src_port_mask = 0, /* Disable */
451 .proto = IPPROTO_TCP,
452 .proto_mask = UINT8_MAX, /* Enable */
454 .priority = 2, /* Higher priority than IP */
455 .queue = l1->tcp_local_q,
458 return rte_eth_dev_filter_ctrl(l1->pmd_id,
459 RTE_ETH_FILTER_NTUPLE,
460 RTE_ETH_FILTER_DELETE,
465 app_link_filter_udp_add(struct app_link_params *l1, struct app_link_params *l2)
467 struct rte_eth_ntuple_filter filter = {
468 .flags = RTE_5TUPLE_FLAGS,
469 .dst_ip = rte_bswap32(l2->ip),
470 .dst_ip_mask = UINT32_MAX, /* Enable */
472 .src_ip_mask = 0, /* Disable */
474 .dst_port_mask = 0, /* Disable */
476 .src_port_mask = 0, /* Disable */
477 .proto = IPPROTO_UDP,
478 .proto_mask = UINT8_MAX, /* Enable */
480 .priority = 2, /* Higher priority than IP */
481 .queue = l1->udp_local_q,
484 return rte_eth_dev_filter_ctrl(l1->pmd_id,
485 RTE_ETH_FILTER_NTUPLE,
491 app_link_filter_udp_del(struct app_link_params *l1, struct app_link_params *l2)
493 struct rte_eth_ntuple_filter filter = {
494 .flags = RTE_5TUPLE_FLAGS,
495 .dst_ip = rte_bswap32(l2->ip),
496 .dst_ip_mask = UINT32_MAX, /* Enable */
498 .src_ip_mask = 0, /* Disable */
500 .dst_port_mask = 0, /* Disable */
502 .src_port_mask = 0, /* Disable */
503 .proto = IPPROTO_UDP,
504 .proto_mask = UINT8_MAX, /* Enable */
506 .priority = 2, /* Higher priority than IP */
507 .queue = l1->udp_local_q,
510 return rte_eth_dev_filter_ctrl(l1->pmd_id,
511 RTE_ETH_FILTER_NTUPLE,
512 RTE_ETH_FILTER_DELETE,
517 app_link_filter_sctp_add(struct app_link_params *l1, struct app_link_params *l2)
519 struct rte_eth_ntuple_filter filter = {
520 .flags = RTE_5TUPLE_FLAGS,
521 .dst_ip = rte_bswap32(l2->ip),
522 .dst_ip_mask = UINT32_MAX, /* Enable */
524 .src_ip_mask = 0, /* Disable */
526 .dst_port_mask = 0, /* Disable */
528 .src_port_mask = 0, /* Disable */
529 .proto = IPPROTO_SCTP,
530 .proto_mask = UINT8_MAX, /* Enable */
532 .priority = 2, /* Higher priority than IP */
533 .queue = l1->sctp_local_q,
536 return rte_eth_dev_filter_ctrl(l1->pmd_id,
537 RTE_ETH_FILTER_NTUPLE,
543 app_link_filter_sctp_del(struct app_link_params *l1, struct app_link_params *l2)
545 struct rte_eth_ntuple_filter filter = {
546 .flags = RTE_5TUPLE_FLAGS,
547 .dst_ip = rte_bswap32(l2->ip),
548 .dst_ip_mask = UINT32_MAX, /* Enable */
550 .src_ip_mask = 0, /* Disable */
552 .dst_port_mask = 0, /* Disable */
554 .src_port_mask = 0, /* Disable */
555 .proto = IPPROTO_SCTP,
556 .proto_mask = UINT8_MAX, /* Enable */
558 .priority = 2, /* Higher priority than IP */
559 .queue = l1->sctp_local_q,
562 return rte_eth_dev_filter_ctrl(l1->pmd_id,
563 RTE_ETH_FILTER_NTUPLE,
564 RTE_ETH_FILTER_DELETE,
569 app_link_set_arp_filter(struct app_params *app, struct app_link_params *cp)
571 if (cp->arp_q != 0) {
572 int status = app_link_filter_arp_add(cp);
574 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
575 "Adding ARP filter (queue = %" PRIu32 ")",
576 cp->name, cp->pmd_id, cp->arp_q);
579 rte_panic("%s (%" PRIu32 "): "
580 "Error adding ARP filter "
581 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
582 cp->name, cp->pmd_id, cp->arp_q, status);
587 app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
589 if (cp->tcp_syn_q != 0) {
590 int status = app_link_filter_tcp_syn_add(cp);
592 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
593 "Adding TCP SYN filter (queue = %" PRIu32 ")",
594 cp->name, cp->pmd_id, cp->tcp_syn_q);
597 rte_panic("%s (%" PRIu32 "): "
598 "Error adding TCP SYN filter "
599 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
600 cp->name, cp->pmd_id, cp->tcp_syn_q,
605 /* rte_eth_dev is removed in DPDK version 16.11 and onwards */
606 #if RTE_VERSION < 0x100b0000
608 app_link_is_virtual(__rte_unused struct app_link_params *p)
610 uint32_t pmd_id = p->pmd_id;
611 struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
612 if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
621 app_link_up_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
626 struct rte_eth_link link;
628 #if RTE_VERSION < 0x100b0000
629 if (app_link_is_virtual(cp)) {
635 /* For each link, add filters for IP of current link */
637 for (i = 0; i < app->n_links; i++) {
638 struct app_link_params *p = &app->link_params[i];
641 if (p->ip_local_q != 0) {
642 int status = app_link_filter_ip_add(p, cp);
644 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
645 "Adding IP filter (queue= %" PRIu32
646 ", IP = 0x%08" PRIx32 ")",
647 p->name, p->pmd_id, p->ip_local_q,
651 rte_panic("%s (%" PRIu32 "): "
653 "filter (queue= %" PRIu32 ", "
657 p->ip_local_q, cp->ip, status);
661 if (p->tcp_local_q != 0) {
662 int status = app_link_filter_tcp_add(p, cp);
664 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
667 ", IP = 0x%08" PRIx32 ")",
668 p->name, p->pmd_id, p->tcp_local_q,
672 rte_panic("%s (%" PRIu32 "): "
674 "filter (queue = %" PRIu32 ", "
678 p->tcp_local_q, cp->ip, status);
682 if (p->udp_local_q != 0) {
683 int status = app_link_filter_udp_add(p, cp);
685 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
688 ", IP = 0x%08" PRIx32 ")",
689 p->name, p->pmd_id, p->udp_local_q,
693 rte_panic("%s (%" PRIu32 "): "
695 "filter (queue = %" PRIu32 ", "
699 p->udp_local_q, cp->ip, status);
703 if (p->sctp_local_q != 0) {
704 int status = app_link_filter_sctp_add(p, cp);
706 APP_LOG(app, LOW, "%s (%" PRIu32
707 "): Adding SCTP filter "
709 ", IP = 0x%08" PRIx32 ")",
710 p->name, p->pmd_id, p->sctp_local_q,
714 rte_panic("%s (%" PRIu32 "): "
716 "filter (queue = %" PRIu32 ", "
720 p->sctp_local_q, cp->ip,
726 rte_eth_link_get(cp->pmd_id, &link);
727 if (!link.link_status) {
729 status = rte_eth_dev_set_link_up(cp->pmd_id);
731 rte_panic("%s (%" PRIu32 "): PMD set link up error %"
732 PRId32 "\n", cp->name, cp->pmd_id, status);
735 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_UP);
737 /* Mark link as UP */
742 app_link_down_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
747 struct rte_eth_link link;
749 #if RTE_VERSION < 0x100b0000
750 if (app_link_is_virtual(cp)) {
756 rte_eth_link_get(cp->pmd_id, &link);
757 if (link.link_status) {
759 status = rte_eth_dev_set_link_down(cp->pmd_id);
761 rte_panic("%s (%" PRIu32 "): PMD set link down error %"
762 PRId32 "\n", cp->name, cp->pmd_id, status);
765 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_DOWN);
766 /* Mark link as DOWN */
769 /* Return if current link IP is not valid */
773 /* For each link, remove filters for IP of current link */
774 for (i = 0; i < app->n_links; i++) {
775 struct app_link_params *p = &app->link_params[i];
778 if (p->ip_local_q != 0) {
779 int status = app_link_filter_ip_del(p, cp);
781 APP_LOG(app, LOW, "%s (%" PRIu32
782 "): Deleting IP filter "
783 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
784 p->name, p->pmd_id, p->ip_local_q, cp->ip);
787 rte_panic("%s (%" PRIu32
788 "): Error deleting IP filter "
792 p->name, p->pmd_id, p->ip_local_q,
797 if (p->tcp_local_q != 0) {
798 int status = app_link_filter_tcp_del(p, cp);
800 APP_LOG(app, LOW, "%s (%" PRIu32
801 "): Deleting TCP filter "
803 ", IP = 0x%" PRIx32 ")",
804 p->name, p->pmd_id, p->tcp_local_q, cp->ip);
807 rte_panic("%s (%" PRIu32
808 "): Error deleting TCP filter "
812 p->name, p->pmd_id, p->tcp_local_q,
817 if (p->udp_local_q != 0) {
818 int status = app_link_filter_udp_del(p, cp);
820 APP_LOG(app, LOW, "%s (%" PRIu32
821 "): Deleting UDP filter "
822 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
823 p->name, p->pmd_id, p->udp_local_q, cp->ip);
826 rte_panic("%s (%" PRIu32
827 "): Error deleting UDP filter "
831 p->name, p->pmd_id, p->udp_local_q,
836 if (p->sctp_local_q != 0) {
837 int status = app_link_filter_sctp_del(p, cp);
839 APP_LOG(app, LOW, "%s (%" PRIu32
840 "): Deleting SCTP filter "
842 ", IP = 0x%" PRIx32 ")",
843 p->name, p->pmd_id, p->sctp_local_q, cp->ip);
846 rte_panic("%s (%" PRIu32
847 "): Error deleting SCTP filter "
851 p->name, p->pmd_id, p->sctp_local_q,
859 app_check_link(struct app_params *app)
861 uint32_t all_links_up, i;
865 for (i = 0; i < app->n_links; i++) {
866 struct app_link_params *p = &app->link_params[i];
867 struct rte_eth_link link_params;
869 memset(&link_params, 0, sizeof(link_params));
870 rte_eth_link_get(p->pmd_id, &link_params);
872 APP_LOG(app, HIGH, "%s (%" PRIu32 ") (%" PRIu32 " Gbps) %s",
875 link_params.link_speed / 1000,
876 link_params.link_status ? "UP" : "DOWN");
878 if (link_params.link_status == ETH_LINK_DOWN)
882 if (all_links_up == 0)
883 rte_panic("Some links are DOWN\n");
887 is_any_swq_frag_or_ras(struct app_params *app)
891 for (i = 0; i < app->n_pktq_swq; i++) {
892 struct app_pktq_swq_params *p = &app->swq_params[i];
894 if ((p->ipv4_frag == 1) || (p->ipv6_frag == 1) ||
895 (p->ipv4_ras == 1) || (p->ipv6_ras == 1))
903 app_init_link_frag_ras(struct app_params *app)
907 if (is_any_swq_frag_or_ras(app)) {
908 for (i = 0; i < app->n_pktq_hwq_out; i++) {
909 struct app_pktq_hwq_out_params *p_txq =
910 &app->hwq_out_params[i];
912 p_txq->conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
918 app_get_cpu_socket_id(uint32_t pmd_id)
920 int status = rte_eth_dev_socket_id(pmd_id);
922 return (status != SOCKET_ID_ANY) ? status : 0;
925 struct rte_eth_rxmode rx_mode = {
926 .max_rx_pkt_len = ETHER_MAX_LEN, /**< Default maximum frame length. */
928 .header_split = 0, /**< Header Split disabled. */
929 .hw_ip_checksum = 0, /**< IP checksum offload disabled. */
930 .hw_vlan_filter = 1, /**< VLAN filtering enabled. */
931 .hw_vlan_strip = 1, /**< VLAN strip enabled. */
932 .hw_vlan_extend = 0, /**< Extended VLAN disabled. */
933 .jumbo_frame = 0, /**< Jumbo Frame Support disabled. */
934 .hw_strip_crc = 0, /**< CRC stripping by hardware disabled. */
936 struct rte_fdir_conf fdir_conf = {
937 .mode = RTE_FDIR_MODE_NONE,
938 .pballoc = RTE_FDIR_PBALLOC_64K,
939 .status = RTE_FDIR_REPORT_STATUS,
941 .vlan_tci_mask = 0x0,
943 .src_ip = 0xFFFFFFFF,
944 .dst_ip = 0xFFFFFFFF,
947 .src_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
948 .dst_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
950 .src_port_mask = 0xFFFF,
951 .dst_port_mask = 0xFFFF,
952 .mac_addr_byte_mask = 0xFF,
953 .tunnel_type_mask = 1,
954 .tunnel_id_mask = 0xFFFFFFFF,
960 app_init_link(struct app_params *app)
964 app_init_link_frag_ras(app);
967 *Configuring port_config_t structure for interface manager initialization
969 size = RTE_CACHE_LINE_ROUNDUP(sizeof(port_config_t));
970 port_config = rte_zmalloc(NULL, (app->n_links * size), RTE_CACHE_LINE_SIZE);
971 if (port_config == NULL)
972 rte_panic("port_config is NULL: Memory Allocation failure\n");
974 for (i = 0; i < app->n_links; i++) {
975 struct app_link_params *p_link = &app->link_params[i];
976 uint32_t link_id, n_hwq_in, n_hwq_out;
979 status = sscanf(p_link->name, "LINK%" PRIu32, &link_id);
981 rte_panic("%s (%" PRId32 "): "
982 "init error (%" PRId32 ")\n",
983 p_link->name, link_id, status);
985 n_hwq_in = app_link_get_n_rxq(app, p_link);
986 n_hwq_out = app_link_get_n_txq(app, p_link);
988 printf("\n\nn_hwq_in %d\n", n_hwq_in);
989 struct rte_eth_conf *My_local_conf = &p_link->conf;
992 My_local_conf->rxmode = rx_mode;
993 My_local_conf->fdir_conf = fdir_conf;
994 My_local_conf->rxmode.mq_mode = ETH_MQ_RX_RSS;
995 My_local_conf->rx_adv_conf.rss_conf.rss_key = NULL;
996 My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
997 /* pkt-filter-mode is perfect */
998 My_local_conf->fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
1001 My_local_conf->rx_adv_conf.rss_conf.rss_hf = 0;
1004 /* Set the hardware CRC stripping to avoid double stripping of FCS in VM */
1005 p_link->conf.rxmode.hw_strip_crc=1;
1007 APP_LOG(app, HIGH, "Initializing %s (%" PRIu32") "
1008 "(%" PRIu32 " RXQ, %" PRIu32 " TXQ) ...",
1014 port_config[i].port_id = p_link->pmd_id;
1015 port_config[i].nrx_queue = n_hwq_in;
1016 port_config[i].ntx_queue = n_hwq_out;
1017 port_config[i].state = 1;
1018 port_config[i].promisc = p_link->promisc;
1019 port_config[i].mempool.pool_size = app->mempool_params[0].pool_size;
1020 port_config[i].mempool.buffer_size = app->mempool_params[0].buffer_size;
1021 port_config[i].mempool.cache_size = app->mempool_params[0].cache_size;
1022 port_config[i].mempool.cpu_socket_id = app->mempool_params[0].cpu_socket_id;
1023 memcpy (&port_config[i].port_conf, &p_link->conf, sizeof(struct rte_eth_conf));
1024 memcpy (&port_config[i].rx_conf, &app->hwq_in_params[0].conf, sizeof(struct rte_eth_rxconf));
1025 memcpy (&port_config[i].tx_conf, &app->hwq_out_params[0].conf, sizeof(struct rte_eth_txconf));
1027 if(app->header_csum_req) {
1028 /* Enable TCP and UDP HW Checksum */
1029 port_config[i].tx_conf.txq_flags &=
1030 ~(ETH_TXQ_FLAGS_NOXSUMTCP|ETH_TXQ_FLAGS_NOXSUMUDP);
1033 if (ifm_port_setup (p_link->pmd_id, &port_config[i])) {
1034 printf("Failed to configure port %s - %"PRIu32
1035 ".\n", p_link->name, p_link->pmd_id);
1036 printf("Try again with offload disabled....\n");
1037 port_config[i].tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOOFFLOADS;
1038 if (ifm_port_setup (p_link->pmd_id, &port_config[i]))
1039 rte_panic ("Port Setup Failed: %s - %"PRIu32"\n", p_link->name, p_link->pmd_id);
1044 status = rte_eth_dev_configure(
1050 rte_panic("%s (%" PRId32 "): "
1051 "init error (%" PRId32 ")\n",
1052 p_link->name, p_link->pmd_id, status);
1054 rte_eth_macaddr_get(p_link->pmd_id,
1055 (struct ether_addr *) &p_link->mac_addr);
1057 if (p_link->promisc)
1058 rte_eth_promiscuous_enable(p_link->pmd_id);
1061 for (j = 0; j < app->n_pktq_hwq_in; j++) {
1062 struct app_pktq_hwq_in_params *p_rxq =
1063 &app->hwq_in_params[j];
1064 uint32_t rxq_link_id, rxq_queue_id;
1067 sscanf(p_rxq->name, "RXQ%" PRIu32 ".%" PRIu32,
1068 &rxq_link_id, &rxq_queue_id);
1070 rte_panic("%s (%" PRId32 "): "
1071 "init error (%" PRId32 ")\n",
1072 p_rxq->name, rxq_queue_id, status);
1074 if (rxq_link_id != link_id)
1077 status = rte_eth_rx_queue_setup(
1081 app_get_cpu_socket_id(p_link->pmd_id),
1083 app->mempool[p_rxq->mempool_id]);
1085 rte_panic("%s (%" PRIu32 "): "
1086 "%s init error (%" PRId32 ")\n",
1094 for (j = 0; j < app->n_pktq_hwq_out; j++) {
1095 struct app_pktq_hwq_out_params *p_txq =
1096 &app->hwq_out_params[j];
1097 uint32_t txq_link_id, txq_queue_id;
1100 sscanf(p_txq->name, "TXQ%" PRIu32 ".%" PRIu32,
1101 &txq_link_id, &txq_queue_id);
1104 rte_panic("%s (%" PRId32 "): "
1105 "init error (%" PRId32 ")\n",
1106 p_txq->name, txq_link_id, status);
1108 if (txq_link_id != link_id)
1111 if (app->header_csum_req) {
1112 /* Enable TCP and UDP HW Checksum */
1113 p_txq->conf.txq_flags &=
1114 ~(ETH_TXQ_FLAGS_NOXSUMTCP|
1115 ETH_TXQ_FLAGS_NOXSUMUDP);
1118 status = rte_eth_tx_queue_setup(
1122 app_get_cpu_socket_id(p_link->pmd_id),
1126 rte_panic("%s (%" PRIu32 "): "
1127 "%s init error (%" PRId32 ")\n",
1135 status = rte_eth_dev_start(p_link->pmd_id);
1137 rte_panic("Cannot start %s (error %" PRId32 ")\n",
1138 p_link->name, status);
1141 app_link_set_arp_filter(app, p_link);
1142 app_link_set_tcp_syn_filter(app, p_link);
1144 app_link_up_internal(app, p_link);
1147 app_check_link(app);
1151 app_init_swq(struct app_params *app)
1155 for (i = 0; i < app->n_pktq_swq; i++) {
1156 struct app_pktq_swq_params *p = &app->swq_params[i];
1157 unsigned int flags = 0;
1159 if (app_swq_get_readers(app, p) == 1)
1160 flags |= RING_F_SC_DEQ;
1161 if (app_swq_get_writers(app, p) == 1)
1162 flags |= RING_F_SP_ENQ;
1164 APP_LOG(app, HIGH, "Initializing %s...", p->name);
1165 app->swq[i] = rte_ring_create(
1171 if (app->swq[i] == NULL)
1172 rte_panic("%s init error\n", p->name);
1177 app_init_tm(struct app_params *app)
1181 for (i = 0; i < app->n_pktq_tm; i++) {
1182 struct app_pktq_tm_params *p_tm = &app->tm_params[i];
1183 struct app_link_params *p_link;
1184 struct rte_eth_link link_eth_params;
1185 struct rte_sched_port *sched;
1186 uint32_t n_subports, subport_id;
1189 p_link = app_get_link_for_tm(app, p_tm);
1191 rte_eth_link_get(p_link->pmd_id, &link_eth_params);
1194 p_tm->sched_port_params.name = p_tm->name;
1195 p_tm->sched_port_params.socket =
1196 app_get_cpu_socket_id(p_link->pmd_id);
1197 p_tm->sched_port_params.rate =
1198 (uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;
1200 APP_LOG(app, HIGH, "Initializing %s ...", p_tm->name);
1201 sched = rte_sched_port_config(&p_tm->sched_port_params);
1203 rte_panic("%s init error\n", p_tm->name);
1207 n_subports = p_tm->sched_port_params.n_subports_per_port;
1208 for (subport_id = 0; subport_id < n_subports; subport_id++) {
1209 uint32_t n_pipes_per_subport, pipe_id;
1211 status = rte_sched_subport_config(sched,
1213 &p_tm->sched_subport_params[subport_id]);
1215 rte_panic("%s subport %" PRIu32
1216 " init error (%" PRId32 ")\n",
1217 p_tm->name, subport_id, status);
1220 n_pipes_per_subport =
1221 p_tm->sched_port_params.n_pipes_per_subport;
1223 pipe_id < n_pipes_per_subport;
1225 int profile_id = p_tm->sched_pipe_to_profile[
1226 subport_id * APP_MAX_SCHED_PIPES +
1229 if (profile_id == -1)
1232 status = rte_sched_pipe_config(sched,
1237 rte_panic("%s subport %" PRIu32
1239 " (profile %" PRId32 ") "
1240 "init error (% " PRId32 ")\n",
1241 p_tm->name, subport_id, pipe_id,
1242 profile_id, status);
1249 app_init_msgq(struct app_params *app)
1253 for (i = 0; i < app->n_msgq; i++) {
1254 struct app_msgq_params *p = &app->msgq_params[i];
1256 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
1257 app->msgq[i] = rte_ring_create(
1261 RING_F_SP_ENQ | RING_F_SC_DEQ);
1263 if (app->msgq[i] == NULL)
1264 rte_panic("%s init error\n", p->name);
1268 static void app_pipeline_params_get(struct app_params *app,
1269 struct app_pipeline_params *p_in,
1270 struct pipeline_params *p_out)
1273 uint32_t mempool_id;
1275 snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
1277 p_out->socket_id = (int) p_in->socket_id;
1279 p_out->log_level = app->log_level;
1282 p_out->n_ports_in = p_in->n_pktq_in;
1283 for (i = 0; i < p_in->n_pktq_in; i++) {
1284 struct app_pktq_in_params *in = &p_in->pktq_in[i];
1285 struct pipeline_port_in_params *out = &p_out->port_in[i];
1288 case APP_PKTQ_IN_HWQ:
1290 struct app_pktq_hwq_in_params *p_hwq_in =
1291 &app->hwq_in_params[in->id];
1292 struct app_link_params *p_link =
1293 app_get_link_for_rxq(app, p_hwq_in);
1294 uint32_t rxq_link_id, rxq_queue_id;
1297 sscanf(p_hwq_in->name, "RXQ%" SCNu32 ".%" SCNu32,
1301 rte_panic("%s (%" PRId32 "): "
1302 "init error (%" PRId32 ")\n",
1303 p_hwq_in->name, rxq_link_id, status);
1305 out->type = PIPELINE_PORT_IN_ETHDEV_READER;
1306 out->params.ethdev.port_id = p_link->pmd_id;
1307 out->params.ethdev.queue_id = rxq_queue_id;
1308 out->burst_size = p_hwq_in->burst;
1311 case APP_PKTQ_IN_SWQ:
1313 struct app_pktq_swq_params *swq_params =
1314 &app->swq_params[in->id];
1316 if ((swq_params->ipv4_frag == 0) &&
1317 (swq_params->ipv6_frag == 0)) {
1318 if (app_swq_get_readers(app,
1321 PIPELINE_PORT_IN_RING_READER;
1322 out->params.ring.ring =
1325 app->swq_params[in->id].
1328 out->type = PIPELINE_PORT_IN_RING_MULTI_READER;
1329 out->params.ring_multi.ring = app->swq[in->id];
1330 out->burst_size = swq_params->burst_read;
1333 if (swq_params->ipv4_frag == 1) {
1334 struct rte_port_ring_reader_ipv4_frag_params
1336 &out->params.ring_ipv4_frag;
1339 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG;
1340 params->ring = app->swq[in->id];
1341 params->mtu = swq_params->mtu;
1342 params->metadata_size =
1343 swq_params->metadata_size;
1344 params->pool_direct =
1346 [swq_params->mempool_direct_id];
1347 params->pool_indirect =
1349 [swq_params->mempool_indirect_id];
1350 out->burst_size = swq_params->burst_read;
1352 struct rte_port_ring_reader_ipv6_frag_params
1354 &out->params.ring_ipv6_frag;
1357 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG;
1358 params->ring = app->swq[in->id];
1359 params->mtu = swq_params->mtu;
1360 params->metadata_size =
1361 swq_params->metadata_size;
1362 params->pool_direct =
1364 [swq_params->mempool_direct_id];
1365 params->pool_indirect =
1367 [swq_params->mempool_indirect_id];
1368 out->burst_size = swq_params->burst_read;
1373 case APP_PKTQ_IN_TM:
1374 out->type = PIPELINE_PORT_IN_SCHED_READER;
1375 out->params.sched.sched = app->tm[in->id];
1376 out->burst_size = app->tm_params[in->id].burst_read;
1378 case APP_PKTQ_IN_SOURCE:
1379 mempool_id = app->source_params[in->id].mempool_id;
1380 out->type = PIPELINE_PORT_IN_SOURCE;
1381 out->params.source.mempool = app->mempool[mempool_id];
1382 out->burst_size = app->source_params[in->id].burst;
1385 if (app->source_params[in->id].file_name
1387 out->params.source.file_name = strdup(
1388 app->source_params[in->id].
1390 if (out->params.source.file_name == NULL) {
1392 n_bytes_per_pkt = 0;
1395 out->params.source.n_bytes_per_pkt =
1396 app->source_params[in->id].
1408 p_out->n_ports_out = p_in->n_pktq_out;
1409 for (i = 0; i < p_in->n_pktq_out; i++) {
1410 struct app_pktq_out_params *in = &p_in->pktq_out[i];
1411 struct pipeline_port_out_params *out = &p_out->port_out[i];
1414 case APP_PKTQ_OUT_HWQ:
1416 struct app_pktq_hwq_out_params *p_hwq_out =
1417 &app->hwq_out_params[in->id];
1418 struct app_link_params *p_link =
1419 app_get_link_for_txq(app, p_hwq_out);
1420 uint32_t txq_link_id, txq_queue_id;
1423 sscanf(p_hwq_out->name,
1424 "TXQ%" SCNu32 ".%" SCNu32,
1428 rte_panic("%s (%" PRId32 "): "
1429 "init error (%" PRId32 ")\n",
1430 p_hwq_out->name, txq_link_id, status);
1432 if (p_hwq_out->dropless == 0) {
1433 struct rte_port_ethdev_writer_params *params =
1434 &out->params.ethdev;
1436 out->type = PIPELINE_PORT_OUT_ETHDEV_WRITER;
1437 params->port_id = p_link->pmd_id;
1438 params->queue_id = txq_queue_id;
1439 params->tx_burst_sz =
1440 app->hwq_out_params[in->id].burst;
1442 struct rte_port_ethdev_writer_nodrop_params
1443 *params = &out->params.ethdev_nodrop;
1446 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP;
1447 params->port_id = p_link->pmd_id;
1448 params->queue_id = txq_queue_id;
1449 params->tx_burst_sz = p_hwq_out->burst;
1450 params->n_retries = p_hwq_out->n_retries;
1454 case APP_PKTQ_OUT_SWQ:
1456 struct app_pktq_swq_params *swq_params =
1457 &app->swq_params[in->id];
1459 if ((swq_params->ipv4_ras == 0) &&
1460 (swq_params->ipv6_ras == 0)) {
1461 if (app_swq_get_writers(app, swq_params) == 1) {
1462 if (app->swq_params[in->id].dropless == 0) {
1463 struct rte_port_ring_writer_params *params =
1466 out->type = PIPELINE_PORT_OUT_RING_WRITER;
1467 params->ring = app->swq[in->id];
1468 params->tx_burst_sz =
1469 app->swq_params[in->id].burst_write;
1471 struct rte_port_ring_writer_nodrop_params
1472 *params = &out->params.ring_nodrop;
1475 PIPELINE_PORT_OUT_RING_WRITER_NODROP;
1476 params->ring = app->swq[in->id];
1477 params->tx_burst_sz =
1478 app->swq_params[in->id].burst_write;
1480 app->swq_params[in->id].n_retries;
1483 if (swq_params->dropless == 0) {
1484 struct rte_port_ring_multi_writer_params
1486 &out->params.ring_multi;
1489 PIPELINE_PORT_OUT_RING_MULTI_WRITER;
1490 params->ring = app->swq[in->id];
1491 params->tx_burst_sz = swq_params->burst_write;
1493 struct rte_port_ring_multi_writer_nodrop_params
1495 &out->params.ring_multi_nodrop;
1498 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP;
1500 params->ring = app->swq[in->id];
1501 params->tx_burst_sz = swq_params->burst_write;
1502 params->n_retries = swq_params->n_retries;
1506 if (swq_params->ipv4_ras == 1) {
1507 struct rte_port_ring_writer_ipv4_ras_params
1509 &out->params.ring_ipv4_ras;
1512 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS;
1513 params->ring = app->swq[in->id];
1514 params->tx_burst_sz = swq_params->burst_write;
1516 struct rte_port_ring_writer_ipv6_ras_params
1518 &out->params.ring_ipv6_ras;
1521 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS;
1522 params->ring = app->swq[in->id];
1523 params->tx_burst_sz = swq_params->burst_write;
1528 case APP_PKTQ_OUT_TM: {
1529 struct rte_port_sched_writer_params *params =
1532 out->type = PIPELINE_PORT_OUT_SCHED_WRITER;
1533 params->sched = app->tm[in->id];
1534 params->tx_burst_sz =
1535 app->tm_params[in->id].burst_write;
1538 case APP_PKTQ_OUT_SINK:
1539 out->type = PIPELINE_PORT_OUT_SINK;
1540 if (app->sink_params[in->id].file_name != NULL) {
1541 out->params.sink.file_name = strdup(
1542 app->sink_params[in->id].
1544 if (out->params.sink.file_name == NULL) {
1545 out->params.sink.max_n_pkts = 0;
1548 out->params.sink.max_n_pkts =
1549 app->sink_params[in->id].
1552 out->params.sink.file_name = NULL;
1553 out->params.sink.max_n_pkts = 0;
1562 p_out->n_msgq = p_in->n_msgq_in;
1564 for (i = 0; i < p_in->n_msgq_in; i++)
1565 p_out->msgq_in[i] = app->msgq[p_in->msgq_in[i]];
1567 for (i = 0; i < p_in->n_msgq_out; i++)
1568 p_out->msgq_out[i] = app->msgq[p_in->msgq_out[i]];
1571 p_out->n_args = p_in->n_args;
1572 for (i = 0; i < p_in->n_args; i++) {
1573 p_out->args_name[i] = p_in->args_name[i];
1574 p_out->args_value[i] = p_in->args_value[i];
1579 app_init_pipelines(struct app_params *app)
1583 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1584 struct app_pipeline_params *params =
1585 &app->pipeline_params[p_id];
1586 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1587 struct pipeline_type *ptype;
1588 struct pipeline_params pp;
1590 APP_LOG(app, HIGH, "Initializing %s ...", params->name);
1592 ptype = app_pipeline_type_find(app, params->type);
1594 rte_panic("Init error: Unknown pipeline type \"%s\"\n",
1597 app_pipeline_params_get(app, params, &pp);
1601 if (ptype->be_ops->f_init) {
1602 data->be = ptype->be_ops->f_init(&pp, (void *) app);
1604 if (data->be == NULL)
1605 rte_panic("Pipeline instance \"%s\" back-end "
1606 "init error\n", params->name);
1611 if (ptype->fe_ops->f_init) {
1612 data->fe = ptype->fe_ops->f_init(&pp, (void *) app);
1614 if (data->fe == NULL)
1615 rte_panic("Pipeline instance \"%s\" front-end "
1616 "init error\n", params->name);
1619 data->ptype = ptype;
1621 data->timer_period = (rte_get_tsc_hz() *
1622 params->timer_period) / 100;
1627 app_init_threads(struct app_params *app)
1629 uint64_t time = rte_get_tsc_cycles();
1632 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1633 struct app_pipeline_params *params =
1634 &app->pipeline_params[p_id];
1635 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1636 struct pipeline_type *ptype;
1637 struct app_thread_data *t;
1638 struct app_thread_pipeline_data *p;
1641 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
1644 params->hyper_th_id);
1647 rte_panic("Invalid core s%" PRIu32 "c%" PRIu32 "%s\n",
1650 (params->hyper_th_id) ? "h" : "");
1652 t = &app->thread_data[lcore_id];
1654 t->timer_period = (rte_get_tsc_hz() *
1655 APP_THREAD_TIMER_PERIOD) / 1000;
1656 t->thread_req_deadline = time + t->timer_period;
1658 t->headroom_cycles = 0;
1659 t->headroom_time = rte_get_tsc_cycles();
1660 t->headroom_ratio = 0.0;
1662 t->msgq_in = app_thread_msgq_in_get(app,
1665 params->hyper_th_id);
1666 if (t->msgq_in == NULL)
1667 rte_panic("Init error: Cannot find MSGQ_IN "
1668 "for thread %" PRId32, lcore_id);
1670 t->msgq_out = app_thread_msgq_out_get(app,
1673 params->hyper_th_id);
1674 if (t->msgq_out == NULL)
1675 rte_panic("Init error: Cannot find MSGQ_OUT "
1676 "for thread %" PRId32, lcore_id);
1678 ptype = app_pipeline_type_find(app, params->type);
1680 rte_panic("Init error: Unknown pipeline "
1681 "type \"%s\"\n", params->type);
1683 p = (ptype->be_ops->f_run == NULL) ?
1684 &t->regular[t->n_regular] :
1685 &t->custom[t->n_custom];
1687 p->pipeline_id = p_id;
1689 p->f_run = ptype->be_ops->f_run;
1690 p->f_timer = ptype->be_ops->f_timer;
1691 p->timer_period = data->timer_period;
1692 p->deadline = time + data->timer_period;
1696 if (ptype->be_ops->f_run == NULL)
1703 int app_init(struct app_params *app)
1705 app_init_core_map(app);
1706 app_init_core_mask(app);
1710 //app_init_mempool(app);
1716 app_pipeline_common_cmd_push(app);
1717 app_pipeline_thread_cmd_push(app);
1718 app_pipeline_type_register(app, &pipeline_master);
1719 app_pipeline_type_register(app, &pipeline_cgnapt);
1720 app_pipeline_type_register(app, &pipeline_loadb);
1721 app_pipeline_type_register(app, &pipeline_timer);
1722 app_pipeline_type_register(app, &pipeline_txrx);
1723 app_pipeline_type_register(app, &pipeline_arpicmp);
1725 app_init_pipelines(app);
1726 app_init_threads(app);
1728 #ifdef L3_STACK_SUPPORT
1732 populate_lpm_routes();
1733 print_interface_details();
1740 app_pipeline_type_cmd_push(struct app_params *app,
1741 struct pipeline_type *ptype)
1743 cmdline_parse_ctx_t *cmds;
1746 /* Check input arguments */
1747 if ((app == NULL) ||
1751 n_cmds = pipeline_type_cmds_count(ptype);
1755 cmds = ptype->fe_ops->cmds;
1757 /* Check for available slots in the application commands array */
1758 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1761 /* Push pipeline commands into the application */
1762 memcpy(&app->cmds[app->n_cmds],
1764 n_cmds * sizeof(cmdline_parse_ctx_t));
1766 for (i = 0; i < n_cmds; i++)
1767 app->cmds[app->n_cmds + i]->data = app;
1769 app->n_cmds += n_cmds;
1770 app->cmds[app->n_cmds] = NULL;
1776 app_pipeline_type_register(struct app_params *app, struct pipeline_type *ptype)
1780 /* Check input arguments */
1781 if ((app == NULL) ||
1783 (ptype->name == NULL) ||
1784 (strlen(ptype->name) == 0) ||
1785 (ptype->be_ops->f_init == NULL) ||
1786 (ptype->be_ops->f_timer == NULL))
1789 /* Check for duplicate entry */
1790 for (i = 0; i < app->n_pipeline_types; i++)
1791 if (strcmp(app->pipeline_type[i].name, ptype->name) == 0)
1794 /* Check for resource availability */
1795 n_cmds = pipeline_type_cmds_count(ptype);
1796 if ((app->n_pipeline_types == APP_MAX_PIPELINE_TYPES) ||
1797 (n_cmds > APP_MAX_CMDS - app->n_cmds))
1800 /* Copy pipeline type */
1801 memcpy(&app->pipeline_type[app->n_pipeline_types++],
1803 sizeof(struct pipeline_type));
1805 /* Copy CLI commands */
1807 app_pipeline_type_cmd_push(app, ptype);
1813 pipeline_type *app_pipeline_type_find(struct app_params *app, char *name)
1817 for (i = 0; i < app->n_pipeline_types; i++)
1818 if (strcmp(app->pipeline_type[i].name, name) == 0)
1819 return &app->pipeline_type[i];