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

ebpf/PSA: Checksum support for fields wider than 64 bits #3801

Merged
merged 3 commits into from
Dec 23, 2022

Conversation

tatry
Copy link
Contributor

@tatry tatry commented Dec 22, 2022

This PR adds support for fields wider than 64 bits in implemented checksum algorithms.

CC: @osinstom

This commit adds support for fields wider than 64 bits in implemented
checksum algorithms.
@tatry
Copy link
Contributor Author

tatry commented Dec 22, 2022

@fruffy do you know why the test case testgen-p4c-bmv2/checksum-l4-bmv2.p4 in workflow test-tools / build-and-test-tools fails? I run these changes in my up-to-date fork (here: tatry#29) and it passed (direct link to job: https://github.com/tatry/p4c/actions/runs/3756482263/jobs/6382602040)

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

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

I approve, but you may want to at least document the code better.

" bpf_trace_message(\"CRC%w%: data byte: %x\\n\", data[i-1]);\n"
" *reg ^= (u16) data[i-1];\n"
"void crc16_update(u16 * reg, const u8 * data, "
"u16 data_size, const u16 poly) {\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused by this code, some documentation would help.

if (addData) {
builder->appendFormat("%s = csum16_add(%s, %s)", stateVar.c_str(),
stateVar.c_str(), tmpVar.c_str());
builder->appendFormat("csum16_add(%s, %s)", stateVar.c_str(), tmpVar.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

the result of csum16_add is ignored here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the result is not ignored. Assignment of the state variable is done 2 lines above, just before if statement. I moved this as a common expression for csum16_add and csum16_sub but I see it can be little confusing.

@fruffy
Copy link
Collaborator

fruffy commented Dec 23, 2022

@fruffy do you know why the test case testgen-p4c-bmv2/checksum-l4-bmv2.p4 in workflow test-tools / build-and-test-tools fails? I run these changes in my up-to-date fork (here: tatry#29) and it passed (direct link to job: https://github.com/tatry/p4c/actions/runs/3756482263/jobs/6382602040)

This is a flaky test. It can be fixed by rerunning. I do not know whether the fault is in bmv2's or testgen's checksum calculation yet.

@mihaibudiu mihaibudiu merged commit a841047 into p4lang:main Dec 23, 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.

3 participants