All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: netdev@vger.kernel.org, jaswinder.singh@linaro.org,
	ard.biesheuvel@linaro.org, bjorn.topel@intel.com,
	magnus.karlsson@intel.com, daniel@iogearbox.net, ast@kernel.org,
	makita.toshiaki@lab.ntt.co.jp, jakub.kicinski@netronome.com,
	john.fastabend@gmail.com, davem@davemloft.net, brouer@redhat.com
Subject: Re: [RFC, PATCH 2/2, net-next] net: netsec: add XDP support
Date: Thu, 27 Jun 2019 14:23:05 +0200	[thread overview]
Message-ID: <20190627142305.16b8f331@carbon> (raw)
In-Reply-To: <1561475179-7686-3-git-send-email-ilias.apalodimas@linaro.org>

On Tue, 25 Jun 2019 18:06:19 +0300
Ilias Apalodimas <ilias.apalodimas@linaro.org> wrote:

> @@ -609,6 +639,9 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
>  	int tail = dring->tail;
>  	int cnt = 0;
>  
> +	if (dring->is_xdp)
> +		spin_lock(&dring->lock);
> +
>  	pkts = 0;
>  	bytes = 0;
>  	entry = dring->vaddr + DESC_SZ * tail;
> @@ -622,16 +655,24 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
>  		eop = (entry->attr >> NETSEC_TX_LAST) & 1;
>  		dma_rmb();
>  
> -		dma_unmap_single(priv->dev, desc->dma_addr, desc->len,
> -				 DMA_TO_DEVICE);
> -		if (eop) {
> -			pkts++;
> +		if (!eop)
> +			goto next;
> +
> +		if (desc->buf_type == TYPE_NETSEC_SKB) {
> +			dma_unmap_single(priv->dev, desc->dma_addr, desc->len,
> +					 DMA_TO_DEVICE);

I don't think this is correct.  If I read the code correctly, you will
miss the DMA unmap for !eop packets.

>  			bytes += desc->skb->len;
>  			dev_kfree_skb(desc->skb);
> +		} else {
> +			if (desc->buf_type == TYPE_NETSEC_XDP_NDO)
> +				dma_unmap_single(priv->dev, desc->dma_addr,
> +						 desc->len, DMA_TO_DEVICE);
> +			xdp_return_frame(desc->xdpf);
>  		}
>  		/* clean up so netsec_uninit_pkt_dring() won't free the skb
>  		 * again
>  		 */
> +next:
>  		*desc = (struct netsec_desc){};
>  
>  		/* entry->attr is not going to be accessed by the NIC until
> @@ -645,6 +686,8 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
>  		entry = dring->vaddr + DESC_SZ * tail;
>  		cnt++;
>  	}
> +	if (dring->is_xdp)
> +		spin_unlock(&dring->lock);
>  
>  	if (!cnt)
>  		return false;



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

  reply	other threads:[~2019-06-27 12:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 15:06 [RFC, PATCH 0/2, net-next] net: netsec: Add XDP Support Ilias Apalodimas
2019-06-25 15:06 ` [RFC, PATCH 1/2, net-next] net: netsec: Use page_pool API Ilias Apalodimas
2019-06-27  9:37   ` Jesper Dangaard Brouer
2019-06-27  9:40     ` Ilias Apalodimas
2019-06-25 15:06 ` [RFC, PATCH 2/2, net-next] net: netsec: add XDP support Ilias Apalodimas
2019-06-27 12:23   ` Jesper Dangaard Brouer [this message]
2019-06-27 12:24     ` Ilias Apalodimas
2019-06-27 14:18   ` Maciej Fijalkowski
2019-06-28  6:54     ` Ilias Apalodimas

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=20190627142305.16b8f331@carbon \
    --to=brouer@redhat.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=jaswinder.singh@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=makita.toshiaki@lab.ntt.co.jp \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.