mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-18 02:41:49 +02:00
[ONOS-7154] Add DSCP bit support as an INT header indicator
Change-Id: I2e80dd64b8c73808e96bba7470c1c331b562c45e
This commit is contained in:
parent
8bcd5863ff
commit
8be0339935
@ -38,7 +38,8 @@ header ethernet_t {
|
||||
header ipv4_t {
|
||||
bit<4> version;
|
||||
bit<4> ihl;
|
||||
bit<8> diffserv;
|
||||
bit<6> dscp;
|
||||
bit<2> ecn;
|
||||
bit<16> len;
|
||||
bit<16> identification;
|
||||
bit<3> flags;
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
#include "defines.p4"
|
||||
|
||||
const next_hop_id_t INT_PORT = 54321;
|
||||
/* indicate INT at LSB of DSCP */
|
||||
const bit<6> INT_DSCP = 0x1;
|
||||
|
||||
typedef bit<48> timestamp_t;
|
||||
typedef bit<32> switch_id_t;
|
@ -84,12 +84,11 @@ header intl4_tail_t {
|
||||
bit<8> dscp;
|
||||
}
|
||||
|
||||
header int_metadata_t {
|
||||
struct int_metadata_t {
|
||||
switch_id_t switch_id;
|
||||
bit<16> insert_byte_cnt;
|
||||
bit<1> source;
|
||||
bit<1> sink;
|
||||
bit<16> origin_port;
|
||||
bit<8> mirror_id;
|
||||
bit<16> flow_id;
|
||||
bit<8> metadata_len;
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
|
||||
/* -*- P4_16 -*- */
|
||||
#ifndef __PARSER__
|
||||
#define __PARSER__
|
||||
#ifndef __INT_PARSER__
|
||||
#define __INT_PARSER__
|
||||
|
||||
parser int_parser (
|
||||
packet_in packet,
|
||||
@ -54,15 +54,20 @@ parser int_parser (
|
||||
|
||||
state parse_tcp {
|
||||
packet.extract(hdr.tcp);
|
||||
transition accept;
|
||||
local_metadata.l4_src_port = hdr.tcp.src_port;
|
||||
local_metadata.l4_dst_port = hdr.tcp.dst_port;
|
||||
transition select((hdr.ipv4.dscp & INT_DSCP) == INT_DSCP) {
|
||||
true: parse_intl4_shim;
|
||||
default: accept;
|
||||
}
|
||||
}
|
||||
|
||||
state parse_udp {
|
||||
packet.extract(hdr.udp);
|
||||
local_metadata.l4_src_port = hdr.udp.src_port;
|
||||
local_metadata.l4_dst_port = hdr.udp.dst_port;
|
||||
transition select(hdr.udp.dst_port) {
|
||||
INT_PORT: parse_intl4_shim;
|
||||
transition select((hdr.ipv4.dscp & INT_DSCP) == INT_DSCP) {
|
||||
true: parse_intl4_shim;
|
||||
default: accept;
|
||||
}
|
||||
}
|
||||
|
@ -23,27 +23,34 @@ control process_int_sink (
|
||||
inout headers_t hdr,
|
||||
inout local_metadata_t local_metadata,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
action restore_header () {
|
||||
hdr.udp.dst_port = hdr.intl4_tail.dest_port;
|
||||
hdr.ipv4.dscp = (bit<6>)hdr.intl4_tail.dscp;
|
||||
}
|
||||
|
||||
action int_sink() {
|
||||
// restore length fields of IPv4 header and UDP header
|
||||
hdr.ipv4.len = hdr.ipv4.len - (bit<16>)((hdr.intl4_shim.len - (bit<8>)hdr.int_header.ins_cnt) << 2);
|
||||
hdr.udp.length_ = hdr.udp.length_ - (bit<16>)((hdr.intl4_shim.len - (bit<8>)hdr.int_header.ins_cnt) << 2);
|
||||
// restore original dst port
|
||||
local_metadata.int_meta.origin_port = hdr.intl4_tail.dest_port;
|
||||
// remove all the INT information from the packet
|
||||
hdr.int_header.setInvalid();
|
||||
hdr.int_data.setInvalid();
|
||||
hdr.intl4_shim.setInvalid();
|
||||
hdr.intl4_tail.setInvalid();
|
||||
}
|
||||
|
||||
action restore_port () {
|
||||
hdr.udp.dst_port = local_metadata.int_meta.origin_port;
|
||||
hdr.int_switch_id.setInvalid();
|
||||
hdr.int_port_ids.setInvalid();
|
||||
hdr.int_hop_latency.setInvalid();
|
||||
hdr.int_q_occupancy.setInvalid();
|
||||
hdr.int_ingress_tstamp.setInvalid();
|
||||
hdr.int_egress_tstamp.setInvalid();
|
||||
hdr.int_q_congestion.setInvalid();
|
||||
hdr.int_egress_tx_util.setInvalid();
|
||||
}
|
||||
|
||||
apply {
|
||||
if (local_metadata.int_meta.sink == 1) {
|
||||
restore_header();
|
||||
int_sink();
|
||||
restore_port();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,26 +52,26 @@ control process_int_source (
|
||||
hdr.intl4_tail.setValid();
|
||||
hdr.intl4_tail.next_proto = hdr.ipv4.protocol;
|
||||
hdr.intl4_tail.dest_port = local_metadata.l4_dst_port;
|
||||
hdr.intl4_tail.dscp = 0; // not used
|
||||
|
||||
hdr.udp.dst_port = INT_PORT;
|
||||
hdr.intl4_tail.dscp = (bit<8>) hdr.ipv4.dscp;
|
||||
|
||||
// add the header len (8 bytes) to total len
|
||||
hdr.ipv4.len = hdr.ipv4.len + 16;
|
||||
hdr.udp.length_ = hdr.udp.length_ + 16;
|
||||
}
|
||||
action int_source_dscp(bit<8> max_hop, bit<5> ins_cnt, bit<4> ins_mask0003, bit<4> ins_mask0407) {
|
||||
int_source(max_hop, ins_cnt, ins_mask0003, ins_mask0407);
|
||||
hdr.ipv4.dscp = INT_DSCP;
|
||||
}
|
||||
|
||||
table tb_int_source {
|
||||
key = {
|
||||
local_metadata.int_meta.sink: exact;
|
||||
local_metadata.int_meta.source: exact;
|
||||
hdr.ipv4.src_addr: ternary;
|
||||
hdr.ipv4.dst_addr: ternary;
|
||||
local_metadata.l4_src_port: ternary;
|
||||
local_metadata.l4_dst_port: ternary;
|
||||
}
|
||||
actions = {
|
||||
int_source; // sink = 0 & source = 1
|
||||
int_source_dscp;
|
||||
}
|
||||
counters = counter_int_source;
|
||||
size = 1024;
|
||||
@ -87,18 +87,17 @@ control process_set_source_sink (
|
||||
inout local_metadata_t local_metadata,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
direct_counter(CounterType.packets_and_bytes) counter_set_source;
|
||||
direct_counter(CounterType.packets_and_bytes) counter_set_sink;
|
||||
direct_counter(CounterType.packets_and_bytes) counter_set_source_sink;
|
||||
|
||||
action int_set_source () {
|
||||
local_metadata.int_meta.source = 1;
|
||||
local_metadata.int_meta.source = 1;
|
||||
}
|
||||
|
||||
action int_set_sink () {
|
||||
local_metadata.int_meta.sink = 1;
|
||||
}
|
||||
|
||||
table tb_set_source {
|
||||
table tb_set_source_sink {
|
||||
key = {
|
||||
hdr.ipv4.src_addr: ternary;
|
||||
hdr.ipv4.dst_addr: ternary;
|
||||
@ -107,30 +106,14 @@ control process_set_source_sink (
|
||||
}
|
||||
actions = {
|
||||
int_set_source;
|
||||
}
|
||||
counters = counter_set_source;
|
||||
size = 1024;
|
||||
}
|
||||
|
||||
table tb_set_sink {
|
||||
key = {
|
||||
hdr.ipv4.src_addr: ternary;
|
||||
hdr.ipv4.dst_addr: ternary;
|
||||
local_metadata.l4_src_port: ternary;
|
||||
local_metadata.l4_dst_port: ternary;
|
||||
}
|
||||
actions = {
|
||||
int_set_sink;
|
||||
}
|
||||
counters = counter_set_sink;
|
||||
counters = counter_set_source_sink;
|
||||
size = 1024;
|
||||
}
|
||||
|
||||
apply {
|
||||
if (hdr.udp.isValid()) {
|
||||
tb_set_source.apply();
|
||||
tb_set_sink.apply();
|
||||
}
|
||||
tb_set_source_sink.apply();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -307,6 +307,8 @@ control process_int_outer_encap (
|
||||
}
|
||||
action int_update_udp() {
|
||||
hdr.udp.length_ = hdr.udp.length_ + local_metadata.int_meta.insert_byte_cnt;
|
||||
}
|
||||
action int_update_shim() {
|
||||
hdr.intl4_shim.len = hdr.intl4_shim.len + (bit<8>)hdr.int_header.ins_cnt;
|
||||
}
|
||||
|
||||
@ -314,10 +316,12 @@ control process_int_outer_encap (
|
||||
if (hdr.ipv4.isValid()) {
|
||||
int_update_ipv4();
|
||||
}
|
||||
|
||||
if (hdr.intl4_shim.isValid()) {
|
||||
if (hdr.udp.isValid()) {
|
||||
int_update_udp();
|
||||
}
|
||||
if (hdr.intl4_shim.isValid()) {
|
||||
int_update_shim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "include/defines.p4"
|
||||
#include "include/headers.p4"
|
||||
#include "include/actions.p4"
|
||||
#include "include/int_defines.p4"
|
||||
#include "include/int_definitions.p4"
|
||||
#include "include/int_headers.p4"
|
||||
#include "include/packet_io.p4"
|
||||
#include "include/port_counters.p4"
|
||||
@ -53,9 +53,11 @@ control int_egress (
|
||||
apply {
|
||||
if (standard_metadata.ingress_port != CPU_PORT &&
|
||||
standard_metadata.egress_port != CPU_PORT &&
|
||||
hdr.udp.isValid()) {
|
||||
process_int_source.apply(hdr, local_metadata, standard_metadata);
|
||||
if(hdr.udp.dst_port == INT_PORT) {
|
||||
(hdr.udp.isValid() || hdr.tcp.isValid())) {
|
||||
if (local_metadata.int_meta.sink == 0 && local_metadata.int_meta.source == 1) {
|
||||
process_int_source.apply(hdr, local_metadata, standard_metadata);
|
||||
}
|
||||
if(hdr.int_header.isValid()) {
|
||||
process_int_transit.apply(hdr, local_metadata, standard_metadata);
|
||||
// update underlay header based on INT information inserted
|
||||
process_int_outer_encap.apply(hdr, local_metadata, standard_metadata);
|
||||
|
@ -47,7 +47,8 @@
|
||||
"fields" : [
|
||||
["version", 4, false],
|
||||
["ihl", 4, false],
|
||||
["diffserv", 8, false],
|
||||
["dscp", 6, false],
|
||||
["ecn", 2, false],
|
||||
["len", 16, false],
|
||||
["identification", 16, false],
|
||||
["flags", 3, false],
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -76,9 +76,9 @@ tables {
|
||||
}
|
||||
tables {
|
||||
preamble {
|
||||
id: 33573105
|
||||
name: "process_set_source_sink.tb_set_source"
|
||||
alias: "tb_set_source"
|
||||
id: 33582667
|
||||
name: "process_set_source_sink.tb_set_source_sink"
|
||||
alias: "tb_set_source_sink"
|
||||
}
|
||||
match_fields {
|
||||
id: 1
|
||||
@ -107,43 +107,6 @@ tables {
|
||||
action_refs {
|
||||
id: 16816387
|
||||
}
|
||||
action_refs {
|
||||
id: 16800567
|
||||
annotations: "@defaultonly()"
|
||||
}
|
||||
direct_resource_ids: 302036180
|
||||
size: 1024
|
||||
}
|
||||
tables {
|
||||
preamble {
|
||||
id: 33590037
|
||||
name: "process_set_source_sink.tb_set_sink"
|
||||
alias: "tb_set_sink"
|
||||
}
|
||||
match_fields {
|
||||
id: 1
|
||||
name: "hdr.ipv4.src_addr"
|
||||
bitwidth: 32
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 2
|
||||
name: "hdr.ipv4.dst_addr"
|
||||
bitwidth: 32
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 3
|
||||
name: "local_metadata.l4_src_port"
|
||||
bitwidth: 16
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 4
|
||||
name: "local_metadata.l4_dst_port"
|
||||
bitwidth: 16
|
||||
match_type: TERNARY
|
||||
}
|
||||
action_refs {
|
||||
id: 16784579
|
||||
}
|
||||
@ -151,7 +114,7 @@ tables {
|
||||
id: 16800567
|
||||
annotations: "@defaultonly()"
|
||||
}
|
||||
direct_resource_ids: 302053848
|
||||
direct_resource_ids: 301997871
|
||||
size: 1024
|
||||
}
|
||||
tables {
|
||||
@ -162,42 +125,30 @@ tables {
|
||||
}
|
||||
match_fields {
|
||||
id: 1
|
||||
name: "local_metadata.int_meta.sink"
|
||||
bitwidth: 1
|
||||
match_type: EXACT
|
||||
}
|
||||
match_fields {
|
||||
id: 2
|
||||
name: "local_metadata.int_meta.source"
|
||||
bitwidth: 1
|
||||
match_type: EXACT
|
||||
}
|
||||
match_fields {
|
||||
id: 3
|
||||
name: "hdr.ipv4.src_addr"
|
||||
bitwidth: 32
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 4
|
||||
id: 2
|
||||
name: "hdr.ipv4.dst_addr"
|
||||
bitwidth: 32
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 5
|
||||
id: 3
|
||||
name: "local_metadata.l4_src_port"
|
||||
bitwidth: 16
|
||||
match_type: TERNARY
|
||||
}
|
||||
match_fields {
|
||||
id: 6
|
||||
id: 4
|
||||
name: "local_metadata.l4_dst_port"
|
||||
bitwidth: 16
|
||||
match_type: TERNARY
|
||||
}
|
||||
action_refs {
|
||||
id: 16841774
|
||||
id: 16820636
|
||||
}
|
||||
action_refs {
|
||||
id: 16800567
|
||||
@ -423,9 +374,9 @@ actions {
|
||||
}
|
||||
actions {
|
||||
preamble {
|
||||
id: 16841774
|
||||
name: "process_int_source.int_source"
|
||||
alias: "int_source"
|
||||
id: 16820636
|
||||
name: "process_int_source.int_source_dscp"
|
||||
alias: "int_source_dscp"
|
||||
}
|
||||
params {
|
||||
id: 1
|
||||
@ -707,16 +658,23 @@ actions {
|
||||
}
|
||||
actions {
|
||||
preamble {
|
||||
id: 16826281
|
||||
name: "process_int_sink.int_sink"
|
||||
alias: "int_sink"
|
||||
id: 16835077
|
||||
name: "process_int_outer_encap.int_update_shim"
|
||||
alias: "int_update_shim"
|
||||
}
|
||||
}
|
||||
actions {
|
||||
preamble {
|
||||
id: 16792548
|
||||
name: "process_int_sink.restore_port"
|
||||
alias: "restore_port"
|
||||
id: 16798801
|
||||
name: "process_int_sink.restore_header"
|
||||
alias: "restore_header"
|
||||
}
|
||||
}
|
||||
actions {
|
||||
preamble {
|
||||
id: 16826281
|
||||
name: "process_int_sink.int_sink"
|
||||
alias: "int_sink"
|
||||
}
|
||||
}
|
||||
counters {
|
||||
@ -754,25 +712,14 @@ direct_counters {
|
||||
}
|
||||
direct_counters {
|
||||
preamble {
|
||||
id: 302036180
|
||||
name: "process_set_source_sink.counter_set_source"
|
||||
alias: "counter_set_source"
|
||||
id: 301997871
|
||||
name: "process_set_source_sink.counter_set_source_sink"
|
||||
alias: "counter_set_source_sink"
|
||||
}
|
||||
spec {
|
||||
unit: BOTH
|
||||
}
|
||||
direct_table_id: 33573105
|
||||
}
|
||||
direct_counters {
|
||||
preamble {
|
||||
id: 302053848
|
||||
name: "process_set_source_sink.counter_set_sink"
|
||||
alias: "counter_set_sink"
|
||||
}
|
||||
spec {
|
||||
unit: BOTH
|
||||
}
|
||||
direct_table_id: 33590037
|
||||
direct_table_id: 33582667
|
||||
}
|
||||
direct_counters {
|
||||
preamble {
|
||||
|
Loading…
x
Reference in New Issue
Block a user