[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191017094450.GB2861@localhost.localdomain>
Date: Thu, 17 Oct 2019 11:44:50 +0200
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc: netdev@...r.kernel.org, lorenzo.bianconi@...hat.com,
davem@...emloft.net, thomas.petazzoni@...tlin.com,
brouer@...hat.com, ilias.apalodimas@...aro.org,
matteo.croce@...hat.com, mw@...ihalf.com
Subject: Re: [PATCH v4 net-next 7/7] net: mvneta: add XDP_TX support
> 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@...nel.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;
> > +}
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists