[01/12] net/sfc: improve TSO header length check in EFX datapath

Message ID 1554197324-32391-2-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: add Tx prepare and encapsulated TSO |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Andrew Rybchenko April 2, 2019, 9:28 a.m. UTC
  From: Igor Romanov <igor.romanov@oktetlabs.ru>

Move the check inside xmit function to the branch in which
the check is mandatory. It makes case when TSO header is not
fragmented a bit more faster.

Fixes: fec33d5bb3eb ("net/sfc: support firmware-assisted TSO")
Cc: stable@dpdk.org

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_tso.c | 11 +++++++----
 drivers/net/sfc/sfc_tx.c  |  3 ++-
 2 files changed, 9 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c
index 076a25d44..a28af0e78 100644
--- a/drivers/net/sfc/sfc_tso.c
+++ b/drivers/net/sfc/sfc_tso.c
@@ -107,10 +107,6 @@  sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
 
 	idx += SFC_TSO_OPT_DESCS_NUM;
 
-	/* Packets which have too big headers should be discarded */
-	if (unlikely(header_len > SFC_TSOH_STD_LEN))
-		return EMSGSIZE;
-
 	/*
 	 * The TCP header must start at most 208 bytes into the frame.
 	 * If it starts later than this then the NIC won't realise
@@ -129,6 +125,13 @@  sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx,
 	 * limitations on address boundaries crossing by DMA descriptor data.
 	 */
 	if (m->data_len < header_len) {
+		/*
+		 * Discard a packet if header linearization is needed but
+		 * the header is too big.
+		 */
+		if (unlikely(header_len > SFC_TSOH_STD_LEN))
+			return EMSGSIZE;
+
 		tsoh = txq->sw_ring[idx & txq->ptr_mask].tsoh;
 		sfc_tso_prepare_header(tsoh, header_len, in_seg, in_off);
 
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index c3e0936cc..4b1f94ce8 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -760,7 +760,8 @@  sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 				/* We may have reached this place for
 				 * one of the following reasons:
 				 *
-				 * 1) Packet header length is greater
+				 * 1) Packet header linearization is needed
+				 *    and the header length is greater
 				 *    than SFC_TSOH_STD_LEN
 				 * 2) TCP header starts at more then
 				 *    208 bytes into the frame