Check how wrapping is done in P4
This commit is contained in:
parent
bef2e512f1
commit
1a39c35e3b
4 changed files with 133 additions and 1 deletions
|
|
@ -52,7 +52,7 @@ action v6sum() {
|
|||
tmp = (tmp >> 16) + (tmp & 0xffff);
|
||||
// tmp = tmp + (tmp >> 16);
|
||||
tmp = ~tmp;
|
||||
// meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ;
|
||||
|
||||
meta.v6sum = (bit<16>) tmp;
|
||||
}
|
||||
|
||||
|
|
|
|||
50
p4src/wraptest.p4
Normal file
50
p4src/wraptest.p4
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- P4_16 -*- */
|
||||
#include <core.p4>
|
||||
#include <v1model.p4>
|
||||
|
||||
#include "headers.p4"
|
||||
#include "parsers.p4"
|
||||
|
||||
control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
/********************** APPLYING TABLES ***********************************/
|
||||
apply {
|
||||
if(hdr.tcp.isValid()) {
|
||||
/* test wrap around */
|
||||
hdr.tcp.checksum = 0xffff;
|
||||
hdr.tcp.checksum = checksum + 2;
|
||||
}
|
||||
standard_metadata.egress_spec = 1;
|
||||
}
|
||||
}
|
||||
|
||||
control MyEgress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
apply {
|
||||
}
|
||||
}
|
||||
|
||||
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
|
||||
apply {}
|
||||
}
|
||||
|
||||
|
||||
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
|
||||
apply {}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*********************** S W I T C H *******************************
|
||||
*************************************************************************/
|
||||
|
||||
V1Switch(
|
||||
MyParser(),
|
||||
MyVerifyChecksum(),
|
||||
MyIngress(),
|
||||
MyEgress(),
|
||||
MyComputeChecksum(),
|
||||
MyDeparser()
|
||||
) main;
|
||||
Loading…
Add table
Add a link
Reference in a new issue