-
Notifications
You must be signed in to change notification settings - Fork 151
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
libxdp: Use opts to create XDP socket #454
Conversation
3604acb
to
bf7a318
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - @magnus-karlsson PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this implementation. Looks good, just some small things to fix.
headers/xdp/xsk.h
Outdated
* The following fields should not be NULL at the same time: | ||
* | ||
* @rx, @tx | ||
* At least one traffic direction should be assigned for an XSk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XSk -> xsk
headers/xdp/xsk.h
Outdated
* | ||
* @fill, @comp, @rx_size, @tx_size, @libbpf_flags, @libxdp_flags, | ||
* @xdp_flags, @bind_flags | ||
* If a socket with exclusive ownership of a umem are going to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are -> is
headers/xdp/xsk.h
Outdated
* If the remaining fields are unset, they will be set to | ||
* default value (see `xsk_set_xdp_socket_config()`). | ||
* | ||
* Except for the fields mentioned above, none field can be set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"none field"? What does that mean?
headers/xdp/xsk.h
Outdated
__u32 rx_size; | ||
__u32 tx_size; | ||
union { | ||
__u32 libbpf_flags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this new interface, let us delete libbpf_flags and be done with the union. libbpf_flags was there just for compatibility with libbpf version prior to 1.0. For this new interface, we can skip this.
lib/libxdp/xsk.c
Outdated
|
||
if (usr_cfg->libbpf_flags & ~XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD) | ||
libbpf_flags = OPTS_GET(opts, libbpf_flags, 0); | ||
if (libbpf_flags & ~XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use LIBXDP instead of LIBBPF in this whole function. Again, the LIBBPF stuff in the interface is only there for some old libbpf compatibility. The local variable can be libxdp_flags too since we are in libxdp :-).
Introduce a new API xsk_socket__create_opts() to create XDP socket using opts struct. Note that if one of fill and comp is unset, the semantic of the new API is the same as xsk_socket__create(), otherwise the same as xsk_socket__create_shared(). Signed-off-by: Muyang Tian <[email protected]>
bf7a318
to
449ed15
Compare
Updated changes LGTM - @magnus-karlsson WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you!
The test is failing, can be re-run @magnus-karlsson @tohojo |
Introduce a new API xsk_socket__create_opts() to create XDP socket using opts struct. Note that if one of fill and comp is unset, the semantic of the new API is the same as xsk_socket__create(), otherwise the same as xsk_socket__create_shared().