Skip to content

BMv2 testgen: emit selector-aware PTF control-plane programming for action_selector tables#5544

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-keyless-tables-issue
Draft

BMv2 testgen: emit selector-aware PTF control-plane programming for action_selector tables#5544
Copilot wants to merge 1 commit intomainfrom
copilot/fix-keyless-tables-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

  • Identify failing path from log (send_request_add_member with unresolved action profile name)
  • Locate BMv2 PTF emission path and control-plane JSON population
  • Apply minimal fix so selector-backed tables use selector control-plane name for member/group programming
  • Add focused backend unit assertion to ensure selector name is rendered
  • Commit minimal change
Original prompt

This section details on the original issue you should resolve

<issue_title>p4testgen attempting to add table entries to keyless tables, perhaps because they have one or more key fields with match_kind selector</issue_title>
<issue_description>Relevant BMv2 issue: p4lang/behavioral-model#1208

That issue was fixed via this PR, merged in 2023-Aug: p4lang/behavioral-model#1209

Before that PR was merged, BMv2 would not give an error if one attempted to add an entry to a table with no key fields.

After that PR was emrged, BMv2 does return an error if you attempt to do so.

This includes tables with implementation action_selector that have only keys with match_kind selector. Technically such tables also have 0 match key fields for determining which table entry is matching, because fields with match_kind selector are only used to determine which among several possible actions in a group of actions is selected and executed, after an entry is matched.

I have seen the following p4c test cases fail for years when building binaries from the most recent behavioral-model and p4c source code and running the p4c tests. I have verified today that all of them have a table with implementation action_selector, and only one key field with match_kind selector. All of the PTF tests fail when they first attempt to add an entry to this table.

  • testgen-p4c-bmv2-ptf/action_profile-bmv2.p4
  • testgen-p4c-bmv2-ptf/action_profile_max_group_size_annotation.p4
  • testgen-p4c-bmv2-ptf/action_profile_sum_of_members_annotation.p4
  • testgen-p4c-bmv2-ptf/action_selector_shared-bmv2.p4
  • testgen-p4c-bmv2-ptf/issue297-bmv2.p4

I would guess that the root cause might be that p4testgen is written in such a way that because there is at least one key field (albeit one with match_kind selector), it therefore "thinks" that it must be possible to add an entry to the table, and thus tries to do so but fails.

If so, the best fix would be for p4testgen to ignore all table key fields with match_kind selector, and after doing so, if there are no remaining key fields, treat it as a keyless table, i.e. one for which lookups will always get a miss result, and for which it is not possible to add entries to it.

Note: These failures have only been seen recently in p4c Github CI, because it has been using a version of BMv2 before the PR linked above until it was recently updated.</issue_description>

<agent_instructions>The reason identified in the issue is a part of why we are seeing these test failures, but another cause is simple that the selector implementation for STF/PTF tests in P4Testgen's BMv2 back end is incomplete. We need to make sure to generate the right configurations for these tests, if the PTF/STF frameworks support it. If we manage to make the tests pass, remove them from XFails. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jafingerhut @fruffy I have a guess why p4testgen got failures on these 5 PTF test cases, described in this issue. If my guess is correct, it sounds like a simple fix in p4testgen to avoid these errors.

Another potential change we could make would be to modify the P4 program in one or all of these 5 test cases so that the releveant table has at least one key field with a match_kind like exact, lpm, or ternary, in addition to the selector key field(s) they have now. That seems to me more like a workaround for the p4testgen issue than a complete fix, though. We might want to do so for one of the test programs so we can be sure that p4testgen is exercised for keyless and keyful tables with implementation action_selector.</comment_new>
<comment_new>@fruffy
Let me check this, could definitely be the root cause. Iirc we do handle selectors in some form but it is possible we did it in a questionable way for BMv2 PTF.</comment_new>


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Fix p4testgen for adding entries to keyless tables Draft: Handle selector-only tables as keyless in BMv2 p4testgen and un-xfail affected PTF cases Mar 17, 2026
Copilot AI requested a review from fruffy March 17, 2026 03:32
Copilot AI changed the title Draft: Handle selector-only tables as keyless in BMv2 p4testgen and un-xfail affected PTF cases Handle selector-only BMv2 tables as keyless in p4testgen and unxfail affected PTF cases Mar 17, 2026
Copilot AI changed the title Handle selector-only BMv2 tables as keyless in p4testgen and unxfail affected PTF cases BMv2 testgen: treat selector-only tables as keyless and route action selectors through selector path Mar 17, 2026
Copilot AI changed the title BMv2 testgen: treat selector-only tables as keyless and route action selectors through selector path Fix BMv2 testgen selector state wiring for one-shot action selector paths Mar 17, 2026
Copilot AI changed the title Fix BMv2 testgen selector state wiring for one-shot action selector paths Implement explicit BMv2 PTF action-selector programming (members/groups + table group entries) Mar 17, 2026
Copilot AI changed the title Implement explicit BMv2 PTF action-selector programming (members/groups + table group entries) Generate explicit BMv2 PTF action-selector programming (members, groups, table group bindings) Mar 18, 2026
Copilot AI changed the title Generate explicit BMv2 PTF action-selector programming (members, groups, table group bindings) BMv2 testgen: emit selector-aware PTF control-plane programming for action_selector tables Mar 18, 2026
@jafingerhut
Copy link
Contributor

If this thing converges to a solution on its own, that would be pleasantly surprising :-)

@fruffy
Copy link
Collaborator

fruffy commented Mar 19, 2026

If this thing converges to a solution on its own, that would be pleasantly surprising :-)

The problem with the free tier is that it has a time limit. Our builds take a while and so it always terminates before doing anything. I'll play around with it a bit more to see whether I can find a functioning approach.

@fruffy fruffy force-pushed the copilot/fix-keyless-tables-issue branch from 3d01511 to d7393dc Compare March 22, 2026 22:49
…ck end.

Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy force-pushed the copilot/fix-keyless-tables-issue branch from d7393dc to cb52da3 Compare March 22, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

p4testgen attempting to add table entries to keyless tables, perhaps because they have one or more key fields with match_kind selector

3 participants