diff --git a/backends/ebpf/tests/p4testdata/action-const-default.p4 b/backends/ebpf/tests/p4testdata/action-const-default.p4 index 00983a12da7..0ddce9ee1d5 100644 --- a/backends/ebpf/tests/p4testdata/action-const-default.p4 +++ b/backends/ebpf/tests/p4testdata/action-const-default.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - const default_action = do_forward((PortId_t) 5); + const default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/action-default-ternary.p4 b/backends/ebpf/tests/p4testdata/action-default-ternary.p4 index 8d72107b62a..e163a54e3e1 100644 --- a/backends/ebpf/tests/p4testdata/action-default-ternary.p4 +++ b/backends/ebpf/tests/p4testdata/action-default-ternary.p4 @@ -97,7 +97,7 @@ control ingress(inout headers hdr, hdr.ipv4.dstAddr : ternary; } actions = { do_forward; NoAction; } - const default_action = do_forward((PortId_t) 5); + const default_action = do_forward((PortId_t) PORT1); } apply { diff --git a/backends/ebpf/tests/p4testdata/action-profile-action-run.p4 b/backends/ebpf/tests/p4testdata/action-profile-action-run.p4 index 4f1cb407e74..a393730c71e 100644 --- a/backends/ebpf/tests/p4testdata/action-profile-action-run.p4 +++ b/backends/ebpf/tests/p4testdata/action-profile-action-run.p4 @@ -54,8 +54,8 @@ control MyIC(inout headers a, inout empty_t bc, apply { switch(tbl.apply().action_run) { - a1: { send_to_port(ostd, (PortId_t) 5); } - a2: { send_to_port(ostd, (PortId_t) 6); } + a1: { send_to_port(ostd, (PortId_t) PORT1); } + a2: { send_to_port(ostd, (PortId_t) PORT2); } default: {} } } diff --git a/backends/ebpf/tests/p4testdata/action-profile-hit.p4 b/backends/ebpf/tests/p4testdata/action-profile-hit.p4 index 658f709172d..683ec3a44a7 100644 --- a/backends/ebpf/tests/p4testdata/action-profile-hit.p4 +++ b/backends/ebpf/tests/p4testdata/action-profile-hit.p4 @@ -54,7 +54,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { if (tbl.apply().hit) - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/action-profile-lpm.p4 b/backends/ebpf/tests/p4testdata/action-profile-lpm.p4 index b8d4d165845..f04fc227a48 100644 --- a/backends/ebpf/tests/p4testdata/action-profile-lpm.p4 +++ b/backends/ebpf/tests/p4testdata/action-profile-lpm.p4 @@ -54,7 +54,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { tbl.apply(); - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/action-profile1.p4 b/backends/ebpf/tests/p4testdata/action-profile1.p4 index 84fa77f21a3..02d3e89abd7 100644 --- a/backends/ebpf/tests/p4testdata/action-profile1.p4 +++ b/backends/ebpf/tests/p4testdata/action-profile1.p4 @@ -54,7 +54,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { tbl.apply(); - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/action-profile2.p4 b/backends/ebpf/tests/p4testdata/action-profile2.p4 index 7170a9afbbd..2c185d30ae9 100644 --- a/backends/ebpf/tests/p4testdata/action-profile2.p4 +++ b/backends/ebpf/tests/p4testdata/action-profile2.p4 @@ -61,7 +61,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { tbl.apply(); tbl2.apply(); - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/action-selector-action-run.p4 b/backends/ebpf/tests/p4testdata/action-selector-action-run.p4 index 12a0312b112..843ef15a9c0 100644 --- a/backends/ebpf/tests/p4testdata/action-selector-action-run.p4 +++ b/backends/ebpf/tests/p4testdata/action-selector-action-run.p4 @@ -56,7 +56,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { switch(tbl.apply().action_run) { - fwd: { send_to_port(ostd, (PortId_t) 5); } + fwd: { send_to_port(ostd, (PortId_t) PORT1); } default: {} } } diff --git a/backends/ebpf/tests/p4testdata/action-selector-hit.p4 b/backends/ebpf/tests/p4testdata/action-selector-hit.p4 index 1f92cefd673..1bfbb58e17a 100644 --- a/backends/ebpf/tests/p4testdata/action-selector-hit.p4 +++ b/backends/ebpf/tests/p4testdata/action-selector-hit.p4 @@ -56,7 +56,7 @@ control MyIC(inout headers a, inout empty_t bc, apply { if (tbl.apply().hit) - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/action-selector3.p4 b/backends/ebpf/tests/p4testdata/action-selector3.p4 index d73de07e0be..83349be5ad3 100644 --- a/backends/ebpf/tests/p4testdata/action-selector3.p4 +++ b/backends/ebpf/tests/p4testdata/action-selector3.p4 @@ -52,7 +52,7 @@ control MyIC(inout headers a, inout empty_t bc, } actions = { NoAction; fwd; } psa_implementation = as; - psa_empty_group_action = fwd((PortId_t) 5); + psa_empty_group_action = fwd((PortId_t) PORT1); } apply { diff --git a/backends/ebpf/tests/p4testdata/bridged-metadata.p4 b/backends/ebpf/tests/p4testdata/bridged-metadata.p4 index 6765496cda0..6175995c320 100644 --- a/backends/ebpf/tests/p4testdata/bridged-metadata.p4 +++ b/backends/ebpf/tests/p4testdata/bridged-metadata.p4 @@ -83,7 +83,7 @@ control ingress(inout headers hdr, inout psa_ingress_output_metadata_t ostd) { apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); hdr.bridged_metadata.setValid(); hdr.bridged_metadata.drop = 0; if (hdr.ethernet.dstAddr == 0xffffffffffff) { diff --git a/backends/ebpf/tests/p4testdata/checksum-updates-crc16.p4 b/backends/ebpf/tests/p4testdata/checksum-updates-crc16.p4 index df91c6d2fe0..a77da117dc2 100644 --- a/backends/ebpf/tests/p4testdata/checksum-updates-crc16.p4 +++ b/backends/ebpf/tests/p4testdata/checksum-updates-crc16.p4 @@ -69,7 +69,7 @@ control ingress(inout headers hdr, { apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/checksum-updates-crc32.p4 b/backends/ebpf/tests/p4testdata/checksum-updates-crc32.p4 index b8b7bf621cf..54f58a635b2 100644 --- a/backends/ebpf/tests/p4testdata/checksum-updates-crc32.p4 +++ b/backends/ebpf/tests/p4testdata/checksum-updates-crc32.p4 @@ -69,7 +69,7 @@ control ingress(inout headers hdr, { apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/const-entry-and-action.p4 b/backends/ebpf/tests/p4testdata/const-entry-and-action.p4 index a2c9ea31c5f..fb2e5ca6d79 100644 --- a/backends/ebpf/tests/p4testdata/const-entry-and-action.p4 +++ b/backends/ebpf/tests/p4testdata/const-entry-and-action.p4 @@ -86,9 +86,9 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - const default_action = do_forward((PortId_t) 5); + const default_action = do_forward((PortId_t) PORT1); const entries = { - (PortId_t)6 : do_forward((PortId_t) 4); + (PortId_t)PORT2 : do_forward((PortId_t) PORT0); } size = 100; } @@ -99,8 +99,8 @@ control ingress(inout headers hdr, } actions = { do_forward; NoAction; } const entries = { - 0x11223300 &&& 0xFFFFFF00 : do_forward((PortId_t) 6); - 0x11223355 &&& 0xFFFFFFFF : do_forward((PortId_t) 4); + 0x11223300 &&& 0xFFFFFF00 : do_forward((PortId_t) PORT2); + 0x11223355 &&& 0xFFFFFFFF : do_forward((PortId_t) PORT0); } } diff --git a/backends/ebpf/tests/p4testdata/const-entry-ternary.p4 b/backends/ebpf/tests/p4testdata/const-entry-ternary.p4 index 9adf80e4b08..ece81d7c2ef 100644 --- a/backends/ebpf/tests/p4testdata/const-entry-ternary.p4 +++ b/backends/ebpf/tests/p4testdata/const-entry-ternary.p4 @@ -72,8 +72,8 @@ control ingress(inout headers hdr, } actions = { do_forward; NoAction; } const entries = { - (0x5555555555 &&& 0x000000000000, 0x11223300 &&& 0xFFFF00FF, 0x33333333 &&& 0xFFFFFFFF, 0x00) : do_forward((PortId_t) 6); - (0x7777777777 &&& 0x000000000000, 0x11223355 &&& 0xFF00FFFF, 0x33333333 &&& 0xFFFFFFFF, 0x00) : do_forward((PortId_t) 5); + (0x5555555555 &&& 0x000000000000, 0x11223300 &&& 0xFFFF00FF, 0x33333333 &&& 0xFFFFFFFF, 0x00) : do_forward((PortId_t) PORT2); + (0x7777777777 &&& 0x000000000000, 0x11223355 &&& 0xFF00FFFF, 0x33333333 &&& 0xFFFFFFFF, 0x00) : do_forward((PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/const-entry.p4 b/backends/ebpf/tests/p4testdata/const-entry.p4 index 2417ee4121b..3dd2a9b4e98 100644 --- a/backends/ebpf/tests/p4testdata/const-entry.p4 +++ b/backends/ebpf/tests/p4testdata/const-entry.p4 @@ -87,7 +87,7 @@ control ingress(inout headers hdr, } actions = { do_forward; NoAction; } const entries = { - (PortId_t)4 : do_forward((PortId_t) 5); + (PortId_t)PORT0 : do_forward((PortId_t) PORT1); } size = 100; } diff --git a/backends/ebpf/tests/p4testdata/cos-psa.p4 b/backends/ebpf/tests/p4testdata/cos-psa.p4 index 8b735bdafdd..80869ef8f71 100644 --- a/backends/ebpf/tests/p4testdata/cos-psa.p4 +++ b/backends/ebpf/tests/p4testdata/cos-psa.p4 @@ -60,7 +60,7 @@ control ingress(inout headers hdr, { apply { - send_to_port(ostdx, (PortId_t) 5); + send_to_port(ostdx, (PortId_t) PORT1); if (hdr.ethernet.etherType == 0x0800) { ostdx.class_of_service = (ClassOfService_t) 100; diff --git a/backends/ebpf/tests/p4testdata/counters.p4 b/backends/ebpf/tests/p4testdata/counters.p4 index 4ae9c7b5b42..51c5a163d6f 100644 --- a/backends/ebpf/tests/p4testdata/counters.p4 +++ b/backends/ebpf/tests/p4testdata/counters.p4 @@ -66,7 +66,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; do_forward_2; NoAction; } - default_action = do_forward((PortId_t) 5); + default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/direct-counters.p4 b/backends/ebpf/tests/p4testdata/direct-counters.p4 index 160e5a0e5d2..9dedbab1d08 100644 --- a/backends/ebpf/tests/p4testdata/direct-counters.p4 +++ b/backends/ebpf/tests/p4testdata/direct-counters.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, apply { ostd.drop = false; - ostd.egress_port = (PortId_t) 5; + ostd.egress_port = (PortId_t) PORT1; tbl1.apply(); tbl2.apply(); diff --git a/backends/ebpf/tests/p4testdata/etm-clone-e2e.p4 b/backends/ebpf/tests/p4testdata/etm-clone-e2e.p4 index 60ec09a2797..dd5b2f230d0 100644 --- a/backends/ebpf/tests/p4testdata/etm-clone-e2e.p4 +++ b/backends/ebpf/tests/p4testdata/etm-clone-e2e.p4 @@ -85,7 +85,7 @@ control ingress(inout headers hdr, apply { ostd.drop = false; - ostd.egress_port = (PortId_t) 5; + ostd.egress_port = (PortId_t) PORT1; } } diff --git a/backends/ebpf/tests/p4testdata/etm-drop.p4 b/backends/ebpf/tests/p4testdata/etm-drop.p4 index 34b33a2e089..886483e72ac 100644 --- a/backends/ebpf/tests/p4testdata/etm-drop.p4 +++ b/backends/ebpf/tests/p4testdata/etm-drop.p4 @@ -76,7 +76,7 @@ control ingress(inout headers hdr, apply { ostd.drop = false; - ostd.egress_port = (PortId_t) 5; + ostd.egress_port = (PortId_t) PORT1; } } diff --git a/backends/ebpf/tests/p4testdata/etm-recirc.p4 b/backends/ebpf/tests/p4testdata/etm-recirc.p4 index 77bbea11ac4..d2ea1acf677 100644 --- a/backends/ebpf/tests/p4testdata/etm-recirc.p4 +++ b/backends/ebpf/tests/p4testdata/etm-recirc.p4 @@ -79,11 +79,11 @@ control ingress(inout headers hdr, apply { ostd.drop = false; - ostd.egress_port = (PortId_t) 5; + ostd.egress_port = (PortId_t) PORT1; if (istd.packet_path == PSA_PacketPath_t.NORMAL) { if (hdr.ethernet.dstAddr[15:0] == 0xfef0) { - ostd.egress_port = (PortId_t) 2; + ostd.egress_port = (PortId_t) PSA_RECIRC; } } else if (istd.packet_path == PSA_PacketPath_t.RECIRCULATE) { } else { diff --git a/backends/ebpf/tests/p4testdata/hash-action.p4 b/backends/ebpf/tests/p4testdata/hash-action.p4 index e315b3540ed..56072c0e66b 100644 --- a/backends/ebpf/tests/p4testdata/hash-action.p4 +++ b/backends/ebpf/tests/p4testdata/hash-action.p4 @@ -82,7 +82,7 @@ control ingress(inout headers hdr, apply { t1.apply(); - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/hash-crc16.p4 b/backends/ebpf/tests/p4testdata/hash-crc16.p4 index b3fbf3e79a6..923f82a2dae 100644 --- a/backends/ebpf/tests/p4testdata/hash-crc16.p4 +++ b/backends/ebpf/tests/p4testdata/hash-crc16.p4 @@ -71,7 +71,7 @@ control ingress(inout headers hdr, Hash>(PSA_HashAlgorithm_t.CRC16) h; apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); hdr.crc.crc = h.get_hash({hdr.crc.f1, hdr.crc.f2, hdr.crc.f3, hdr.crc.f4}); } diff --git a/backends/ebpf/tests/p4testdata/hash-crc32.p4 b/backends/ebpf/tests/p4testdata/hash-crc32.p4 index e0d65cb5e08..b4764ca9323 100644 --- a/backends/ebpf/tests/p4testdata/hash-crc32.p4 +++ b/backends/ebpf/tests/p4testdata/hash-crc32.p4 @@ -71,7 +71,7 @@ control ingress(inout headers hdr, Hash>(PSA_HashAlgorithm_t.CRC32) h; apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); hdr.crc.crc = h.get_hash({hdr.crc.f1, hdr.crc.f2, hdr.crc.f3, hdr.crc.f4}); } diff --git a/backends/ebpf/tests/p4testdata/hash-range.p4 b/backends/ebpf/tests/p4testdata/hash-range.p4 index 23894634910..1d1e2e6befa 100644 --- a/backends/ebpf/tests/p4testdata/hash-range.p4 +++ b/backends/ebpf/tests/p4testdata/hash-range.p4 @@ -70,7 +70,7 @@ control ingress(inout headers hdr, Hash>(PSA_HashAlgorithm_t.CRC16) h; apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); hdr.crc.crc = (bit<8>) h.get_hash(16w50, {hdr.crc.f1, hdr.crc.f3, hdr.crc.f4}, 16w200); } diff --git a/backends/ebpf/tests/p4testdata/internet-checksum.p4 b/backends/ebpf/tests/p4testdata/internet-checksum.p4 index 935f4608f14..0bd5abd328d 100644 --- a/backends/ebpf/tests/p4testdata/internet-checksum.p4 +++ b/backends/ebpf/tests/p4testdata/internet-checksum.p4 @@ -83,7 +83,7 @@ control ingress(inout headers hdr, return; } - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/meters-action.p4 b/backends/ebpf/tests/p4testdata/meters-action.p4 index 1a4ebb26a4c..d5e4a1fbb79 100644 --- a/backends/ebpf/tests/p4testdata/meters-action.p4 +++ b/backends/ebpf/tests/p4testdata/meters-action.p4 @@ -82,7 +82,7 @@ control ingress(inout headers hdr, Meter>(1, PSA_MeterType_t.BYTES) meter1; bit<7> idx; PSA_MeterColor_t color1 = PSA_MeterColor_t.RED; - PortId_t port = (PortId_t)5; + PortId_t port = (PortId_t)PORT1; action do_forward(PortId_t egress_port) { color1 = meter1.execute((bit<7>) 0); @@ -94,7 +94,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/meters-color-aware.p4 b/backends/ebpf/tests/p4testdata/meters-color-aware.p4 index c66b06cce00..062fb33aebb 100644 --- a/backends/ebpf/tests/p4testdata/meters-color-aware.p4 +++ b/backends/ebpf/tests/p4testdata/meters-color-aware.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, color1 = meter1.execute((bit<7>) 0, PSA_MeterColor_t.YELLOW); if (color1 != PSA_MeterColor_t.RED) { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } else { ingress_drop(ostd); } diff --git a/backends/ebpf/tests/p4testdata/meters-direct-and-counter.p4 b/backends/ebpf/tests/p4testdata/meters-direct-and-counter.p4 index c084ba16308..86369297cba 100644 --- a/backends/ebpf/tests/p4testdata/meters-direct-and-counter.p4 +++ b/backends/ebpf/tests/p4testdata/meters-direct-and-counter.p4 @@ -100,7 +100,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = meter1; psa_direct_counter = counter1; diff --git a/backends/ebpf/tests/p4testdata/meters-direct-and-indirect-single-action.p4 b/backends/ebpf/tests/p4testdata/meters-direct-and-indirect-single-action.p4 index b425c1141a8..652dfaa657d 100644 --- a/backends/ebpf/tests/p4testdata/meters-direct-and-indirect-single-action.p4 +++ b/backends/ebpf/tests/p4testdata/meters-direct-and-indirect-single-action.p4 @@ -100,7 +100,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = direct_meter; } diff --git a/backends/ebpf/tests/p4testdata/meters-direct-and-indirect.p4 b/backends/ebpf/tests/p4testdata/meters-direct-and-indirect.p4 index 5323b0c01a2..b06c44889ea 100644 --- a/backends/ebpf/tests/p4testdata/meters-direct-and-indirect.p4 +++ b/backends/ebpf/tests/p4testdata/meters-direct-and-indirect.p4 @@ -99,7 +99,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = direct_meter; } diff --git a/backends/ebpf/tests/p4testdata/meters-direct-color-aware.p4 b/backends/ebpf/tests/p4testdata/meters-direct-color-aware.p4 index 28ca2db5432..5fee2f8b27d 100644 --- a/backends/ebpf/tests/p4testdata/meters-direct-color-aware.p4 +++ b/backends/ebpf/tests/p4testdata/meters-direct-color-aware.p4 @@ -98,7 +98,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = meter1; } diff --git a/backends/ebpf/tests/p4testdata/meters-direct.p4 b/backends/ebpf/tests/p4testdata/meters-direct.p4 index 11ef45dd010..0497f55fe69 100644 --- a/backends/ebpf/tests/p4testdata/meters-direct.p4 +++ b/backends/ebpf/tests/p4testdata/meters-direct.p4 @@ -98,7 +98,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = meter1; } diff --git a/backends/ebpf/tests/p4testdata/meters-packets.p4 b/backends/ebpf/tests/p4testdata/meters-packets.p4 index e7225d429cd..04a0e6453e8 100644 --- a/backends/ebpf/tests/p4testdata/meters-packets.p4 +++ b/backends/ebpf/tests/p4testdata/meters-packets.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, color1 = meter1.execute((bit<7>) 0); if (color1 != PSA_MeterColor_t.RED) { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } else { ingress_drop(ostd); } diff --git a/backends/ebpf/tests/p4testdata/meters-two-direct.p4 b/backends/ebpf/tests/p4testdata/meters-two-direct.p4 index aaa93f90f94..8fa9c61b0ea 100644 --- a/backends/ebpf/tests/p4testdata/meters-two-direct.p4 +++ b/backends/ebpf/tests/p4testdata/meters-two-direct.p4 @@ -101,7 +101,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; psa_direct_meter = { meter1, meter2 }; } diff --git a/backends/ebpf/tests/p4testdata/meters.p4 b/backends/ebpf/tests/p4testdata/meters.p4 index 7dc1120221b..f9051e1fe34 100644 --- a/backends/ebpf/tests/p4testdata/meters.p4 +++ b/backends/ebpf/tests/p4testdata/meters.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, color1 = meter1.execute((bit<7>) 0); if (color1 != PSA_MeterColor_t.RED) { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } else { ingress_drop(ostd); } diff --git a/backends/ebpf/tests/p4testdata/packet_in-advance.p4 b/backends/ebpf/tests/p4testdata/packet_in-advance.p4 index 30acb5c72bd..56f27b1aa99 100644 --- a/backends/ebpf/tests/p4testdata/packet_in-advance.p4 +++ b/backends/ebpf/tests/p4testdata/packet_in-advance.p4 @@ -90,7 +90,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 5); + default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/packet_in-length.p4 b/backends/ebpf/tests/p4testdata/packet_in-length.p4 index 11bc85ebdee..68a40d6aeb7 100644 --- a/backends/ebpf/tests/p4testdata/packet_in-length.p4 +++ b/backends/ebpf/tests/p4testdata/packet_in-length.p4 @@ -87,7 +87,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 5); + default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/psa-ternary.p4 b/backends/ebpf/tests/p4testdata/psa-ternary.p4 index 63b0e07a5f6..dc40bd5b491 100644 --- a/backends/ebpf/tests/p4testdata/psa-ternary.p4 +++ b/backends/ebpf/tests/p4testdata/psa-ternary.p4 @@ -145,7 +145,7 @@ control ingress(inout headers hdr, } apply { - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); tbl_ternary_0.apply(); tbl_ternary_2.apply(); tbl_ternary_1.apply(); diff --git a/backends/ebpf/tests/p4testdata/psa-tunneling.p4 b/backends/ebpf/tests/p4testdata/psa-tunneling.p4 index 6e40bc85fd5..670c84b9b79 100644 --- a/backends/ebpf/tests/p4testdata/psa-tunneling.p4 +++ b/backends/ebpf/tests/p4testdata/psa-tunneling.p4 @@ -94,7 +94,7 @@ control ingress(inout headers hdr, } else { mpls_encap(); } - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/p4testdata/pvs.p4 b/backends/ebpf/tests/p4testdata/pvs.p4 index da0b08d0715..8d33bc5f846 100644 --- a/backends/ebpf/tests/p4testdata/pvs.p4 +++ b/backends/ebpf/tests/p4testdata/pvs.p4 @@ -72,7 +72,7 @@ control ingress(inout headers hdr, if (hdr.udp.isValid()) { if (hdr.udp.dstPort == 80) { ostd.drop = false; - ostd.egress_port = (PortId_t) 5; + ostd.egress_port = (PortId_t) PORT1; } } } diff --git a/backends/ebpf/tests/p4testdata/random.p4 b/backends/ebpf/tests/p4testdata/random.p4 index 761e2e643d5..0a2b4fa3bab 100644 --- a/backends/ebpf/tests/p4testdata/random.p4 +++ b/backends/ebpf/tests/p4testdata/random.p4 @@ -61,7 +61,7 @@ control MyIC(inout headers a, inout empty_t bc, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 5); + default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/register-action.p4 b/backends/ebpf/tests/p4testdata/register-action.p4 index 79629698939..46fa98b514f 100644 --- a/backends/ebpf/tests/p4testdata/register-action.p4 +++ b/backends/ebpf/tests/p4testdata/register-action.p4 @@ -96,7 +96,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 6); + default_action = do_forward((PortId_t) PORT2); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/register-default.p4 b/backends/ebpf/tests/p4testdata/register-default.p4 index 013bcc4c1a1..a73b3f928d5 100644 --- a/backends/ebpf/tests/p4testdata/register-default.p4 +++ b/backends/ebpf/tests/p4testdata/register-default.p4 @@ -80,7 +80,7 @@ control ingress(inout headers hdr, apply { // Values used there are arbitrary chosen just for PTF tests // See PTF test description - PortId_t egress_port = (PortId_t) 5; + PortId_t egress_port = (PortId_t) PORT1; bit<32> tmp; tmp = reg.read(egress_port); if (tmp < 5) { diff --git a/backends/ebpf/tests/p4testdata/resubmit.p4 b/backends/ebpf/tests/p4testdata/resubmit.p4 index 2a1686f97cd..700850bb42e 100644 --- a/backends/ebpf/tests/p4testdata/resubmit.p4 +++ b/backends/ebpf/tests/p4testdata/resubmit.p4 @@ -81,7 +81,7 @@ control ingress(inout headers hdr, // part of the code _should_ affect the output packet // contents, because we are not resubmitting it again. hdr.ethernet.dstAddr = user_meta.dst_addr; - send_to_port(ostdx, (PortId_t) 5); + send_to_port(ostdx, (PortId_t) PORT1); } } } diff --git a/backends/ebpf/tests/p4testdata/simple-fwd.p4 b/backends/ebpf/tests/p4testdata/simple-fwd.p4 index 4a450f36247..e9d7980f09b 100644 --- a/backends/ebpf/tests/p4testdata/simple-fwd.p4 +++ b/backends/ebpf/tests/p4testdata/simple-fwd.p4 @@ -86,7 +86,7 @@ control ingress(inout headers hdr, istd.ingress_port : exact; } actions = { do_forward; NoAction; } - default_action = do_forward((PortId_t) 5); + default_action = do_forward((PortId_t) PORT1); size = 100; } diff --git a/backends/ebpf/tests/p4testdata/verify.p4 b/backends/ebpf/tests/p4testdata/verify.p4 index b2dbe569591..2ab5d5a3fde 100644 --- a/backends/ebpf/tests/p4testdata/verify.p4 +++ b/backends/ebpf/tests/p4testdata/verify.p4 @@ -65,7 +65,7 @@ control ingress(inout headers hdr, return; } - send_to_port(ostd, (PortId_t) 5); + send_to_port(ostd, (PortId_t) PORT1); } } diff --git a/backends/ebpf/tests/ptf/bng.py b/backends/ebpf/tests/ptf/bng.py index 5b02d0a2566..aea458b5d20 100644 --- a/backends/ebpf/tests/ptf/bng.py +++ b/backends/ebpf/tests/ptf/bng.py @@ -68,10 +68,6 @@ pppoe_session_id = 0xbeac core_router_mac = HOST1_MAC -PORT0 = 0 -PORT1 = 1 - - def pkt_route(pkt, mac_dst): new_pkt = pkt.copy() new_pkt[Ether].src = pkt[Ether].dst @@ -244,14 +240,14 @@ def runTest(self): pppoe_session_id=pppoe_session_id, enabled=True) self.session_installed = True # Setup port 1: packets on this port are double tagged packets - self.setup_port(4, vlan_id=s_tag, port_type=PORT_TYPE_EDGE, double_tagged=True, inner_vlan_id=c_tag) + self.setup_port(DP_PORTS[0], vlan_id=s_tag, port_type=PORT_TYPE_EDGE, double_tagged=True, inner_vlan_id=c_tag) # Setup port 2 - self.setup_port(5, vlan_id=s_tag, port_type=PORT_TYPE_INFRA) + self.setup_port(DP_PORTS[1], vlan_id=s_tag, port_type=PORT_TYPE_INFRA) - self.set_forwarding_type(4, SWITCH_MAC, ETH_TYPE_PPPOE, + self.set_forwarding_type(DP_PORTS[0], SWITCH_MAC, ETH_TYPE_PPPOE, FORWARDING_TYPE_UNICAST_IPV4) - self.add_forwarding_routing_v4_entry(SERVER_IP, 24, 5, SWITCH_MAC, HOST1_MAC) - self.add_next_vlan(5, s_tag) + self.add_forwarding_routing_v4_entry(SERVER_IP, 24, DP_PORTS[1], SWITCH_MAC, HOST1_MAC) + self.add_next_vlan(DP_PORTS[1], s_tag) print("") for pkt_type in ["tcp", "udp", "icmp"]: print("Testing %s packet..." \ @@ -280,13 +276,13 @@ def doRunTest(self, pkt): def runTest(self): # Setup port 1: packets on this port are double tagged packets - self.setup_port(4, vlan_id=VLAN_ID_3, port_type=PORT_TYPE_EDGE, double_tagged=True, inner_vlan_id=c_tag) + self.setup_port(DP_PORTS[0], vlan_id=VLAN_ID_3, port_type=PORT_TYPE_EDGE, double_tagged=True, inner_vlan_id=c_tag) # Setup port 2 - self.setup_port(5, vlan_id=s_tag, port_type=PORT_TYPE_INFRA) - self.set_forwarding_type(5, SWITCH_MAC, ETH_TYPE_IPV4, + self.setup_port(DP_PORTS[1], vlan_id=s_tag, port_type=PORT_TYPE_INFRA) + self.set_forwarding_type(DP_PORTS[1], SWITCH_MAC, ETH_TYPE_IPV4, FORWARDING_TYPE_UNICAST_IPV4) - self.add_forwarding_routing_v4_entry(CLIENT_IP, 24, 4, SWITCH_MAC, HOST1_MAC) - self.add_next_double_vlan(4, s_tag, c_tag) + self.add_forwarding_routing_v4_entry(CLIENT_IP, 24, DP_PORTS[0], SWITCH_MAC, HOST1_MAC) + self.add_next_double_vlan(DP_PORTS[0], s_tag, c_tag) self.setup_line_v4( s_tag=s_tag, c_tag=c_tag, line_id=line_id, ipv4_addr=CLIENT_IP, pppoe_session_id=pppoe_session_id, enabled=True) diff --git a/backends/ebpf/tests/ptf/checksum.py b/backends/ebpf/tests/ptf/checksum.py index 24ac425d438..5f3a53619b6 100644 --- a/backends/ebpf/tests/ptf/checksum.py +++ b/backends/ebpf/tests/ptf/checksum.py @@ -19,7 +19,7 @@ def runTest(self): pkt = Ether() / "1234567890000" exp_pkt = Ether() / bytes.fromhex('313233343536373839 cbf43926') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) @xdp2tc_head_not_supported @@ -30,7 +30,7 @@ def runTest(self): pkt = Ether() / "1234567890000" exp_pkt = Ether() / bytes.fromhex('313233343536373839 BB3D') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) class InternetChecksumPSATest(P4EbpfTest): @@ -63,7 +63,7 @@ def runTest(self): pkt[IP].src = '10.0.0.1' pkt[IP].chksum = None pkt[UDP].chksum = None - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) @xdp2tc_head_not_supported @@ -74,7 +74,7 @@ def runTest(self): pkt = Ether() / "12345678900" exp_pkt = Ether() / bytes.fromhex('313233343536373839 bb3d') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) @xdp2tc_head_not_supported @@ -85,7 +85,7 @@ def runTest(self): pkt = Ether() / "12345678900" exp_pkt = Ether() / bytes.fromhex('313233343536373839 bb3d') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) @xdp2tc_head_not_supported @@ -96,7 +96,7 @@ def runTest(self): pkt = Ether() / "1234567890000" exp_pkt = Ether() / bytes.fromhex('313233343536373839 cbf43926') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) @xdp2tc_head_not_supported @@ -108,4 +108,4 @@ def runTest(self): pkt = Ether() / "1234567890" exp_pkt = Ether() / bytes.fromhex('313233343536373839 {}'.format(format(res, 'x'))) testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, exp_pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, exp_pkt, PTF_PORTS) diff --git a/backends/ebpf/tests/ptf/common.py b/backends/ebpf/tests/ptf/common.py index 150ffdeb973..c63296b45cb 100644 --- a/backends/ebpf/tests/ptf/common.py +++ b/backends/ebpf/tests/ptf/common.py @@ -33,6 +33,8 @@ import ptf import ptf.testutils as testutils +import pyroute2 +from pyroute2 import NetNS from ptf.base_tests import BaseTest @@ -44,6 +46,16 @@ TEST_PIPELINE_MOUNT_PATH = "/sys/fs/bpf/pipeline{}".format(TEST_PIPELINE_ID) PIPELINE_MAPS_MOUNT_PATH = "{}/maps".format(TEST_PIPELINE_MOUNT_PATH) +PORT0 = 0 +PORT1 = 1 +PORT2 = 2 +# PTF_PORTS stores port numbers used by PTF test cases to send packets to the test switch. +# PTF_PORTS should only be used in PTF test cases to send/receive packets. +PTF_PORTS = [PORT0, PORT1, PORT2] + +# DP_PORTS stores real interface numbers retrieved from OS. +# DP_PORTS corresponds to switch interfaces and are used as data plane port numbers inside P4 programs. +DP_PORTS = dict() def xdp2tc_head_not_supported(cls): if cls.xdp2tc_mode(cls) == 'head': @@ -77,8 +89,23 @@ def setUp(self): head, tail = os.path.split(self.p4_file_path) filename = tail.split(".")[0] self.test_prog_image = os.path.join("ptf_out", filename + ".o") + logger.info("\nUsing test params: %s", testutils.test_params_get()) + if "namespace" in testutils.test_params_get(): + self.switch_ns = testutils.test_param_get("namespace") + self.interfaces = testutils.test_param_get("interfaces").split(",") + + # fetch data plane ports from network namespace + global DP_PORTS + next_idx = 0 + for intf in self.interfaces: + if intf != "psa_recirc": + DP_PORTS[next_idx] = self.get_dataplane_port_number(intf) + next_idx += 1 p4args = "--Wdisable=unused --max-ternary-masks 3" + for idx, dp_port in DP_PORTS.items(): + p4args += " -DPORT{}={}".format(idx, dp_port) + p4args += " -DPSA_RECIRC={}".format(self.get_dataplane_port_number("psa_recirc")) if self.is_trace_logs_enabled(): p4args += " --trace" @@ -90,16 +117,12 @@ def setUp(self): "ARGS=\"{cargs}\" P4C=p4c-ebpf P4ARGS=\"{p4args}\" psa".format( output=self.test_prog_image, p4file=self.p4_file_path, - cargs="-DPSA_PORT_RECIRCULATE=2", + cargs="-DPSA_PORT_RECIRCULATE={}".format(self.get_dataplane_port_number("psa_recirc")), p4args=p4args), "Compilation error") self.dataplane = ptf.dataplane_instance self.dataplane.flush() - logger.info("\nUsing test params: %s", testutils.test_params_get()) - if "namespace" in testutils.test_params_get(): - self.switch_ns = testutils.test_param_get("namespace") - self.interfaces = testutils.test_param_get("interfaces").split(",") self.exec_ns_cmd("psabpf-ctl pipeline load id {} {}".format(TEST_PIPELINE_ID, self.test_prog_image), "Can't load programs into eBPF subsystem") @@ -112,6 +135,11 @@ def tearDown(self): self.exec_ns_cmd("psabpf-ctl pipeline unload id {}".format(TEST_PIPELINE_ID)) super(P4EbpfTest, self).tearDown() + def get_dataplane_port_number(self, name): + with pyroute2.NetNS(self.switch_ns) as netns: + idx = netns.link_lookup(ifname=name) + return idx[0] + def exec_ns_cmd(self, command='echo me', do_fail=None): command = "nsenter --net=/var/run/netns/" + self.switch_ns + " " + command return self.exec_cmd(command, do_fail) diff --git a/backends/ebpf/tests/ptf/l2l3_acl.py b/backends/ebpf/tests/ptf/l2l3_acl.py index 1de333bd5f3..e1237668d93 100644 --- a/backends/ebpf/tests/ptf/l2l3_acl.py +++ b/backends/ebpf/tests/ptf/l2l3_acl.py @@ -49,12 +49,12 @@ def configure_port(self, port_id, vlan_id=None): def setUp(self): super(L2L3SwitchTest, self).setUp() - self.configure_port(port_id=4) - self.configure_port(port_id=9) - self.configure_port(port_id=5, vlan_id=1) - self.configure_port(port_id=6, vlan_id=1) - self.configure_port(port_id=8, vlan_id=1) - self.configure_port(port_id=7, vlan_id=2) + self.configure_port(port_id=DP_PORTS[0]) + self.configure_port(port_id=DP_PORTS[5]) + self.configure_port(port_id=DP_PORTS[1], vlan_id=1) + self.configure_port(port_id=DP_PORTS[2], vlan_id=1) + self.configure_port(port_id=DP_PORTS[4], vlan_id=1) + self.configure_port(port_id=DP_PORTS[3], vlan_id=2) def tearDown(self): super(L2L3SwitchTest, self).tearDown() @@ -76,9 +76,9 @@ def runTest(self): testutils.verify_no_other_packets(self) # check connectivity between ports in VLAN 1 - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 1], action=1, data=[5]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 1], action=1, data=[6]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[8]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 1], action=1, data=[DP_PORTS[1]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 1], action=1, data=[DP_PORTS[2]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[DP_PORTS[4]]) pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:00:03") pkt = pkt_add_vlan(pkt, vlan_vid=1) testutils.send_packet(self, PORT1, pkt) @@ -99,8 +99,8 @@ def runTest(self): testutils.verify_no_other_packets(self) # check connectivity between ports with no VLAN - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 0], action=1, data=[4]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 0], action=1, data=[9]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 0], action=1, data=[DP_PORTS[0]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 0], action=1, data=[DP_PORTS[5]]) pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:00:02") testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT5) @@ -109,14 +109,14 @@ def runTest(self): testutils.verify_packet(self, pkt, PORT0) # check no connectivity between VLAN 1 and VLAN 2 - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:02:02", 2], action=1, data=[6]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:02:02", 2], action=1, data=[DP_PORTS[2]]) pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:02:02") pkt = pkt_add_vlan(pkt, vlan_vid=1) testutils.send_packet(self, PORT1, pkt) testutils.verify_no_packet(self, pkt, PORT3) # check no connectivity between VLAN 1 and no VLAN ports - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:03:02", 0], action=1, data=[4]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:03:02", 0], action=1, data=[DP_PORTS[0]]) pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:02:02") pkt = pkt_add_vlan(pkt, vlan_vid=1) testutils.send_packet(self, PORT1, pkt) @@ -126,10 +126,10 @@ def runTest(self): class RoutingTest(L2L3SwitchTest): def runTest(self): - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:02:02", 2], action=1, data=[7]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 1], action=1, data=[5]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 1], action=1, data=[6]) - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[8]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:02:02", 2], action=1, data=[DP_PORTS[3]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:01", 1], action=1, data=[DP_PORTS[1]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:02", 1], action=1, data=[DP_PORTS[2]]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[DP_PORTS[4]]) # check no connectivity between VLAN 1 and VLAN 2 pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:02:02") @@ -199,7 +199,7 @@ def runTest(self): value = self.digest_get("packet_deparser_mac_learn_digest") if len(value) != 1: self.fail("Digest not generated") - if int(value[0]["port"], 0) != p[0]+4: + if int(value[0]["port"], 0) != DP_PORTS[p[0]]: self.fail("Digest generated invalid port") @@ -209,17 +209,17 @@ def runTest(self): # Create multicast group and add members # Multicast group for VLAN 1 self.multicast_group_create(group=1) - self.multicast_group_add_member(group=1, egress_port=5) - self.multicast_group_add_member(group=1, egress_port=6) - self.multicast_group_add_member(group=1, egress_port=8) + self.multicast_group_add_member(group=1, egress_port=DP_PORTS[1]) + self.multicast_group_add_member(group=1, egress_port=DP_PORTS[2]) + self.multicast_group_add_member(group=1, egress_port=DP_PORTS[4]) # Multicast group for VLAN 2 self.multicast_group_create(group=2) # Multicast group for no VLAN ports (VLAN 0) self.multicast_group_create(group=3) - self.multicast_group_add_member(group=3, egress_port=4) - self.multicast_group_add_member(group=3, egress_port=9) + self.multicast_group_add_member(group=3, egress_port=DP_PORTS[0]) + self.multicast_group_add_member(group=3, egress_port=DP_PORTS[5]) # no VLAN, Multicast group ID = 0 self.table_add(table="ingress_tbl_switching", key=["ff:ff:ff:ff:ff:ff", 0], action=2, data=[3]) @@ -249,7 +249,7 @@ def runTest(self): class ACLTest(L2L3SwitchTest): def runTest(self): - self.table_add(table="ingress_tbl_switching", key=["00:01:02:03:04:05", 0], action=1, data=[9]) + self.table_add(table="ingress_tbl_switching", key=["00:01:02:03:04:05", 0], action=1, data=[DP_PORTS[5]]) udp_pkt_1 = testutils.simple_udp_packet(ip_src="10.0.0.1", ip_dst="10.0.0.2", udp_sport=1234, udp_dport=50051) tcp_pkt_1 = testutils.simple_tcp_packet(ip_src="10.0.0.1", ip_dst="10.0.0.2", @@ -280,7 +280,7 @@ def runTest(self): class PortCountersTest(L2L3SwitchTest): def runTest(self): - self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[8]) + self.table_add(table="ingress_tbl_switching", key=["00:00:00:00:00:03", 1], action=1, data=[DP_PORTS[4]]) pkt = testutils.simple_udp_packet(eth_dst="00:00:00:00:00:03") pkt = pkt_add_vlan(pkt, vlan_vid=1) @@ -293,6 +293,6 @@ def runTest(self): ig_bytes += len(pkt) eg_bytes = ig_bytes + (4*(i+1)) pkts_cnt = i + 1 - self.counter_verify(name="ingress_in_pkts", key=[5], bytes=ig_bytes, packets=pkts_cnt) - self.table_verify(table="egress_tbl_vlan_egress", key=[8], action=2, data=[1], + self.counter_verify(name="ingress_in_pkts", key=[DP_PORTS[1]], bytes=ig_bytes, packets=pkts_cnt) + self.table_verify(table="egress_tbl_vlan_egress", key=[DP_PORTS[4]], action=2, data=[1], counters={"egress_out_pkts": {"bytes": eg_bytes, "packets": pkts_cnt}}) diff --git a/backends/ebpf/tests/ptf/meters.py b/backends/ebpf/tests/ptf/meters.py index e0b76984d78..5f92d228b82 100644 --- a/backends/ebpf/tests/ptf/meters.py +++ b/backends/ebpf/tests/ptf/meters.py @@ -180,7 +180,7 @@ def runTest(self): # cir, pir -> 10 Mb/s -> 1,25 MB/s, cbs, pbs -> bs (10 ms) -> 6250 B self.meter_update(name="ingress_meter1", index=0, pir=1250000, pbs=6250, cir=1250000, cbs=6250) - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data=[5]) + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]]) testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) @@ -227,7 +227,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data="5", + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]], meters={"ingress_meter1": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}}) testutils.send_packet(self, PORT0, pkt) @@ -236,7 +236,7 @@ def runTest(self): meter_value = build_meter_value(pir=1250000, cir=1250000, pbs=6250, pbs_left=6150, cbs=6250, cbs_left=6150) expected_value = "hex 01 00 00 00 05 00 00 00 " + meter_value - self.verify_map_entry(name="ingress_tbl_fwd", key="hex 04 00 00 00", + self.verify_map_entry(name="ingress_tbl_fwd", key="hex {:02x} 00 00 00".format(DP_PORTS[0]), expected_value=expected_value, mask=get_meter_value_mask()) @@ -253,7 +253,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data="5", + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]], meters={"ingress_meter1": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}}) testutils.send_packet(self, PORT0, pkt) @@ -262,7 +262,7 @@ def runTest(self): meter_value = build_meter_value(pir=1250000, cir=1250000, pbs=6250, pbs_left=6150, cbs=6250, cbs_left=6250) expected_value = "hex 01 00 00 00 05 00 00 00 " + meter_value - self.verify_map_entry(name="ingress_tbl_fwd", key="hex 04 00 00 00", + self.verify_map_entry(name="ingress_tbl_fwd", key="hex {:02x} 00 00 00".format(DP_PORTS[0]), expected_value=expected_value, mask=get_meter_value_mask()) @@ -279,7 +279,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data="5", + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]], meters={"ingress_direct_meter": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}}) # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B @@ -292,7 +292,7 @@ def runTest(self): pbs_left=6150, cbs=6250, cbs_left=6150) # action id | egress_port | meter_value expected_value = "hex 01 00 00 00 05 00 00 00 " + meter_value - self.verify_map_entry(name="ingress_tbl_fwd", key="hex 04 00 00 00", + self.verify_map_entry(name="ingress_tbl_fwd", key="hex {:02x} 00 00 00".format(DP_PORTS[0]), expected_value=expected_value, mask=get_meter_value_mask()) @@ -326,7 +326,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data=[5], + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]], meters={"ingress_meter1": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}, "ingress_meter2": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}}) @@ -340,7 +340,7 @@ def runTest(self): pbs_left=6150, cbs=6250, cbs_left=6150, add_spin_lock=True) expected_value = "hex 01 00 00 00 05 00 00 00 " + meter_1_value + meter_2_value - self.verify_map_entry(name="ingress_tbl_fwd", key="hex 04 00 00 00", + self.verify_map_entry(name="ingress_tbl_fwd", key="hex {:02x} 00 00 00".format(DP_PORTS[0]), expected_value=expected_value, mask=get_meter_value_mask(with_spin_lock=False) + get_meter_value_mask(add_hex_prefix=False)) @@ -358,7 +358,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() # cir, pir -> 10 Mb/s, cbs, pbs -> bs (10 ms) -> 6250 B - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data=[5], + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]], counters={"ingress_counter1": {"packets": 1}}, meters={"ingress_meter1": {"pir": 1250000, "pbs": 6250, "cir": 1250000, "cbs": 6250}}) @@ -369,6 +369,6 @@ def runTest(self): pbs_left=6150, cbs=6250, cbs_left=6150) # action id | egress_port | counter packets and padding | meter_value expected_value = "hex 01 00 00 00 05 00 00 00 02 00 00 00 00 00 00 00 " + meter_value - self.verify_map_entry(name="ingress_tbl_fwd", key="hex 04 00 00 00", + self.verify_map_entry(name="ingress_tbl_fwd", key="hex {:02x} 00 00 00".format(DP_PORTS[0]), expected_value=expected_value, mask=get_meter_value_mask()) diff --git a/backends/ebpf/tests/ptf/register.py b/backends/ebpf/tests/ptf/register.py index a765707baa5..f132cace5ce 100644 --- a/backends/ebpf/tests/ptf/register.py +++ b/backends/ebpf/tests/ptf/register.py @@ -44,17 +44,17 @@ class RegisterActionPSATest(P4EbpfTest): def runTest(self): pkt = testutils.simple_ip_packet() - self.table_add(table="ingress_tbl_fwd", key=[4], action=1, data=[5]) + self.table_add(table="ingress_tbl_fwd", key=[DP_PORTS[0]], action=1, data=[DP_PORTS[1]]) testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) # Checks action run - self.register_verify(name="ingress_reg", index=["0x5"], expected_value=["0x5"]) + self.register_verify(name="ingress_reg", index=[DP_PORTS[1]], expected_value=["0x5"]) # After next action run in register should be stored a new value - 15 testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) - self.register_verify(name="ingress_reg", index=["0x5"], expected_value=["0xf"]) + self.register_verify(name="ingress_reg", index=["{}".format(hex(DP_PORTS[1]))], expected_value=["0xf"]) class RegisterApplyPSATest(P4EbpfTest): @@ -95,7 +95,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() testutils.send_packet(self, PORT0, pkt) - self.register_verify(name="ingress_reg", index=["0x5"], expected_value=["0x10"]) + self.register_verify(name="ingress_reg", index=["{}".format(hex(DP_PORTS[1]))], expected_value=["0x10"]) class RegisterBigKeyPSATest(P4EbpfTest): diff --git a/backends/ebpf/tests/ptf/table_implementation.py b/backends/ebpf/tests/ptf/table_implementation.py index e13d11cacd4..c74f0072d2a 100644 --- a/backends/ebpf/tests/ptf/table_implementation.py +++ b/backends/ebpf/tests/ptf/table_implementation.py @@ -39,14 +39,14 @@ class SimpleActionProfilePSATest(P4EbpfTest): def runTest(self): pkt = testutils.simple_ip_packet(eth_src="11:22:33:44:55:66", eth_dst="22:33:44:55:66:77") testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) ref = self.action_profile_add_action(ap="MyIC_ap", action=2, data=[0x1122]) self.table_add(table="MyIC_tbl", key=["11:22:33:44:55:66"], references=[ref]) testutils.send_packet(self, PORT0, pkt) pkt[Ether].type = 0x1122 - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) class ActionProfileTwoTablesSameInstancePSATest(P4EbpfTest): @@ -63,12 +63,12 @@ def runTest(self): pkt = testutils.simple_ip_packet(eth_src="11:22:33:44:55:66", eth_dst="22:33:44:55:66:77") testutils.send_packet(self, PORT0, pkt) pkt[Ether].type = 0x1122 - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt = testutils.simple_ip_packet(eth_src="AA:BB:CC:DD:EE:FF", eth_dst="22:33:44:55:66:77") testutils.send_packet(self, PORT0, pkt) pkt[Ether].type = 0x1122 - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) class ActionProfileLPMTablePSATest(P4EbpfTest): @@ -84,12 +84,12 @@ def runTest(self): pkt = testutils.simple_ip_packet(eth_src="AA:BB:CC:DD:EE:FF", eth_dst="22:33:44:55:66:77") testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[Ether].src = "11:22:33:44:55:66" testutils.send_packet(self, PORT0, pkt) pkt[Ether].type = 0x1122 - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) # TODO: add test with ternary table @@ -136,7 +136,7 @@ def runTest(self): testutils.send_packet(self, PORT0, pkt) pkt[Ether].type = 0x1122 - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) # ----------------------------- Action Selector ----------------------------- @@ -149,8 +149,8 @@ class ActionSelectorTest(P4EbpfTest): def create_actions(self, selector): for i in range(1, 7): - # i: member reference; 3+i: output port - ref = self.action_selector_add_action(selector, action=1, data=[i+3]) + # i: member reference; output port from DP_PORTS + ref = self.action_selector_add_action(selector, action=1, data=[DP_PORTS[i-1]]) if i != ref: self.fail("Invalid member reference: expected {}, got {}".format(i, ref)) @@ -244,7 +244,7 @@ def runTest(self): testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) - cmd = "psabpf-ctl action-selector empty-group-action pipe {} MyIC_as action id 1 data 6".format(TEST_PIPELINE_ID) + cmd = "psabpf-ctl action-selector empty-group-action pipe {} MyIC_as action id 1 data {}".format(TEST_PIPELINE_ID, DP_PORTS[2]) self.exec_ns_cmd(cmd, "empty group action update failed") testutils.send_packet(self, PORT0, pkt) @@ -342,7 +342,7 @@ def runTest(self): pkt = testutils.simple_ip_packet(eth_src="02:22:33:44:55:66", eth_dst="22:33:44:55:66:77") testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[Ether].src = "03:22:33:44:55:66" testutils.send_packet(self, PORT0, pkt) diff --git a/backends/ebpf/tests/ptf/test.py b/backends/ebpf/tests/ptf/test.py index d2ddccabb3d..8f69d609c3d 100644 --- a/backends/ebpf/tests/ptf/test.py +++ b/backends/ebpf/tests/ptf/test.py @@ -25,11 +25,6 @@ from ptf.packet import MPLS from ptf.mask import Mask -PORT0 = 0 -PORT1 = 1 -PORT2 = 2 -ALL_PORTS = [PORT0, PORT1, PORT2] - class SimpleForwardingPSATest(P4EbpfTest): @@ -41,7 +36,7 @@ def runTest(self): testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) # change default action - self.table_set_default(table="ingress_tbl_fwd", action=1, data=[6]) + self.table_set_default(table="ingress_tbl_fwd", action=1, data=[DP_PORTS[2]]) testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT2) @@ -81,12 +76,12 @@ class PSACloneI2E(P4EbpfTest): def runTest(self): # create clone session table self.clone_session_create(8) - # add egress_port=6 (PORT2), instance=1 as clone session member, cos = 0 - self.clone_session_add_member(clone_session=8, egress_port=6) - # add egress_port=6 (PORT2), instance=2 as clone session member, cos = 1 - self.clone_session_add_member(clone_session=8, egress_port=6, instance=2, cos=1) + # add PORT2, instance=1 as clone session member, cos = 0 + self.clone_session_add_member(clone_session=8, egress_port=DP_PORTS[2]) + # add PORT2, instance=2 as clone session member, cos = 1 + self.clone_session_add_member(clone_session=8, egress_port=DP_PORTS[2], instance=2, cos=1) - pkt = testutils.simple_eth_packet(eth_dst='00:00:00:00:00:05') + pkt = testutils.simple_eth_packet(eth_dst='00:00:00:00:00:{:02x}'.format(DP_PORTS[1])) testutils.send_packet(self, PORT0, pkt) cloned_pkt = copy.deepcopy(pkt) cloned_pkt[Ether].type = 0xface @@ -95,7 +90,7 @@ def runTest(self): pkt[Ether].src = "00:00:00:00:ca:fe" testutils.verify_packet(self, pkt, PORT1) - pkt = testutils.simple_eth_packet(eth_dst='00:00:00:00:00:09') + pkt = testutils.simple_eth_packet(eth_dst='00:00:00:00:00:{:02x}'.format(DP_PORTS[5])) testutils.send_packet(self, PORT0, pkt) testutils.verify_no_packet(self, pkt, PORT1) @@ -110,7 +105,7 @@ class EgressTrafficManagerDropPSATest(P4EbpfTest): def runTest(self): pkt = testutils.simple_ip_packet(eth_dst='00:11:22:33:44:55', eth_src='55:44:33:22:11:00') testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[Ether].src = '00:44:33:22:FF:FF' testutils.send_packet(self, PORT0, pkt) testutils.verify_no_other_packets(self) @@ -130,8 +125,8 @@ class EgressTrafficManagerClonePSATest(P4EbpfTest): def runTest(self): # create clone session table self.clone_session_create(8) - # add egress_port=6 (PORT2), instance=1 as clone session member, cos = 0 - self.clone_session_add_member(clone_session=8, egress_port=6) + # add PORT2, instance=1 as clone session member, cos = 0 + self.clone_session_add_member(clone_session=8, egress_port=DP_PORTS[2]) pkt = testutils.simple_ip_packet(eth_dst='aa:bb:cc:dd:ee:ff', eth_src='55:44:33:22:11:00') testutils.send_packet(self, PORT1, pkt) @@ -161,13 +156,13 @@ def runTest(self): pkt = testutils.simple_ip_packet(eth_dst='00:11:22:33:44:55', eth_src='55:44:33:22:11:00') testutils.send_packet(self, PORT0, pkt) pkt[Ether].src = '00:44:33:22:11:00' - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt = testutils.simple_ip_packet(eth_dst='00:11:22:33:FE:F0', eth_src='55:44:33:22:11:00') testutils.send_packet(self, PORT0, pkt) pkt[Ether].dst = '00:00:00:00:00:00' pkt[Ether].src = '00:44:33:22:11:00' - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) class MulticastPSATest(P4EbpfTest): @@ -175,8 +170,8 @@ class MulticastPSATest(P4EbpfTest): def runTest(self): self.multicast_group_create(group=8) - self.multicast_group_add_member(group=8, egress_port=5) - self.multicast_group_add_member(group=8, egress_port=6) + self.multicast_group_add_member(group=8, egress_port=DP_PORTS[1]) + self.multicast_group_add_member(group=8, egress_port=DP_PORTS[2]) pkt = testutils.simple_eth_packet(eth_dst='00:00:00:00:00:05') testutils.send_packet(self, PORT0, pkt) @@ -199,13 +194,13 @@ class SimpleLpmP4PSATest(P4EbpfTest): def runTest(self): # This command adds LPM entry 10.10.0.0/16 with action forwarding on port 6 (PORT2 in ptf) - self.table_add(table="ingress_tbl_fwd_lpm", key=["10.10.0.0/16"], action=1, data=[6]) + self.table_add(table="ingress_tbl_fwd_lpm", key=["10.10.0.0/16"], action=1, data=[DP_PORTS[2]]) self.table_add(table="ingress_tbl_fwd_lpm", key=["10.10.10.10/8"], action="_NoAction") pkt = testutils.simple_ip_packet(ip_src='1.1.1.1', ip_dst='10.10.11.11') testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT2) - self.table_add(table="ingress_tbl_fwd_lpm", key=["192.168.2.1/24"], action=1, data=[5]) + self.table_add(table="ingress_tbl_fwd_lpm", key=["192.168.2.1/24"], action=1, data=[DP_PORTS[1]]) pkt = testutils.simple_ip_packet(ip_src='1.1.1.1', ip_dst='192.168.2.1') testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) @@ -217,16 +212,16 @@ class SimpleLpmP4TwokeyPSATest(P4EbpfTest): def runTest(self): pkt = testutils.simple_ip_packet(ip_src='1.2.3.4', ip_dst='10.10.11.11') - # This command adds LPM entry 10.10.11.0/24 with action forwarding on port 6 (PORT2 in ptf) + # This command adds LPM entry 10.10.11.0/24 with action forwarding on PORT2 # Note that prefix value has to be a sum of exact fields size and lpm prefix - self.table_add(table="ingress_tbl_fwd_exact_lpm", key=["1.2.3.4", "10.10.11.0/24"], action=1, data=[6]) + self.table_add(table="ingress_tbl_fwd_exact_lpm", key=["1.2.3.4", "10.10.11.0/24"], action=1, data=[DP_PORTS[2]]) testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT2) pkt = testutils.simple_ip_packet(ip_src='1.2.3.4', ip_dst='192.168.2.1') - # This command adds LPM entry 192.168.2.1/24 with action forwarding on port 5 (PORT1 in ptf) - self.table_add(table="ingress_tbl_fwd_exact_lpm", key=["1.2.3.4", "192.168.2.1/24"], action=1, data=[5]) + # This command adds LPM entry 192.168.2.1/24 with action forwarding on PORT1 + self.table_add(table="ingress_tbl_fwd_exact_lpm", key=["1.2.3.4", "192.168.2.1/24"], action=1, data=[DP_PORTS[1]]) testutils.send_packet(self, PORT0, pkt) testutils.verify_packet(self, pkt, PORT1) @@ -282,7 +277,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[Ether].dst = 'FF:FF:FF:FF:FF:FF' testutils.send_packet(self, PORT0, pkt) @@ -361,7 +356,7 @@ def runTest(self): if len(digests) != 3: self.fail("Expected 3 digest messages, got {}".format(len(digests))) for d in digests: - if d["srcAddr"] != "0xfafbfcfdfef0" or d["ingress_port"] != "0x4": + if d["srcAddr"] != "0xfafbfcfdfef0" or int(d["ingress_port"], 0) != DP_PORTS[0]: self.fail("Digest map stored wrong values: mac->{}, port->{}".format(d["srcAddr"], d["ingress_port"])) @@ -373,23 +368,23 @@ def runTest(self): eth_src='00:AA:00:00:00:01', pktlen=100) testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) self.counter_verify(name="ingress_test1_cnt", key=[1], bytes=100) self.counter_verify(name="ingress_test2_cnt", key=[1], packets=1) self.counter_verify(name="ingress_test3_cnt", key=[1], bytes=100, packets=1) - self.counter_verify(name="ingress_action_cnt", key=[5], bytes=100, packets=1) + self.counter_verify(name="ingress_action_cnt", key=[DP_PORTS[1]], bytes=100, packets=1) pkt = testutils.simple_ip_packet(eth_dst='00:11:22:33:44:55', eth_src='00:AA:00:00:01:FE', pktlen=199) testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) self.counter_verify(name="ingress_test1_cnt", key=[0x1fe], bytes=199) self.counter_verify(name="ingress_test2_cnt", key=[0x1fe], packets=1) self.counter_verify(name="ingress_test3_cnt", key=[0x1fe], bytes=199, packets=1) - self.counter_verify(name="ingress_action_cnt", key=[5], bytes=299, packets=2) + self.counter_verify(name="ingress_action_cnt", key=[DP_PORTS[1]], bytes=299, packets=2) class DirectCountersPSATest(P4EbpfTest): @@ -403,7 +398,7 @@ def runTest(self): for i in range(3): pkt = testutils.simple_ip_packet(pktlen=100, ip_src='10.0.0.{}'.format(i)) testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) self.table_verify(table="ingress_tbl1", key=["10.0.0.0"], action=1, counters={"ingress_test3_cnt": {"bytes": 100, "packets": 1}}) @@ -431,7 +426,7 @@ def runTest(self): self.value_set_insert(name="IngressParserImpl_pvs", value=["10.0.0.1"]) testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[IP].dst = '8.8.8.8' testutils.send_packet(self, PORT0, pkt) @@ -477,7 +472,7 @@ def runTest(self): sequence = [[], [], []] for _ in range(10): testutils.send_packet(self, PORT0, pkt) - (_, recv_pkt) = testutils.verify_packet_any_port(self, mask, ALL_PORTS) + (_, recv_pkt) = testutils.verify_packet_any_port(self, mask, PTF_PORTS) recv_pkt = Ether(recv_pkt) self.verify_range(value=recv_pkt[self.RandomHeader].f1, min_value=0x80_00_00_01, max_value=0x80_00_00_05) sequence[0].append(recv_pkt[self.RandomHeader].f1) @@ -497,7 +492,7 @@ def runTest(self): pkt = testutils.simple_ip_packet() testutils.send_packet(self, PORT0, pkt) - testutils.verify_packet_any_port(self, pkt, ALL_PORTS) + testutils.verify_packet_any_port(self, pkt, PTF_PORTS) pkt[Ether].src = '00:00:00:00:00:00' testutils.send_packet(self, PORT0, pkt) diff --git a/backends/ebpf/tests/ptf/upf.py b/backends/ebpf/tests/ptf/upf.py index 202c5ee7f05..8fe19e0b832 100644 --- a/backends/ebpf/tests/ptf/upf.py +++ b/backends/ebpf/tests/ptf/upf.py @@ -22,11 +22,6 @@ GTPU_UDP_PORT=2152 -#link number -N3_PORT=4 -N6_PORT=5 -N9_PORT=6 - #PTF N3_PTF_PORT=0 N6_PTF_PORT=1 @@ -84,6 +79,10 @@ def setup_pfcp_session(self,seid, teid, ue_ip): self.table_add(table="ingress_upf_ingress_session_lookup_by_ue_ip", key=[ue_ip], action=1,data=[seid]) def runTest(self): + #link number + N3_PORT=DP_PORTS[0] + N6_PORT=DP_PORTS[1] + N9_PORT=DP_PORTS[2] self.table_add(table="ingress_upf_ingress_source_interface_lookup_by_port", key=[N3_PORT], action=1, data=[ACCESS]) self.table_add(table="ingress_upf_ingress_source_interface_lookup_by_port", key=[N9_PORT], action=1, data=[CORE]) self.table_add(table="ingress_upf_ingress_source_interface_lookup_by_port", key=[N6_PORT], action=1, data=[SGi_LAN])