netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org, lorenzo.bianconi@redhat.com,
	davem@davemloft.net, thomas.petazzoni@bootlin.com,
	brouer@redhat.com, ilias.apalodimas@linaro.org,
	matteo.croce@redhat.com, mw@semihalf.com
Subject: Re: [PATCH v4 net-next 7/7] net: mvneta: add XDP_TX support
Date: Thu, 17 Oct 2019 11:44:50 +0200	[thread overview]
Message-ID: <20191017094450.GB2861@localhost.localdomain> (raw)
In-Reply-To: <20191016182849.27d130db@cakuba.netronome.com>

[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]

> On Wed, 16 Oct 2019 23:03:12 +0200, Lorenzo Bianconi wrote:
> > Implement XDP_TX verdict and ndo_xdp_xmit net_device_ops function
> > pointer
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> > +static int
> > +mvneta_xdp_submit_frame(struct mvneta_port *pp, struct mvneta_tx_queue *txq,
> > +			struct xdp_frame *xdpf, bool dma_map)
> > +{
> > +	struct mvneta_tx_desc *tx_desc;
> > +	struct mvneta_tx_buf *buf;
> > +	dma_addr_t dma_addr;
> > +
> > +	if (txq->count >= txq->tx_stop_threshold)
> > +		return MVNETA_XDP_DROPPED;
> > +
> > +	tx_desc = mvneta_txq_next_desc_get(txq);
> > +
> > +	buf = &txq->buf[txq->txq_put_index];
> > +	if (dma_map) {
> > +		/* ndo_xdp_xmit */
> > +		dma_addr = dma_map_single(pp->dev->dev.parent, xdpf->data,
> > +					  xdpf->len, DMA_TO_DEVICE);
> > +		if (dma_mapping_error(pp->dev->dev.parent, dma_addr)) {
> > +			mvneta_txq_desc_put(txq);
> > +			return MVNETA_XDP_DROPPED;
> > +		}
> > +		buf->type = MVNETA_TYPE_XDP_NDO;
> > +	} else {
> > +		struct page *page = virt_to_page(xdpf->data);
> > +
> > +		dma_addr = page_pool_get_dma_addr(page) +
> > +			   xdpf->headroom + sizeof(*xdpf);
> 
> nit:
> 
>  sizeof(*xdpf) + xdpf->headroom
> 
> order would be slightly preferable since it matches field ordering in
> memory.

ack, agree. Will do in v5.

Regards,
Lorenzo

> 
> > +		dma_sync_single_for_device(pp->dev->dev.parent, dma_addr,
> > +					   xdpf->len, DMA_BIDIRECTIONAL);
> > +		buf->type = MVNETA_TYPE_XDP_TX;
> > +	}
> > +	buf->xdpf = xdpf;
> > +
> > +	tx_desc->command = MVNETA_TXD_FLZ_DESC;
> > +	tx_desc->buf_phys_addr = dma_addr;
> > +	tx_desc->data_size = xdpf->len;
> > +
> > +	mvneta_update_stats(pp, 1, xdpf->len, true);
> > +	mvneta_txq_inc_put(txq);
> > +	txq->pending++;
> > +	txq->count++;
> > +
> > +	return MVNETA_XDP_TX;
> > +}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2019-10-17  9:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 21:03 [PATCH v4 net-next 0/7] add XDP support to mvneta driver Lorenzo Bianconi
2019-10-16 21:03 ` [PATCH v4 net-next 1/7] net: mvneta: introduce mvneta_update_stats routine Lorenzo Bianconi
2019-10-17  1:01   ` Jakub Kicinski
2019-10-16 21:03 ` [PATCH v4 net-next 2/7] net: mvneta: introduce page pool API for sw buffer manager Lorenzo Bianconi
2019-10-17  1:14   ` Jakub Kicinski
2019-10-17  9:58     ` Lorenzo Bianconi
2019-10-16 21:03 ` [PATCH v4 net-next 3/7] net: mvneta: rely on build_skb in mvneta_rx_swbm poll routine Lorenzo Bianconi
2019-10-17  1:19   ` Jakub Kicinski
2019-10-16 21:03 ` [PATCH v4 net-next 4/7] net: mvneta: add basic XDP support Lorenzo Bianconi
2019-10-17  1:26   ` Jakub Kicinski
2019-10-17  9:46     ` Lorenzo Bianconi
2019-10-16 21:03 ` [PATCH v4 net-next 5/7] net: mvneta: move header prefetch in mvneta_swbm_rx_frame Lorenzo Bianconi
2019-10-16 21:03 ` [PATCH v4 net-next 6/7] net: mvneta: make tx buffer array agnostic Lorenzo Bianconi
2019-10-16 21:03 ` [PATCH v4 net-next 7/7] net: mvneta: add XDP_TX support Lorenzo Bianconi
2019-10-17  1:28   ` Jakub Kicinski
2019-10-17  9:44     ` Lorenzo Bianconi [this message]

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=20191017094450.GB2861@localhost.localdomain \
    --to=lorenzo@kernel.org \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=matteo.croce@redhat.com \
    --cc=mw@semihalf.com \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.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).