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>
30 #include "pipeline_common_fe.h"
31 #include "pipeline_master.h"
32 #include "thread_fe.h"
33 #include "pipeline_cgnapt.h"
34 #include "pipeline_loadb.h"
35 #include "pipeline_timer.h"
36 #include "pipeline_txrx.h"
37 #include "pipeline_arpicmp.h"
38 #include "interface.h"
39 #include "l3fwd_common.h"
40 #include "l3fwd_lpm4.h"
41 #include "l3fwd_lpm6.h"
44 #define APP_NAME_SIZE 32
45 port_config_t *port_config;
48 app_init_core_map(struct app_params *app)
50 APP_LOG(app, HIGH, "Initializing CPU core map ...");
51 app->core_map = cpu_core_map_init(4, 32, 4, 0);
53 if (app->core_map == NULL)
54 rte_panic("Cannot create CPU core map\n");
56 if (app->log_level >= APP_LOG_LEVEL_LOW)
57 cpu_core_map_print(app->core_map);
60 /* Core Mask String in Hex Representation */
61 #define APP_CORE_MASK_STRING_SIZE ((64 * APP_CORE_MASK_SIZE) / 8 * 2 + 1)
64 app_init_core_mask(struct app_params *app)
66 char core_mask_str[APP_CORE_MASK_STRING_SIZE];
69 for (i = 0; i < app->n_pipelines; i++) {
70 struct app_pipeline_params *p = &app->pipeline_params[i];
73 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
79 rte_panic("Cannot create CPU core mask\n");
81 app_core_enable_in_core_mask(app, lcore_id);
84 app_core_build_core_mask_string(app, core_mask_str);
85 APP_LOG(app, HIGH, "CPU core mask = 0x%s", core_mask_str);
90 app_init_eal(struct app_params *app)
93 char core_mask_str[APP_CORE_MASK_STRING_SIZE];
94 struct app_eal_params *p = &app->eal_params;
99 app->eal_argv[n_args++] = strdup(app->app_name);
101 app_core_build_core_mask_string(app, core_mask_str);
102 snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str);
103 app->eal_argv[n_args++] = strdup(buffer);
106 snprintf(buffer, sizeof(buffer), "--lcores=%s", p->coremap);
107 app->eal_argv[n_args++] = strdup(buffer);
110 if (p->master_lcore_present) {
113 "--master-lcore=%" PRIu32,
115 app->eal_argv[n_args++] = strdup(buffer);
118 snprintf(buffer, sizeof(buffer), "-n%" PRIu32, p->channels);
119 app->eal_argv[n_args++] = strdup(buffer);
121 if (p->memory_present) {
122 snprintf(buffer, sizeof(buffer), "-m%" PRIu32, p->memory);
123 app->eal_argv[n_args++] = strdup(buffer);
126 if (p->ranks_present) {
127 snprintf(buffer, sizeof(buffer), "-r%" PRIu32, p->ranks);
128 app->eal_argv[n_args++] = strdup(buffer);
131 for (i = 0; i < APP_MAX_LINKS; i++) {
132 if (p->pci_blacklist[i] == NULL)
137 "--pci-blacklist=%s",
138 p->pci_blacklist[i]);
139 app->eal_argv[n_args++] = strdup(buffer);
142 if (app->port_mask != 0)
143 for (i = 0; i < APP_MAX_LINKS; i++) {
144 if (p->pci_whitelist[i] == NULL)
149 "--pci-whitelist=%s",
150 p->pci_whitelist[i]);
152 app->eal_argv[n_args++] = strdup(buffer);
155 for (i = 0; i < app->n_links; i++) {
156 char *pci_bdf = app->link_params[i].pci_bdf;
160 "--pci-whitelist=%s",
162 app->eal_argv[n_args++] = strdup(buffer);
165 for (i = 0; i < APP_MAX_LINKS; i++) {
166 if (p->vdev[i] == NULL)
173 app->eal_argv[n_args++] = strdup(buffer);
176 if ((p->vmware_tsc_map_present) && p->vmware_tsc_map) {
177 snprintf(buffer, sizeof(buffer), "--vmware-tsc-map");
178 app->eal_argv[n_args++] = strdup(buffer);
186 app->eal_argv[n_args++] = strdup(buffer);
190 snprintf(buffer, sizeof(buffer), "--syslog=%s", p->syslog);
191 app->eal_argv[n_args++] = strdup(buffer);
194 if (p->log_level_present) {
197 "--log-level=%" PRIu32,
199 app->eal_argv[n_args++] = strdup(buffer);
202 if ((p->version_present) && p->version) {
203 snprintf(buffer, sizeof(buffer), "-v");
204 app->eal_argv[n_args++] = strdup(buffer);
207 if ((p->help_present) && p->help) {
208 snprintf(buffer, sizeof(buffer), "--help");
209 app->eal_argv[n_args++] = strdup(buffer);
212 if ((p->no_huge_present) && p->no_huge) {
213 snprintf(buffer, sizeof(buffer), "--no-huge");
214 app->eal_argv[n_args++] = strdup(buffer);
217 if ((p->no_pci_present) && p->no_pci) {
218 snprintf(buffer, sizeof(buffer), "--no-pci");
219 app->eal_argv[n_args++] = strdup(buffer);
222 if ((p->no_hpet_present) && p->no_hpet) {
223 snprintf(buffer, sizeof(buffer), "--no-hpet");
224 app->eal_argv[n_args++] = strdup(buffer);
227 if ((p->no_shconf_present) && p->no_shconf) {
228 snprintf(buffer, sizeof(buffer), "--no-shconf");
229 app->eal_argv[n_args++] = strdup(buffer);
233 snprintf(buffer, sizeof(buffer), "-d=%s", p->add_driver);
234 app->eal_argv[n_args++] = strdup(buffer);
242 app->eal_argv[n_args++] = strdup(buffer);
246 snprintf(buffer, sizeof(buffer), "--huge-dir=%s", p->huge_dir);
247 app->eal_argv[n_args++] = strdup(buffer);
250 if (p->file_prefix) {
255 app->eal_argv[n_args++] = strdup(buffer);
258 if (p->base_virtaddr) {
261 "--base-virtaddr=%s",
263 app->eal_argv[n_args++] = strdup(buffer);
266 if ((p->create_uio_dev_present) && p->create_uio_dev) {
267 snprintf(buffer, sizeof(buffer), "--create-uio-dev");
268 app->eal_argv[n_args++] = strdup(buffer);
276 app->eal_argv[n_args++] = strdup(buffer);
279 if ((p->xen_dom0_present) && (p->xen_dom0)) {
280 snprintf(buffer, sizeof(buffer), "--xen-dom0");
281 app->eal_argv[n_args++] = strdup(buffer);
284 snprintf(buffer, sizeof(buffer), "--");
285 app->eal_argv[n_args++] = strdup(buffer);
287 app->eal_argc = n_args;
289 APP_LOG(app, HIGH, "Initializing EAL ...");
290 if (app->log_level >= APP_LOG_LEVEL_LOW) {
293 fprintf(stdout, "[APP] EAL arguments: \"");
294 for (i = 1; i < app->eal_argc; i++)
295 fprintf(stdout, "%s ", app->eal_argv[i]);
296 fprintf(stdout, "\"\n");
299 status = rte_eal_init(app->eal_argc, app->eal_argv);
301 rte_panic("EAL init error\n");
305 app_init_mempool(struct app_params *app)
309 for (i = 0; i < app->n_mempools; i++) {
310 struct app_mempool_params *p = &app->mempool_params[i];
312 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
313 app->mempool[i] = rte_mempool_create(
318 sizeof(struct rte_pktmbuf_pool_private),
319 rte_pktmbuf_pool_init, NULL,
320 rte_pktmbuf_init, NULL,
324 if (app->mempool[i] == NULL)
325 rte_panic("%s init error\n", p->name);
330 app_link_filter_arp_add(struct app_link_params *link)
332 struct rte_eth_ethertype_filter filter = {
333 .ether_type = ETHER_TYPE_ARP,
335 .queue = link->arp_q,
338 return rte_eth_dev_filter_ctrl(link->pmd_id,
339 RTE_ETH_FILTER_ETHERTYPE,
345 app_link_filter_tcp_syn_add(struct app_link_params *link)
347 struct rte_eth_syn_filter filter = {
349 .queue = link->tcp_syn_q,
352 return rte_eth_dev_filter_ctrl(link->pmd_id,
359 app_link_filter_ip_add(struct app_link_params *l1, struct app_link_params *l2)
361 struct rte_eth_ntuple_filter filter = {
362 .flags = RTE_5TUPLE_FLAGS,
363 .dst_ip = rte_bswap32(l2->ip),
364 .dst_ip_mask = UINT32_MAX, /* Enable */
366 .src_ip_mask = 0, /* Disable */
368 .dst_port_mask = 0, /* Disable */
370 .src_port_mask = 0, /* Disable */
372 .proto_mask = 0, /* Disable */
374 .priority = 1, /* Lowest */
375 .queue = l1->ip_local_q,
378 return rte_eth_dev_filter_ctrl(l1->pmd_id,
379 RTE_ETH_FILTER_NTUPLE,
385 app_link_filter_ip_del(struct app_link_params *l1, struct app_link_params *l2)
387 struct rte_eth_ntuple_filter filter = {
388 .flags = RTE_5TUPLE_FLAGS,
389 .dst_ip = rte_bswap32(l2->ip),
390 .dst_ip_mask = UINT32_MAX, /* Enable */
392 .src_ip_mask = 0, /* Disable */
394 .dst_port_mask = 0, /* Disable */
396 .src_port_mask = 0, /* Disable */
398 .proto_mask = 0, /* Disable */
400 .priority = 1, /* Lowest */
401 .queue = l1->ip_local_q,
404 return rte_eth_dev_filter_ctrl(l1->pmd_id,
405 RTE_ETH_FILTER_NTUPLE,
406 RTE_ETH_FILTER_DELETE,
411 app_link_filter_tcp_add(struct app_link_params *l1, struct app_link_params *l2)
413 struct rte_eth_ntuple_filter filter = {
414 .flags = RTE_5TUPLE_FLAGS,
415 .dst_ip = rte_bswap32(l2->ip),
416 .dst_ip_mask = UINT32_MAX, /* Enable */
418 .src_ip_mask = 0, /* Disable */
420 .dst_port_mask = 0, /* Disable */
422 .src_port_mask = 0, /* Disable */
423 .proto = IPPROTO_TCP,
424 .proto_mask = UINT8_MAX, /* Enable */
426 .priority = 2, /* Higher priority than IP */
427 .queue = l1->tcp_local_q,
430 return rte_eth_dev_filter_ctrl(l1->pmd_id,
431 RTE_ETH_FILTER_NTUPLE,
437 app_link_filter_tcp_del(struct app_link_params *l1, struct app_link_params *l2)
439 struct rte_eth_ntuple_filter filter = {
440 .flags = RTE_5TUPLE_FLAGS,
441 .dst_ip = rte_bswap32(l2->ip),
442 .dst_ip_mask = UINT32_MAX, /* Enable */
444 .src_ip_mask = 0, /* Disable */
446 .dst_port_mask = 0, /* Disable */
448 .src_port_mask = 0, /* Disable */
449 .proto = IPPROTO_TCP,
450 .proto_mask = UINT8_MAX, /* Enable */
452 .priority = 2, /* Higher priority than IP */
453 .queue = l1->tcp_local_q,
456 return rte_eth_dev_filter_ctrl(l1->pmd_id,
457 RTE_ETH_FILTER_NTUPLE,
458 RTE_ETH_FILTER_DELETE,
463 app_link_filter_udp_add(struct app_link_params *l1, struct app_link_params *l2)
465 struct rte_eth_ntuple_filter filter = {
466 .flags = RTE_5TUPLE_FLAGS,
467 .dst_ip = rte_bswap32(l2->ip),
468 .dst_ip_mask = UINT32_MAX, /* Enable */
470 .src_ip_mask = 0, /* Disable */
472 .dst_port_mask = 0, /* Disable */
474 .src_port_mask = 0, /* Disable */
475 .proto = IPPROTO_UDP,
476 .proto_mask = UINT8_MAX, /* Enable */
478 .priority = 2, /* Higher priority than IP */
479 .queue = l1->udp_local_q,
482 return rte_eth_dev_filter_ctrl(l1->pmd_id,
483 RTE_ETH_FILTER_NTUPLE,
489 app_link_filter_udp_del(struct app_link_params *l1, struct app_link_params *l2)
491 struct rte_eth_ntuple_filter filter = {
492 .flags = RTE_5TUPLE_FLAGS,
493 .dst_ip = rte_bswap32(l2->ip),
494 .dst_ip_mask = UINT32_MAX, /* Enable */
496 .src_ip_mask = 0, /* Disable */
498 .dst_port_mask = 0, /* Disable */
500 .src_port_mask = 0, /* Disable */
501 .proto = IPPROTO_UDP,
502 .proto_mask = UINT8_MAX, /* Enable */
504 .priority = 2, /* Higher priority than IP */
505 .queue = l1->udp_local_q,
508 return rte_eth_dev_filter_ctrl(l1->pmd_id,
509 RTE_ETH_FILTER_NTUPLE,
510 RTE_ETH_FILTER_DELETE,
515 app_link_filter_sctp_add(struct app_link_params *l1, struct app_link_params *l2)
517 struct rte_eth_ntuple_filter filter = {
518 .flags = RTE_5TUPLE_FLAGS,
519 .dst_ip = rte_bswap32(l2->ip),
520 .dst_ip_mask = UINT32_MAX, /* Enable */
522 .src_ip_mask = 0, /* Disable */
524 .dst_port_mask = 0, /* Disable */
526 .src_port_mask = 0, /* Disable */
527 .proto = IPPROTO_SCTP,
528 .proto_mask = UINT8_MAX, /* Enable */
530 .priority = 2, /* Higher priority than IP */
531 .queue = l1->sctp_local_q,
534 return rte_eth_dev_filter_ctrl(l1->pmd_id,
535 RTE_ETH_FILTER_NTUPLE,
541 app_link_filter_sctp_del(struct app_link_params *l1, struct app_link_params *l2)
543 struct rte_eth_ntuple_filter filter = {
544 .flags = RTE_5TUPLE_FLAGS,
545 .dst_ip = rte_bswap32(l2->ip),
546 .dst_ip_mask = UINT32_MAX, /* Enable */
548 .src_ip_mask = 0, /* Disable */
550 .dst_port_mask = 0, /* Disable */
552 .src_port_mask = 0, /* Disable */
553 .proto = IPPROTO_SCTP,
554 .proto_mask = UINT8_MAX, /* Enable */
556 .priority = 2, /* Higher priority than IP */
557 .queue = l1->sctp_local_q,
560 return rte_eth_dev_filter_ctrl(l1->pmd_id,
561 RTE_ETH_FILTER_NTUPLE,
562 RTE_ETH_FILTER_DELETE,
567 app_link_set_arp_filter(struct app_params *app, struct app_link_params *cp)
569 if (cp->arp_q != 0) {
570 int status = app_link_filter_arp_add(cp);
572 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
573 "Adding ARP filter (queue = %" PRIu32 ")",
574 cp->name, cp->pmd_id, cp->arp_q);
577 rte_panic("%s (%" PRIu32 "): "
578 "Error adding ARP filter "
579 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
580 cp->name, cp->pmd_id, cp->arp_q, status);
585 app_link_set_tcp_syn_filter(struct app_params *app, struct app_link_params *cp)
587 if (cp->tcp_syn_q != 0) {
588 int status = app_link_filter_tcp_syn_add(cp);
590 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
591 "Adding TCP SYN filter (queue = %" PRIu32 ")",
592 cp->name, cp->pmd_id, cp->tcp_syn_q);
595 rte_panic("%s (%" PRIu32 "): "
596 "Error adding TCP SYN filter "
597 "(queue = %" PRIu32 ") (%" PRId32 ")\n",
598 cp->name, cp->pmd_id, cp->tcp_syn_q,
604 app_link_is_virtual(__rte_unused struct app_link_params *p)
606 uint32_t pmd_id = p->pmd_id;
607 struct rte_eth_dev *dev = &rte_eth_devices[pmd_id];
608 if (dev->dev_type == RTE_ETH_DEV_VIRTUAL)
615 app_link_up_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
620 struct rte_eth_link link;
622 if (app_link_is_virtual(cp)) {
628 /* For each link, add filters for IP of current link */
630 for (i = 0; i < app->n_links; i++) {
631 struct app_link_params *p = &app->link_params[i];
634 if (p->ip_local_q != 0) {
635 int status = app_link_filter_ip_add(p, cp);
637 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
638 "Adding IP filter (queue= %" PRIu32
639 ", IP = 0x%08" PRIx32 ")",
640 p->name, p->pmd_id, p->ip_local_q,
644 rte_panic("%s (%" PRIu32 "): "
646 "filter (queue= %" PRIu32 ", "
650 p->ip_local_q, cp->ip, status);
654 if (p->tcp_local_q != 0) {
655 int status = app_link_filter_tcp_add(p, cp);
657 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
660 ", IP = 0x%08" PRIx32 ")",
661 p->name, p->pmd_id, p->tcp_local_q,
665 rte_panic("%s (%" PRIu32 "): "
667 "filter (queue = %" PRIu32 ", "
671 p->tcp_local_q, cp->ip, status);
675 if (p->udp_local_q != 0) {
676 int status = app_link_filter_udp_add(p, cp);
678 APP_LOG(app, LOW, "%s (%" PRIu32 "): "
681 ", IP = 0x%08" PRIx32 ")",
682 p->name, p->pmd_id, p->udp_local_q,
686 rte_panic("%s (%" PRIu32 "): "
688 "filter (queue = %" PRIu32 ", "
692 p->udp_local_q, cp->ip, status);
696 if (p->sctp_local_q != 0) {
697 int status = app_link_filter_sctp_add(p, cp);
699 APP_LOG(app, LOW, "%s (%" PRIu32
700 "): Adding SCTP filter "
702 ", IP = 0x%08" PRIx32 ")",
703 p->name, p->pmd_id, p->sctp_local_q,
707 rte_panic("%s (%" PRIu32 "): "
709 "filter (queue = %" PRIu32 ", "
713 p->sctp_local_q, cp->ip,
719 rte_eth_link_get(cp->pmd_id, &link);
720 if (!link.link_status) {
722 status = rte_eth_dev_set_link_up(cp->pmd_id);
724 rte_panic("%s (%" PRIu32 "): PMD set link up error %"
725 PRId32 "\n", cp->name, cp->pmd_id, status);
728 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_UP);
730 /* Mark link as UP */
735 app_link_down_internal(__rte_unused struct app_params *app, struct app_link_params *cp)
740 struct rte_eth_link link;
742 if (app_link_is_virtual(cp)) {
746 rte_eth_link_get(cp->pmd_id, &link);
747 if (link.link_status) {
749 status = rte_eth_dev_set_link_down(cp->pmd_id);
751 rte_panic("%s (%" PRIu32 "): PMD set link down error %"
752 PRId32 "\n", cp->name, cp->pmd_id, status);
755 ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_DOWN);
756 /* Mark link as DOWN */
759 /* Return if current link IP is not valid */
763 /* For each link, remove filters for IP of current link */
764 for (i = 0; i < app->n_links; i++) {
765 struct app_link_params *p = &app->link_params[i];
768 if (p->ip_local_q != 0) {
769 int status = app_link_filter_ip_del(p, cp);
771 APP_LOG(app, LOW, "%s (%" PRIu32
772 "): Deleting IP filter "
773 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
774 p->name, p->pmd_id, p->ip_local_q, cp->ip);
777 rte_panic("%s (%" PRIu32
778 "): Error deleting IP filter "
782 p->name, p->pmd_id, p->ip_local_q,
787 if (p->tcp_local_q != 0) {
788 int status = app_link_filter_tcp_del(p, cp);
790 APP_LOG(app, LOW, "%s (%" PRIu32
791 "): Deleting TCP filter "
793 ", IP = 0x%" PRIx32 ")",
794 p->name, p->pmd_id, p->tcp_local_q, cp->ip);
797 rte_panic("%s (%" PRIu32
798 "): Error deleting TCP filter "
802 p->name, p->pmd_id, p->tcp_local_q,
807 if (p->udp_local_q != 0) {
808 int status = app_link_filter_udp_del(p, cp);
810 APP_LOG(app, LOW, "%s (%" PRIu32
811 "): Deleting UDP filter "
812 "(queue = %" PRIu32 ", IP = 0x%" PRIx32 ")",
813 p->name, p->pmd_id, p->udp_local_q, cp->ip);
816 rte_panic("%s (%" PRIu32
817 "): Error deleting UDP filter "
821 p->name, p->pmd_id, p->udp_local_q,
826 if (p->sctp_local_q != 0) {
827 int status = app_link_filter_sctp_del(p, cp);
829 APP_LOG(app, LOW, "%s (%" PRIu32
830 "): Deleting SCTP filter "
832 ", IP = 0x%" PRIx32 ")",
833 p->name, p->pmd_id, p->sctp_local_q, cp->ip);
836 rte_panic("%s (%" PRIu32
837 "): Error deleting SCTP filter "
841 p->name, p->pmd_id, p->sctp_local_q,
849 app_check_link(struct app_params *app)
851 uint32_t all_links_up, i;
855 for (i = 0; i < app->n_links; i++) {
856 struct app_link_params *p = &app->link_params[i];
857 struct rte_eth_link link_params;
859 memset(&link_params, 0, sizeof(link_params));
860 rte_eth_link_get(p->pmd_id, &link_params);
862 APP_LOG(app, HIGH, "%s (%" PRIu32 ") (%" PRIu32 " Gbps) %s",
865 link_params.link_speed / 1000,
866 link_params.link_status ? "UP" : "DOWN");
868 if (link_params.link_status == ETH_LINK_DOWN)
872 if (all_links_up == 0)
873 rte_panic("Some links are DOWN\n");
877 is_any_swq_frag_or_ras(struct app_params *app)
881 for (i = 0; i < app->n_pktq_swq; i++) {
882 struct app_pktq_swq_params *p = &app->swq_params[i];
884 if ((p->ipv4_frag == 1) || (p->ipv6_frag == 1) ||
885 (p->ipv4_ras == 1) || (p->ipv6_ras == 1))
893 app_init_link_frag_ras(struct app_params *app)
897 if (is_any_swq_frag_or_ras(app)) {
898 for (i = 0; i < app->n_pktq_hwq_out; i++) {
899 struct app_pktq_hwq_out_params *p_txq =
900 &app->hwq_out_params[i];
902 p_txq->conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
908 app_get_cpu_socket_id(uint32_t pmd_id)
910 int status = rte_eth_dev_socket_id(pmd_id);
912 return (status != SOCKET_ID_ANY) ? status : 0;
915 struct rte_eth_rxmode rx_mode = {
916 .max_rx_pkt_len = ETHER_MAX_LEN, /**< Default maximum frame length. */
918 .header_split = 0, /**< Header Split disabled. */
919 .hw_ip_checksum = 0, /**< IP checksum offload disabled. */
920 .hw_vlan_filter = 1, /**< VLAN filtering enabled. */
921 .hw_vlan_strip = 1, /**< VLAN strip enabled. */
922 .hw_vlan_extend = 0, /**< Extended VLAN disabled. */
923 .jumbo_frame = 0, /**< Jumbo Frame Support disabled. */
924 .hw_strip_crc = 0, /**< CRC stripping by hardware disabled. */
926 struct rte_fdir_conf fdir_conf = {
927 .mode = RTE_FDIR_MODE_NONE,
928 .pballoc = RTE_FDIR_PBALLOC_64K,
929 .status = RTE_FDIR_REPORT_STATUS,
931 .vlan_tci_mask = 0x0,
933 .src_ip = 0xFFFFFFFF,
934 .dst_ip = 0xFFFFFFFF,
937 .src_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
938 .dst_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
940 .src_port_mask = 0xFFFF,
941 .dst_port_mask = 0xFFFF,
942 .mac_addr_byte_mask = 0xFF,
943 .tunnel_type_mask = 1,
944 .tunnel_id_mask = 0xFFFFFFFF,
950 app_init_link(struct app_params *app)
954 app_init_link_frag_ras(app);
957 *Configuring port_config_t structure for interface manager initialization
959 size = RTE_CACHE_LINE_ROUNDUP(sizeof(port_config_t));
960 port_config = rte_zmalloc(NULL, (app->n_links * size), RTE_CACHE_LINE_SIZE);
961 if (port_config == NULL)
962 rte_panic("port_config is NULL: Memory Allocation failure\n");
964 for (i = 0; i < app->n_links; i++) {
965 struct app_link_params *p_link = &app->link_params[i];
966 uint32_t link_id, n_hwq_in, n_hwq_out;
969 status = sscanf(p_link->name, "LINK%" PRIu32, &link_id);
971 rte_panic("%s (%" PRId32 "): "
972 "init error (%" PRId32 ")\n",
973 p_link->name, link_id, status);
975 n_hwq_in = app_link_get_n_rxq(app, p_link);
976 n_hwq_out = app_link_get_n_txq(app, p_link);
978 printf("\n\nn_hwq_in %d\n", n_hwq_in);
979 struct rte_eth_conf *My_local_conf = &p_link->conf;
982 My_local_conf->rxmode = rx_mode;
983 My_local_conf->fdir_conf = fdir_conf;
984 My_local_conf->rxmode.mq_mode = ETH_MQ_RX_RSS;
985 My_local_conf->rx_adv_conf.rss_conf.rss_key = NULL;
986 My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP;
987 //My_local_conf->rx_adv_conf.rss_conf.rss_hf |= ETH_RSS_UDP;
988 //My_local_conf->rx_adv_conf.rss_conf.rss_hf |= ETH_RSS_IP;
989 // My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_TCP;
991 //#else /*for FDIR Filter*/
994 My_local_conf->rx_adv_conf.rss_conf.rss_hf = 0;
995 /* pkt-filter-mode is perfect */
996 My_local_conf->fdir_conf.mode = RTE_FDIR_MODE_PERFECT;
999 /* Set the hardware CRC stripping to avoid double stripping of FCS in VM */
1000 p_link->conf.rxmode.hw_strip_crc=1;
1002 APP_LOG(app, HIGH, "Initializing %s (%" PRIu32") "
1003 "(%" PRIu32 " RXQ, %" PRIu32 " TXQ) ...",
1009 port_config[i].port_id = p_link->pmd_id;
1010 port_config[i].nrx_queue = n_hwq_in;
1011 port_config[i].ntx_queue = n_hwq_out;
1012 port_config[i].state = 1;
1013 port_config[i].promisc = p_link->promisc;
1014 port_config[i].mempool.pool_size = app->mempool_params[0].pool_size;
1015 port_config[i].mempool.buffer_size = app->mempool_params[0].buffer_size;
1016 port_config[i].mempool.cache_size = app->mempool_params[0].cache_size;
1017 port_config[i].mempool.cpu_socket_id = app->mempool_params[0].cpu_socket_id;
1018 memcpy (&port_config[i].port_conf, &p_link->conf, sizeof(struct rte_eth_conf));
1019 memcpy (&port_config[i].rx_conf, &app->hwq_in_params[0].conf, sizeof(struct rte_eth_rxconf));
1020 memcpy (&port_config[i].tx_conf, &app->hwq_out_params[0].conf, sizeof(struct rte_eth_txconf));
1022 if(app->header_csum_req) {
1023 /* Enable TCP and UDP HW Checksum */
1024 port_config[i].tx_conf.txq_flags &=
1025 ~(ETH_TXQ_FLAGS_NOXSUMTCP|ETH_TXQ_FLAGS_NOXSUMUDP);
1028 if (ifm_port_setup (p_link->pmd_id, &port_config[i]))
1029 rte_panic ("Port Setup Failed: %s - %"PRIu32"\n", p_link->name, p_link->pmd_id);
1033 status = rte_eth_dev_configure(
1039 rte_panic("%s (%" PRId32 "): "
1040 "init error (%" PRId32 ")\n",
1041 p_link->name, p_link->pmd_id, status);
1043 rte_eth_macaddr_get(p_link->pmd_id,
1044 (struct ether_addr *) &p_link->mac_addr);
1046 if (p_link->promisc)
1047 rte_eth_promiscuous_enable(p_link->pmd_id);
1050 for (j = 0; j < app->n_pktq_hwq_in; j++) {
1051 struct app_pktq_hwq_in_params *p_rxq =
1052 &app->hwq_in_params[j];
1053 uint32_t rxq_link_id, rxq_queue_id;
1056 sscanf(p_rxq->name, "RXQ%" PRIu32 ".%" PRIu32,
1057 &rxq_link_id, &rxq_queue_id);
1059 rte_panic("%s (%" PRId32 "): "
1060 "init error (%" PRId32 ")\n",
1061 p_rxq->name, rxq_queue_id, status);
1063 if (rxq_link_id != link_id)
1066 status = rte_eth_rx_queue_setup(
1070 app_get_cpu_socket_id(p_link->pmd_id),
1072 app->mempool[p_rxq->mempool_id]);
1074 rte_panic("%s (%" PRIu32 "): "
1075 "%s init error (%" PRId32 ")\n",
1083 for (j = 0; j < app->n_pktq_hwq_out; j++) {
1084 struct app_pktq_hwq_out_params *p_txq =
1085 &app->hwq_out_params[j];
1086 uint32_t txq_link_id, txq_queue_id;
1089 sscanf(p_txq->name, "TXQ%" PRIu32 ".%" PRIu32,
1090 &txq_link_id, &txq_queue_id);
1093 rte_panic("%s (%" PRId32 "): "
1094 "init error (%" PRId32 ")\n",
1095 p_txq->name, txq_link_id, status);
1097 if (txq_link_id != link_id)
1100 if (app->header_csum_req) {
1101 /* Enable TCP and UDP HW Checksum */
1102 p_txq->conf.txq_flags &=
1103 ~(ETH_TXQ_FLAGS_NOXSUMTCP|
1104 ETH_TXQ_FLAGS_NOXSUMUDP);
1107 status = rte_eth_tx_queue_setup(
1111 app_get_cpu_socket_id(p_link->pmd_id),
1115 rte_panic("%s (%" PRIu32 "): "
1116 "%s init error (%" PRId32 ")\n",
1124 status = rte_eth_dev_start(p_link->pmd_id);
1126 rte_panic("Cannot start %s (error %" PRId32 ")\n",
1127 p_link->name, status);
1130 app_link_set_arp_filter(app, p_link);
1131 app_link_set_tcp_syn_filter(app, p_link);
1133 app_link_up_internal(app, p_link);
1136 app_check_link(app);
1140 app_init_swq(struct app_params *app)
1144 for (i = 0; i < app->n_pktq_swq; i++) {
1145 struct app_pktq_swq_params *p = &app->swq_params[i];
1146 unsigned int flags = 0;
1148 if (app_swq_get_readers(app, p) == 1)
1149 flags |= RING_F_SC_DEQ;
1150 if (app_swq_get_writers(app, p) == 1)
1151 flags |= RING_F_SP_ENQ;
1153 APP_LOG(app, HIGH, "Initializing %s...", p->name);
1154 app->swq[i] = rte_ring_create(
1160 if (app->swq[i] == NULL)
1161 rte_panic("%s init error\n", p->name);
1166 app_init_tm(struct app_params *app)
1170 for (i = 0; i < app->n_pktq_tm; i++) {
1171 struct app_pktq_tm_params *p_tm = &app->tm_params[i];
1172 struct app_link_params *p_link;
1173 struct rte_eth_link link_eth_params;
1174 struct rte_sched_port *sched;
1175 uint32_t n_subports, subport_id;
1178 p_link = app_get_link_for_tm(app, p_tm);
1180 rte_eth_link_get(p_link->pmd_id, &link_eth_params);
1183 p_tm->sched_port_params.name = p_tm->name;
1184 p_tm->sched_port_params.socket =
1185 app_get_cpu_socket_id(p_link->pmd_id);
1186 p_tm->sched_port_params.rate =
1187 (uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;
1189 APP_LOG(app, HIGH, "Initializing %s ...", p_tm->name);
1190 sched = rte_sched_port_config(&p_tm->sched_port_params);
1192 rte_panic("%s init error\n", p_tm->name);
1196 n_subports = p_tm->sched_port_params.n_subports_per_port;
1197 for (subport_id = 0; subport_id < n_subports; subport_id++) {
1198 uint32_t n_pipes_per_subport, pipe_id;
1200 status = rte_sched_subport_config(sched,
1202 &p_tm->sched_subport_params[subport_id]);
1204 rte_panic("%s subport %" PRIu32
1205 " init error (%" PRId32 ")\n",
1206 p_tm->name, subport_id, status);
1209 n_pipes_per_subport =
1210 p_tm->sched_port_params.n_pipes_per_subport;
1212 pipe_id < n_pipes_per_subport;
1214 int profile_id = p_tm->sched_pipe_to_profile[
1215 subport_id * APP_MAX_SCHED_PIPES +
1218 if (profile_id == -1)
1221 status = rte_sched_pipe_config(sched,
1226 rte_panic("%s subport %" PRIu32
1228 " (profile %" PRId32 ") "
1229 "init error (% " PRId32 ")\n",
1230 p_tm->name, subport_id, pipe_id,
1231 profile_id, status);
1238 app_init_msgq(struct app_params *app)
1242 for (i = 0; i < app->n_msgq; i++) {
1243 struct app_msgq_params *p = &app->msgq_params[i];
1245 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
1246 app->msgq[i] = rte_ring_create(
1250 RING_F_SP_ENQ | RING_F_SC_DEQ);
1252 if (app->msgq[i] == NULL)
1253 rte_panic("%s init error\n", p->name);
1257 static void app_pipeline_params_get(struct app_params *app,
1258 struct app_pipeline_params *p_in,
1259 struct pipeline_params *p_out)
1262 uint32_t mempool_id;
1264 snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
1266 p_out->socket_id = (int) p_in->socket_id;
1268 p_out->log_level = app->log_level;
1271 p_out->n_ports_in = p_in->n_pktq_in;
1272 for (i = 0; i < p_in->n_pktq_in; i++) {
1273 struct app_pktq_in_params *in = &p_in->pktq_in[i];
1274 struct pipeline_port_in_params *out = &p_out->port_in[i];
1277 case APP_PKTQ_IN_HWQ:
1279 struct app_pktq_hwq_in_params *p_hwq_in =
1280 &app->hwq_in_params[in->id];
1281 struct app_link_params *p_link =
1282 app_get_link_for_rxq(app, p_hwq_in);
1283 uint32_t rxq_link_id, rxq_queue_id;
1286 sscanf(p_hwq_in->name, "RXQ%" SCNu32 ".%" SCNu32,
1290 rte_panic("%s (%" PRId32 "): "
1291 "init error (%" PRId32 ")\n",
1292 p_hwq_in->name, rxq_link_id, status);
1294 out->type = PIPELINE_PORT_IN_ETHDEV_READER;
1295 out->params.ethdev.port_id = p_link->pmd_id;
1296 out->params.ethdev.queue_id = rxq_queue_id;
1297 out->burst_size = p_hwq_in->burst;
1300 case APP_PKTQ_IN_SWQ:
1302 struct app_pktq_swq_params *swq_params =
1303 &app->swq_params[in->id];
1305 if ((swq_params->ipv4_frag == 0) &&
1306 (swq_params->ipv6_frag == 0)) {
1307 if (app_swq_get_readers(app,
1310 PIPELINE_PORT_IN_RING_READER;
1311 out->params.ring.ring =
1314 app->swq_params[in->id].
1317 out->type = PIPELINE_PORT_IN_RING_MULTI_READER;
1318 out->params.ring_multi.ring = app->swq[in->id];
1319 out->burst_size = swq_params->burst_read;
1322 if (swq_params->ipv4_frag == 1) {
1323 struct rte_port_ring_reader_ipv4_frag_params
1325 &out->params.ring_ipv4_frag;
1328 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG;
1329 params->ring = app->swq[in->id];
1330 params->mtu = swq_params->mtu;
1331 params->metadata_size =
1332 swq_params->metadata_size;
1333 params->pool_direct =
1335 [swq_params->mempool_direct_id];
1336 params->pool_indirect =
1338 [swq_params->mempool_indirect_id];
1339 out->burst_size = swq_params->burst_read;
1341 struct rte_port_ring_reader_ipv6_frag_params
1343 &out->params.ring_ipv6_frag;
1346 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG;
1347 params->ring = app->swq[in->id];
1348 params->mtu = swq_params->mtu;
1349 params->metadata_size =
1350 swq_params->metadata_size;
1351 params->pool_direct =
1353 [swq_params->mempool_direct_id];
1354 params->pool_indirect =
1356 [swq_params->mempool_indirect_id];
1357 out->burst_size = swq_params->burst_read;
1362 case APP_PKTQ_IN_TM:
1363 out->type = PIPELINE_PORT_IN_SCHED_READER;
1364 out->params.sched.sched = app->tm[in->id];
1365 out->burst_size = app->tm_params[in->id].burst_read;
1367 case APP_PKTQ_IN_SOURCE:
1368 mempool_id = app->source_params[in->id].mempool_id;
1369 out->type = PIPELINE_PORT_IN_SOURCE;
1370 out->params.source.mempool = app->mempool[mempool_id];
1371 out->burst_size = app->source_params[in->id].burst;
1374 if (app->source_params[in->id].file_name
1376 out->params.source.file_name = strdup(
1377 app->source_params[in->id].
1379 if (out->params.source.file_name == NULL) {
1381 n_bytes_per_pkt = 0;
1384 out->params.source.n_bytes_per_pkt =
1385 app->source_params[in->id].
1397 p_out->n_ports_out = p_in->n_pktq_out;
1398 for (i = 0; i < p_in->n_pktq_out; i++) {
1399 struct app_pktq_out_params *in = &p_in->pktq_out[i];
1400 struct pipeline_port_out_params *out = &p_out->port_out[i];
1403 case APP_PKTQ_OUT_HWQ:
1405 struct app_pktq_hwq_out_params *p_hwq_out =
1406 &app->hwq_out_params[in->id];
1407 struct app_link_params *p_link =
1408 app_get_link_for_txq(app, p_hwq_out);
1409 uint32_t txq_link_id, txq_queue_id;
1412 sscanf(p_hwq_out->name,
1413 "TXQ%" SCNu32 ".%" SCNu32,
1417 rte_panic("%s (%" PRId32 "): "
1418 "init error (%" PRId32 ")\n",
1419 p_hwq_out->name, txq_link_id, status);
1421 if (p_hwq_out->dropless == 0) {
1422 struct rte_port_ethdev_writer_params *params =
1423 &out->params.ethdev;
1425 out->type = PIPELINE_PORT_OUT_ETHDEV_WRITER;
1426 params->port_id = p_link->pmd_id;
1427 params->queue_id = txq_queue_id;
1428 params->tx_burst_sz =
1429 app->hwq_out_params[in->id].burst;
1431 struct rte_port_ethdev_writer_nodrop_params
1432 *params = &out->params.ethdev_nodrop;
1435 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP;
1436 params->port_id = p_link->pmd_id;
1437 params->queue_id = txq_queue_id;
1438 params->tx_burst_sz = p_hwq_out->burst;
1439 params->n_retries = p_hwq_out->n_retries;
1443 case APP_PKTQ_OUT_SWQ:
1445 struct app_pktq_swq_params *swq_params =
1446 &app->swq_params[in->id];
1448 if ((swq_params->ipv4_ras == 0) &&
1449 (swq_params->ipv6_ras == 0)) {
1450 if (app_swq_get_writers(app, swq_params) == 1) {
1451 if (app->swq_params[in->id].dropless == 0) {
1452 struct rte_port_ring_writer_params *params =
1455 out->type = PIPELINE_PORT_OUT_RING_WRITER;
1456 params->ring = app->swq[in->id];
1457 params->tx_burst_sz =
1458 app->swq_params[in->id].burst_write;
1460 struct rte_port_ring_writer_nodrop_params
1461 *params = &out->params.ring_nodrop;
1464 PIPELINE_PORT_OUT_RING_WRITER_NODROP;
1465 params->ring = app->swq[in->id];
1466 params->tx_burst_sz =
1467 app->swq_params[in->id].burst_write;
1469 app->swq_params[in->id].n_retries;
1472 if (swq_params->dropless == 0) {
1473 struct rte_port_ring_multi_writer_params
1475 &out->params.ring_multi;
1478 PIPELINE_PORT_OUT_RING_MULTI_WRITER;
1479 params->ring = app->swq[in->id];
1480 params->tx_burst_sz = swq_params->burst_write;
1482 struct rte_port_ring_multi_writer_nodrop_params
1484 &out->params.ring_multi_nodrop;
1487 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP;
1489 params->ring = app->swq[in->id];
1490 params->tx_burst_sz = swq_params->burst_write;
1491 params->n_retries = swq_params->n_retries;
1495 if (swq_params->ipv4_ras == 1) {
1496 struct rte_port_ring_writer_ipv4_ras_params
1498 &out->params.ring_ipv4_ras;
1501 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS;
1502 params->ring = app->swq[in->id];
1503 params->tx_burst_sz = swq_params->burst_write;
1505 struct rte_port_ring_writer_ipv6_ras_params
1507 &out->params.ring_ipv6_ras;
1510 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS;
1511 params->ring = app->swq[in->id];
1512 params->tx_burst_sz = swq_params->burst_write;
1517 case APP_PKTQ_OUT_TM: {
1518 struct rte_port_sched_writer_params *params =
1521 out->type = PIPELINE_PORT_OUT_SCHED_WRITER;
1522 params->sched = app->tm[in->id];
1523 params->tx_burst_sz =
1524 app->tm_params[in->id].burst_write;
1527 case APP_PKTQ_OUT_SINK:
1528 out->type = PIPELINE_PORT_OUT_SINK;
1529 if (app->sink_params[in->id].file_name != NULL) {
1530 out->params.sink.file_name = strdup(
1531 app->sink_params[in->id].
1533 if (out->params.sink.file_name == NULL) {
1534 out->params.sink.max_n_pkts = 0;
1537 out->params.sink.max_n_pkts =
1538 app->sink_params[in->id].
1541 out->params.sink.file_name = NULL;
1542 out->params.sink.max_n_pkts = 0;
1551 p_out->n_msgq = p_in->n_msgq_in;
1553 for (i = 0; i < p_in->n_msgq_in; i++)
1554 p_out->msgq_in[i] = app->msgq[p_in->msgq_in[i]];
1556 for (i = 0; i < p_in->n_msgq_out; i++)
1557 p_out->msgq_out[i] = app->msgq[p_in->msgq_out[i]];
1560 p_out->n_args = p_in->n_args;
1561 for (i = 0; i < p_in->n_args; i++) {
1562 p_out->args_name[i] = p_in->args_name[i];
1563 p_out->args_value[i] = p_in->args_value[i];
1568 app_init_pipelines(struct app_params *app)
1572 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1573 struct app_pipeline_params *params =
1574 &app->pipeline_params[p_id];
1575 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1576 struct pipeline_type *ptype;
1577 struct pipeline_params pp;
1579 APP_LOG(app, HIGH, "Initializing %s ...", params->name);
1581 ptype = app_pipeline_type_find(app, params->type);
1583 rte_panic("Init error: Unknown pipeline type \"%s\"\n",
1586 app_pipeline_params_get(app, params, &pp);
1590 if (ptype->be_ops->f_init) {
1591 data->be = ptype->be_ops->f_init(&pp, (void *) app);
1593 if (data->be == NULL)
1594 rte_panic("Pipeline instance \"%s\" back-end "
1595 "init error\n", params->name);
1600 if (ptype->fe_ops->f_init) {
1601 data->fe = ptype->fe_ops->f_init(&pp, (void *) app);
1603 if (data->fe == NULL)
1604 rte_panic("Pipeline instance \"%s\" front-end "
1605 "init error\n", params->name);
1608 data->ptype = ptype;
1610 data->timer_period = (rte_get_tsc_hz() *
1611 params->timer_period) / 100;
1616 app_init_threads(struct app_params *app)
1618 uint64_t time = rte_get_tsc_cycles();
1621 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1622 struct app_pipeline_params *params =
1623 &app->pipeline_params[p_id];
1624 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1625 struct pipeline_type *ptype;
1626 struct app_thread_data *t;
1627 struct app_thread_pipeline_data *p;
1630 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
1633 params->hyper_th_id);
1636 rte_panic("Invalid core s%" PRIu32 "c%" PRIu32 "%s\n",
1639 (params->hyper_th_id) ? "h" : "");
1641 t = &app->thread_data[lcore_id];
1643 t->timer_period = (rte_get_tsc_hz() *
1644 APP_THREAD_TIMER_PERIOD) / 1000;
1645 t->thread_req_deadline = time + t->timer_period;
1647 t->headroom_cycles = 0;
1648 t->headroom_time = rte_get_tsc_cycles();
1649 t->headroom_ratio = 0.0;
1651 t->msgq_in = app_thread_msgq_in_get(app,
1654 params->hyper_th_id);
1655 if (t->msgq_in == NULL)
1656 rte_panic("Init error: Cannot find MSGQ_IN "
1657 "for thread %" PRId32, lcore_id);
1659 t->msgq_out = app_thread_msgq_out_get(app,
1662 params->hyper_th_id);
1663 if (t->msgq_out == NULL)
1664 rte_panic("Init error: Cannot find MSGQ_OUT "
1665 "for thread %" PRId32, lcore_id);
1667 ptype = app_pipeline_type_find(app, params->type);
1669 rte_panic("Init error: Unknown pipeline "
1670 "type \"%s\"\n", params->type);
1672 p = (ptype->be_ops->f_run == NULL) ?
1673 &t->regular[t->n_regular] :
1674 &t->custom[t->n_custom];
1676 p->pipeline_id = p_id;
1678 p->f_run = ptype->be_ops->f_run;
1679 p->f_timer = ptype->be_ops->f_timer;
1680 p->timer_period = data->timer_period;
1681 p->deadline = time + data->timer_period;
1685 if (ptype->be_ops->f_run == NULL)
1692 int app_init(struct app_params *app)
1694 app_init_core_map(app);
1695 app_init_core_mask(app);
1699 //app_init_mempool(app);
1705 app_pipeline_common_cmd_push(app);
1706 app_pipeline_thread_cmd_push(app);
1707 app_pipeline_type_register(app, &pipeline_master);
1708 app_pipeline_type_register(app, &pipeline_cgnapt);
1709 app_pipeline_type_register(app, &pipeline_loadb);
1710 app_pipeline_type_register(app, &pipeline_timer);
1711 app_pipeline_type_register(app, &pipeline_txrx);
1712 app_pipeline_type_register(app, &pipeline_arpicmp);
1714 app_init_pipelines(app);
1715 app_init_threads(app);
1720 populate_lpm_routes();
1721 print_interface_details();
1727 app_pipeline_type_cmd_push(struct app_params *app,
1728 struct pipeline_type *ptype)
1730 cmdline_parse_ctx_t *cmds;
1733 /* Check input arguments */
1734 if ((app == NULL) ||
1738 n_cmds = pipeline_type_cmds_count(ptype);
1742 cmds = ptype->fe_ops->cmds;
1744 /* Check for available slots in the application commands array */
1745 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1748 /* Push pipeline commands into the application */
1749 memcpy(&app->cmds[app->n_cmds],
1751 n_cmds * sizeof(cmdline_parse_ctx_t));
1753 for (i = 0; i < n_cmds; i++)
1754 app->cmds[app->n_cmds + i]->data = app;
1756 app->n_cmds += n_cmds;
1757 app->cmds[app->n_cmds] = NULL;
1763 app_pipeline_type_register(struct app_params *app, struct pipeline_type *ptype)
1767 /* Check input arguments */
1768 if ((app == NULL) ||
1770 (ptype->name == NULL) ||
1771 (strlen(ptype->name) == 0) ||
1772 (ptype->be_ops->f_init == NULL) ||
1773 (ptype->be_ops->f_timer == NULL))
1776 /* Check for duplicate entry */
1777 for (i = 0; i < app->n_pipeline_types; i++)
1778 if (strcmp(app->pipeline_type[i].name, ptype->name) == 0)
1781 /* Check for resource availability */
1782 n_cmds = pipeline_type_cmds_count(ptype);
1783 if ((app->n_pipeline_types == APP_MAX_PIPELINE_TYPES) ||
1784 (n_cmds > APP_MAX_CMDS - app->n_cmds))
1787 /* Copy pipeline type */
1788 memcpy(&app->pipeline_type[app->n_pipeline_types++],
1790 sizeof(struct pipeline_type));
1792 /* Copy CLI commands */
1794 app_pipeline_type_cmd_push(app, ptype);
1800 pipeline_type *app_pipeline_type_find(struct app_params *app, char *name)
1804 for (i = 0; i < app->n_pipeline_types; i++)
1805 if (strcmp(app->pipeline_type[i].name, name) == 0)
1806 return &app->pipeline_type[i];