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