net/mlx5: fix multi-segment packet wraparound
authorDariusz Sosnowski <dsosnowski@nvidia.com>
Tue, 23 Nov 2021 13:57:40 +0000 (15:57 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Tue, 23 Nov 2021 16:57:13 +0000 (17:57 +0100)
This patch fixes the assertion failure triggered when the user
configured minimum inline length requirements and the application
transmitted multi segment packets. Failure was triggered when space left
in TX queue was not enough to cover this requirement.

This patch limits the length of data to be copied to the available space
in TX queue.

Fixes: cacb44a09962 ("net/mlx5: add no-inline Tx flag")
Cc: stable@dpdk.org
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/net/mlx5/mlx5_tx.h

index bc62998..099e729 100644 (file)
@@ -1071,7 +1071,6 @@ mlx5_tx_mseg_memcpy(uint8_t *pdst,
        uint8_t *psrc;
 
        MLX5_ASSERT(len);
-       MLX5_ASSERT(must <= len);
        do {
                /* Allow zero length packets, must check first. */
                dlen = rte_pktmbuf_data_len(loc->mbuf);
@@ -1098,9 +1097,11 @@ mlx5_tx_mseg_memcpy(uint8_t *pdst,
                                if (diff <= rte_pktmbuf_data_len(loc->mbuf)) {
                                        /*
                                         * Copy only the minimal required
-                                        * part of the data buffer.
+                                        * part of the data buffer. Limit amount
+                                        * of data to be copied to the length of
+                                        * available space.
                                         */
-                                       len = diff;
+                                       len = RTE_MIN(len, diff);
                                }
                        }
                        continue;