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 315AAA034F; Fri, 10 Sep 2021 09:59:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ABFBA40041; Fri, 10 Sep 2021 09:59:08 +0200 (CEST) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by mails.dpdk.org (Postfix) with ESMTP id 8461E4003E for ; Fri, 10 Sep 2021 09:59:07 +0200 (CEST) Received: by mail-lf1-f43.google.com with SMTP id s10so2319607lfr.11 for ; Fri, 10 Sep 2021 00:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FN38D46gUwrMWOGWg+KE/IoKKzOJcSwDQ+ElP4aqJ0k=; b=M8WbwWIVJxxsIwQqoA22li1OdkstK34fIWol3LlXvqyHt38uJseS9yddYcPngv3A5B rm3f9gHCnIWdXqhb9vdgqWwU5LMYhcrtQYcewaIQvuuvZ8VrKbvISbuHxudYefMvriNL araO1H8s/IKB6mdC1BwWApHao0M0c+UpxtgdUxamLUvYktbVDByjXW2SUYlCu53mFaAI is0mhXI1pCip2rvYi9yXthGYdcd5+A+fsUM5FFQxmH0bfd9DnuQISMgGCVlv+VXqU/dP kmh5OrXCqjDG66ujtpQ8DN7GBo5UH1ACXWR5d8n8lMgFIH78NUOaJii640uOxT1OxHdS gwMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FN38D46gUwrMWOGWg+KE/IoKKzOJcSwDQ+ElP4aqJ0k=; b=cK278E/ejg38rQBFz04/IT8E+HWuSpSQ2hlVqk6GG4a3mD5bf+A48oliCSQnH7eQQt 6d3FSWFLRykcHpiY+Rf5azDHdh4qip7erjtSRRlsp+N9Ao7XSvnk37rVgmywugvaJLxA mWmDfoHYduSXAQmeOHh4Rr5mkChSwvFXHUZJhF2PBev5rUr3oiPHC/J32ekYnSlaI9bw RGSOCAB6XEdBI32P3kNcOWnWnKW0Lb9xA40KsKVo9yYX/MUeaLptEKhWHgIanffrVkQa cu1Cz6vwgelPEA6hmWOSbPHYdxmjAHDhohuEHwuD8DypbXHuCmO82kiBqiapvzPOSFmO HFoA== X-Gm-Message-State: AOAM531Eo9vWEmDuNLAFiC+9aKKjICqr0Pd9tdPhizCOxmuSzGrgS0W5 BNvVMeFrihMnpH0iYGMOhmEkyW3cfms= X-Google-Smtp-Source: ABdhPJx0nO1t/WJ0RksVIB2+iavXTnhxVSNr9/EEjwh4UyUrY6raUze9P7iEWfb8nLtOMOrqDxVjFA== X-Received: by 2002:ac2:5fc5:: with SMTP id q5mr2832680lfg.629.1631260746991; Fri, 10 Sep 2021 00:59:06 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id u20sm486553lff.240.2021.09.10.00.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 00:59:06 -0700 (PDT) Date: Fri, 10 Sep 2021 10:59:05 +0300 From: Dmitry Kozlyuk To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20210910105905.27583a7b@sovereign> In-Reply-To: <20210909233329.190021-4-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210909233329.190021-1-stephen@networkplumber.org> <20210909233329.190021-4-stephen@networkplumber.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 03/10] bpf: add function to convert classic BPF to DPDK BPF 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 Sender: "dev" 2021-09-09 16:33 (UTC-0700), Stephen Hemminger: [...] > + prm = rte_zmalloc("bpf_filter", > + sizeof(*prm) + ebpf_len * sizeof(*ebpf), 0); > + if (prm == NULL) { > + rte_errno = ENOMEM; > + return NULL; > + } > + > + /* The EPBF instructions in this case are right after the header */ > + ebpf = (void *)(prm + 1); > + > + /* 2nd pass: remap cBPF to eBPF instructions */ > + ret = bpf_convert_filter(prog->bf_insns, prog->bf_len, ebpf, &ebpf_len); > + if (ret < 0) { > + RTE_BPF_LOG(ERR, "%s: cannot convert cBPF to eBPF\n", __func__); > + free(prm); free -> rte_free > + rte_errno = -ret; > + return NULL; > + } [...] > diff --git a/lib/bpf/rte_bpf.h b/lib/bpf/rte_bpf.h > index 69116f36ba8b..2f23e272a376 100644 > --- a/lib/bpf/rte_bpf.h > +++ b/lib/bpf/rte_bpf.h > @@ -198,6 +198,31 @@ rte_bpf_exec_burst(const struct rte_bpf *bpf, void *ctx[], uint64_t rc[], > int > rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit); > > +#ifdef RTE_PORT_PCAP In libre_bpf the function for ELF loading is always declared, and defined as a stub when libelf is unavailable. The app using it can link to DPDK with or without ELF support. No strong opinion here, but using different approaches is a bit messy. > + > +struct bpf_program; > + > +/** > + * Convert a Classic BPF program from libpcap into a DPDK BPF code. > + * > + * @param prog > + * Classic BPF program from pcap_compile(). > + * @param prm > + * Result Extended BPF program. > + * @return > + * Pointer to BPF program (allocated with *rte_malloc*) > + * that is used in future BPF operations, > + * or NULL on error, with error code set in rte_errno. > + * Possible rte_errno errors include: > + * - EINVAL - invalid parameter passed to function > + * - ENOMEM - can't reserve enough memory > + */ > +__rte_experimental > +struct rte_bpf_prm * > +rte_bpf_convert(const struct bpf_program *prog); > + > +#endif > + > #ifdef __cplusplus > } > #endif