aarch64 CPU arch / ThunderX platform initial support
[vpp.git] / vpp / vnet / main.c
index 09adfea..1dffa7c 100644 (file)
@@ -52,8 +52,6 @@ vpe_main_init (vlib_main_t * vm)
        return error;
     if ((error = vlib_call_init_function (vm, ethernet_arp_init)))
        return error;
-    if ((error = vlib_call_init_function (vm, sr_init)))
-       return error;
     if ((error = vlib_call_init_function (vm, map_init)))
        return error;
     if ((error = vlib_call_init_function (vm, sixrd_init)))
@@ -72,8 +70,10 @@ vpe_main_init (vlib_main_t * vm)
         return error;
     if ((error = vlib_call_init_function (vm, vhost_user_init)))
        return error;
+#if IPSEC > 0
     if ((error = vlib_call_init_function (vm, ipsec_init)))
         return error;
+#endif /* IPSEC */
 #endif    
     if ((error = vlib_call_init_function (vm, vlibmemory_init)))
        return error;
@@ -102,16 +102,20 @@ vpe_main_init (vlib_main_t * vm)
         return error;
     if ((error = vlib_call_init_function (vm, tuntap_init)))
        return error;
+#if IPV6SR > 0
     if ((error = vlib_call_init_function (vm, sr_init)))
         return error;
+#endif
     if ((error = vlib_call_init_function (vm, l2_classify_init)))
         return error;
     if ((error = vlib_call_init_function (vm, policer_init)))
         return error;
     if ((error = vlib_call_init_function (vm, vxlan_init)))
         return error;
+#if VCGN > 0
     if ((error = vlib_call_init_function (vm, vcgn_init)))
         return error;
+#endif
     if ((error = vlib_call_init_function (vm, li_init)))
         return error;
 
@@ -143,6 +147,65 @@ int main (int argc, char * argv[])
     u32 size;
     void vlib_set_get_handoff_structure_cb (void *cb);
 
+    /*
+     * Load startup config from file.
+     * usage: vpp -c /etc/vpp/startup.conf
+     */
+    if ((argc == 3) && !strncmp(argv[1], "-c", 2))
+      {
+        FILE * fp;
+        char inbuf[4096];
+        int argc_ = 1;
+        char ** argv_ = NULL;
+        char * arg = NULL;
+        char * p;
+
+        fp = fopen (argv[2], "r");
+        if (fp == NULL)
+          {
+            fprintf(stderr, "open configuration file '%s' failed\n", argv[2]);
+            return 1;
+          }
+        argv_ = calloc(1, sizeof(char *));
+        if (argv_ == NULL)
+          return 1;
+        arg = strndup(argv[0], 1024);
+        if (arg == NULL)
+          return 1;
+        argv_[0] = arg;
+
+        while (1) {
+          if (fgets(inbuf, 4096, fp) == 0)
+            break;
+          p = strtok(inbuf, " \t\n");
+          while (p != NULL) {
+            if (*p == '#')
+              break;
+            argc_++;
+            char ** tmp = realloc(argv_, argc_ * sizeof(char *));
+            if (tmp == NULL)
+              return 1;
+            argv_ = tmp;
+            arg = strndup(p, 1024);
+            if (arg == NULL)
+              return 1;
+            argv_[argc_ - 1] = arg;
+            p = strtok(NULL, " \t\n");
+          }
+        }
+
+        fclose(fp);
+
+        char ** tmp = realloc(argv_, (argc_ + 1) * sizeof(char *));
+        if (tmp == NULL)
+           return 1;
+        argv_ = tmp;
+        argv_[argc_] = NULL;
+
+        argc = argc_;
+        argv = argv_;
+      }
+
     /* 
      * Look for and parse the "heapsize" config parameter.
      * Manual since none of the clib infra has been bootstrapped yet.
@@ -280,6 +343,39 @@ u32 vlib_app_num_thread_stacks_needed (void)
   return 1;
 }
 
+/* 
+ * Depending on the configuration selected above,
+ * it may be necessary to generate stub graph nodes.
+ * It is never OK to ignore "node 'x' refers to unknown node 'y'
+ * messages!
+ */
+
+#if IPV6SR == 0
+#define foreach_ipv6_sr_stub_node \
+_(ipsec-output, ipsec_output)
+#else
+#define foreach_ipv6_sr_stub_node
+#endif
+
+#define _(n,m)                                          \
+static uword                                            \
+m##_node_fn (vlib_main_t *vm,                           \
+           vlib_node_runtime_t *node,                   \
+           vlib_frame_t *frame)                         \
+{                                                       \
+  clib_warning("unimplemented, leaking buffers...");    \
+  return 0;                                             \
+}                                                       \
+                                                        \
+VLIB_REGISTER_NODE(m##_node) = {                        \
+  .function = m##_node_fn,                              \
+  .name = #n,                                           \
+  .vector_size = sizeof(u32),                           \
+  .type = VLIB_NODE_TYPE_INTERNAL,                      \
+};
+foreach_ipv6_sr_stub_node;
+#undef _
+
 #if CLIB_DEBUG > 0
 
 static clib_error_t *