diff options
author | Hadi Rayan Al-Sandid <halsandi@cisco.com> | 2024-08-01 17:10:54 +0200 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2024-08-22 08:00:52 +0000 |
commit | 8629336fa502b5859ed46bcc1976c824470092b3 (patch) | |
tree | 72c5757fba8d7009111a24cd6f814cf13b386bec /src | |
parent | 85ce93160fa71c5e6fb9140704c07e6d8989889d (diff) |
misc: move osi to plugin
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 <halsandi@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/osi/CMakeLists.txt | 24 | ||||
-rw-r--r-- | src/plugins/osi/FEATURE.yaml | 11 | ||||
-rw-r--r-- | src/plugins/osi/node.c (renamed from src/vnet/osi/node.c) | 2 | ||||
-rw-r--r-- | src/plugins/osi/osi.c (renamed from src/vnet/osi/osi.c) | 14 | ||||
-rw-r--r-- | src/plugins/osi/osi.h (renamed from src/vnet/osi/osi.h) | 0 | ||||
-rw-r--r-- | src/plugins/osi/pg.c (renamed from src/vnet/osi/pg.c) | 2 | ||||
-rw-r--r-- | src/plugins/osi/plugin.c | 23 | ||||
-rw-r--r-- | src/vnet/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/vnet/llc/llc.c | 4 | ||||
-rw-r--r-- | src/vnet/llc/node.c | 4 | ||||
-rw-r--r-- | src/vnet/snap/snap.c | 5 |
11 files changed, 69 insertions, 33 deletions
diff --git a/src/plugins/osi/CMakeLists.txt b/src/plugins/osi/CMakeLists.txt new file mode 100644 index 00000000000..8ab014770ea --- /dev/null +++ b/src/plugins/osi/CMakeLists.txt @@ -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 index 00000000000..337be1c7146 --- /dev/null +++ b/src/plugins/osi/FEATURE.yaml @@ -0,0 +1,11 @@ +--- +name: OSI plugin +maintainer: + - community <vpp-dev@lists.fd.io> +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 diff --git a/src/vnet/osi/node.c b/src/plugins/osi/node.c index 9edc354cda7..a36b1525e0e 100644 --- a/src/vnet/osi/node.c +++ b/src/plugins/osi/node.c @@ -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> diff --git a/src/vnet/osi/osi.c b/src/plugins/osi/osi.c index 9556481448a..67c7053f388 100644 --- a/src/vnet/osi/osi.c +++ b/src/plugins/osi/osi.c @@ -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 diff --git a/src/vnet/osi/osi.h b/src/plugins/osi/osi.h index fb248ed9cc5..fb248ed9cc5 100644 --- a/src/vnet/osi/osi.h +++ b/src/plugins/osi/osi.h diff --git a/src/vnet/osi/pg.c b/src/plugins/osi/pg.c index c87a869b28d..3bac693c127 100644 --- a/src/vnet/osi/pg.c +++ b/src/plugins/osi/pg.c @@ -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 index 00000000000..5fc412e093e --- /dev/null +++ b/src/plugins/osi/plugin.c @@ -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 diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt index ca35d0dba4e..b7a1bbe58c9 100644 --- a/src/vnet/CMakeLists.txt +++ b/src/vnet/CMakeLists.txt @@ -607,19 +607,6 @@ list(APPEND VNET_HEADERS ) ############################################################################## -# 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 ############################################################################## list(APPEND VNET_SOURCES diff --git a/src/vnet/llc/llc.c b/src/vnet/llc/llc.c index 4cbf17d48df..e17eaa6fd25 100644 --- a/src/vnet/llc/llc.c +++ b/src/vnet/llc/llc.c @@ -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); } diff --git a/src/vnet/llc/node.c b/src/vnet/llc/node.c index d1ee6948269..dee0e060460 100644 --- a/src/vnet/llc/node.c +++ b/src/vnet/llc/node.c @@ -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); diff --git a/src/vnet/snap/snap.c b/src/vnet/snap/snap.c index 9bee415390a..bf5994271a4 100644 --- a/src/vnet/snap/snap.c +++ b/src/vnet/snap/snap.c @@ -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 |