net/octeontx: fix mbuf corruption with large private sizes
authorNitin Saxena <nitin.saxena@caviumnetworks.com>
Mon, 12 Nov 2018 17:54:09 +0000 (17:54 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 13 Nov 2018 23:35:53 +0000 (00:35 +0100)
When the priv_size of the mbuf is > 128 bytes, the mbuf would not be
properly constructed. This would lead to a corrupt mbuf.

This patch fixes the issue by accounting for
rte_pktmbuf_priv_size(pool) and RTE_PKTMBUF_HEADROOM
while configuring first skip register calculation.

Fixes: 197438ee9f18 ("net/octeontx: add Rx queue setup and release ops")
Cc: stable@dpdk.org
Suggested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
Signed-off-by: Nitin Saxena <nitin.saxena@caviumnetworks.com>
Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
drivers/net/octeontx/base/octeontx_pki_var.h
drivers/net/octeontx/octeontx_ethdev.c

index c793b65..f4661d2 100644 (file)
@@ -7,8 +7,17 @@
 
 #include <rte_byteorder.h>
 
-#define OCTTX_PACKET_WQE_SKIP          128
-#define OCTTX_PACKET_FIRST_SKIP                240
+#define OCTTX_PACKET_WQE_SKIP                  128
+#define OCTTX_PACKET_FIRST_SKIP_MAXREGVAL      496
+#define OCTTX_PACKET_FIRST_SKIP_MAXLEN         512
+#define OCTTX_PACKET_FIRST_SKIP_ADJUST(x)                              \
+               (RTE_MIN(x, OCTTX_PACKET_FIRST_SKIP_MAXREGVAL))
+#define OCTTX_PACKET_FIRST_SKIP_SUM(p)                                 \
+                               (OCTTX_PACKET_WQE_SKIP                  \
+                               + rte_pktmbuf_priv_size(p)              \
+                               + RTE_PKTMBUF_HEADROOM)
+#define OCTTX_PACKET_FIRST_SKIP(p)                                     \
+       OCTTX_PACKET_FIRST_SKIP_ADJUST(OCTTX_PACKET_FIRST_SKIP_SUM(p))
 #define OCTTX_PACKET_LATER_SKIP                128
 
 /* WQE descriptor */
index 0681486..a3063be 100644 (file)
@@ -844,10 +844,11 @@ octeontx_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
                pktbuf_conf.mmask.f_cache_mode = 1;
 
                pktbuf_conf.wqe_skip = OCTTX_PACKET_WQE_SKIP;
-               pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP;
+               pktbuf_conf.first_skip = OCTTX_PACKET_FIRST_SKIP(mb_pool);
                pktbuf_conf.later_skip = OCTTX_PACKET_LATER_SKIP;
                pktbuf_conf.mbuff_size = (mb_pool->elt_size -
                                        RTE_PKTMBUF_HEADROOM -
+                                       rte_pktmbuf_priv_size(mb_pool) -
                                        sizeof(struct rte_mbuf));
 
                pktbuf_conf.cache_mode = PKI_OPC_MODE_STF2_STT;