]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: support mbuf headroom for LRO packet
authorMatan Azrad <matan@mellanox.com>
Mon, 29 Jul 2019 11:53:22 +0000 (11:53 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 29 Jul 2019 14:54:27 +0000 (16:54 +0200)
Patch [1] zeroes the mbuf headroom when the port is configured with LRO
because when working with more than one stride per packet the HW cannot
guaranty an headroom in the start stride of each packet.

Change the solution to support mbuf headroom by adding an empty buffer
as the first packet segment, scatter mode must be enabled to support it.

[1] http://patches.dpdk.org/patch/56912/

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
doc/guides/nics/mlx5.rst
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_rxtx.c

index 92f1b97f661c79e91884c54aa5f6969589e98310..cd550f46ed01b8c1e09a34991383d2d95326aa19 100644 (file)
@@ -165,8 +165,7 @@ Limitations
 
 - LRO:
 
-  - No mbuf headroom space is created for RX packets when LRO is configured.
-  - ``scatter_fcs`` is disabled when LRO is configured.
+  - scatter_fcs is disabled when LRO is configured.
 
 Statistics
 ----------
index bd26ee2fe7ee43c045d3d22d070a4a3f4d8fb742..d10c5c1f32b0cbc7a4ab607b9cfc277ec2c8d087 100644 (file)
@@ -1599,12 +1599,7 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
        unsigned int mb_len = rte_pktmbuf_data_room_size(mp);
        unsigned int mprq_stride_size;
        struct mlx5_dev_config *config = &priv->config;
-       /*
-        * LRO packet may consume all the stride memory, hence we cannot
-        * guaranty head-room. A new striding RQ feature may be added in CX6 DX
-        * to allow head-room and tail-room for the LRO packets.
-        */
-       unsigned int strd_headroom_en = mlx5_lro_on(dev) ? 0 : 1;
+       unsigned int strd_headroom_en;
        /*
         * Always allocate extra slots, even if eventually
         * the vector Rx will not be used.
@@ -1644,6 +1639,21 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
        tmpl->socket = socket;
        if (dev->data->dev_conf.intr_conf.rxq)
                tmpl->irq = 1;
+       /*
+        * LRO packet may consume all the stride memory, hence we cannot
+        * guaranty head-room near the packet memory in the stride.
+        * In this case scatter is, for sure, enabled and an empty mbuf may be
+        * added in the start for the head-room.
+        */
+       if (mlx5_lro_on(dev) && RTE_PKTMBUF_HEADROOM > 0 &&
+           non_scatter_min_mbuf_size > mb_len) {
+               strd_headroom_en = 0;
+               mprq_stride_size = RTE_MIN(max_rx_pkt_len,
+                                       1u << config->mprq.max_stride_size_n);
+       } else {
+               strd_headroom_en = 1;
+               mprq_stride_size = non_scatter_min_mbuf_size;
+       }
        /*
         * This Rx queue can be configured as a Multi-Packet RQ if all of the
         * following conditions are met:
@@ -1653,8 +1663,6 @@ mlx5_rxq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc,
         *    stride.
         *  Otherwise, enable Rx scatter if necessary.
         */
-       mprq_stride_size = max_rx_pkt_len + RTE_PKTMBUF_HEADROOM *
-                               strd_headroom_en;
        if (mprq_en &&
            desc > (1U << config->mprq.stride_num_n) &&
            mprq_stride_size <= (1U << config->mprq.max_stride_size_n)) {
index a7ec73d02219a23d24069a0fca9c4dc07f4fb2cb..003eefdd40be0f2d482d21e78275cf8150e99e79 100644 (file)
@@ -1639,6 +1639,7 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
                                continue;
                        }
                        rte_memcpy(rte_pktmbuf_mtod(pkt, void *), addr, len);
+                       DATA_LEN(pkt) = len;
                } else {
                        rte_iova_t buf_iova;
                        struct rte_mbuf_ext_shared_info *shinfo;
@@ -1679,6 +1680,26 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
                                ++rxq->stats.idropped;
                                continue;
                        }
+                       DATA_LEN(pkt) = len;
+                       /*
+                        * LRO packet may consume all the stride memory, in this
+                        * case packet head-room space is not guaranteed so must
+                        * to add an empty mbuf for the head-room.
+                        */
+                       if (!rxq->strd_headroom_en) {
+                               struct rte_mbuf *headroom_mbuf =
+                                               rte_pktmbuf_alloc(rxq->mp);
+
+                               if (unlikely(headroom_mbuf == NULL)) {
+                                       rte_pktmbuf_free_seg(pkt);
+                                       ++rxq->stats.rx_nombuf;
+                                       break;
+                               }
+                               PORT(pkt) = rxq->port_id;
+                               NEXT(headroom_mbuf) = pkt;
+                               pkt = headroom_mbuf;
+                               NB_SEGS(pkt) = 2;
+                       }
                }
                rxq_cq_to_mbuf(rxq, pkt, cqe, rss_hash_res);
                if (lro_num_seg > 1) {
@@ -1687,7 +1708,6 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
                        pkt->tso_segsz = strd_sz;
                }
                PKT_LEN(pkt) = len;
-               DATA_LEN(pkt) = len;
                PORT(pkt) = rxq->port_id;
 #ifdef MLX5_PMD_SOFT_COUNTERS
                /* Increment bytes counter. */