DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: "Karlsson, Magnus" <magnus.karlsson@intel.com>,
	"Topel, Bjorn" <bjorn.topel@intel.com>
Subject: Re: [dpdk-dev] [RFC v2 6/7] net/af_xdp: load BPF file
Date: Thu, 8 Mar 2018 14:20:56 +0000	[thread overview]
Message-ID: <039ED4275CED7440929022BC67E7061153160BD9@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20180308135249.28187-7-qi.z.zhang@intel.com>



> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Thursday, March 8, 2018 9:53 PM
> To: dev@dpdk.org
> Cc: Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn
> <bjorn.topel@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [RFC v2 6/7] net/af_xdp: load BPF file
> 
> 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 mode
> first, then SKB mode if failed in previoius. Link will be released during
> dev_close.
> 
> Note: this is workaround solution, af_xdp may remove BPF dependency in
> future.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  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
> 
> diff --git a/drivers/net/af_xdp/Makefile b/drivers/net/af_xdp/Makefile index
> 990073655..f16b5306b 100644
> --- a/drivers/net/af_xdp/Makefile
> +++ b/drivers/net/af_xdp/Makefile
> @@ -12,7 +12,9 @@ EXPORT_MAP := rte_pmd_af_xdp_version.map
> 
> +static char bpf_log_buf[BPF_LOG_BUF_SIZE];
> +
> +struct bpf_insn prog[] = {
> +	{
> +		.code = 0x85, //call imm
> +		.dst_reg = 0,
> +		.src_reg = 0,
> +		.off = 0,
> +		.imm = BPF_FUNC_xdpsk_redirect,
> +	},
> +	{
> +		.code = 0x95, //exit
> +		.dst_reg = 0,
> +		.src_reg = 0,
> +		.off = 0,
> +		.imm = 0,
> +	},
> +};
> +
> +int load_bpf_file(void)
> +{
> +	int fd;
> +
> +	fd = 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 defined by default, so compile failed here, replace with "2" is a quick fix.
> +			      "GPL", 0,
> +			      bpf_log_buf, BPF_LOG_BUF_SIZE);
> +
> +	

  reply	other threads:[~2018-03-08 14:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 13:52 [dpdk-dev] [RFC v2 0/7] PMD driver for AF_XDP Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 1/7] net/af_xdp: new PMD driver Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 2/7] lib/mbuf: enable parse flags when create mempool Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 3/7] lib/mempool: allow page size aligned mempool Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 4/7] net/af_xdp: use mbuf mempool for buffer management Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 5/7] net/af_xdp: enable share mempool Qi Zhang
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 6/7] net/af_xdp: load BPF file Qi Zhang
2018-03-08 14:20   ` Zhang, Qi Z [this message]
2018-03-08 23:15   ` Stephen Hemminger
2018-05-09  7:02     ` Björn Töpel
2018-03-08 13:52 ` [dpdk-dev] [RFC v2 7/7] app/testpmd: enable parameter for mempool flags Qi Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=039ED4275CED7440929022BC67E7061153160BD9@SHSMSX103.ccr.corp.intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=bjorn.topel@intel.com \
    --cc=dev@dpdk.org \
    --cc=magnus.karlsson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).