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 printf("Failed to configure port %s - %"PRIu32
1030 ".\n", p_link->name, p_link->pmd_id);
1031 printf("Try again with offload disabled....\n");
1032 port_config[i].tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOOFFLOADS;
1033 if (ifm_port_setup (p_link->pmd_id, &port_config[i]))
1034 rte_panic ("Port Setup Failed: %s - %"PRIu32"\n", p_link->name, p_link->pmd_id);
1039 status = rte_eth_dev_configure(
1045 rte_panic("%s (%" PRId32 "): "
1046 "init error (%" PRId32 ")\n",
1047 p_link->name, p_link->pmd_id, status);
1049 rte_eth_macaddr_get(p_link->pmd_id,
1050 (struct ether_addr *) &p_link->mac_addr);
1052 if (p_link->promisc)
1053 rte_eth_promiscuous_enable(p_link->pmd_id);
1056 for (j = 0; j < app->n_pktq_hwq_in; j++) {
1057 struct app_pktq_hwq_in_params *p_rxq =
1058 &app->hwq_in_params[j];
1059 uint32_t rxq_link_id, rxq_queue_id;
1062 sscanf(p_rxq->name, "RXQ%" PRIu32 ".%" PRIu32,
1063 &rxq_link_id, &rxq_queue_id);
1065 rte_panic("%s (%" PRId32 "): "
1066 "init error (%" PRId32 ")\n",
1067 p_rxq->name, rxq_queue_id, status);
1069 if (rxq_link_id != link_id)
1072 status = rte_eth_rx_queue_setup(
1076 app_get_cpu_socket_id(p_link->pmd_id),
1078 app->mempool[p_rxq->mempool_id]);
1080 rte_panic("%s (%" PRIu32 "): "
1081 "%s init error (%" PRId32 ")\n",
1089 for (j = 0; j < app->n_pktq_hwq_out; j++) {
1090 struct app_pktq_hwq_out_params *p_txq =
1091 &app->hwq_out_params[j];
1092 uint32_t txq_link_id, txq_queue_id;
1095 sscanf(p_txq->name, "TXQ%" PRIu32 ".%" PRIu32,
1096 &txq_link_id, &txq_queue_id);
1099 rte_panic("%s (%" PRId32 "): "
1100 "init error (%" PRId32 ")\n",
1101 p_txq->name, txq_link_id, status);
1103 if (txq_link_id != link_id)
1106 if (app->header_csum_req) {
1107 /* Enable TCP and UDP HW Checksum */
1108 p_txq->conf.txq_flags &=
1109 ~(ETH_TXQ_FLAGS_NOXSUMTCP|
1110 ETH_TXQ_FLAGS_NOXSUMUDP);
1113 status = rte_eth_tx_queue_setup(
1117 app_get_cpu_socket_id(p_link->pmd_id),
1121 rte_panic("%s (%" PRIu32 "): "
1122 "%s init error (%" PRId32 ")\n",
1130 status = rte_eth_dev_start(p_link->pmd_id);
1132 rte_panic("Cannot start %s (error %" PRId32 ")\n",
1133 p_link->name, status);
1136 app_link_set_arp_filter(app, p_link);
1137 app_link_set_tcp_syn_filter(app, p_link);
1139 app_link_up_internal(app, p_link);
1142 app_check_link(app);
1146 app_init_swq(struct app_params *app)
1150 for (i = 0; i < app->n_pktq_swq; i++) {
1151 struct app_pktq_swq_params *p = &app->swq_params[i];
1152 unsigned int flags = 0;
1154 if (app_swq_get_readers(app, p) == 1)
1155 flags |= RING_F_SC_DEQ;
1156 if (app_swq_get_writers(app, p) == 1)
1157 flags |= RING_F_SP_ENQ;
1159 APP_LOG(app, HIGH, "Initializing %s...", p->name);
1160 app->swq[i] = rte_ring_create(
1166 if (app->swq[i] == NULL)
1167 rte_panic("%s init error\n", p->name);
1172 app_init_tm(struct app_params *app)
1176 for (i = 0; i < app->n_pktq_tm; i++) {
1177 struct app_pktq_tm_params *p_tm = &app->tm_params[i];
1178 struct app_link_params *p_link;
1179 struct rte_eth_link link_eth_params;
1180 struct rte_sched_port *sched;
1181 uint32_t n_subports, subport_id;
1184 p_link = app_get_link_for_tm(app, p_tm);
1186 rte_eth_link_get(p_link->pmd_id, &link_eth_params);
1189 p_tm->sched_port_params.name = p_tm->name;
1190 p_tm->sched_port_params.socket =
1191 app_get_cpu_socket_id(p_link->pmd_id);
1192 p_tm->sched_port_params.rate =
1193 (uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;
1195 APP_LOG(app, HIGH, "Initializing %s ...", p_tm->name);
1196 sched = rte_sched_port_config(&p_tm->sched_port_params);
1198 rte_panic("%s init error\n", p_tm->name);
1202 n_subports = p_tm->sched_port_params.n_subports_per_port;
1203 for (subport_id = 0; subport_id < n_subports; subport_id++) {
1204 uint32_t n_pipes_per_subport, pipe_id;
1206 status = rte_sched_subport_config(sched,
1208 &p_tm->sched_subport_params[subport_id]);
1210 rte_panic("%s subport %" PRIu32
1211 " init error (%" PRId32 ")\n",
1212 p_tm->name, subport_id, status);
1215 n_pipes_per_subport =
1216 p_tm->sched_port_params.n_pipes_per_subport;
1218 pipe_id < n_pipes_per_subport;
1220 int profile_id = p_tm->sched_pipe_to_profile[
1221 subport_id * APP_MAX_SCHED_PIPES +
1224 if (profile_id == -1)
1227 status = rte_sched_pipe_config(sched,
1232 rte_panic("%s subport %" PRIu32
1234 " (profile %" PRId32 ") "
1235 "init error (% " PRId32 ")\n",
1236 p_tm->name, subport_id, pipe_id,
1237 profile_id, status);
1244 app_init_msgq(struct app_params *app)
1248 for (i = 0; i < app->n_msgq; i++) {
1249 struct app_msgq_params *p = &app->msgq_params[i];
1251 APP_LOG(app, HIGH, "Initializing %s ...", p->name);
1252 app->msgq[i] = rte_ring_create(
1256 RING_F_SP_ENQ | RING_F_SC_DEQ);
1258 if (app->msgq[i] == NULL)
1259 rte_panic("%s init error\n", p->name);
1263 static void app_pipeline_params_get(struct app_params *app,
1264 struct app_pipeline_params *p_in,
1265 struct pipeline_params *p_out)
1268 uint32_t mempool_id;
1270 snprintf(p_out->name, PIPELINE_NAME_SIZE, "%s", p_in->name);
1272 p_out->socket_id = (int) p_in->socket_id;
1274 p_out->log_level = app->log_level;
1277 p_out->n_ports_in = p_in->n_pktq_in;
1278 for (i = 0; i < p_in->n_pktq_in; i++) {
1279 struct app_pktq_in_params *in = &p_in->pktq_in[i];
1280 struct pipeline_port_in_params *out = &p_out->port_in[i];
1283 case APP_PKTQ_IN_HWQ:
1285 struct app_pktq_hwq_in_params *p_hwq_in =
1286 &app->hwq_in_params[in->id];
1287 struct app_link_params *p_link =
1288 app_get_link_for_rxq(app, p_hwq_in);
1289 uint32_t rxq_link_id, rxq_queue_id;
1292 sscanf(p_hwq_in->name, "RXQ%" SCNu32 ".%" SCNu32,
1296 rte_panic("%s (%" PRId32 "): "
1297 "init error (%" PRId32 ")\n",
1298 p_hwq_in->name, rxq_link_id, status);
1300 out->type = PIPELINE_PORT_IN_ETHDEV_READER;
1301 out->params.ethdev.port_id = p_link->pmd_id;
1302 out->params.ethdev.queue_id = rxq_queue_id;
1303 out->burst_size = p_hwq_in->burst;
1306 case APP_PKTQ_IN_SWQ:
1308 struct app_pktq_swq_params *swq_params =
1309 &app->swq_params[in->id];
1311 if ((swq_params->ipv4_frag == 0) &&
1312 (swq_params->ipv6_frag == 0)) {
1313 if (app_swq_get_readers(app,
1316 PIPELINE_PORT_IN_RING_READER;
1317 out->params.ring.ring =
1320 app->swq_params[in->id].
1323 out->type = PIPELINE_PORT_IN_RING_MULTI_READER;
1324 out->params.ring_multi.ring = app->swq[in->id];
1325 out->burst_size = swq_params->burst_read;
1328 if (swq_params->ipv4_frag == 1) {
1329 struct rte_port_ring_reader_ipv4_frag_params
1331 &out->params.ring_ipv4_frag;
1334 PIPELINE_PORT_IN_RING_READER_IPV4_FRAG;
1335 params->ring = app->swq[in->id];
1336 params->mtu = swq_params->mtu;
1337 params->metadata_size =
1338 swq_params->metadata_size;
1339 params->pool_direct =
1341 [swq_params->mempool_direct_id];
1342 params->pool_indirect =
1344 [swq_params->mempool_indirect_id];
1345 out->burst_size = swq_params->burst_read;
1347 struct rte_port_ring_reader_ipv6_frag_params
1349 &out->params.ring_ipv6_frag;
1352 PIPELINE_PORT_IN_RING_READER_IPV6_FRAG;
1353 params->ring = app->swq[in->id];
1354 params->mtu = swq_params->mtu;
1355 params->metadata_size =
1356 swq_params->metadata_size;
1357 params->pool_direct =
1359 [swq_params->mempool_direct_id];
1360 params->pool_indirect =
1362 [swq_params->mempool_indirect_id];
1363 out->burst_size = swq_params->burst_read;
1368 case APP_PKTQ_IN_TM:
1369 out->type = PIPELINE_PORT_IN_SCHED_READER;
1370 out->params.sched.sched = app->tm[in->id];
1371 out->burst_size = app->tm_params[in->id].burst_read;
1373 case APP_PKTQ_IN_SOURCE:
1374 mempool_id = app->source_params[in->id].mempool_id;
1375 out->type = PIPELINE_PORT_IN_SOURCE;
1376 out->params.source.mempool = app->mempool[mempool_id];
1377 out->burst_size = app->source_params[in->id].burst;
1380 if (app->source_params[in->id].file_name
1382 out->params.source.file_name = strdup(
1383 app->source_params[in->id].
1385 if (out->params.source.file_name == NULL) {
1387 n_bytes_per_pkt = 0;
1390 out->params.source.n_bytes_per_pkt =
1391 app->source_params[in->id].
1403 p_out->n_ports_out = p_in->n_pktq_out;
1404 for (i = 0; i < p_in->n_pktq_out; i++) {
1405 struct app_pktq_out_params *in = &p_in->pktq_out[i];
1406 struct pipeline_port_out_params *out = &p_out->port_out[i];
1409 case APP_PKTQ_OUT_HWQ:
1411 struct app_pktq_hwq_out_params *p_hwq_out =
1412 &app->hwq_out_params[in->id];
1413 struct app_link_params *p_link =
1414 app_get_link_for_txq(app, p_hwq_out);
1415 uint32_t txq_link_id, txq_queue_id;
1418 sscanf(p_hwq_out->name,
1419 "TXQ%" SCNu32 ".%" SCNu32,
1423 rte_panic("%s (%" PRId32 "): "
1424 "init error (%" PRId32 ")\n",
1425 p_hwq_out->name, txq_link_id, status);
1427 if (p_hwq_out->dropless == 0) {
1428 struct rte_port_ethdev_writer_params *params =
1429 &out->params.ethdev;
1431 out->type = PIPELINE_PORT_OUT_ETHDEV_WRITER;
1432 params->port_id = p_link->pmd_id;
1433 params->queue_id = txq_queue_id;
1434 params->tx_burst_sz =
1435 app->hwq_out_params[in->id].burst;
1437 struct rte_port_ethdev_writer_nodrop_params
1438 *params = &out->params.ethdev_nodrop;
1441 PIPELINE_PORT_OUT_ETHDEV_WRITER_NODROP;
1442 params->port_id = p_link->pmd_id;
1443 params->queue_id = txq_queue_id;
1444 params->tx_burst_sz = p_hwq_out->burst;
1445 params->n_retries = p_hwq_out->n_retries;
1449 case APP_PKTQ_OUT_SWQ:
1451 struct app_pktq_swq_params *swq_params =
1452 &app->swq_params[in->id];
1454 if ((swq_params->ipv4_ras == 0) &&
1455 (swq_params->ipv6_ras == 0)) {
1456 if (app_swq_get_writers(app, swq_params) == 1) {
1457 if (app->swq_params[in->id].dropless == 0) {
1458 struct rte_port_ring_writer_params *params =
1461 out->type = PIPELINE_PORT_OUT_RING_WRITER;
1462 params->ring = app->swq[in->id];
1463 params->tx_burst_sz =
1464 app->swq_params[in->id].burst_write;
1466 struct rte_port_ring_writer_nodrop_params
1467 *params = &out->params.ring_nodrop;
1470 PIPELINE_PORT_OUT_RING_WRITER_NODROP;
1471 params->ring = app->swq[in->id];
1472 params->tx_burst_sz =
1473 app->swq_params[in->id].burst_write;
1475 app->swq_params[in->id].n_retries;
1478 if (swq_params->dropless == 0) {
1479 struct rte_port_ring_multi_writer_params
1481 &out->params.ring_multi;
1484 PIPELINE_PORT_OUT_RING_MULTI_WRITER;
1485 params->ring = app->swq[in->id];
1486 params->tx_burst_sz = swq_params->burst_write;
1488 struct rte_port_ring_multi_writer_nodrop_params
1490 &out->params.ring_multi_nodrop;
1493 PIPELINE_PORT_OUT_RING_MULTI_WRITER_NODROP;
1495 params->ring = app->swq[in->id];
1496 params->tx_burst_sz = swq_params->burst_write;
1497 params->n_retries = swq_params->n_retries;
1501 if (swq_params->ipv4_ras == 1) {
1502 struct rte_port_ring_writer_ipv4_ras_params
1504 &out->params.ring_ipv4_ras;
1507 PIPELINE_PORT_OUT_RING_WRITER_IPV4_RAS;
1508 params->ring = app->swq[in->id];
1509 params->tx_burst_sz = swq_params->burst_write;
1511 struct rte_port_ring_writer_ipv6_ras_params
1513 &out->params.ring_ipv6_ras;
1516 PIPELINE_PORT_OUT_RING_WRITER_IPV6_RAS;
1517 params->ring = app->swq[in->id];
1518 params->tx_burst_sz = swq_params->burst_write;
1523 case APP_PKTQ_OUT_TM: {
1524 struct rte_port_sched_writer_params *params =
1527 out->type = PIPELINE_PORT_OUT_SCHED_WRITER;
1528 params->sched = app->tm[in->id];
1529 params->tx_burst_sz =
1530 app->tm_params[in->id].burst_write;
1533 case APP_PKTQ_OUT_SINK:
1534 out->type = PIPELINE_PORT_OUT_SINK;
1535 if (app->sink_params[in->id].file_name != NULL) {
1536 out->params.sink.file_name = strdup(
1537 app->sink_params[in->id].
1539 if (out->params.sink.file_name == NULL) {
1540 out->params.sink.max_n_pkts = 0;
1543 out->params.sink.max_n_pkts =
1544 app->sink_params[in->id].
1547 out->params.sink.file_name = NULL;
1548 out->params.sink.max_n_pkts = 0;
1557 p_out->n_msgq = p_in->n_msgq_in;
1559 for (i = 0; i < p_in->n_msgq_in; i++)
1560 p_out->msgq_in[i] = app->msgq[p_in->msgq_in[i]];
1562 for (i = 0; i < p_in->n_msgq_out; i++)
1563 p_out->msgq_out[i] = app->msgq[p_in->msgq_out[i]];
1566 p_out->n_args = p_in->n_args;
1567 for (i = 0; i < p_in->n_args; i++) {
1568 p_out->args_name[i] = p_in->args_name[i];
1569 p_out->args_value[i] = p_in->args_value[i];
1574 app_init_pipelines(struct app_params *app)
1578 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1579 struct app_pipeline_params *params =
1580 &app->pipeline_params[p_id];
1581 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1582 struct pipeline_type *ptype;
1583 struct pipeline_params pp;
1585 APP_LOG(app, HIGH, "Initializing %s ...", params->name);
1587 ptype = app_pipeline_type_find(app, params->type);
1589 rte_panic("Init error: Unknown pipeline type \"%s\"\n",
1592 app_pipeline_params_get(app, params, &pp);
1596 if (ptype->be_ops->f_init) {
1597 data->be = ptype->be_ops->f_init(&pp, (void *) app);
1599 if (data->be == NULL)
1600 rte_panic("Pipeline instance \"%s\" back-end "
1601 "init error\n", params->name);
1606 if (ptype->fe_ops->f_init) {
1607 data->fe = ptype->fe_ops->f_init(&pp, (void *) app);
1609 if (data->fe == NULL)
1610 rte_panic("Pipeline instance \"%s\" front-end "
1611 "init error\n", params->name);
1614 data->ptype = ptype;
1616 data->timer_period = (rte_get_tsc_hz() *
1617 params->timer_period) / 100;
1622 app_init_threads(struct app_params *app)
1624 uint64_t time = rte_get_tsc_cycles();
1627 for (p_id = 0; p_id < app->n_pipelines; p_id++) {
1628 struct app_pipeline_params *params =
1629 &app->pipeline_params[p_id];
1630 struct app_pipeline_data *data = &app->pipeline_data[p_id];
1631 struct pipeline_type *ptype;
1632 struct app_thread_data *t;
1633 struct app_thread_pipeline_data *p;
1636 lcore_id = cpu_core_map_get_lcore_id(app->core_map,
1639 params->hyper_th_id);
1642 rte_panic("Invalid core s%" PRIu32 "c%" PRIu32 "%s\n",
1645 (params->hyper_th_id) ? "h" : "");
1647 t = &app->thread_data[lcore_id];
1649 t->timer_period = (rte_get_tsc_hz() *
1650 APP_THREAD_TIMER_PERIOD) / 1000;
1651 t->thread_req_deadline = time + t->timer_period;
1653 t->headroom_cycles = 0;
1654 t->headroom_time = rte_get_tsc_cycles();
1655 t->headroom_ratio = 0.0;
1657 t->msgq_in = app_thread_msgq_in_get(app,
1660 params->hyper_th_id);
1661 if (t->msgq_in == NULL)
1662 rte_panic("Init error: Cannot find MSGQ_IN "
1663 "for thread %" PRId32, lcore_id);
1665 t->msgq_out = app_thread_msgq_out_get(app,
1668 params->hyper_th_id);
1669 if (t->msgq_out == NULL)
1670 rte_panic("Init error: Cannot find MSGQ_OUT "
1671 "for thread %" PRId32, lcore_id);
1673 ptype = app_pipeline_type_find(app, params->type);
1675 rte_panic("Init error: Unknown pipeline "
1676 "type \"%s\"\n", params->type);
1678 p = (ptype->be_ops->f_run == NULL) ?
1679 &t->regular[t->n_regular] :
1680 &t->custom[t->n_custom];
1682 p->pipeline_id = p_id;
1684 p->f_run = ptype->be_ops->f_run;
1685 p->f_timer = ptype->be_ops->f_timer;
1686 p->timer_period = data->timer_period;
1687 p->deadline = time + data->timer_period;
1691 if (ptype->be_ops->f_run == NULL)
1698 int app_init(struct app_params *app)
1700 app_init_core_map(app);
1701 app_init_core_mask(app);
1705 //app_init_mempool(app);
1711 app_pipeline_common_cmd_push(app);
1712 app_pipeline_thread_cmd_push(app);
1713 app_pipeline_type_register(app, &pipeline_master);
1714 app_pipeline_type_register(app, &pipeline_cgnapt);
1715 app_pipeline_type_register(app, &pipeline_loadb);
1716 app_pipeline_type_register(app, &pipeline_timer);
1717 app_pipeline_type_register(app, &pipeline_txrx);
1718 app_pipeline_type_register(app, &pipeline_arpicmp);
1720 app_init_pipelines(app);
1721 app_init_threads(app);
1726 populate_lpm_routes();
1727 print_interface_details();
1733 app_pipeline_type_cmd_push(struct app_params *app,
1734 struct pipeline_type *ptype)
1736 cmdline_parse_ctx_t *cmds;
1739 /* Check input arguments */
1740 if ((app == NULL) ||
1744 n_cmds = pipeline_type_cmds_count(ptype);
1748 cmds = ptype->fe_ops->cmds;
1750 /* Check for available slots in the application commands array */
1751 if (n_cmds > APP_MAX_CMDS - app->n_cmds)
1754 /* Push pipeline commands into the application */
1755 memcpy(&app->cmds[app->n_cmds],
1757 n_cmds * sizeof(cmdline_parse_ctx_t));
1759 for (i = 0; i < n_cmds; i++)
1760 app->cmds[app->n_cmds + i]->data = app;
1762 app->n_cmds += n_cmds;
1763 app->cmds[app->n_cmds] = NULL;
1769 app_pipeline_type_register(struct app_params *app, struct pipeline_type *ptype)
1773 /* Check input arguments */
1774 if ((app == NULL) ||
1776 (ptype->name == NULL) ||
1777 (strlen(ptype->name) == 0) ||
1778 (ptype->be_ops->f_init == NULL) ||
1779 (ptype->be_ops->f_timer == NULL))
1782 /* Check for duplicate entry */
1783 for (i = 0; i < app->n_pipeline_types; i++)
1784 if (strcmp(app->pipeline_type[i].name, ptype->name) == 0)
1787 /* Check for resource availability */
1788 n_cmds = pipeline_type_cmds_count(ptype);
1789 if ((app->n_pipeline_types == APP_MAX_PIPELINE_TYPES) ||
1790 (n_cmds > APP_MAX_CMDS - app->n_cmds))
1793 /* Copy pipeline type */
1794 memcpy(&app->pipeline_type[app->n_pipeline_types++],
1796 sizeof(struct pipeline_type));
1798 /* Copy CLI commands */
1800 app_pipeline_type_cmd_push(app, ptype);
1806 pipeline_type *app_pipeline_type_find(struct app_params *app, char *name)
1810 for (i = 0; i < app->n_pipeline_types; i++)
1811 if (strcmp(app->pipeline_type[i].name, name) == 0)
1812 return &app->pipeline_type[i];