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

Support const entries in P4TC #15

Closed
wants to merge 13 commits into from
Closed

Support const entries in P4TC #15

wants to merge 13 commits into from

Conversation

komaljai
Copy link
Owner

@komaljai komaljai commented Jan 4, 2024

Ticket - https://github.com/p4tc-dev/p4tc-e2e/issues/30

As an example, in the following program:

table calculate {
        key = {
            hdr.p4calc.op        : exact @name("op");
        }
        actions = {
            operation_add;
            operation_sub;
            operation_and;
            operation_or;
            operation_xor;
            operation_drop;
        }
        const default_action = operation_drop();
        const entries = {
            P4CALC_PLUS : operation_add();
            P4CALC_MINUS: operation_sub();
            P4CALC_AND  : operation_and();
            P4CALC_OR   : operation_or();
            P4CALC_CARET: operation_xor();
        }
    }

The compiler should generate the template code for these constant table enties.
For the above example, it should be the following:

$TC p4template update table/calc/MainControlImpl/calculate entry op 0x2b action calc/MainControlImpl/operation_add
$TC p4template update table/calc/MainControlImpl/calculate entry op 0x2d action calc/MainControlImpl/operation_sub
$TC p4template update table/calc/MainControlImpl/calculate entry op 0x26 action calc/MainControlImpl/operation_and
$TC p4template update table/calc/MainControlImpl/calculate entry op 0x7c action calc/MainControlImpl/operation_or
$TC p4template update table/calc/MainControlImpl/calculate entry op 0x5e action calc/MainControlImpl/operation_xor

Copy link

@psivanup psivanup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check

backends/tc/backend.cpp Show resolved Hide resolved
backends/tc/ebpfCodeGen.cpp Outdated Show resolved Hide resolved
backends/tc/tc.def Outdated Show resolved Hide resolved
Copy link

@psivanup psivanup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine

@komaljai
Copy link
Owner Author

Merged to main

@komaljai komaljai closed this Jan 30, 2024
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.

2 participants