bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Magnus Karlsson <magnus.karlsson@intel.com>
Cc: bjorn.topel@intel.com, ast@kernel.org, daniel@iogearbox.net,
	netdev@vger.kernel.org, jonathan.lemon@gmail.com,
	linux-doc@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf v2] xsk: improve documentation for AF_XDP
Date: Fri, 18 Oct 2019 16:27:58 -0700	[thread overview]
Message-ID: <20191018232756.akn4yvyxmi63dl5b@ast-mbp> (raw)
In-Reply-To: <1571391220-22835-1-git-send-email-magnus.karlsson@intel.com>

On Fri, Oct 18, 2019 at 11:33:40AM +0200, Magnus Karlsson wrote:
> +
> +   #include <linux/bpf.h>
> +   #include "bpf_helpers.h"
> +
> +   #define MAX_SOCKS 16
> +
> +   struct {
> +        __uint(type, BPF_MAP_TYPE_XSKMAP);
> +        __uint(max_entries, MAX_SOCKS);
> +        __uint(key_size, sizeof(int));
> +        __uint(value_size, sizeof(int));
> +   } xsks_map SEC(".maps");
> +
> +   struct {
> +        __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
> +        __uint(max_entries, 1);
> +        __type(key, int);
> +        __type(value, unsigned int);
> +   } rr_map SEC(".maps");

hmm. does xsks_map compile?

> +
> +   SEC("xdp_sock") int xdp_sock_prog(struct xdp_md *ctx)
> +   {
> +	int key = 0, idx;
> +	unsigned int *rr;
> +
> +	rr = bpf_map_lookup_elem(&rr_map, &key);
> +	if (!rr)
> +	   return XDP_ABORTED;

could you please use global data and avoid lookup?
The run-time will be much faster.


  reply	other threads:[~2019-10-18 23:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18  9:33 [PATCH bpf v2] xsk: improve documentation for AF_XDP Magnus Karlsson
2019-10-18 23:27 ` Alexei Starovoitov [this message]
2019-10-20  8:13   ` Magnus Karlsson
2019-10-20 17:25     ` Alexei Starovoitov
2019-10-20 19:12       ` Magnus Karlsson

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=20191018232756.akn4yvyxmi63dl5b@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    /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).