bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Ong Boon Leong <boon.leong.ong@intel.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S . Miller" <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, KP Singh <kpsingh@kernel.org>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v3 5/6] net: stmmac: Add support for XDP_TX action
Date: Wed, 31 Mar 2021 14:42:35 -0700	[thread overview]
Message-ID: <20210331144235.799dea32@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210331154135.8507-6-boon.leong.ong@intel.com>

On Wed, 31 Mar 2021 23:41:34 +0800 Ong Boon Leong wrote:
> This patch adds support for XDP_TX action which enables XDP program to
> transmit back received frames.
> 
> This patch has been tested with the "xdp2" app located in samples/bpf
> dir. The DUT receives burst traffic packet generated using pktgen script
> 'pktgen_sample03_burst_single_flow.sh'.
> 
> v3: Added 'nq->trans_start = jiffies' to avoid TX time-out as we are
>     sharing TX queue between slow path and XDP. Thanks to Jakub Kicinski
>     for pointing out.
> 
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>

> +static int stmmac_xdp_xmit_back(struct stmmac_priv *priv,
> +				struct xdp_buff *xdp)
> +{
> +	struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp);
> +	int cpu = smp_processor_id();
> +	struct netdev_queue *nq;
> +	int queue;
> +	int res;
> +
> +	if (unlikely(!xdpf))
> +		return -EFAULT;

Can you return -EFAULT here? looks like the function is otherwise
returning positive STMMAC_XDP_* return codes/masks.

> +	queue = stmmac_xdp_get_tx_queue(priv, cpu);
> +	nq = netdev_get_tx_queue(priv->dev, queue);
> +
> +	__netif_tx_lock(nq, cpu);
> +	/* Avoids TX time-out as we are sharing with slow path */
> +	nq->trans_start = jiffies;
> +	res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf);
> +	if (res == STMMAC_XDP_TX) {
> +		stmmac_flush_tx_descriptors(priv, queue);
> +		stmmac_tx_timer_arm(priv, queue);

Would it make sense to arm the timer and flush descriptors at the end
of the NAPI poll cycle? Instead of after every TX frame?

> +	}
> +	__netif_tx_unlock(nq);
> +
> +	return res;
> +}

> @@ -4365,16 +4538,26 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
>  			xdp.data_hard_start = page_address(buf->page);
>  			xdp_set_data_meta_invalid(&xdp);
>  			xdp.frame_sz = buf_sz;
> +			xdp.rxq = &rx_q->xdp_rxq;
>  
> +			pre_len = xdp.data_end - xdp.data_hard_start -
> +				  buf->page_offset;
>  			skb = stmmac_xdp_run_prog(priv, &xdp);
> +			/* Due xdp_adjust_tail: DMA sync for_device
> +			 * cover max len CPU touch
> +			 */
> +			sync_len = xdp.data_end - xdp.data_hard_start -
> +				   buf->page_offset;
> +			sync_len = max(sync_len, pre_len);
>  
>  			/* For Not XDP_PASS verdict */
>  			if (IS_ERR(skb)) {
>  				unsigned int xdp_res = -PTR_ERR(skb);
>  
>  				if (xdp_res & STMMAC_XDP_CONSUMED) {
> -					page_pool_recycle_direct(rx_q->page_pool,
> -								 buf->page);
> +					page_pool_put_page(rx_q->page_pool,
> +							   virt_to_head_page(xdp.data),
> +							   sync_len, true);

IMHO the dma_sync_size logic is a little question, but it's not really
related to your patch, others are already doing the same thing, so it's
fine, I guess.

>  					buf->page = NULL;
>  					priv->dev->stats.rx_dropped++;


  reply	other threads:[~2021-03-31 21:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 15:41 [PATCH net-next v3 0/6] stmmac: Add XDP support Ong Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 1/6] net: stmmac: set IRQ affinity hint for multi MSI vectors Ong Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 2/6] net: stmmac: make SPH enable/disable to be configurable Ong Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 3/6] net: stmmac: arrange Tx tail pointer update to stmmac_flush_tx_descriptors Ong Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 4/6] net: stmmac: Add initial XDP support Ong Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 5/6] net: stmmac: Add support for XDP_TX action Ong Boon Leong
2021-03-31 21:42   ` Jakub Kicinski [this message]
2021-03-31 23:09     ` Ong, Boon Leong
2021-03-31 15:41 ` [PATCH net-next v3 6/6] net: stmmac: Add support for XDP_REDIRECT action Ong Boon Leong

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=20210331144235.799dea32@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=alexandre.torgue@st.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=boon.leong.ong@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=joabreu@synopsys.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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).