REST_API: rest api client implementation
[samplevnf.git] / VNFs / vACL / init.c
index e85dc29..dda6277 100644 (file)
@@ -24,6 +24,7 @@
 #include <rte_ip.h>
 #include <rte_eal.h>
 #include <rte_malloc.h>
+#include <rte_version.h>
 
 #include "app.h"
 #include "pipeline.h"
@@ -512,6 +513,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 +526,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)
@@ -534,13 +538,14 @@ app_link_up_internal(struct app_params *app, struct app_link_params *cp)
         if(app == NULL || cp == NULL)
                 printf("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;
 
@@ -555,11 +560,13 @@ app_link_down_internal(struct app_params *app, struct app_link_params *cp)
 
         if(app == NULL || cp == NULL)
                 printf("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 +706,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 +741,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 +1300,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;
 }