Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v3 2/4] i40e: Initial support for XDP
Date: Fri, 16 Dec 2016 10:07:32 -0800	[thread overview]
Message-ID: <58542D64.2070801@gmail.com> (raw)
In-Reply-To: <20161213134007.14707-3-bjorn.topel@gmail.com>

On 16-12-13 05:40 AM, Bj?rn T?pel wrote:
> From: Bj?rn T?pel <bjorn.topel@intel.com>
> 
> This commit adds basic XDP support for i40e derived NICs. All XDP
> actions will end up in XDP_DROP.
> 
> Only the default/main VSI has support for enabling XDP.
> 
> Signed-off-by: Bj?rn T?pel <bjorn.topel@intel.com>
> ---

[...]

>  
>  /**
> + * i40e_run_xdp - Runs an XDP program for an Rx ring
> + * @rx_ring: Rx ring used for XDP
> + * @rx_buffer: current Rx buffer
> + * @rx_desc: current Rx descriptor
> + * @size: buffer size
> + * @xdp_prog: the XDP program to run
> + *
> + * Returns true if the XDP program consumed the incoming frame. False
> + * means pass the frame to the good old stack.
> + **/
> +static bool i40e_run_xdp(struct i40e_ring *rx_ring,
> +			 struct i40e_rx_buffer *rx_buffer,
> +			 union i40e_rx_desc *rx_desc,
> +			 unsigned int size,
> +			 struct bpf_prog *xdp_prog)
> +{
> +	struct xdp_buff xdp;
> +	u32 xdp_action;
> +
> +	if (unlikely(!i40e_test_staterr(rx_desc,
> +					BIT(I40E_RX_DESC_STATUS_EOF_SHIFT)))) {
> +		dev_warn_once(&rx_ring->vsi->back->pdev->dev,
> +			      "Received unexpected RXD_EOF!\n");
> +		goto do_drop;
> +	}
> +
> +	xdp.data = page_address(rx_buffer->page) + rx_buffer->page_offset;
> +	xdp.data_end = xdp.data + size;

We need to set the xdp.data_hard_start as well here.

	xdp.data_hard_start = xdp.data

should be good enough for now.

> +	xdp_action = bpf_prog_run_xdp(xdp_prog, &xdp);
> +
> +	switch (xdp_action) {
> +	case XDP_PASS:
> +		return false;
> +	default:
> +		bpf_warn_invalid_xdp_action(xdp_action);
> +	case XDP_ABORTED:
> +	case XDP_TX:
> +	case XDP_DROP:
> +do_drop:
> +		if (likely(i40e_page_is_reusable(rx_buffer->page))) {
> +			i40e_reuse_rx_page(rx_ring, rx_buffer);
> +			rx_ring->rx_stats.page_reuse_count++;
> +			break;
> +		}
> +
> +		/* we are not reusing the buffer so unmap it */
> +		dma_unmap_page(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,
> +			       DMA_FROM_DEVICE);
> +		__free_pages(rx_buffer->page, 0);
> +	}
> +
> +	/* clear contents of buffer_info */
> +	rx_buffer->page = NULL;
> +	return true; /* Swallowed by XDP */
> +}
> +
> +/**
>   * i40e_fetch_rx_buffer - Allocate skb and populate it

Thanks,
John


  reply	other threads:[~2016-12-16 18:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-13 13:40 [Intel-wired-lan] [PATCH v3 0/4] i40e: Support for XDP =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-13 13:40 ` [Intel-wired-lan] [PATCH v3 1/4] i40e: Sync DMA region prior skbuff allocation =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-13 13:40 ` [Intel-wired-lan] [PATCH v3 2/4] i40e: Initial support for XDP =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-16 18:07   ` John Fastabend [this message]
2016-12-16 18:31     ` =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-13 13:40 ` [Intel-wired-lan] [PATCH v3 3/4] i40e: Add XDP_TX support =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-13 19:57   ` =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=
2016-12-13 13:40 ` [Intel-wired-lan] [PATCH v3 4/4] i40e: Validate xdp_adjust_head support =?unknown-8bit?q?Bj=C3=B6rn_T=C3=B6pel?=

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=58542D64.2070801@gmail.com \
    --to=john.fastabend@gmail.com \
    --cc=intel-wired-lan@osuosl.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