From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31F29A0093; Thu, 28 Apr 2022 19:03:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0A3C42819; Thu, 28 Apr 2022 19:03:28 +0200 (CEST) Received: from forward501o.mail.yandex.net (forward501o.mail.yandex.net [37.140.190.203]) by mails.dpdk.org (Postfix) with ESMTP id 1C2D840E50 for ; Thu, 28 Apr 2022 19:03:27 +0200 (CEST) Received: from myt5-c4b663bd17ea.qloud-c.yandex.net (myt5-c4b663bd17ea.qloud-c.yandex.net [IPv6:2a02:6b8:c12:2d2e:0:640:c4b6:63bd]) by forward501o.mail.yandex.net (Yandex) with ESMTP id 7032145C4DD3; Thu, 28 Apr 2022 20:03:26 +0300 (MSK) Received: from myt6-9bdf92ffd111.qloud-c.yandex.net (myt6-9bdf92ffd111.qloud-c.yandex.net [2a02:6b8:c12:468a:0:640:9bdf:92ff]) by myt5-c4b663bd17ea.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 9VrlX2Ky6M-3QfCajLG; Thu, 28 Apr 2022 20:03:26 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1651165406; bh=oZTR1+QEJJAqoHhJ5yo3EoI5/nfcFdV1evPkPcOeyno=; h=In-Reply-To:From:Subject:References:Date:Message-ID:To; b=Rlc9YeGgvgute/NmLaM4HpcyufEjFRK5ZxyGrii68XchHgW0y3NR7WwD5FihaFt/y k9OGxSsKblqk4K0rmDxiMDB6DB7DxFRKFfKb+sfAsSxu+icmxpemlDyYpUzxqvcsTH UMWvBKjIsjdJimowJT6byhsJokgFYh823CrnWVZk= Authentication-Results: myt5-c4b663bd17ea.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by myt6-9bdf92ffd111.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id VRFMBQPWAz-3PMCcwX1; Thu, 28 Apr 2022 20:03:25 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: <8e8fcdea-5265-1126-4912-c7fec9b659c4@yandex.ru> Date: Thu, 28 Apr 2022 18:03:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: librte_bpf: roadmap or any specific plans for this library Content-Language: en-US To: =?UTF-8?Q?Bj=c3=b6rn_Svensson_A?= , "dev@dpdk.org" References: From: Konstantin Ananyev In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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