Skip to content

Commit

Permalink
Merge pull request #2 from lnobach/lnobach-dev
Browse files Browse the repository at this point in the history
Initial commit of fabric version
  • Loading branch information
ccascone committed Nov 5, 2018
2 parents 8381f45 + 677ce3c commit e69f44e
Show file tree
Hide file tree
Showing 12 changed files with 2,548 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ BNG/PPPoE P4 software

## Generic

The directory `generic` contains a cross-platform P4 implementation
The directory `generic` contains a cross-platform P4 implementation
for devices intended to be attached to a leaf switch, tested against bmv2.

## Fabric

The directory `fabric` contains a P4 implementation integrated into a
leaf switch of a CORD-like leaf-spine topology. The code has been tested
against the Barefoot Tofino.
16 changes: 16 additions & 0 deletions fabric/NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This program, the P4 Service Edge data plane, is designed to terminate
residential network access customers using PPPoE.

Authors: Jeremias Blendin, Leonhard Nobach

This program is licensed under the Apache-2.0 License (http://opensource.org/licenses/Apache-2.0). See also file LICENSING
Development sponsored by Deutsche Telekom AG [ opensource@telekom.de<mailto:opensource@telekom.de> ]

Modification sections:
1. 2017-2018, Blendin, Jeremias and Nobach, Leonhard: Initial Development.

Disclaimer of Warranty
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION

Limitation of Liability'
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
52 changes: 52 additions & 0 deletions fabric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

P4 CORD Service Edge
====================

This repository contains a P4 program that implements
a residential network access service data plane. The data plane has been
designed to support a typical large-scale residential broadband access
network using PPPoE for subscriber access.

The repository contains the data plane only, no control plane is included at
the moment. The current status of the program is described in the following
status section.

Status
------

The generic part of the service edge should be understood as
a prototype to support the subscriber termination and has not been tested
in detail yet. The code does not include a control plane.
All tests have been conducted using the Barefoot SDE 8.0.0.19 and the Barefoot
Tofino simulator.

Open tasks

- Running tests on an Barefoot Tofino hardware switch
- Testing the data plane together with a control plane and physical residential
gateway devices

Directory Layout
----------------

'''
./p4src
The P4 source code.

./wireshark-dissectors/
Wireshark dissector for the data plane to control plane communication protocol.
'''

Build Instructions
------------------

Requirements: Barefoot SDE 8.0.0.19

```
cd $SDE
./p4_build.sh <se.p4 dir>/p4src/se.p4
```

For details on testing and the Wireshark dissectors, please refer to
`README.md` in the respective folders.

133 changes: 133 additions & 0 deletions fabric/p4src/acl.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* Copyright 2018-present Open Networking Foundation and Barefoot Networks
*
* This file is adapted from an original acl.p4 from Barefoot Networks.
*
* Contributed and sponsored by Deutsche Telekom AG.
* Originally developed as part of the D-Nets 6 P4 Service Edge project
* in collaboration with Technische Universitaet Darmstadt.
* Authors: Jeremias Blendin, Leonhard Nobach
*
* 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.
*
* For details see the file LICENSE in the top project directory.
*/

/*****************************************************************************/
/* Egress System ACL */
/*****************************************************************************/

action ingress_redirect_to_cpu_with_reason(reason_code) {
modify_field(cpu_md.reason_code, reason_code);
modify_field(cpu_md.handling_type, HANDLING_TYPE_ERROR);
modify_field(serviceedge_md.fwd_net_proto, NET_PROTO_CP);
modify_field(serviceedge_md.out_net_proto, NET_PROTO_CP);
}

/*
MRU/MTU check for the tunnel should be done in
the processor. The details have not been worked out yet.
action ingress_pkt_too_big() {
ingress_redirect_to_cpu_with_reason(CPU_ERROR_PKT_TOO_BIG);
}
*/

action egress_copy_to_cpu(mirror_id) {
clone_egress_pkt_to_egress(mirror_id, error_fields);
}

action egress_redirect_to_cpu(mirror_id) {
egress_copy_to_cpu(mirror_id);
drop();
}

action egress_copy_to_cpu_with_reason(mirror_id, reason_code) {
modify_field(cpu_md.reason_code, reason_code);
egress_copy_to_cpu(mirror_id);
}

action egress_redirect_to_cpu_with_reason(mirror_id, reason_code) {
egress_copy_to_cpu_with_reason(mirror_id, reason_code);
drop();
}


action egress_pkt_too_big(mirror_id) {
modify_field(cpu_md.expected_value, serviceedge_md.mtu_out);
modify_field(cpu_md.actual_value, serviceedge_md.pkt_len_out);
modify_field(cpu_md.handling_type, HANDLING_TYPE_ERROR);
modify_field(serviceedge_md.out_net_proto, NET_PROTO_CP);
egress_copy_to_cpu_with_reason(mirror_id, CPU_ERROR_PKT_TOO_BIG);
drop();
}


table ingress_system_acl {
reads {
serviceedge_md.in_net_proto : ternary;
serviceedge_md.fwd_net_proto : ternary;
serviceedge_md.out_net_proto : ternary;
serviceedge_md.processor_ingress : ternary;
serviceedge_md.processor_egress : ternary;
serviceedge_md.next_hop_id : ternary;
mcast_md.is_multicast : ternary;
ipv4.valid : ternary;
ipv4.ttl : ternary;
ipv4.totalLen : ternary;
ipv6.valid : ternary;
ipv6.hopLimit : ternary;
ipv6.payloadLen : ternary;
}
actions {
_nop;
_drop;
ingress_redirect_to_cpu_with_reason;
}
size : 64;
}

control process_ingress_system_acl {
apply(ingress_system_acl);
}

table egress_system_acl {
reads {
ig_intr_md_for_tm.packet_color : ternary;
eg_intr_md.egress_port : ternary;
eg_intr_md_from_parser_aux.clone_src : ternary;
cpu_md.packet_color : ternary;
pcr_bng_md.ds_packet_color : ternary;
serviceedge_md.pkt_len_out : ternary;
serviceedge_md.mtu_out : ternary;
serviceedge_md.mtu_check : ternary;
serviceedge_md.in_net_proto : ternary;
serviceedge_md.fwd_net_proto : ternary;
serviceedge_md.out_net_proto : ternary;
serviceedge_md.next_hop_id : ternary;
}
actions {
_nop;
_drop;
egress_pkt_too_big;
egress_copy_to_cpu;
egress_redirect_to_cpu;
egress_copy_to_cpu_with_reason;
egress_redirect_to_cpu_with_reason;
}
size : 64;
}

control process_egress_system_acl {
apply(egress_system_acl);
}

83 changes: 83 additions & 0 deletions fabric/p4src/constants.p4
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright 2018-present Open Networking Foundation
*
* Contributed and sponsored by Deutsche Telekom AG.
* Originally developed as part of the D-Nets 6 P4 Service Edge project
* in collaboration with Technische Universitaet Darmstadt.
* Authors: Jeremias Blendin, Leonhard Nobach
*
* 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.
*
* For details see the file LICENSE in the top project directory.
*/


#define ROUTE_CAPACITY 256
#define NEXT_HOP_CAPACITY 256
#define ACL_CAPACITY 128

#define VLAN_SERVICE_VID 7

#define MPLS_TUNNEL 9000
#define MPLS_IPV4 16384
#define MPLS_IPV6 16385
#define MPLS_IP 16386

#define NEXT_HOP_CP 255

#define FALSE 0
#define TRUE 1

#define IN_CLASSIFY_TABLE_SIZE 64

#define PROCESSOR_NONE 0
#define PROCESSOR_SR_FWD 1
#define PROCESSOR_SR_TERM 2
#define PROCESSOR_BNG 3
#define PROCESSOR_WHOLESALE 4

#define NET_PROTO_UNDEFINED 0
#define NET_PROTO_IP 1
#define NET_PROTO_SR 2 // Segment Routing
#define NET_PROTO_CP 3 // Control Plane

#define PKT_LEN_OPERATOR_NOCHANGE 0
#define PKT_LEN_OPERATOR_INC 0
#define PKT_LEN_OPERATOR_DEC 0

#define CPU_ERROR_NONE 0
#define CPU_ERROR_PKT_TOO_BIG 1
#define HANDLING_TYPE_ERROR 1
#define HANDLING_TYPE_CP_PRC_US 2
#define HANDLING_TYPE_PRC_DS_CP 3

//#define CPU_MIRROR_SESSION_ID 250
#define CPU_MIRROR_SESSION_ID 100

#define CPU_PORT 64

#define SR_SERVICE_TYPE_NONE 0
#define SR_SERVICE_TYPE_IP 1
#define SR_SERVICE_TYPE_SUBSCRIBER_TUNNEL 2

#define ETHERTYPE_IPV4 0x0800
#define ETHERTYPE_IPV6 0x86DD
#define ETHERTYPE_VLAN 0x8100
#define ETHERTYPE_PPPOED 0x8863
#define ETHERTYPE_PPPOES 0x8864
#define ETHERTYPE_MPLS 0x8847
#define ETHERTYPE_CPUHEADER 0xeeee

#define PPPOE_PROTOCOL_IPV4 0x0021
#define PPPOE_PROTOCOL_IPV6 0x0057

Loading

0 comments on commit e69f44e

Please sign in to comment.