Skip to content

Commit

Permalink
Add p4tc_filter_fields in add_entry (#4559)
Browse files Browse the repository at this point in the history
  • Loading branch information
komaljai authored Mar 26, 2024
1 parent cbfcb41 commit 1de63e6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backends/tc/ebpfCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,16 @@ void ControlBodyTranslatorPNA::processFunction(const P4::ExternFunction *functio
builder->emitIndent();
builder->appendLine(" .pipeid = p4tc_filter_fields.pipeid,");
builder->emitIndent();
builder->appendLine(" .handle = p4tc_filter_fields.handle,");
builder->emitIndent();
builder->appendLine(" .classid = p4tc_filter_fields.classid,");
builder->emitIndent();
builder->appendLine(" .chain = p4tc_filter_fields.chain,");
builder->emitIndent();
builder->appendLine(" .proto = p4tc_filter_fields.proto,");
builder->emitIndent();
builder->appendLine(" .prio = p4tc_filter_fields.prio,");
builder->emitIndent();
auto tableName = table->instanceName.substr(controlName.size() + 1);
auto tblId = tcIR->getTableId(tableName);
BUG_CHECK(tblId != 0, "Table ID not found");
Expand Down
5 changes: 5 additions & 0 deletions backends/tc/runtime/pna.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ struct p4tc_table_entry_create_bpf_params__local {
u32 pipeid;
u32 tblid;
u32 profile_id;
u32 handle;
u32 classid;
u32 chain;
u16 proto;
u16 prio;
};
extern struct p4tc_table_entry_act_bpf *bpf_p4tc_tbl_read(
struct __sk_buff *skb, struct p4tc_table_entry_act_bpf_params__local *params, void *key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ if (/* hdr->ipv4.isValid() */
/* construct key */
struct p4tc_table_entry_create_bpf_params__local update_params = {
.pipeid = p4tc_filter_fields.pipeid,
.handle = p4tc_filter_fields.handle,
.classid = p4tc_filter_fields.classid,
.chain = p4tc_filter_fields.chain,
.proto = p4tc_filter_fields.proto,
.prio = p4tc_filter_fields.prio,
.tblid = 1,
.profile_id = 2
};
Expand Down
10 changes: 10 additions & 0 deletions testdata/p4tc_samples_outputs/add_entry_example_control_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ if (/* hdr->ipv4.isValid() */
/* construct key */
struct p4tc_table_entry_create_bpf_params__local update_params = {
.pipeid = p4tc_filter_fields.pipeid,
.handle = p4tc_filter_fields.handle,
.classid = p4tc_filter_fields.classid,
.chain = p4tc_filter_fields.chain,
.proto = p4tc_filter_fields.proto,
.prio = p4tc_filter_fields.prio,
.tblid = 1,
.profile_id = 2
};
Expand Down Expand Up @@ -174,6 +179,11 @@ if (/* hdr->ipv4.isValid() */
/* construct key */
struct p4tc_table_entry_create_bpf_params__local update_params = {
.pipeid = p4tc_filter_fields.pipeid,
.handle = p4tc_filter_fields.handle,
.classid = p4tc_filter_fields.classid,
.chain = p4tc_filter_fields.chain,
.proto = p4tc_filter_fields.proto,
.prio = p4tc_filter_fields.prio,
.tblid = 2,
.profile_id = 2
};
Expand Down

0 comments on commit 1de63e6

Please sign in to comment.