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: Support for large keysize >64 bytes with additional restrictions #3580

Merged
merged 8 commits into from
Oct 19, 2022

Conversation

usha1830
Copy link
Contributor

Earlier, dpdk target had a limitation of keysize to be within 64 bytes including any holes in the key fields in the underlying structure.

Ex:
struct meta {
bit <8> meta1; // table key
bit <32> meta2; // hole
bit <64> meta3; // table key
}

table {
keys = {
meta3: exact;
meta1 : exact
}
}

This limitation is now removed but newer restrictions are imposed and based on the conditions a copy of tables keys should be made to make them come from the same underlying structure and make them contiguous in the underlying structure.

The following conditions are checked to make decision about making a copy of the header/metadata field used as table key.

  • As before, all the table key fields must be part of the same structure (either header or meta-data).

  • As before, a mix of header and meta-data fields in the table key requires copying the header fields to meta-data.

  • “Regular” tables (exact match, wildcard match): In the target implementation, if all fields are contiguous and exact match, the exact match table type is used, otherwise the wildcard match table type is used. Even if all the fields are exact match, if they are not contiguous, the wildcard match table type will be used. So in the case of a mix of header and meta-data fields in the table key, which requires a copying the header fields to meta-data, it is important is there is a hole in between fields: if there is a hole, the exact match table type cannot be used, which result in performance penalty.

  • P4C needs to do the best to make all fields contiguou. Sometimes, when there is a large gap between (A) existing meta-data fields and the (B) new meta-data fields (generated by the compiler to mirror the header fields), we should also create metadata copies for the (A) fields, so that the (A) fields and the (B) fields now become contiguous in meta-data , so the exact match table type could be used. This should be done for the typical case of relatively small key sizes with a relatively small number of fields, where performance delta might be important (if the key is very large, performance will be typically not great anyway); Heuristic adopted: copy only if the number of (A) fields is less than 5.

  • Learner tables (add_on_miss tables) are a special type of exact match tables: The key fields must be contiguous in their structure. If not contiguous, need to create meta-data copies for all key fields (in order to make the key fields contiguous).

This PR removes the validation for keysize limit and adds the new restrictions and makes copy of fields used as key based on the conditions described above.

}

int CopyMatchKeysToSingleStruct::getFieldSizeBits(const IR::Type *field_type) {
if (auto t = field_type->to<IR::Type_Bits>()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

have enums been eliminated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Enum elimination is done in midend.

@usha1830
Copy link
Contributor Author

@mbudiu-vmw Can this be merged?

@mihaibudiu mihaibudiu merged commit 7aaeddd into p4lang:main Oct 19, 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