DPDK patches and discussions
 help / color / mirror / Atom feed
* librte_bpf: roadmap or any specific plans for this library
@ 2022-04-25 23:38 Björn Svensson A
  2022-04-28 10:34 ` David Marchand
  2022-04-28 17:03 ` Konstantin Ananyev
  0 siblings, 2 replies; 5+ messages in thread
From: Björn Svensson A @ 2022-04-25 23:38 UTC (permalink / raw)
  To: dev

[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]

Hi all,
I hope this is the correct maillist for this topic.

DPDK provides the nice library `librte_bpf` to load and execute eBPF bytecode
and we would like to broaden our usage of this library.

Today there are hints that this library might have been purpose built to enable inspection or modification of packets;
for example the eBPF program is expected to only use a single input argument, pointing to data of some sort.
We believe it would be beneficial to be able to use this library to run generic eBPF programs as well,
as an alternative to run them as RX- TX-port/queue callbacks (i.e. generic programs which only uses supported features)

I have seen some discussions regarding moving towards using a common library with the kernel implementation of bpf,
but I couldn't figure out the outcome.
My question is if there any plans to evolve this library or would improvements possibly be accepted?

Here are some improvements we are interested to look into:

* Add additional API for loading eBPF code.
  Today it's possible to load eBPF code from an ELF file, but having an API to load code from an ELF image from memory
  would open up for other ways to manage eBPF code.

  Example of the new API:
    struct rte_bpf *
    rte_bpf_elf_image_load(const struct rte_bpf_prm *prm, char *image,
                           size_t size, const char *sname);

* Add support of more than a single input argument.
  There are cases when additional information is needed. Being able to use more than a single input argument
  would help when running generic eBPF programs.

  Example of change:
       struct rte_bpf_prm {
       ...
    -    struct rte_bpf_arg prog_arg; /**< eBPF program input arg description */
    +    uint32_t nb_args;
    +    struct rte_bpf_arg prog_args[EBPF_FUNC_MAX_ARGS]; /**< eBPF program input args */
       };

Any feedback regarding this is welcomed.
Best regard
Bjorn


