Skip to content

Commit

Permalink
Fix up the DPDK and PSA back end, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy committed Jan 24, 2024
1 parent c061772 commit 8d21304
Show file tree
Hide file tree
Showing 32 changed files with 522 additions and 18 deletions.
2 changes: 1 addition & 1 deletion backends/dpdk/dpdkAsmOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ bool EmitDpdkTableConfig::isAllKeysDefaultExpression(const IR::ListExpression *k
void EmitDpdkTableConfig::postorder(const IR::DpdkTable *table) {
auto entriesList = table->getEntries();
if (entriesList == nullptr) return;
dpdkTableConfigFile.open(table->name + ".txt");
dpdkTableConfigFile.open(table->name + ".txtpb");
auto needsPriority = tableNeedsPriority(table, refMap);
int entryPriority = entriesList->entries.size();
for (auto e : entriesList->entries) {
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/run-dpdk-ptf-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def run_test(options: Options) -> int:

# Define the test environment and compile the P4 target
test_name = Path(options.p4_file.name)
info_name = options.testdir.joinpath("p4Info.txt")
info_name = options.testdir.joinpath("p4Info.txtpb")
bf_rt_schema = options.testdir.joinpath("bf-rt.json")
conf_bin = options.testdir.joinpath(test_name.with_suffix(".pb.bin"))
# Files needed by the pipeline
Expand Down
4 changes: 2 additions & 2 deletions backends/dpdk/run-dpdk-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ def process_file(options, argv):
print("Writing temporary files into ", tmpdir)
stderr = os.path.join(tmpdir, basename + "-error")
spec = os.path.join(tmpdir, basename + ".spec")
p4runtimeFile = os.path.join(tmpdir, basename + ".p4info.txt")
p4runtimeEntriesFile = os.path.join(tmpdir, basename + ".entries.txt")
p4runtimeFile = os.path.join(tmpdir, basename + ".p4info.txtpb")
p4runtimeEntriesFile = os.path.join(tmpdir, basename + ".entries.txtpb")
bfRtSchemaFile = os.path.join(tmpdir, basename + ".bfrt.json")

def getArch(path):
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/ebpfParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void StateTranslationVisitor::compileExtractField(const IR::Expression *expr,
// 0x112233445566778809
// 0x112233445566778890
// To correctly insert that padding, the length of field must be known, but tools like
// nikss-ctl (and the nikss library) don't consume P4info.txt to have such knowledge.
// nikss-ctl (and the nikss library) don't consume P4info.txtpb to have such knowledge.
// There is also a bug in (de)parser causing such fields to be deparsed incorrectly.
::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET,
"%1%: fields wider than 64 bits must have a size multiple of 8 bits (1 byte) "
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 9 additions & 1 deletion backends/ebpf/run-ebpf-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,15 @@ def run_test(options, argv):
result = testutils.SUCCESS
else:
result = run_model(ebpf, testfile)
elif options.replace:
exp_dir = os.path.dirname(options.p4filename).replace("_errors", "_errors_outputs", 1)
exp_file = options.p4filename.replace("_errors/", "_errors_outputs/", 1) + "-stderr"
testutils.check_and_create_dir(Path(exp_dir))
with open(exp_file, mode="w+", encoding="utf-8") as error_file:
error_file.write(out)
else: # Expected error, check output matches
exp_file = options.p4filename.replace("_errors/", "_errors_outputs/", 1) + "-stderr"
with open(exp_file, 'r') as f:
with open(exp_file, 'r', encoding="utf-8") as f:
exp_stderr = f.read().strip()
# Output will have full path which differs
out = out.replace(options.p4filename, basename).strip()
Expand Down Expand Up @@ -234,6 +240,8 @@ def run_test(options, argv):
options.compiler = testutils.check_if_file(args.compiler).as_posix()
options.p4filename = testutils.check_if_file(args.p4filename).as_posix()
options.replace = args.replace
if "P4TEST_REPLACE" in os.environ:
options.replace = True
options.cleanupTmp = args.nocleanup
if args.testfile:
options.testfile = testutils.check_if_file(args.testfile).as_posix()
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/tests/ptf/bng.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def pkt_decrement_ttl(pkt):

class BNGTest(P4EbpfTest):
p4_file_path = "../psa/examples/bng.p4"
p4info_reference_file_path = "../psa/examples/bng.p4info.txt"
p4info_reference_file_path = "../psa/examples/bng.p4info.txtpb"
session_installed = False

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/tests/ptf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def setUp(self):
p4args += " --xdp"

if self.p4info_reference_file_path:
self.p4info_p4c_generated = os.path.join("ptf_out", filename + ".p4info.txt")
self.p4info_p4c_generated = os.path.join("ptf_out", filename + ".p4info.txtpb")
p4args += " --p4runtime-files {}".format(self.p4info_p4c_generated)

p4args = p4args + " " + self.p4c_additional_args
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/tests/ptf/l2l3_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def pkt_add_vlan(pkt, vlan_vid=10, vlan_pcp=0, dl_vlan_cfi=0):

class L2L3SwitchTest(P4EbpfTest):
p4_file_path = "../psa/examples/l2l3-acl.p4"
p4info_reference_file_path = "../psa/examples/l2l3-acl.p4info.txt"
p4info_reference_file_path = "../psa/examples/l2l3-acl.p4info.txtpb"

def configure_port(self, port_id, vlan_id=None):
if vlan_id is None:
Expand Down
4 changes: 2 additions & 2 deletions backends/ebpf/tests/ptf/meters.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MeterPSATest(P4EbpfTest):
"""

p4_file_path = "p4testdata/meters.p4"
p4info_reference_file_path = "p4testdata/meters.p4info.txt"
p4info_reference_file_path = "p4testdata/meters.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_ip_packet()
Expand Down Expand Up @@ -237,7 +237,7 @@ class DirectMeterPSATest(P4EbpfTest):
"""

p4_file_path = "p4testdata/meters-direct.p4"
p4info_reference_file_path = "p4testdata/meters-direct.p4info.txt"
p4info_reference_file_path = "p4testdata/meters-direct.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_ip_packet()
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/tests/ptf/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RegisterApplyPSATest(P4EbpfTest):
"""

p4_file_path = "p4testdata/register-apply.p4"
p4info_reference_file_path = "p4testdata/register-apply.p4info.txt"
p4info_reference_file_path = "p4testdata/register-apply.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_ip_packet()
Expand Down
4 changes: 2 additions & 2 deletions backends/ebpf/tests/ptf/table_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ActionProfileTwoTablesSameInstancePSATest(P4EbpfTest):
"""

p4_file_path = "p4testdata/action-profile2.p4"
p4info_reference_file_path = "p4testdata/action-profile2.p4info.txt"
p4info_reference_file_path = "p4testdata/action-profile2.p4info.txtpb"

def runTest(self):
ref = self.action_profile_add_action(ap="MyIC_ap", action=2, data=[0x1122])
Expand Down Expand Up @@ -236,7 +236,7 @@ class ActionSelectorTwoTablesSameInstancePSATest(ActionSelectorTest):
"""

p4_file_path = "p4testdata/action-selector2.p4"
p4info_reference_file_path = "p4testdata/action-selector2.p4info.txt"
p4info_reference_file_path = "p4testdata/action-selector2.p4info.txtpb"

def runTest(self):
self.create_default_rule_set(table="MyIC_tbl", selector="MyIC_as")
Expand Down
6 changes: 3 additions & 3 deletions backends/ebpf/tests/ptf/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def runTest(self):

class DigestPSATest(P4EbpfTest):
p4_file_path = "p4testdata/digest.p4"
p4info_reference_file_path = "p4testdata/digest.p4info.txt"
p4info_reference_file_path = "p4testdata/digest.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_ip_packet(eth_src="fa:fb:fc:fd:fe:f0")
Expand Down Expand Up @@ -409,7 +409,7 @@ def runTest(self):

class CountersPSATest(P4EbpfTest):
p4_file_path = "p4testdata/counters.p4"
p4info_reference_file_path = "p4testdata/counters.p4info.txt"
p4info_reference_file_path = "p4testdata/counters.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_ip_packet(
Expand Down Expand Up @@ -481,7 +481,7 @@ class ParserValueSetPSATest(P4EbpfTest):
"""

p4_file_path = "p4testdata/pvs.p4"
p4info_reference_file_path = "p4testdata/pvs.p4info.txt"
p4info_reference_file_path = "p4testdata/pvs.p4info.txtpb"

def runTest(self):
pkt = testutils.simple_udp_packet(ip_dst="10.0.0.1", udp_dport=80)
Expand Down
2 changes: 1 addition & 1 deletion backends/ebpf/tests/ptf/upf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def pkt_route(pkt, mac_src, mac_dst):

class UPFTest(P4EbpfTest):
p4_file_path = "../psa/examples/upf.p4"
p4info_reference_file_path = "../psa/examples/upf.p4info.txt"
p4info_reference_file_path = "../psa/examples/upf.p4info.txtpb"

def setup_pfcp_session(self, seid, teid, ue_ip):
self.table_add(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
psa-action-profile2.p4(59): [--Werror=invalid] error: Expected psa_implementation property value for table MyIC.tbl to resolve to an extern instance: psa_implementation
psa_implementation = { ap, ap1 };
^^^^^^^^^^^^^^^^^^
psa-action-profile2.p4(59): [--Werror=invalid] error: Expected psa_implementation property value for table MyIC.tbl to resolve to an extern instance: psa_implementation
psa_implementation = { ap, ap1 };
^^^^^^^^^^^^^^^^^^
81 changes: 81 additions & 0 deletions testdata/p4_16_psa_errors_outputs/psa-action-profile2.p4.bfrt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"schema_version" : "1.0.0",
"tables" : [
{
"name" : "ip.MyIC.tbl",
"id" : 39967501,
"table_type" : "MatchAction_Direct",
"size" : 1024,
"annotations" : [],
"depends_on" : [],
"has_const_default_action" : false,
"key" : [
{
"id" : 1,
"name" : "hdr.ethernet.srcAddr",
"repeated" : false,
"annotations" : [],
"mandatory" : false,
"match_type" : "Exact",
"type" : {
"type" : "bytes",
"width" : 48
}
}
],
"action_specs" : [
{
"id" : 21257015,
"name" : "NoAction",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : []
},
{
"id" : 21832421,
"name" : "MyIC.a1",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : [
{
"id" : 1,
"name" : "param",
"repeated" : false,
"mandatory" : true,
"read_only" : false,
"annotations" : [],
"type" : {
"type" : "bytes",
"width" : 48
}
}
]
},
{
"id" : 23466264,
"name" : "MyIC.a2",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : [
{
"id" : 1,
"name" : "param",
"repeated" : false,
"mandatory" : true,
"read_only" : false,
"annotations" : [],
"type" : {
"type" : "bytes",
"width" : 16
}
}
]
}
],
"data" : [],
"supported_operations" : [],
"attributes" : ["EntryScope"]
}
],
"learn_filters" : []
}
2 changes: 2 additions & 0 deletions testdata/p4_16_psa_errors_outputs/psa-counter6.p4-error
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[--Werror=duplicate] error: Name 'MyIC.counter0' is used for multiple direct counter objects in the P4Info message
[--Werror=duplicate] error: Found 1 duplicate name(s) in the P4Info
120 changes: 120 additions & 0 deletions testdata/p4_16_psa_errors_outputs/psa-counter6.p4.bfrt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"schema_version" : "1.0.0",
"tables" : [
{
"name" : "ip.MyIC.tbl",
"id" : 39967501,
"table_type" : "MatchAction_Direct",
"size" : 1024,
"annotations" : [],
"depends_on" : [],
"has_const_default_action" : false,
"key" : [
{
"id" : 1,
"name" : "hdr.ethernet.srcAddr",
"repeated" : false,
"annotations" : [],
"mandatory" : false,
"match_type" : "Exact",
"type" : {
"type" : "bytes",
"width" : 48
}
}
],
"action_specs" : [
{
"id" : 21257015,
"name" : "NoAction",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : []
},
{
"id" : 22078320,
"name" : "MyIC.execute",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : []
}
],
"data" : [
{
"mandatory" : false,
"read_only" : false,
"singleton" : {
"id" : 65554,
"name" : "$COUNTER_SPEC_PKTS",
"repeated" : false,
"annotations" : [],
"type" : {
"type" : "uint64",
"default_value" : 0
}
}
}
],
"supported_operations" : ["SyncCounters"],
"attributes" : ["EntryScope"]
},
{
"name" : "ip.MyIC.tbl2",
"id" : 47318070,
"table_type" : "MatchAction_Direct",
"size" : 1024,
"annotations" : [],
"depends_on" : [],
"has_const_default_action" : false,
"key" : [
{
"id" : 1,
"name" : "hdr.ethernet.srcAddr",
"repeated" : false,
"annotations" : [],
"mandatory" : false,
"match_type" : "Exact",
"type" : {
"type" : "bytes",
"width" : 48
}
}
],
"action_specs" : [
{
"id" : 21257015,
"name" : "NoAction",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : []
},
{
"id" : 22078320,
"name" : "MyIC.execute",
"action_scope" : "TableAndDefault",
"annotations" : [],
"data" : []
}
],
"data" : [
{
"mandatory" : false,
"read_only" : false,
"singleton" : {
"id" : 65554,
"name" : "$COUNTER_SPEC_PKTS",
"repeated" : false,
"annotations" : [],
"type" : {
"type" : "uint64",
"default_value" : 0
}
}
}
],
"supported_operations" : ["SyncCounters"],
"attributes" : ["EntryScope"]
}
],
"learn_filters" : []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
psa.p4(670): [--Werror=unexpected] error: dpdk_execute method of meter0 extern can only be invoked from within action of ownertable
PSA_MeterColor_t dpdk_execute(in bit<32> pkt_len);
^^^^^^^^^^^^
Loading

0 comments on commit 8d21304

Please sign in to comment.