All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] nfp: RX and XDP buffer fixes
@ 2017-03-02 23:26 Jakub Kicinski
  2017-03-02 23:26 ` [PATCH net 1/2] nfp: don't tell FW about the reserved buffer space Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2017-03-02 23:26 UTC (permalink / raw)
  To: netdev; +Cc: kubakici, oss-drivers, Jakub Kicinski

Hi!

Two trivial fixes for code introduced with XDP support.  First
one corrects the buffer size we populate a register with.  The
register is designed to be used for scatter transfers which 
the driver (and most FWs) don't support so it's not critical.
The other one for DMA direction is mostly cosmetic, DMA API
doesn't seem to care today about the precise direction in sync
calls.

Jakub Kicinski (2):
  nfp: don't tell FW about the reserved buffer space
  nfp: correct DMA direction in XDP DMA sync

 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] nfp: don't tell FW about the reserved buffer space
  2017-03-02 23:26 [PATCH net 0/2] nfp: RX and XDP buffer fixes Jakub Kicinski
@ 2017-03-02 23:26 ` Jakub Kicinski
  2017-03-02 23:26 ` [PATCH net 2/2] nfp: correct DMA direction in XDP DMA sync Jakub Kicinski
  2017-03-03 17:48 ` [PATCH net 0/2] nfp: RX and XDP buffer fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2017-03-02 23:26 UTC (permalink / raw)
  To: netdev; +Cc: kubakici, oss-drivers, Jakub Kicinski

Since commit c0f031bc8866 ("nfp_net: use alloc_frag() and build_skb()")
we are allocating buffers which have to hold both the data and skb to
be created in place by build_skb().

FW should only be told about the buffer space it can DMA to, that
is without the build_skb() headroom and tailroom.  Note: firmware
applications should validate the buffers against both MTU and
free list buffer size so oversized packets would not pass through
the NIC anyway.

Fixes: c0f031bc8866 ("nfp: use alloc_frag() and build_skb()")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 074259cc8e06..00a83218857a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -2198,7 +2198,8 @@ static int __nfp_net_set_config_and_enable(struct nfp_net *nn)
 	nfp_net_write_mac_addr(nn);
 
 	nn_writel(nn, NFP_NET_CFG_MTU, nn->netdev->mtu);
-	nn_writel(nn, NFP_NET_CFG_FLBUFSZ, nn->fl_bufsz);
+	nn_writel(nn, NFP_NET_CFG_FLBUFSZ,
+		  nn->fl_bufsz - NFP_NET_RX_BUF_NON_DATA);
 
 	/* Enable device */
 	new_ctrl |= NFP_NET_CFG_CTRL_ENABLE;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] nfp: correct DMA direction in XDP DMA sync
  2017-03-02 23:26 [PATCH net 0/2] nfp: RX and XDP buffer fixes Jakub Kicinski
  2017-03-02 23:26 ` [PATCH net 1/2] nfp: don't tell FW about the reserved buffer space Jakub Kicinski
@ 2017-03-02 23:26 ` Jakub Kicinski
  2017-03-03 17:48 ` [PATCH net 0/2] nfp: RX and XDP buffer fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2017-03-02 23:26 UTC (permalink / raw)
  To: netdev; +Cc: kubakici, oss-drivers, Jakub Kicinski

dma_sync_single_for_*() takes the direction in which the buffer
was mapped, not the direction of the sync.  We should sync XDP
buffers bidirectionally.

Fixes: ecd63a0217d5 ("nfp: add XDP support in the driver")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 00a83218857a..9179a99563af 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -1498,7 +1498,7 @@ nfp_net_tx_xdp_buf(struct nfp_net *nn, struct nfp_net_rx_ring *rx_ring,
 	txbuf->real_len = pkt_len;
 
 	dma_sync_single_for_device(&nn->pdev->dev, rxbuf->dma_addr + pkt_off,
-				   pkt_len, DMA_TO_DEVICE);
+				   pkt_len, DMA_BIDIRECTIONAL);
 
 	/* Build TX descriptor */
 	txd = &tx_ring->txds[wr_idx];
@@ -1611,7 +1611,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
 
 			dma_sync_single_for_cpu(&nn->pdev->dev,
 						rxbuf->dma_addr + pkt_off,
-						pkt_len, DMA_FROM_DEVICE);
+						pkt_len, DMA_BIDIRECTIONAL);
 			act = nfp_net_run_xdp(xdp_prog, rxbuf->frag + data_off,
 					      pkt_len);
 			switch (act) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] nfp: RX and XDP buffer fixes
  2017-03-02 23:26 [PATCH net 0/2] nfp: RX and XDP buffer fixes Jakub Kicinski
  2017-03-02 23:26 ` [PATCH net 1/2] nfp: don't tell FW about the reserved buffer space Jakub Kicinski
  2017-03-02 23:26 ` [PATCH net 2/2] nfp: correct DMA direction in XDP DMA sync Jakub Kicinski
@ 2017-03-03 17:48 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-03-03 17:48 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: netdev, kubakici, oss-drivers

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Thu,  2 Mar 2017 15:26:19 -0800

> Two trivial fixes for code introduced with XDP support.  First
> one corrects the buffer size we populate a register with.  The
> register is designed to be used for scatter transfers which 
> the driver (and most FWs) don't support so it's not critical.
> The other one for DMA direction is mostly cosmetic, DMA API
> doesn't seem to care today about the precise direction in sync
> calls.

Series applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-03 17:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 23:26 [PATCH net 0/2] nfp: RX and XDP buffer fixes Jakub Kicinski
2017-03-02 23:26 ` [PATCH net 1/2] nfp: don't tell FW about the reserved buffer space Jakub Kicinski
2017-03-02 23:26 ` [PATCH net 2/2] nfp: correct DMA direction in XDP DMA sync Jakub Kicinski
2017-03-03 17:48 ` [PATCH net 0/2] nfp: RX and XDP buffer fixes David Miller

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.