net/sfc: improve TSO header length check in EF10 datapath
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Tue, 2 Apr 2019 09:28:34 +0000 (10:28 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 5 Apr 2019 15:45:22 +0000 (17:45 +0200)
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: 6bc985e41155 ("net/sfc: support TSO in EF10 Tx datapath")
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_ef10_tx.c

index 0711c11..97b1b62 100644 (file)
@@ -340,9 +340,7 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg,
        struct rte_mbuf *m_seg_to_free_up_to = first_m_seg;
        bool eop;
 
-       /* Both checks may be done, so use bit OR to have only one branching */
-       if (unlikely((header_len > SFC_TSOH_STD_LEN) |
-                    (tcph_off > txq->tso_tcp_header_offset_limit)))
+       if (unlikely(tcph_off > txq->tso_tcp_header_offset_limit))
                return EMSGSIZE;
 
        /*
@@ -407,6 +405,13 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg,
                unsigned int hdr_addr_off = (*added & txq->ptr_mask) *
                                SFC_TSOH_STD_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;
+
                hdr_addr = txq->tsoh + hdr_addr_off;
                hdr_iova = txq->tsoh_iova + hdr_addr_off;
                copied_segs = sfc_tso_prepare_header(hdr_addr, header_len,