Commit e071dfc4 authored by Georgios P. Katsikas's avatar Georgios P. Katsikas
Browse files

feat: P4 L2 simple service handler

parent 80b30827
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ from .l3slice_ietfslice.L3SliceIETFSliceServiceHandler import L3NMSliceIETFSlice
from .microwave.MicrowaveServiceHandler import MicrowaveServiceHandler
from .p4_dummy_l1.p4_dummy_l1_service_handler import P4DummyL1ServiceHandler
from .p4_fabric_tna_int.p4_fabric_tna_int_service_handler import P4FabricINTServiceHandler
from .p4_fabric_tna_l2_simple.p4_fabric_tna_l2_simple_service_handler import P4FabricL2SimpleServiceHandler
from .tapi_tapi.TapiServiceHandler import TapiServiceHandler
from .tapi_xr.TapiXrServiceHandler import TapiXrServiceHandler
from .optical_tfs.OpticalTfsServiceHandler import OpticalTfsServiceHandler
@@ -118,6 +119,12 @@ SERVICE_HANDLERS = [
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (P4FabricL2SimpleServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE: ServiceTypeEnum.SERVICETYPE_L2NM,
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (L2NM_IETFL2VPN_ServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_L2NM,
+13 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.
+69 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

"""
Common objects and methods for L2 forwarding based on the SD-Fabric dataplane model.
This dataplane covers both software based and hardware-based Stratum-enabled P4 switches,
such as the BMv2 software switch and Intel's Tofino/Tofino-2 switches.

SD-Fabric repo: https://github.com/stratum/fabric-tna
SD-Fabric docs: https://docs.sd-fabric.org/master/index.html
"""

import logging
from common.proto.context_pb2 import ConfigActionEnum

from service.service.service_handlers.p4_fabric_tna_commons.p4_fabric_tna_commons import *

LOGGER = logging.getLogger(__name__)

# L2 simple service handler settings
FORWARDING_LIST = "fwd_list"
HOST_MAC = "host_mac"

def rules_set_up_port_host(
        port : int,
        vlan_id : int,
        action : ConfigActionEnum, # type: ignore
        fwd_type=FORWARDING_TYPE_BRIDGING,
        eth_type=ETHER_TYPE_IPV4):
    # This is a host facing port
    port_type = PORT_TYPE_HOST

    return rules_set_up_port(
        port=port,
        port_type=port_type,
        fwd_type=fwd_type,
        vlan_id=vlan_id,
        action=action,
        eth_type=eth_type
    )

def rules_set_up_port_switch(
        port : int,
        vlan_id : int,
        action : ConfigActionEnum, # type: ignore
        fwd_type=FORWARDING_TYPE_BRIDGING,
        eth_type=ETHER_TYPE_IPV4):
    # This is a switch facing port
    port_type = PORT_TYPE_SWITCH

    return rules_set_up_port(
        port=port,
        port_type=port_type,
        fwd_type=fwd_type,
        vlan_id=vlan_id,
        action=action,
        eth_type=eth_type
    )
+518 −0

File added.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
@@ -125,6 +125,20 @@ bash src/tests/p4-fabric-tna/run_test_02b_sbi_deprovision_int_l2_l3_acl.sh
To avoid interacting with the switch using low-level P4 rules (via the SBI), we created modular network services, which allow users to easily provision L2, L3, ACL, and INT network functions.
These services require users to define the service endpoints as well as some high-level service configuration, while leaving the rest of complexity to tailored service handlers that interact with the SBI on behalf of the user.

#### Provision L2 network service via the Service API

```shell
cd ~/tfs-ctrl/
bash src/tests/p4-fabric-tna/run_test_03a_service_provision_l2.sh
```

#### Deprovision L2 network service via the Service API

```shell
cd ~/tfs-ctrl/
bash src/tests/p4-fabric-tna/run_test_03b_service_deprovision_l2.sh
```

#### Provision INT service via the Service API

```shell
Loading