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

DPDK Backend: Emit name information for externs in context json #3433

Merged
merged 5 commits into from
Jul 14, 2022

Conversation

usha1830
Copy link
Contributor

The names of extern objects in spec file and bfrt json/p4info differ in cases when the extern declarations are not in the global scope. Compiler adds some prefix and suffix to the extern object's name based on the scope of the the object. New array of externs needs to be added into context json to handle this mismatch issue and to allow control plane software to access the name of the extern as in the spec file corresponding to the control plane name.

The schema changes are as follows:

"externs" : [
   {
    name : "ipv4_host_counter",
    target_name: "ipv4_host_counter_1",
    extern_type: "counter",    
    attributes {
        type: packets_and_bytes
    }    
    },
{
    name : "reg1",
    target_name: "reg1_0",
    extern_type: "register",    
    attributes {
    }    
},
....
]

context_all.json.txt
psa-example-dpdk-externs.p4.txt

for (auto ed : structure->externDecls) {
if (auto type = ed->type->to<IR::Type_Specialized>()) {
auto externTypeName = type->baseType->path->name.name;
if (externTypeName == "Counter" ||
Copy link
Contributor

Choose a reason for hiding this comment

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

do you want to ignore silently all other externs?

@mihaibudiu mihaibudiu merged commit 77ac13f into p4lang:main Jul 14, 2022
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