netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Firo Yang <firo.yang@suse.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Alexander Duyck <alexander.h.duyck@linux.intel.com>,
	Andrew Bowers <andrewx.bowers@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 13/15] ixgbe: sync the first fragment unconditionally
Date: Mon,  9 Sep 2019 15:48:00 -0700	[thread overview]
Message-ID: <20190909224802.29595-14-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20190909224802.29595-1-jeffrey.t.kirsher@intel.com>

From: Firo Yang <firo.yang@suse.com>

In Xen environment, if Xen-swiotlb is enabled, ixgbe driver
could possibly allocate a page, DMA memory buffer, for the first
fragment which is not suitable for Xen-swiotlb to do DMA operations.
Xen-swiotlb have to internally allocate another page for doing DMA
operations. This mechanism requires syncing the data from the internal
page to the page which ixgbe sends to upper network stack. However,
since commit f3213d932173 ("ixgbe: Update driver to make use of DMA
attributes in Rx path"), the unmap operation is performed with
DMA_ATTR_SKIP_CPU_SYNC. As a result, the sync is not performed.
Since the sync isn't performed, the upper network stack could receive
a incomplete network packet. By incomplete, it means the linear data
on the first fragment(between skb->head and skb->end) is invalid. So
we have to copy the data from the internal xen-swiotlb page to the page
which ixgbe sends to upper network stack through the sync operation.

More details from Alexander Duyck:
Specifically since we are mapping the frame with
DMA_ATTR_SKIP_CPU_SYNC we have to unmap with that as well. As a result
a sync is not performed on an unmap and must be done manually as we
skipped it for the first frag. As such we need to always sync before
possibly performing a page unmap operation.

Fixes: f3213d932173 ("ixgbe: Update driver to make use of DMA attributes in Rx path")
Signed-off-by: Firo Yang <firo.yang@suse.com>
Reviewed-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 9bcae44e9883..99df595abfba 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1825,13 +1825,7 @@ static void ixgbe_pull_tail(struct ixgbe_ring *rx_ring,
 static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring,
 				struct sk_buff *skb)
 {
-	/* if the page was released unmap it, else just sync our portion */
-	if (unlikely(IXGBE_CB(skb)->page_released)) {
-		dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma,
-				     ixgbe_rx_pg_size(rx_ring),
-				     DMA_FROM_DEVICE,
-				     IXGBE_RX_DMA_ATTR);
-	} else if (ring_uses_build_skb(rx_ring)) {
+	if (ring_uses_build_skb(rx_ring)) {
 		unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK;
 
 		dma_sync_single_range_for_cpu(rx_ring->dev,
@@ -1848,6 +1842,14 @@ static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring,
 					      skb_frag_size(frag),
 					      DMA_FROM_DEVICE);
 	}
+
+	/* If the page was released, just unmap it. */
+	if (unlikely(IXGBE_CB(skb)->page_released)) {
+		dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma,
+				     ixgbe_rx_pg_size(rx_ring),
+				     DMA_FROM_DEVICE,
+				     IXGBE_RX_DMA_ATTR);
+	}
 }
 
 /**
-- 
2.21.0


  parent reply	other threads:[~2019-09-09 22:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 22:47 [net-next v2 00/15][pull request] Intel Wired LAN Driver Updates 2019-09-09 Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 01/15] iavf: remove unused debug function iavf_debug_d Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 02/15] ixgbevf: Link lost in VM on ixgbevf when restoring from freeze or suspend Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 03/15] e1000e: Make speed detection on hotplugging cable more reliable Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 04/15] igc: Remove useless forward declaration Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 05/15] Documentation: iavf: Update the Intel LAN driver doc for iavf Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 06/15] fm10k: use a local variable for the frag pointer Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 07/15] igc: Add NVM checksum validation Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 08/15] iavf: allow permanent MAC address to change Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 09/15] igc: Remove unneeded PCI bus defines Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 10/15] i40e: fix hw_dbg usage in i40e_hmc_get_object_va Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 11/15] i40e: Implement debug macro hw_dbg using dev_dbg Jeff Kirsher
2019-09-09 22:47 ` [net-next v2 12/15] i40e: Remove EMPR traces from debugfs facility Jeff Kirsher
2019-09-09 22:48 ` Jeff Kirsher [this message]
2019-09-09 22:48 ` [net-next v2 14/15] igc: Add tx_csum offload functionality Jeff Kirsher
2019-09-09 22:48 ` [net-next v2 15/15] i40e: Add support for X710 device Jeff Kirsher
2019-09-10  7:45 ` [net-next v2 00/15][pull request] Intel Wired LAN Driver Updates 2019-09-09 David Miller

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=20190909224802.29595-14-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=alexander.h.duyck@linux.intel.com \
    --cc=andrewx.bowers@intel.com \
    --cc=davem@davemloft.net \
    --cc=firo.yang@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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).