misc: move osi to plugin 60/41360/6
authorHadi Rayan Al-Sandid <[email protected]>
Thu, 1 Aug 2024 15:10:54 +0000 (17:10 +0200)
committerBeno�t Ganne <[email protected]>
Thu, 22 Aug 2024 08:00:52 +0000 (08:00 +0000)
Type: refactor

This patch moves osi into a plugin, and also modifies
the init functions of llc and snap to preserve init
order dependency (llc_init --> osi_init --> snap_init).

While the initial intent was to move osi/llc/snap together
into a single plugin, there exists a dependency on llc
in vnet/ethernet, which would require further refactoring
and testing work.

Change-Id: Ic0eff030ee29c8d316c0e0fe13931451aa193527
Signed-off-by: Hadi Rayan Al-Sandid <[email protected]>
12 files changed:
docs/spelling_wordlist.txt
src/plugins/osi/CMakeLists.txt [new file with mode: 0644]
src/plugins/osi/FEATURE.yaml [new file with mode: 0644]
src/plugins/osi/node.c [moved from src/vnet/osi/node.c with 99% similarity]
src/plugins/osi/osi.c [moved from src/vnet/osi/osi.c with 95% similarity]
src/plugins/osi/osi.h [moved from src/vnet/osi/osi.h with 100% similarity]
src/plugins/osi/pg.c [moved from src/vnet/osi/pg.c with 99% similarity]
src/plugins/osi/plugin.c [new file with mode: 0644]
src/vnet/CMakeLists.txt
src/vnet/llc/llc.c
src/vnet/llc/node.c
src/vnet/snap/snap.c

index f90ffa8..e428390 100644 (file)
@@ -805,6 +805,7 @@ operationalize
 Optimisations
 optimised
 os
+osi
 outacl
 packagecloud
 papi
diff --git a/src/plugins/osi/CMakeLists.txt b/src/plugins/osi/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8ab0147
--- /dev/null
@@ -0,0 +1,24 @@
+# Copyright (c) 2023 Cisco and/or its affiliates
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_vpp_plugin(osi
+
+  SOURCES
+  osi.c
+  node.c
+  pg.c
+  plugin.c
+
+  INSTALL_HEADERS
+  osi.h
+)
diff --git a/src/plugins/osi/FEATURE.yaml b/src/plugins/osi/FEATURE.yaml
new file mode 100644 (file)
index 0000000..337be1c
--- /dev/null
@@ -0,0 +1,11 @@
+---
+name: OSI plugin
+maintainer:
+  - community <[email protected]>
+features:
+  - Adds support for OSI protocols (SAP types)
+  - Registered as input protocol for PPP, HDLC, and LLC
+missing:
+  - No tests for this feature currently exist
+description: ""
+state: experimental
similarity index 99%
rename from src/vnet/osi/node.c
rename to src/plugins/osi/node.c
index 9edc354..a36b152 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <vlib/vlib.h>
 #include <vnet/pg/pg.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
 #include <vnet/ppp/ppp.h>
 #include <vnet/hdlc/hdlc.h>
 #include <vnet/llc/llc.h>
similarity index 95%
rename from src/vnet/osi/osi.c
rename to src/plugins/osi/osi.c
index 9556481..67c7053 100644 (file)
@@ -38,7 +38,7 @@
  */
 
 #include <vnet/vnet.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
 
 /* Global main structure. */
 osi_main_t osi_main;
@@ -169,13 +169,8 @@ add_protocol (osi_main_t * pm, osi_protocol_t protocol, char *protocol_name)
 static clib_error_t *
 osi_init (vlib_main_t * vm)
 {
-  clib_error_t *error = 0;
   osi_main_t *pm = &osi_main;
 
-  /* init order dependency: llc_init -> osi_init */
-  if ((error = vlib_call_init_function (vm, llc_init)))
-    return error;
-
   clib_memset (pm, 0, sizeof (pm[0]));
   pm->vlib_main = vm;
 
@@ -189,8 +184,11 @@ osi_init (vlib_main_t * vm)
   return vlib_call_init_function (vm, osi_input_init);
 }
 
-VLIB_INIT_FUNCTION (osi_init);
-
+/* init order dependency: llc_init -> osi_init -> snap_init*/
+/* Otherwise, osi_input_init will wipe out e.g. the snap init */
+VLIB_INIT_FUNCTION (osi_init) = {
+  .init_order = VLIB_INITS ("llc_init", "osi_init", "snap_init"),
+};
 
 /*
  * fd.io coding-style-patch-verification: ON
similarity index 100%
rename from src/vnet/osi/osi.h
rename to src/plugins/osi/osi.h
similarity index 99%
rename from src/vnet/osi/pg.c
rename to src/plugins/osi/pg.c
index c87a869..3bac693 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <vlib/vlib.h>
 #include <vnet/pg/pg.h>
-#include <vnet/osi/osi.h>
+#include <osi/osi.h>
 
 typedef struct
 {
diff --git a/src/plugins/osi/plugin.c b/src/plugins/osi/plugin.c
new file mode 100644 (file)
index 0000000..5fc412e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * plugin.c: osi
+ *
+ * Copyright (c) 2023 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vlib/vlib.h>
+#include <vnet/plugin/plugin.h>
+#include <vpp/app/version.h>
+VLIB_PLUGIN_REGISTER () = {
+  .version = VPP_BUILD_VER,
+  .description = "OSI plugin",
+};
\ No newline at end of file
index ca35d0d..b7a1bbe 100644 (file)
@@ -606,19 +606,6 @@ list(APPEND VNET_HEADERS
   ipsec/ah.h
 )
 
-##############################################################################
-# Layer 3 protocol: osi
-##############################################################################
-list(APPEND VNET_SOURCES
-  osi/node.c
-  osi/osi.c
-  osi/pg.c
-)
-
-list(APPEND VNET_HEADERS
-  osi/osi.h
-)
-
 ##############################################################################
 # Layer 4 protocol: tcp
 ##############################################################################
index 4cbf17d..e17eaa6 100644 (file)
@@ -208,7 +208,6 @@ add_protocol (llc_main_t * pm, llc_protocol_t protocol, char *protocol_name)
 static clib_error_t *
 llc_init (vlib_main_t * vm)
 {
-  clib_error_t *error;
   llc_main_t *pm = &llc_main;
 
   clib_memset (pm, 0, sizeof (pm[0]));
@@ -221,9 +220,6 @@ llc_init (vlib_main_t * vm)
   foreach_llc_protocol;
 #undef _
 
-  if ((error = vlib_call_init_function (vm, snap_init)))
-    return error;
-
   return vlib_call_init_function (vm, llc_input_init);
 }
 
index d1ee694..dee0e06 100644 (file)
@@ -313,10 +313,6 @@ llc_register_input_protocol (vlib_main_t * vm,
     clib_error_t *error = vlib_call_init_function (vm, llc_input_init);
     if (error)
       clib_error_report (error);
-    /* Otherwise, osi_input_init will wipe out e.g. the snap init */
-    error = vlib_call_init_function (vm, osi_input_init);
-    if (error)
-      clib_error_report (error);
   }
 
   pi = llc_get_protocol_info (lm, protocol);
index 9bee415..bf59942 100644 (file)
@@ -192,8 +192,9 @@ snap_init (vlib_main_t * vm)
   return vlib_call_init_function (vm, snap_input_init);
 }
 
-VLIB_INIT_FUNCTION (snap_init);
-
+VLIB_INIT_FUNCTION (snap_init) = {
+  .runs_after = VLIB_INITS ("llc_init"),
+};
 
 /*
  * fd.io coding-style-patch-verification: ON