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>
This commit is contained in:
Hadi Rayan Al-Sandid
2024-08-01 17:10:54 +02:00
committed by Beno�t Ganne
parent 85ce93160f
commit 8629336fa5
12 changed files with 70 additions and 33 deletions

View File

@ -805,6 +805,7 @@ operationalize
Optimisations
optimised
os
osi
outacl
packagecloud
papi

View File

@ -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
)

View File

@ -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

View 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>

View 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

View 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
{

23
src/plugins/osi/plugin.c Normal file
View File

@ -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",
};

View 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
##############################################################################

View 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);
}

View 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);

View 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