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

xdp-bench: Add support for xdp_buff with empty linear part #409

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

nimrod-oren
Copy link
Contributor

In some network driver implementations, the linear part of the xdp_buff structure might be empty, with all data stored in the frags section. Accessing packet data directly is impossible in this case, and requires an API like the bpf_xdp_load/store_bytes helpers or dynptr.

This pull request ensures support for all xdp-bench packet operations (swap-macs, read-data, etc.) of basic actions (DROP, PASS, TX) when the linear part is empty.

The next step is to extend this functionality to the REDIRECT actions and explore integration with other tools beyond xdp-bench. After that, the plan is to introduce the option to use the superior dynptr API as another packet access alternative.

Remove a condition in xdp_parse_load_bytes_prog that assumes the
packet header data is in the linear part of the xdp_buff.

Signed-off-by: Nimrod Oren <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
Remove a condition in xdp_basic_prog that assumes the
packet header data is in the linear part of the xdp_buff.

Signed-off-by: Nimrod Oren <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
This commit introduces xdp_read_data_load_bytes_prog to xdp-bench.
This program uses the bpf_xdp_load_bytes helper for packet data access.
In contrast, xdp_read_data_prog uses direct packet access.

This addition aligns with the existing behavior of -p parse-ip:
- 'xdp-bench -p read-data' loads xdp_read_data_prog.
- 'xdp-bench -p read-data -l load-bytes' loads xdp_read_data_load_bytes_prog.

Signed-off-by: Nimrod Oren <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
This commit introduces xdp_swap_macs_load_bytes_prog to xdp-bench.
This program uses the bpf_xdp_load_bytes and bpf_xdp_store_bytes helpers for packet data access.
In contrast, xdp_swap_macs_prog uses direct packet access.

This addition aligns with the existing behavior of -p parse-ip:
- 'xdp-bench -p swap-macs' loads xdp_swap_macs_prog.
- 'xdp-bench -p swap-macs -l load-bytes' loads xdp_swap_macs_load_bytes_prog.

Signed-off-by: Nimrod Oren <[email protected]>
Reviewed-by: Tariq Toukan <[email protected]>
@tohojo
Copy link
Member

tohojo commented Apr 2, 2024 via email

@gal-pressman
Copy link

nimrod-oren @.***> writes:
In some network driver implementations, the linear part of the xdp_buff structure might be empty, with all data stored in the frags section. Accessing packet data directly is impossible in this case, and requires an API like the bpf_xdp_load/store_bytes helpers or dynptr.
Which driver does that? None that's in-tree, AFAIK?

mlx5 (in certain configurations) is an example.

@nimrod-oren
Copy link
Contributor Author

nimrod-oren @.***> writes:
In some network driver implementations, the linear part of the xdp_buff structure might be empty, with all data stored in the frags section. Accessing packet data directly is impossible in this case, and requires an API like the bpf_xdp_load/store_bytes helpers or dynptr.
Which driver does that? None that's in-tree, AFAIK?

mlx5 (in certain configurations) is an example.

Introduced in commit cd02a1a24897.

@tohojo
Copy link
Member

tohojo commented Apr 12, 2024

Introduced in commit cd02a1a24897.

Huh, I never noticed that go in. I remember there was some discussion around it (in https://lore.kernel.org/r/[email protected]), but I also remember the outcome differently. Ah well, in that case I certainly have no objections to merging this :)

Copy link
Member

@tohojo tohojo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the patch :)

@tohojo tohojo merged commit d7edea3 into xdp-project:master Apr 12, 2024
5 checks passed
@nimrod-oren nimrod-oren deleted the xdp-bench_no-dpa branch April 14, 2024 08:14
nimrod-oren added a commit to nimrod-oren/xdp-tools that referenced this pull request Nov 5, 2024
Update the documentation to reflect the changes made in pull request xdp-project#409 (d7edea3).

Signed-off-by: Nimrod Oren <[email protected]>
tohojo pushed a commit to nimrod-oren/xdp-tools that referenced this pull request Nov 19, 2024
Update the documentation to reflect the changes made in pull request xdp-project#409 (d7edea3).

Signed-off-by: Nimrod Oren <[email protected]>
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