From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 66E411B76E for ; Mon, 9 Apr 2018 13:10:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2018 04:10:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,427,1517904000"; d="scan'208";a="44649689" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by fmsmga004.fm.intel.com with ESMTP; 09 Apr 2018 04:10:21 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.164]) by IRSMSX154.ger.corp.intel.com ([169.254.12.234]) with mapi id 14.03.0319.002; Mon, 9 Apr 2018 12:10:20 +0100 From: "Ananyev, Konstantin" To: Jerin Jacob CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 00/10] add framework to load and execute BPF code Thread-Index: AQHTzdgUKFezMEulfkadyxbRBX7TZaP30TiAgAB2DzA= Date: Mon, 9 Apr 2018 11:10:20 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258AE91217D@IRSMSX102.ger.corp.intel.com> References: <1522431163-25621-2-git-send-email-konstantin.ananyev@intel.com> <1523040581-2522-1-git-send-email-konstantin.ananyev@intel.com> <20180409045426.GA9585@jerin> In-Reply-To: <20180409045426.GA9585@jerin> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2QwMzBhZTctYjY0Ny00NjFjLThjZDEtN2U0ODI2MDQzNDhmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpoVXpEYXN4amR1UTdLOTFyMVdwQ3pIb29LYjdESVpqRGdpSDY5cVdrZjA9In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 00/10] add framework to load and execute BPF code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2018 11:10:25 -0000 Hi Jerin, > > > > BPF is used quite intensively inside Linux (and BSD) kernels > > for various different purposes and proved to be extremely useful. > > > > BPF inside DPDK might also be used in a lot of places > > for a lot of similar things. > > As an example to: > > - packet filtering/tracing (aka tcpdump) > > - packet classification > > - statistics collection > > - HW/PMD live-system debugging/prototyping - trace HW descriptors, > > internal PMD SW state, etc. > > - Comeup with your own idea > > > > All of that in a dynamic, user-defined and extensible manner. > > > > So these series introduce new library - librte_bpf. > > librte_bpf provides API to load and execute BPF bytecode within > > user-space dpdk app. > > It supports basic set of features from eBPF spec. > > Also it introduces basic framework to load/unload BPF-based filters > > on eth devices (right now via SW RX/TX callbacks). > > > > How to try it: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > 1) run testpmd as usual and start your favorite forwarding case. > > 2) build bpf program you'd like to load > > (you'll need clang v3.7 or above): > > $ cd test/bpf > > $ clang -O2 -target bpf -c t1.c > > > > 3) load bpf program(s): > > testpmd> bpf-load rx|tx > > > > : [-][J][M] > > J - use JIT generated native code, otherwise BPF interpreter will be us= ed. > > M - assume input parameter is a pointer to rte_mbuf, > > otherwise assume it is a pointer to first segment's data. > > > > Few examples: > > > > # to load (not JITed) dummy.o at TX queue 0, port 0: > > testpmd> bpf-load tx 0 0 - ./dpdk.org/test/bpf/dummy.o > > #to load (and JIT compile) t1.o at RX queue 0, port 1: > > testpmd> bpf-load rx 1 0 J ./dpdk.org/test/bpf/t1.o > > > > #to load and JIT t3.o (note that it expects mbuf as an input): > > testpmd> bpf-load rx 2 0 JM ./dpdk.org/test/bpf/t3.o > > > > 4) observe changed traffic behavior > > Let say with the examples above: > > - dummy.o does literally nothing, so no changes should be here, > > except some possible slowdown. > > - t1.o - should force to drop all packets that doesn't match: > > 'dst 1.2.3.4 && udp && dst port 5000' filter. > > - t3.o - should dump to stdout ARP packets. > > > > 5) unload some or all bpf programs: > > testpmd> bpf-unload tx 0 0 > > > > 6) continue with step 3) or exit > > > > Not currently supported features: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > - cBPF > > - tail-pointer call > > - eBPF MAP > > - JIT for non X86_64 targets >=20 > May be for next release, we are planning to add arm64 JIT support. Sounds great :) > Just wondering, How do you test all EBPF opcodes in JIT/Interpreter mode? > Are you planning to add any UT like linux kernel in dpdk ? or it was > similar to https://github.com/iovisor/ubpf/tree/master/tests ? I added UT for it in v3: http://dpdk.org/dev/patchwork/patch/37456/ But it doesn't cover whole ISA yet. In fact - that's what I am working right now - adding more test-cases to it= , so hopefully by next release will have much better test coverage. Another thing I plan to add - harden validate() to catch more cases with Invalid code.=20 Konstantin >=20 > Just asking because, when we introduce arm64 JIT support similar > test cases should be required to verify the implementation.