From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6B2831F1C for ; Thu, 8 Mar 2018 15:21:03 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 06:20:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,441,1515484800"; d="scan'208";a="209860353" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 08 Mar 2018 06:20:59 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 06:20:59 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 06:20:59 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Thu, 8 Mar 2018 22:20:56 +0800 From: "Zhang, Qi Z" To: "dev@dpdk.org" CC: "Karlsson, Magnus" , "Topel, Bjorn" Thread-Topic: [RFC v2 6/7] net/af_xdp: load BPF file Thread-Index: AQHTtuTI2ScEnPCWeky0wOsUHgPb8KPGYKsg Date: Thu, 8 Mar 2018 14:20:56 +0000 Message-ID: <039ED4275CED7440929022BC67E7061153160BD9@SHSMSX103.ccr.corp.intel.com> References: <20180308135249.28187-1-qi.z.zhang@intel.com> <20180308135249.28187-7-qi.z.zhang@intel.com> In-Reply-To: <20180308135249.28187-7-qi.z.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC v2 6/7] net/af_xdp: load BPF file 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: Thu, 08 Mar 2018 14:21:04 -0000 > -----Original Message----- > From: Zhang, Qi Z > Sent: Thursday, March 8, 2018 9:53 PM > To: dev@dpdk.org > Cc: Karlsson, Magnus ; Topel, Bjorn > ; Zhang, Qi Z > Subject: [RFC v2 6/7] net/af_xdp: load BPF file >=20 > Add libbpf and libelf dependency in Makefile. > Durring initialization, a bpf prog which call imm "xdpsk_redirect" > will be loaded. Then the driver will always try to link XDP fd with DRV m= ode > first, then SKB mode if failed in previoius. Link will be released during > dev_close. >=20 > Note: this is workaround solution, af_xdp may remove BPF dependency in > future. >=20 > Signed-off-by: Qi Zhang > --- > drivers/net/af_xdp/Makefile | 5 +- > drivers/net/af_xdp/bpf_load.c | 168 > ++++++++++++++++++++++++++++++++++++ > drivers/net/af_xdp/bpf_load.h | 11 +++ > drivers/net/af_xdp/rte_eth_af_xdp.c | 80 ++++++++++++++--- > mk/rte.app.mk | 2 +- > 5 files changed, 254 insertions(+), 12 deletions(-) create mode 100644 > drivers/net/af_xdp/bpf_load.c create mode 100644 > drivers/net/af_xdp/bpf_load.h >=20 > diff --git a/drivers/net/af_xdp/Makefile b/drivers/net/af_xdp/Makefile in= dex > 990073655..f16b5306b 100644 > --- a/drivers/net/af_xdp/Makefile > +++ b/drivers/net/af_xdp/Makefile > @@ -12,7 +12,9 @@ EXPORT_MAP :=3D rte_pmd_af_xdp_version.map >=20 > +static char bpf_log_buf[BPF_LOG_BUF_SIZE]; > + > +struct bpf_insn prog[] =3D { > + { > + .code =3D 0x85, //call imm > + .dst_reg =3D 0, > + .src_reg =3D 0, > + .off =3D 0, > + .imm =3D BPF_FUNC_xdpsk_redirect, > + }, > + { > + .code =3D 0x95, //exit > + .dst_reg =3D 0, > + .src_reg =3D 0, > + .off =3D 0, > + .imm =3D 0, > + }, > +}; > + > +int load_bpf_file(void) > +{ > + int fd; > + > + fd =3D bpf_load_program(BPF_PROG_TYPE_XDP, prog, > + ARRAY_SIZE(prog), Sorry for one mistake. checkpatch recommend to use ARRAY_SIZE here, but seems this macro is not de= fined by default, so compile failed here, replace with "2" is a quick fix. > + "GPL", 0, > + bpf_log_buf, BPF_LOG_BUF_SIZE); > + > +=09