X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FvACL%2Finit.c;h=b83825b3e31f2f4a9f2003ee032f336ad5ee5117;hb=d5801e449ca4c7115c2c11bf164bcce7b149917c;hp=e85dc297b86e1e98455c72148581220c199e7a6a;hpb=8a4e9e534fcb1ef718ed5c1089fdc8698b13fb7f;p=samplevnf.git diff --git a/VNFs/vACL/init.c b/VNFs/vACL/init.c index e85dc297..b83825b3 100644 --- a/VNFs/vACL/init.c +++ b/VNFs/vACL/init.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "app.h" #include "pipeline.h" @@ -99,14 +100,20 @@ app_init_eal(struct app_params *app) uint32_t i; int status; + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(app->app_name); app_core_build_core_mask_string(app, core_mask_str); snprintf(buffer, sizeof(buffer), "-c%s", core_mask_str); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); if (p->coremap) { snprintf(buffer, sizeof(buffer), "--lcores=%s", p->coremap); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -115,19 +122,27 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--master-lcore=%" PRIu32, p->master_lcore); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } snprintf(buffer, sizeof(buffer), "-n%" PRIu32, p->channels); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); if (p->memory_present) { snprintf(buffer, sizeof(buffer), "-m%" PRIu32, p->memory); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->ranks_present) { snprintf(buffer, sizeof(buffer), "-r%" PRIu32, p->ranks); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -139,6 +154,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--pci-blacklist=%s", p->pci_blacklist[i]); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -162,6 +179,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--pci-whitelist=%s", pci_bdf); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -173,11 +192,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--vdev=%s", p->vdev[i]); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->vmware_tsc_map_present) && p->vmware_tsc_map) { snprintf(buffer, sizeof(buffer), "--vmware-tsc-map"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -186,11 +209,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--proc-type=%s", p->proc_type); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->syslog) { snprintf(buffer, sizeof(buffer), "--syslog=%s", p->syslog); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -199,41 +226,57 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--log-level=%" PRIu32, p->log_level); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->version_present) && p->version) { snprintf(buffer, sizeof(buffer), "-v"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->help_present) && p->help) { snprintf(buffer, sizeof(buffer), "--help"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_huge_present) && p->no_huge) { snprintf(buffer, sizeof(buffer), "--no-huge"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_pci_present) && p->no_pci) { snprintf(buffer, sizeof(buffer), "--no-pci"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_hpet_present) && p->no_hpet) { snprintf(buffer, sizeof(buffer), "--no-hpet"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->no_shconf_present) && p->no_shconf) { snprintf(buffer, sizeof(buffer), "--no-shconf"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->add_driver) { snprintf(buffer, sizeof(buffer), "-d=%s", p->add_driver); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -242,11 +285,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--socket-mem=%s", p->socket_mem); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if (p->huge_dir) { snprintf(buffer, sizeof(buffer), "--huge-dir=%s", p->huge_dir); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -255,6 +302,8 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--file-prefix=%s", p->file_prefix); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -263,11 +312,15 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--base-virtaddr=%s", p->base_virtaddr); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->create_uio_dev_present) && p->create_uio_dev) { snprintf(buffer, sizeof(buffer), "--create-uio-dev"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } @@ -276,15 +329,21 @@ app_init_eal(struct app_params *app) sizeof(buffer), "--vfio-intr=%s", p->vfio_intr); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } if ((p->xen_dom0_present) && (p->xen_dom0)) { snprintf(buffer, sizeof(buffer), "--xen-dom0"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); } snprintf(buffer, sizeof(buffer), "--"); + if (unlikely (n_args >= APP_EAL_ARGC)) + goto error_exit; app->eal_argv[n_args++] = strdup(buffer); app->eal_argc = n_args; @@ -300,8 +359,10 @@ app_init_eal(struct app_params *app) } status = rte_eal_init(app->eal_argc, app->eal_argv); - if (status < 0) + if (status < 0) { +error_exit: rte_panic("EAL init error\n"); + } } static inline int @@ -512,6 +573,8 @@ app_link_filter_sctp_del(struct app_link_params *l1, struct app_link_params *l2) &filter); } +/* rte_eth_dev is removed in DPDK version 16.11 and onwards */ +#if RTE_VERSION < 0x100b0000 static int app_link_is_virtual(struct app_link_params *p) { @@ -523,6 +586,7 @@ app_link_is_virtual(struct app_link_params *p) return 0; } +#endif void app_link_up_internal(struct app_params *app, struct app_link_params *cp) @@ -532,15 +596,16 @@ app_link_up_internal(struct app_params *app, struct app_link_params *cp) struct rte_eth_link link; if(app == NULL || cp == NULL) - printf("NULL Pointers"); + rte_panic("NULL Pointers"); +#if RTE_VERSION < 0x100b0000 if (app_link_is_virtual(cp)) { cp->state = 1; return; } - +#endif ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_UP); - + /* Mark link as UP */ cp->state = 1; @@ -554,12 +619,14 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp) struct rte_eth_link link; if(app == NULL || cp == NULL) - printf("NULL Pointers"); - + rte_panic("NULL Pointers"); + +#if RTE_VERSION < 0x100b0000 if (app_link_is_virtual(cp)) { cp->state = 0; return; } +#endif ifm_update_linkstatus(cp->pmd_id, IFM_ETH_LINK_DOWN); @@ -699,11 +766,12 @@ app_init_link(struct app_params *app) My_local_conf->rxmode.mq_mode = ETH_MQ_RX_RSS; My_local_conf->rx_adv_conf.rss_conf.rss_key = NULL; My_local_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_UDP | ETH_RSS_TCP; - } else {/* disable-rss */ - My_local_conf->rx_adv_conf.rss_conf.rss_hf = 0; /* pkt-filter-mode is perfect */ My_local_conf->fdir_conf.mode = RTE_FDIR_MODE_PERFECT; - } + } else { + /* disable-rss */ + My_local_conf->rx_adv_conf.rss_conf.rss_hf = 0; + } /* Set the hardware CRC stripping to avoid double stripping of FCS in VM */ p_link->conf.rxmode.hw_strip_crc = 1; @@ -733,11 +801,15 @@ app_init_link(struct app_params *app) port_config[i].tx_conf.txq_flags &= ~(ETH_TXQ_FLAGS_NOXSUMTCP|ETH_TXQ_FLAGS_NOXSUMUDP); } - - if (ifm_port_setup (p_link->pmd_id, &port_config[i])) { - rte_panic ("Port Setup Failed: %s - %"PRIu32"\n", - p_link->name, p_link->pmd_id); - } + if (ifm_port_setup(p_link->pmd_id, &port_config[i])) { + printf("Failed to configure port %s - %"PRIu32 + ".\n", p_link->name, p_link->pmd_id); + printf("Try again with offload disabled....\n"); + port_config[i].tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOOFFLOADS; + if (ifm_port_setup (p_link->pmd_id, &port_config[i])) + rte_panic("Port Setup Failed: %s - %" PRIu32 + "\n", p_link->name, p_link->pmd_id); + } /* LINK UP */ app_link_up_internal(app, p_link); @@ -1288,11 +1360,13 @@ int app_init(struct app_params *app) app_init_pipelines(app); app_init_threads(app); + #ifdef L3_STACK_SUPPORT l3fwd_init(); create_arp_table(); create_nd_table(); populate_lpm_routes(); print_interface_details(); + #endif return 0; }