-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INT DEMO (was ONS DEMO): Version 2.0 of INT source added
- Loading branch information
Tomas Zavodnik
committed
Nov 2, 2018
1 parent
b195c84
commit c1e1383
Showing
5 changed files
with
1,394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// defines.p4: Constant definitions of Netcope P4 INT source & transit processing example. | ||
// Copyright (C) 2018 Netcope Technologies, a.s. | ||
// Author(s): Michal Kekely <[email protected]> | ||
// | ||
|
||
// | ||
// This file is part of Netcope distribution (https://github.com/netcope). | ||
// Copyright (c) 2018 Netcope Technologies, a.s. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
#define INT_HEADER_LEN_WORD 4 | ||
#define CPU_PORT 128 | ||
#define ETH_PORT 0 | ||
|
||
#define GTP_ENC_SIZE 36 | ||
#define IPV4_HEADER_SIZE 20 | ||
|
||
#define CONST_HOP_LATENCY 1 | ||
#define CONST_Q_OCCUPANCY 2 | ||
|
||
// Protocol numbers ============================================================ | ||
#define PROTOCOL_IPV4 0x0800 | ||
#define PROTOCOL_IPV6 0x86dd | ||
#define PROTOCOL_TCP 0x06 | ||
#define PROTOCOL_UDP 0x11 | ||
#define GTPV1_PORT_VALUE 2152 | ||
#define GTPV1_PORT GTPV1_PORT_VALUE mask 0x00FFFF | ||
#define INT_DSCP_WDP 0x200000 mask 0x3F0000 | ||
#define INT_DSCP 0x20 | ||
|
||
// Select statements of INT stack ============================================== | ||
// The select consists of: | ||
// instruction count (5b), instruction bit map (16b), lenght (8b) | ||
#define INT_SELECT_CONCAT md_netcope.INTinscnt,md_netcope.INTinsmap,md_netcope.INTlen | ||
// When choosing the next instruction we want to mask out length and IC | ||
// and then only set the corresponding bit | ||
#define MASK_SWITCH_ID 0x00800000 | ||
#define VAL_SWITCH_ID MASK_SWITCH_ID | ||
#define MASK_PORT_IDS 0x00400000 | ||
#define VAL_PORT_IDS MASK_PORT_IDS | ||
#define MASK_HOP_LATENCY 0x00200000 | ||
#define VAL_HOP_LATENCY MASK_HOP_LATENCY | ||
#define MASK_Q_OCCUPANCY 0x00100000 | ||
#define VAL_Q_OCCUPANCY MASK_Q_OCCUPANCY | ||
#define MASK_INGRESS_TSTAMP 0x00080000 | ||
#define VAL_INGRESS_TSTAMP MASK_INGRESS_TSTAMP | ||
#define MASK_EGRESS_TSTAMP 0x00040000 | ||
#define VAL_EGRESS_TSTAMP MASK_EGRESS_TSTAMP | ||
#define MASK_Q_CONGESTION 0x00020000 | ||
#define VAL_Q_CONGESTION MASK_Q_CONGESTION | ||
#define MASK_EGRESS_PORT_TX_UTIL 0x00010000 | ||
#define VAL_EGRESS_PORT_TX_UTIL MASK_EGRESS_PORT_TX_UTIL | ||
// For length set either only length bits or also IC bits | ||
#define MLI 0x1F0000FF | ||
#define ML 0x000000FF | ||
// Expected INT lengths based on number of hops (and IC) | ||
// 0 hops always mean length of 4 | ||
#define LEN_HOPS_0 0x00000004 mask ML | ||
// 1 hop means length of 4+(IC*1) - this means 5 for IC=1, 6 for IC=2 and so on up to 12 for IC=8 | ||
#define LEN_HOPS_1 0x01000005 mask MLI, 0x02000006 mask MLI, 0x03000007 mask MLI, 0x04000008 mask MLI, 0x05000009 mask MLI, 0x0600000A mask MLI, 0x0700000B mask MLI, 0x0800000C mask MLI | ||
// 2 hops mean length of 4+(IC*2) - this means 6 for IC=1, 8 for IC=2 and so on up to 20 for IC=8 | ||
#define LEN_HOPS_2 0x01000006 mask MLI, 0x02000008 mask MLI, 0x0300000A mask MLI, 0x0400000C mask MLI, 0x0500000E mask MLI, 0x06000010 mask MLI, 0x07000012 mask MLI, 0x08000014 mask MLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
// | ||
// headers.p4: Header definitions of Netcope P4 INT source & transit processing example. | ||
// Copyright (C) 2018 Netcope Technologies, a.s. | ||
// Author(s): Michal Kekely <[email protected]> | ||
// | ||
|
||
// | ||
// This file is part of Netcope distribution (https://github.com/netcope). | ||
// Copyright (c) 2018 Netcope Technologies, a.s. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3. | ||
// | ||
// This program is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
|
||
// Ethernet ==================================================================== | ||
header_type ethernet_t { | ||
fields { | ||
dstAddr : 48; | ||
srcAddr : 48; | ||
etherType : 16; | ||
} | ||
} | ||
|
||
// IP (v4, v6) ================================================================ | ||
header_type ipv4_t { | ||
fields { | ||
version : 4; | ||
ihl : 4; | ||
dscp : 6; | ||
ecn : 2; | ||
totalLen : 16; | ||
id : 16; | ||
flags : 3; | ||
fragOffset : 13; | ||
ttl : 8; | ||
protocol : 8; | ||
hdrChecksum : 16; | ||
srcAddr : 32; | ||
dstAddr : 32; | ||
} | ||
|
||
//length : (ihl)*4; | ||
//max_length : 60; | ||
} | ||
|
||
header_type ipv6_t { | ||
fields { | ||
ver : 4; | ||
trafClass : 8; | ||
flowLab : 20; | ||
payLen : 16; | ||
nextHead : 8; | ||
hopLim : 8; | ||
srcAddr : 128; | ||
dstAddr : 128; | ||
} | ||
} | ||
|
||
// L4 protocols ================================================================ | ||
header_type tcp_t { | ||
fields { | ||
srcPort : 16; | ||
dstPort : 16; | ||
seqNum : 32; | ||
ackNum : 32; | ||
dataOffset : 4; | ||
reserved : 3; | ||
flags : 9; | ||
winSize : 16; | ||
csum : 16; | ||
urgPoint : 16; | ||
} | ||
|
||
//length : (dataOffset)*4; | ||
//max_length : 60; | ||
} | ||
|
||
header_type udp_t { | ||
fields { | ||
srcPort : 16; | ||
dstPort : 16; | ||
len : 16; | ||
csum : 16; | ||
} | ||
} | ||
|
||
// GTP ========================================================================= | ||
header_type gtp_start_t { | ||
fields { | ||
version : 3; | ||
protType : 1; | ||
reserved : 1; | ||
flags : 3; | ||
messageType : 8; | ||
messageLen : 16; | ||
teid : 32; | ||
} | ||
} | ||
|
||
header_type gtp_optional_t { | ||
fields { | ||
seqNum : 16; | ||
npduNum : 8; | ||
nextExtHdr : 8; | ||
} | ||
} | ||
|
||
// INT ========================================================================= | ||
// INT shim header | ||
header_type intl4_shim_t { | ||
fields { | ||
int_type : 8; | ||
rsvd1 : 8; | ||
len : 8; | ||
rsvd2 : 8; | ||
} | ||
} | ||
|
||
// INT tail header for TCP/UDP | ||
header_type intl4_tail_t { | ||
fields { | ||
next_proto : 8; | ||
dest_port : 16; | ||
dscp : 8; | ||
} | ||
} | ||
|
||
// INT headers | ||
header_type int_header_v1_0_t { | ||
fields { | ||
ver : 4; | ||
rep : 2; | ||
c : 1; | ||
e : 1; | ||
m : 1; | ||
rsvd1 : 10; | ||
ins_cnt : 5; | ||
remaining_hop_cnt : 8; | ||
instruction_map : 16; | ||
rsvd2 : 16; | ||
} | ||
} | ||
|
||
header_type int_header_v0_5_t { | ||
fields { | ||
ver : 4; | ||
rep : 2; | ||
c : 1; | ||
e : 1; | ||
rsvd1 : 3; | ||
ins_cnt : 5; | ||
max_hop_count : 8; | ||
total_hop_count : 8; | ||
instruction_map : 16; | ||
rsvd2 : 16; | ||
} | ||
} | ||
|
||
// INT meta-value headers - different header for each value type | ||
header_type int_switch_id_t { | ||
fields { | ||
switch_id : 32; | ||
} | ||
} | ||
|
||
header_type int_port_ids_t { | ||
fields { | ||
ingress_port_id : 16; | ||
egress_port_id : 16; | ||
} | ||
} | ||
|
||
header_type int_hop_latency_t { | ||
fields { | ||
hop_latency : 32; | ||
} | ||
} | ||
|
||
header_type int_q_occupancy_t { | ||
fields { | ||
q_id : 8; | ||
q_occupancy : 24; | ||
} | ||
} | ||
|
||
header_type int_ingress_tstamp_t { | ||
fields { | ||
ingress_tstamp : 32; | ||
} | ||
} | ||
|
||
header_type int_egress_tstamp_t { | ||
fields { | ||
egress_tstamp : 32; | ||
} | ||
} | ||
|
||
header_type int_q_congestion_t { | ||
fields { | ||
q_id : 8; | ||
q_congestion : 24; | ||
} | ||
} | ||
|
||
header_type int_egress_port_tx_util_t { | ||
fields { | ||
egress_port_tx_util : 32; | ||
} | ||
} | ||
|
||
// Metadata ==================================================================== | ||
// Oudput netcope metadata | ||
header_type netcope_metadata_t { | ||
fields { | ||
valid_int : 1; | ||
hop0_vld : 1; | ||
hop1_vld : 1; | ||
IPsrc : 32; | ||
IPdst : 32; | ||
IPver : 8; | ||
L4src : 16; | ||
L4dst : 16; | ||
L4proto : 8; | ||
INTinsmap : 16; | ||
INTinscnt : 5; | ||
INTlen : 8; | ||
} | ||
} | ||
|
||
// Internal metadata | ||
header_type internal_metadata_t { | ||
fields { | ||
dscp : 6; | ||
INTlenB : 10; | ||
} | ||
} | ||
|
||
header_type int_meta_t { | ||
fields { | ||
source : 1; | ||
sink : 1; | ||
switch_id : 32; | ||
insert_byte_cnt : 7; | ||
} | ||
} |
Oops, something went wrong.