Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create dpdk specific pna.p4 and extend it #3658

Merged
merged 11 commits into from
Nov 11, 2022
Prev Previous commit
Next Next commit
update tests
  • Loading branch information
kamleshbhalui committed Nov 11, 2022
commit 0e8b523f8218a41b70b27f5cef1dbca29a8f59a9
7 changes: 6 additions & 1 deletion backends/dpdk/DpdkXfail.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
p4c_add_xfail_reason("dpdk"
"use dpdk specific `dpdk_execute` method"
testdata/p4_16_samples/psa-example-dpdk-meter-execute-err.p4
testdata/p4_16_samples/psa-meter3.p4
testdata/p4_16_samples/psa-meter7-bmv2.p4
)
p4c_add_xfail_reason("dpdk"
"Meter function execute not implemented, use dpdk_execute"
testdata/p4_16_samples/psa-meter1.p4
)

p4c_add_xfail_reason("dpdk"
"Expected packet length argument for count method of indirect counter"
testdata/p4_16_samples/psa-example-counters-bmv2.p4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.hdrChecksum[5:0] == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.hdrChecksum[5:0] == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.hdrChecksum[5:0] == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.hdrChecksum[5:0] == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.version == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.version == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.version == 6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
hdr.ipv4.ihl = 5;
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
if (hdr.ipv4.hdrChecksum[5:0] == 6)
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_samples/psa-example-dpdk-externs.p4
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_out;
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
color_out = meter0.execute(index, color_in, (bit <32>) hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit <32>) hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
reg.write(index, user_meta.port_out);
}
Expand Down
2 changes: 1 addition & 1 deletion testdata/p4_16_samples/psa-example-dpdk-meter1.p4
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ control ingress(inout headers hdr, inout metadata_t user_meta, in psa_ingress_in
PSA_MeterColor_t color_out;
PSA_MeterColor_t color_in = PSA_MeterColor_t.RED;
action execute(bit<12> index) {
color_out = meter0.dpdk_execute(index, color_in, hdr.ipv4.totalLen);
color_out = meter0.dpdk_execute(index, color_in, (bit<32>)hdr.ipv4.totalLen);
user_meta.port_out = (color_out == PSA_MeterColor_t.GREEN ? 32w1 : 32w0);
}
table tbl {
Expand Down
194 changes: 194 additions & 0 deletions testdata/p4_16_samples_outputs/pna-example-addhit.p4.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@

struct ethernet_t {
bit<48> dstAddr
bit<48> srcAddr
bit<16> etherType
}

struct ipv4_t {
bit<8> version_ihl
bit<8> diffserv
bit<16> totalLen
bit<16> identification
bit<16> flags_fragOffset
bit<8> ttl
bit<8> protocol
bit<16> hdrChecksum
bit<32> srcAddr
bit<32> dstAddr
}

struct tcp_t {
bit<16> srcPort
bit<16> dstPort
bit<32> seqNo
bit<32> ackNo
bit<16> dataOffset_res_ecn_flags
bit<16> window
bit<16> checksum
bit<16> urgentPtr
}

struct do_range_checks_1_arg_t {
bit<16> min1
bit<16> max1
}

struct do_range_checks_2_arg_t {
bit<16> min1
bit<16> max1
}

struct next_hop2_arg_t {
bit<32> vport
bit<32> newAddr
}

struct next_hop_arg_t {
bit<32> vport
}

struct main_metadata_t {
bit<32> pna_main_input_metadata_input_port
bit<32> local_metadata_rng_result1
bit<32> local_metadata_val1
bit<32> local_metadata_val2
bit<8> local_metadata_timeout
bit<32> pna_main_output_metadata_output_port
bit<32> MainControlT_tmp
bit<32> MainControlT_tmp_0
bit<32> MainControlT_tmp_1
bit<32> MainControlT_tmp_2
bit<32> MainControlT_tmp_3
bit<32> MainControlT_tmp_4
bit<32> learnArg
bit<32> learnArg_0
}
metadata instanceof main_metadata_t

header ethernet instanceof ethernet_t
header ipv4 instanceof ipv4_t
header tcp instanceof tcp_t

regarray direction size 0x100 initval 0

action do_range_checks_1 args instanceof do_range_checks_1_arg_t {
jmpgt LABEL_FALSE_1 t.min1 h.tcp.srcPort
jmpgt LABEL_FALSE_1 h.tcp.srcPort t.max1
mov m.MainControlT_tmp_3 0x1
jmp LABEL_END_1
LABEL_FALSE_1 : mov m.MainControlT_tmp_3 0x0
LABEL_END_1 : mov m.local_metadata_rng_result1 m.MainControlT_tmp_3
return
}

action next_hop args instanceof next_hop_arg_t {
mov m.learnArg 0x0
learn next_hop m.learnArg m.local_metadata_timeout
mov m.pna_main_output_metadata_output_port t.vport
return
}

action add_on_miss_action args none {
mov m.learnArg_0 0x0
learn next_hop m.learnArg_0 m.local_metadata_timeout
return
}

action do_range_checks_2 args instanceof do_range_checks_2_arg_t {
jmpgt LABEL_FALSE_2 t.min1 h.tcp.srcPort
jmpgt LABEL_FALSE_2 h.tcp.srcPort t.max1
jmpgt LABEL_FALSE_3 0x32 h.tcp.srcPort
jmpgt LABEL_FALSE_3 h.tcp.srcPort 0x64
mov m.MainControlT_tmp_2 m.local_metadata_val1
jmp LABEL_END_3
LABEL_FALSE_3 : mov m.MainControlT_tmp_2 m.local_metadata_val2
LABEL_END_3 : mov m.MainControlT_tmp_1 m.MainControlT_tmp_2
jmp LABEL_END_2
LABEL_FALSE_2 : mov m.MainControlT_tmp_1 m.local_metadata_val1
LABEL_END_2 : mov m.local_metadata_rng_result1 m.MainControlT_tmp_1
return
}

action next_hop2 args instanceof next_hop2_arg_t {
mov m.pna_main_output_metadata_output_port t.vport
mov h.ipv4.srcAddr t.newAddr
return
}

action add_on_miss_action2 args none {
mov m.MainControlT_tmp 0x0
mov m.MainControlT_tmp_0 0x4d2
learn next_hop m.MainControlT_tmp m.local_metadata_timeout
return
}

learner ipv4_da {
key {
h.ipv4.dstAddr
}
actions {
next_hop @tableonly
add_on_miss_action @defaultonly
}
default_action add_on_miss_action args none
size 0x10000
timeout {
10
30
60
120
300
43200
120
120

}
}

learner ipv4_da2 {
key {
h.ipv4.dstAddr
}
actions {
next_hop2 @tableonly
add_on_miss_action2 @defaultonly
do_range_checks_2
do_range_checks_1
}
default_action add_on_miss_action2 args none
size 0x10000
timeout {
10
30
60
120
300
43200
120
120

}
}

apply {
rx m.pna_main_input_metadata_input_port
extract h.ethernet
jmpeq MAINPARSERIMPL_PARSE_IPV4 h.ethernet.etherType 0x800
jmp MAINPARSERIMPL_ACCEPT
MAINPARSERIMPL_PARSE_IPV4 : extract h.ipv4
MAINPARSERIMPL_ACCEPT : jmpgt LABEL_FALSE 0x64 h.tcp.srcPort
jmpgt LABEL_FALSE h.tcp.srcPort 0xc8
mov m.MainControlT_tmp_4 0x1
jmp LABEL_END
LABEL_FALSE : mov m.MainControlT_tmp_4 0x0
LABEL_END : mov m.local_metadata_rng_result1 m.MainControlT_tmp_4
jmpnv LABEL_END_0 h.ipv4
table ipv4_da
table ipv4_da2
LABEL_END_0 : emit h.ethernet
emit h.ipv4
tx m.pna_main_output_metadata_output_port
}


Loading