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 40273A0C41; Wed, 15 Sep 2021 13:02:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F39B24003F; Wed, 15 Sep 2021 13:02:24 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 5B9284003C for ; Wed, 15 Sep 2021 13:02:23 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10107"; a="219103114" X-IronPort-AV: E=Sophos;i="5.85,295,1624345200"; d="scan'208";a="219103114" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 04:02:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,295,1624345200"; d="scan'208";a="482288448" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga008.jf.intel.com with ESMTP; 15 Sep 2021 04:02:22 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 15 Sep 2021 04:02:21 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 15 Sep 2021 04:02:21 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 15 Sep 2021 04:02:21 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Wed, 15 Sep 2021 04:02:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gOWiQQauxYgItfGt7mupgnOGNEgQIN3H3/mAl37CfvQPetUhGErtgH/1OXQ/WDBasd3y87ffp4IPxERIsx48+k8cWu95MJ+m2b905m4kEtN8F3JtILsGpUu5o9T/qkBatWFAXffJdoq3yiqNfIMU1OGutHuPn4NGgiJmpHKio/5pTWuhduj5M1sea7m7ocPhONK2TRkAQwGBPabLxV0RyVS8aSBbQ6pmsZVJJaK4tndes8CYdmiW7iWa4Ip5Q5fLCimZ1gRhDksMUOIw/vSJvcE70hs36Z17S5Ayavu0r9U18Kgsg+GdUkKDutDUUy3Pj41HMaYmW/gcvKRUxZpdbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CwFcHkirv2KAHILQbw94LJK4hNri+oyV8DkHq5WNIBY=; b=l0//hK3geDWXEtpH+Z1TUn+gq5cTe4XJztrpGhQ8YvF60IsivNBPu1nNe/0VkomMocSJTikw7W2z6WFP4JF7hH30f6WTswFPbMuxCkDTEyjkVF2GwYpwZiVGC0qO8AGblp2uNXgxQh6uqkdPWBTFdI8j101Ho7Y1PqciRv+9hZ44QtytQNSqpNZ2kfU3bhQfIUkZoWeMGGGYs1omOXuWOS/XUa67JTkzjM9+m1cUQjJwYxtnM3vV6/q4GMXRCy8F2JRkhKEOIBE5yd1nXDqJLHE2d111ucoNcCOri9dstHaa2m/DGRDgQHiSHRQLyHzonx3ptQ4PwR0ONgNU1dRJzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CwFcHkirv2KAHILQbw94LJK4hNri+oyV8DkHq5WNIBY=; b=zdvynj0qwHQujHPj22fkAt0n13vz5JwGaL8fcOoBX87nDUAiIyLG7xjDjJoUh2PalUBVUv5hKTl+zAOngLmaaDOaDXeObCtAvhM3PChth343VP46y+xHft4H3MwdtREMr95bnCciemRojSVfNEZ+BCw/jsmrgNx1wuEAEgLFm0A= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM5PR1101MB2249.namprd11.prod.outlook.com (2603:10b6:4:5a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Wed, 15 Sep 2021 11:02:20 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::740e:126e:c785:c8fd]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::740e:126e:c785:c8fd%4]) with mapi id 15.20.4523.014; Wed, 15 Sep 2021 11:02:20 +0000 From: "Ananyev, Konstantin" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v8 04/12] bpf: add function to convert classic BPF to DPDK BPF Thread-Index: AQHXqMtnVQUTn8lw7EyS9vOIC3kiJauk7sWw Date: Wed, 15 Sep 2021 11:02:20 +0000 Message-ID: References: <20210903004732.109023-1-stephen@networkplumber.org> <20210913181510.46058-1-stephen@networkplumber.org> <20210913181510.46058-5-stephen@networkplumber.org> In-Reply-To: <20210913181510.46058-5-stephen@networkplumber.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.200.16 authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 467ddeb7-0474-4610-252c-08d9783849ed x-ms-traffictypediagnostic: DM5PR1101MB2249: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: z5VZzkg1A9rm3dhxs5B7HtViLM+2pcf5bgz/+TGzXRwWVi5h66l1Igvdua58dK0K+/l4neJEimd7yjPJKcbpih2aVP46LNEygEsMp1eJxhW7ONRFzW7JUgX8nx5gZQA3kZdGQFsgmoecZwYiLw7NnSXanAXbc21d0LWEpZPh9fnwz2Clv7exPh3aSLveQ996iWoJ6ETsOFlkU91ozmL2uZYi5QSPmi+i5V1g2FoUyQmpD3XdmsJ8h1LV/c2EmQ6vVdRU+3ez0c1AqIbjaW/3jpY94S6F3esfH/m2H+Jl54juCwuHKH4hpFKqt7JEk0927Rm3tBeJ+3ve+Rjxkoqctzz+q7lFBN6rwN298+lisWIeQ2LCp634Uam1meYoCZBsi/S54qosyd/3GPjguLX1f5r1rS0RuyGT1OSse0X/XmEotXdxWRQ58jkYoqEcypOOwq/eeo4rWrcgyfCZEHItcPBKhNLd1nPdBLaFOrNZbXI8PmLuYc1rAKNOf+3rIdpQEdZNa6mKjCTBO0kP5JcHKWXpqOL4zMiviAINuG+skcAF8iBN+XzQauIEle89Uz5V6dKx8x0cqz5CF3ynR27tYCGLVHYHXAHitaFxAAn8Z9ulM0o+hhMZLAPsUSQ23LNhq0N6ssnnCzg/y0k8K/t/kO9rApWNrMoxAbPTXnZkz3cayVABV2QohuHHJtDZc7ngKE4sbGSSgdD0ydOByhpUCg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(26005)(2906002)(33656002)(8936002)(122000001)(9686003)(110136005)(52536014)(508600001)(8676002)(5660300002)(66946007)(38070700005)(76116006)(55016002)(186003)(66446008)(66556008)(316002)(86362001)(64756008)(66476007)(6506007)(38100700002)(7696005)(55236004)(83380400001)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?/eorfeGbMe458Nb7u8H5OqeIujm2wbrIVVQl8GIsRrqCItemRJx1nE50gfLA?= =?us-ascii?Q?+C5O8rFlIjM93PjfayQfMHzIKC//FOIioBHal1WCb7QBEEYcubKIrAlxODse?= =?us-ascii?Q?I37qGE2UMtWyTI9aQegSQyl1H8ZIZOfcUgwZURCAYw7GagILSJYQK4NRZKpg?= =?us-ascii?Q?DoJHZ+eKe63M+y7u7tj9Mzo76Cbg1E9UrcWI0pmeYTzjByVM2Vz8pY9Tsrgi?= =?us-ascii?Q?PmrFSsGAX1pxucqQSKjaHe0xO07h/EzL4l0P6wELUq7NKEQg8gSGYZlOeaCM?= =?us-ascii?Q?TK8Us0mknV6EZnJC2htF9VzHYSJCCIL3LlQUjdAg0jyZD5Q98WhTX8EJp2oo?= =?us-ascii?Q?UeoYjU85f5JWy0CVrEuwl63aEnlrK9QOO01OvXd9Pt7MQyoBuuoDLjTUR8/4?= =?us-ascii?Q?TJtFnhyAei63ank98uDO3uEPG2YXbCK68zLrB62z1UHsnKcNF9lPQnRnZ0MF?= =?us-ascii?Q?2Gm5VaBMB7ECdZDZMCk4rE0YugjysZ5j2ALJS3QvNkkajHplS8ei9rUfDNQz?= =?us-ascii?Q?H3atT7FMWxME1Zb4kit0RTnfGz0xMkTdl9tvjrk8UXBAWltnJMrVS2Pr4oQ6?= =?us-ascii?Q?1AWXZAw5wG7AzwabBkwpMba47c2SV8SwjbmbtahlAsYSafLkWsKHxhqM9sKz?= =?us-ascii?Q?UkiDZ9kzATeyFMeaGA9IkE9RwcBASEtktFHBxLtAiAKBCGuqhrHCwuR7mwiS?= =?us-ascii?Q?Qi0VQ6DRIaDKWz8c11tX+jz1sW0Py1oCSXappXc7Mz1in351imKelMmgWX5s?= =?us-ascii?Q?QCsw8VsPtGiyRTonwaRERsTc7fW8LLrzGV0GObKN6fXIv1nwm7zxZ9GPWFow?= =?us-ascii?Q?hs6ZigZJxxcq6k2neOQfTNuoJthUSX8yHvYE2W5eunZjD6PHQIMaBimSoSry?= =?us-ascii?Q?zQbnON9xDS4rCJfbH4ekIn+ZZLjkPZ2AVfJ8zq4sX7N3c7nrIRcDK3cqe8ru?= =?us-ascii?Q?zW6Xo4E2GioDIqLwjZMi2wRnm5xwy3LXwio7JM1TI7cSyYF6h8Gn19ZdkcxK?= =?us-ascii?Q?5VEfMtL0AIPvww8/mADuOpbgEjxo/Sg/4Ir/RSr58Ll9lhY8XK7H/vx9MwNv?= =?us-ascii?Q?CBn//bTCiIihZSdf3yBAmq8oPqy9iNR8PBwXDT0defdIjpzlfWjajdMv7i5k?= =?us-ascii?Q?JiUJKt5Iipc8uUNWR39Z08BElzpwDDDMJf/rQBBn4C/9wgD5D8sa/BLKlcn+?= =?us-ascii?Q?L7/gRNSRdZjNPgURxEw7ZxSVUKcGeLH31UxG18rZTo9YI8QRUcqbmxQilOcq?= =?us-ascii?Q?CjoBCIlgCJCwZit7AviBwtgp24ud+YCrkswecyyWcXIzqvZyFmShRCdFGIk8?= =?us-ascii?Q?NQ6KhAN0nBgTgBDVQJkVGoP7?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 467ddeb7-0474-4610-252c-08d9783849ed X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2021 11:02:20.2436 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qk5TftbuL8xeB8Nc9qZO9x3TAHXlnOq1S/2cqnLxXuI6EmvwJ0flnwY94xnuTB/estV+UIAeuc//IDW2q5iEwrQGKZmHfDbO9YzNFZApZBg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1101MB2249 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v8 04/12] 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" >=20 > The pcap library emits classic BPF (32 bit) and is useful for > creating filter programs. The DPDK BPF library only implements > extended BPF (eBPF). Add an function to convert from old to > new. >=20 > The rte_bpf_convert function uses rte_malloc to put the resulting > program in hugepage shared memory so it can be passed from a > secondary process to a primary process. >=20 > The code to convert was originally done as part of the Linux > kernel implementation then converted to a userspace program. > Both authors have agreed that it is allowable to license this > as BSD licensed in DPDK. >=20 > Signed-off-by: Stephen Hemminger > --- > lib/bpf/bpf_convert.c | 570 ++++++++++++++++++++++++++++++++++++++++++ > lib/bpf/meson.build | 5 + > lib/bpf/rte_bpf.h | 25 ++ > lib/bpf/version.map | 6 + > 4 files changed, 606 insertions(+) > create mode 100644 lib/bpf/bpf_convert.c >=20 > diff --git a/lib/bpf/meson.build b/lib/bpf/meson.build > index 63cbd60185e0..54f7610ae990 100644 > --- a/lib/bpf/meson.build > +++ b/lib/bpf/meson.build > @@ -25,3 +25,8 @@ if dep.found() > sources +=3D files('bpf_load_elf.c') > ext_deps +=3D dep > endif > + > +if dpdk_conf.has('RTE_PORT_PCAP') Do we really need that 'if' above? Why not to always have it enabled? > + sources +=3D files('bpf_convert.c') > + ext_deps +=3D pcap_dep > +endif > 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); >=20 > +#ifdef RTE_PORT_PCAP > + > +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 > diff --git a/lib/bpf/version.map b/lib/bpf/version.map > index 0bf35f487666..47082d5003ef 100644 > --- a/lib/bpf/version.map > +++ b/lib/bpf/version.map > @@ -14,3 +14,9 @@ DPDK_22 { >=20 > local: *; > }; > + > +EXPERIMENTAL { > + global: > + > + rte_bpf_convert; > +}; > -- Cool feature, thanks for contributing. Acked-by: Konstantin Ananyev > 2.30.2