[-- Attachment #2: Type: text/html, Size: 3182 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: librte_bpf: roadmap or any specific plans for this library
  2022-04-25 23:38 librte_bpf: roadmap or any specific plans for this library Björn Svensson A
@ 2022-04-28 10:34 ` David Marchand
  2022-04-28 17:03 ` Konstantin Ananyev
  1 sibling, 0 replies; 5+ messages in thread
From: David Marchand @ 2022-04-28 10:34 UTC (permalink / raw)
  To: Björn Svensson A; +Cc: dev, Ananyev, Konstantin, Stephen Hemminger

Hello,

On Tue, Apr 26, 2022 at 10:34 AM Björn Svensson A
<bjorn.a.svensson@est.tech> wrote:
>
> Hi all,
> I hope this is the correct maillist for this topic.

Yes it is.
I copied the maintainer and people that might be interested in this topic.


>
> DPDK provides the nice library `librte_bpf` to load and execute eBPF bytecode
> and we would like to broaden our usage of this library.
>
> Today there are hints that this library might have been purpose built to enable inspection or modification of packets;
> for example the eBPF program is expected to only use a single input argument, pointing to data of some sort.
> We believe it would be beneficial to be able to use this library to run generic eBPF programs as well,
> as an alternative to run them as RX- TX-port/queue callbacks (i.e. generic programs which only uses supported features)
>
> I have seen some discussions regarding moving towards using a common library with the kernel implementation of bpf,
> but I couldn't figure out the outcome.

I don't think there was progress on this.


> My question is if there any plans to evolve this library or would improvements possibly be accepted?
>
> Here are some improvements we are interested to look into:
>
> * Add additional API for loading eBPF code.
>   Today it's possible to load eBPF code from an ELF file, but having an API to load code from an ELF image from memory
>   would open up for other ways to manage eBPF code.
>
>   Example of the new API:
>     struct rte_bpf *
>     rte_bpf_elf_image_load(const struct rte_bpf_prm *prm, char *image,
>                            size_t size, const char *sname);
>
> * Add support of more than a single input argument.
>   There are cases when additional information is needed. Being able to use more than a single input argument
>   would help when running generic eBPF programs.
>
>   Example of change:
>        struct rte_bpf_prm {
>        ...
>     -    struct rte_bpf_arg prog_arg; /**< eBPF program input arg description */
>     +    uint32_t nb_args;
>     +    struct rte_bpf_arg prog_args[EBPF_FUNC_MAX_ARGS]; /**< eBPF program input args */
>        };

All I can tell, is that this proposal breaks ABI.
This is a blocker to get it accepted until next ABI breakage window opens.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: librte_bpf: roadmap or any specific plans for this library
  2022-04-25 23:38 librte_bpf: roadmap or any specific plans for this library Björn Svensson A
  2022-04-28 10:34 ` David Marchand
@ 2022-04-28 17:03 ` Konstantin Ananyev
  2022-05-02 14:28   ` Björn Svensson A
  1 sibling, 1 reply; 5+ messages in thread
From: Konstantin Ananyev @ 2022-04-28 17:03 UTC (permalink / raw)
  To: Björn Svensson A, dev

Hi Bjorn,

 > Hi all,
 > I hope this is the correct maillist for this topic.
 >
 > DPDK provides the nice library `librte_bpf` to load and execute eBPF 
bytecode
 > and we would like to broaden our usage of this library.

Great to hear :)

 > Today there are hints that this library might have been purpose built 
to enable inspection or modification of packets;
 > for example the eBPF program is expected to only use a single input 
argument, pointing to data of some sort.
 > We believe it would be beneficial to be able to use this library to 
run generic eBPF programs as well,
 > as an alternative to run them as RX- TX-port/queue callbacks (i.e. 
generic programs which only uses supported features)

In fact, there is such ability.
For that you need to specify RTE_BPF_ARG_PTR, as an argument type for 
your program.

 >
 > I have seen some discussions regarding moving towards using a common 
library with the kernel implementation of bpf,
 > but I couldn't figure out the outcome.


As I remember, there were few attempts to start such discussion,
but no much progress happened.

 > My question is if there any plans to evolve this library or would 
improvements possibly be accepted?

Yes, in general improvements are always welcomed.
Usual approach to submit an RFC with your proposed changes
for community review/discussion.
If there is an consensus about moving forward with it,
then actual patches can be submitted, reviewed, accepted.


 > Here are some improvements we are interested to look into:
 >
 > * Add additional API for loading eBPF code.
 >    Today it's possible to load eBPF code from an ELF file, but having 
an API to load code from an ELF image from memory
 >    would open up for other ways to manage eBPF code.
 >
 >    Example of the new API:
 >      struct rte_bpf *
 >      rte_bpf_elf_image_load(const struct rte_bpf_prm *prm, char *image,
 >                             size_t size, const char *sname);

Did you look at rte_bpf_load()?
Basically it works with already pre-loaded into memory bpf program.
In fact, rte_bpf_elf_load() calls it internally after reading elf 
sections, resolving external references, etc.
Would it meet your needs?


 > * Add support of more than a single input argument.
 >    There are cases when additional information is needed. Being able 
to use more than a single input argument
 >    would help when running generic eBPF programs.
 >
 >    Example of change:
 >         struct rte_bpf_prm {
 >         ...
 >      -    struct rte_bpf_arg prog_arg; /**< eBPF program input arg 
description */
 >      +    uint32_t nb_args;
 >      +    struct rte_bpf_arg prog_args[EBPF_FUNC_MAX_ARGS]; /**< eBPF 
program input args */
 >         };
 >

While it is possible in principle, I would be very conscious about such 
change.
AFAIK linux BPF is restricted to work with a single argument only.
I don't want DPDK version to fork too far away from 'canonical' version.
Though, as I said above, nothing prevents you to create a struct
with several fields, and pass pointer to that struct to your BPF program.
Would such approach work for you?

Konstantin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: librte_bpf: roadmap or any specific plans for this library
  2022-04-28 17:03 ` Konstantin Ananyev
@ 2022-05-02 14:28   ` Björn Svensson A
  2022-05-03 23:17     ` Konstantin Ananyev
  0 siblings, 1 reply; 5+ messages in thread
From: Björn Svensson A @ 2022-05-02 14:28 UTC (permalink / raw)
  To: Konstantin Ananyev, dev

[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]

Thanks for the feedback.

>>    Example of the new API:
>>      struct rte_bpf *
>>      rte_bpf_elf_image_load(const struct rte_bpf_prm *prm, char *image,
>>                             size_t size, const char *sname);
>>
> Did you look at rte_bpf_load()?
> Basically it works with already pre-loaded into memory bpf program.
> In fact, rte_bpf_elf_load() calls it internally after reading elf
> sections, resolving external references, etc.
> Would it meet your needs?

Yes, I think we could create our own elf_image_load() function that uses rte_bpf_load().
I understand that we don't want to have a bunch of specific variants of load-functions in dpdk,
specially if they are not used in any example or usecase.

> AFAIK linux BPF is restricted to work with a single argument only.
> I don't want DPDK version to fork too far away from 'canonical' version.
> Though, as I said above, nothing prevents you to create a struct
> with several fields, and pass pointer to that struct to your BPF program.
> Would such approach work for you?

Good alternative idea. We will test this approach.
I guess we will use the RTE_BPF_ARG_PTR as an argument for the program in this case.

Just as sidenote: we have also had a glance at
https://github.com/iovisor/ubpf
as an alternative. This is a standalone BPF VM lib, but with Apache 2.0 license and it's not bound to the dpdk log framework.
I have no views on benefits using this in dpdk, but it might be an input for future talks about a common library / collaboration.

Thanks again.
Bjorn

[-- Attachment #2: Type: text/html, Size: 4798 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: librte_bpf: roadmap or any specific plans for this library
  2022-05-02 14:28   ` Björn Svensson A
@ 2022-05-03 23:17     ` Konstantin Ananyev
  0 siblings, 0 replies; 5+ messages in thread
From: Konstantin Ananyev @ 2022-05-03 23:17 UTC (permalink / raw)
  To: Björn Svensson A, dev




>> AFAIK linux BPF is restricted to work with a single argument only.
>> I don't want DPDK version to fork too far away from 'canonical' version.
>> Though, as I said above, nothing prevents you to create a struct
>> with several fields, and pass pointer to that struct to your BPF program.
>> Would such approach work for you?
> 
> Good alternative idea. We will test this approach.
> I guess we will use the RTE_BPF_ARG_PTR as an argument for the program 
> in this case.

Yes, I believe so.


> 
> Just as sidenote: we have also had a glance at
> https://github.com/iovisor/ubpf <https://github.com/iovisor/ubpf>
> as an alternative. This is a standalone BPF VM lib, but with Apache 2.0 
> license and it's not bound to the dpdk log framework.
> I have no views on benefits using this in dpdk, but it might be an input 
> for future talks about a common library / collaboration.
> 
> Thanks again.
> Bjorn


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-03 23:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 23:38 librte_bpf: roadmap or any specific plans for this library Björn Svensson A
2022-04-28 10:34 ` David Marchand
2022-04-28 17:03 ` Konstantin Ananyev
2022-05-02 14:28   ` Björn Svensson A
2022-05-03 23:17     ` Konstantin Ananyev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).