DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx
@ 2018-05-12  1:35 Yongseok Koh
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow Yongseok Koh
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Yongseok Koh @ 2018-05-12  1:35 UTC (permalink / raw)
  To: shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev, Yongseok Koh

Offset in a MPRQ buffer must be calculated before updating the stride
index.

Fixes: f0d61f8f8953 ("net/mlx5: add Multi-Packet Rx support")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index d960a73d5..387463792 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2146,6 +2146,8 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		consumed_strd = (byte_cnt & MLX5_MPRQ_STRIDE_NUM_MASK) >>
 				MLX5_MPRQ_STRIDE_NUM_SHIFT;
 		assert(consumed_strd);
+		/* Calculate offset before adding up stride index. */
+		offset = strd_idx * strd_sz + strd_shift;
 		strd_idx += consumed_strd;
 		if (byte_cnt & MLX5_MPRQ_FILLER_MASK)
 			continue;
@@ -2169,7 +2171,6 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		assert((int)len >= (rxq->crc_present << 2));
 		if (rxq->crc_present)
 			len -= ETHER_CRC_LEN;
-		offset = strd_idx * strd_sz + strd_shift;
 		addr = RTE_PTR_ADD(mlx5_mprq_buf_addr(buf), offset);
 		/* Initialize the offload flag. */
 		pkt->ol_flags = 0;
-- 
2.11.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow
  2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
@ 2018-05-12  1:35 ` Yongseok Koh
  2018-05-14 12:03   ` Ferruh Yigit
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 3/4] net/mlx5: use coherent I/O memory barrier Yongseok Koh
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Yongseok Koh @ 2018-05-12  1:35 UTC (permalink / raw)
  To: shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev, Yongseok Koh

Fixes: f0d61f8f8953 ("net/mlx5: add Multi-Packet Rx support")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 387463792..c887d550f 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2180,6 +2180,15 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 		 * - Out of buffer in the Mempool for Multi-Packet RQ.
 		 */
 		if (len <= rxq->mprq_max_memcpy_len || rxq->mprq_repl == NULL) {
+			/*
+			 * When memcpy'ing packet due to out-of-buffer, the
+			 * packet must be smaller than the target mbuf.
+			 */
+			if (unlikely(rte_pktmbuf_tailroom(pkt) < len)) {
+				rte_pktmbuf_free_seg(pkt);
+				++rxq->stats.idropped;
+				continue;
+			}
 			rte_memcpy(rte_pktmbuf_mtod(pkt, void *), addr, len);
 		} else {
 			rte_iova_t buf_iova;
@@ -2214,8 +2223,11 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 			 * Prevent potential overflow due to MTU change through
 			 * kernel interface.
 			 */
-			len = RTE_MIN(len, (uint16_t)(pkt->buf_len -
-						      pkt->data_off));
+			if (unlikely(rte_pktmbuf_tailroom(pkt) < len)) {
+				rte_pktmbuf_free_seg(pkt);
+				++rxq->stats.idropped;
+				continue;
+			}
 		}
 		rxq_cq_to_mbuf(rxq, pkt, cqe, rss_hash_res);
 		PKT_LEN(pkt) = len;
-- 
2.11.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 3/4] net/mlx5: use coherent I/O memory barrier
  2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow Yongseok Koh
@ 2018-05-12  1:35 ` Yongseok Koh
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 4/4] net/mlx5: use correct field in a union structure Yongseok Koh
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Yongseok Koh @ 2018-05-12  1:35 UTC (permalink / raw)
  To: shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev, Yongseok Koh

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index c887d550f..7605e2620 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -2243,11 +2243,11 @@ mlx5_rx_burst_mprq(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 	}
 	/* Update the consumer indexes. */
 	rxq->strd_ci = strd_idx;
-	rte_io_wmb();
+	rte_cio_wmb();
 	*rxq->cq_db = rte_cpu_to_be_32(rxq->cq_ci);
 	if (rq_ci != rxq->rq_ci) {
 		rxq->rq_ci = rq_ci;
-		rte_io_wmb();
+		rte_cio_wmb();
 		*rxq->rq_db = rte_cpu_to_be_32(rxq->rq_ci);
 	}
 #ifdef MLX5_PMD_SOFT_COUNTERS
-- 
2.11.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 4/4] net/mlx5: use correct field in a union structure
  2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow Yongseok Koh
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 3/4] net/mlx5: use coherent I/O memory barrier Yongseok Koh
@ 2018-05-12  1:35 ` Yongseok Koh
  2018-05-13  6:42 ` [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Shahaf Shuler
  2018-05-14 12:04 ` Ferruh Yigit
  4 siblings, 0 replies; 7+ messages in thread
From: Yongseok Koh @ 2018-05-12  1:35 UTC (permalink / raw)
  To: shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev, Yongseok Koh

This is not a bug but it is better to use semantically correct field.

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 587b22fc2..de3f869ed 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -160,7 +160,7 @@ rxq_alloc_elts_mprq(struct mlx5_rxq_ctrl *rxq_ctrl)
 	err = rte_errno; /* Save rte_errno before cleanup. */
 	wqe_n = i;
 	for (i = 0; (i != wqe_n); ++i) {
-		if ((*rxq->elts)[i] != NULL)
+		if ((*rxq->mprq_bufs)[i] != NULL)
 			rte_mempool_put(rxq->mprq_mp,
 					(*rxq->mprq_bufs)[i]);
 		(*rxq->mprq_bufs)[i] = NULL;
-- 
2.11.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx
  2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
                   ` (2 preceding siblings ...)
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 4/4] net/mlx5: use correct field in a union structure Yongseok Koh
@ 2018-05-13  6:42 ` Shahaf Shuler
  2018-05-14 12:04 ` Ferruh Yigit
  4 siblings, 0 replies; 7+ messages in thread
From: Shahaf Shuler @ 2018-05-13  6:42 UTC (permalink / raw)
  To: Yongseok Koh, Adrien Mazarguil, Nélio Laranjeiro; +Cc: dev

Saturday, May 12, 2018 4:36 AM, Yongseok Koh:
> Cc: dev@dpdk.org; Yongseok Koh <yskoh@mellanox.com>
> Subject: [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx
> 
> Offset in a MPRQ buffer must be calculated before updating the stride index.
> 
> Fixes: f0d61f8f8953 ("net/mlx5: add Multi-Packet Rx support")
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>

Series applied to next-net-mlx, thanks. 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow
  2018-05-12  1:35 ` [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow Yongseok Koh
@ 2018-05-14 12:03   ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2018-05-14 12:03 UTC (permalink / raw)
  To: Yongseok Koh, shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev

On 5/12/2018 2:35 AM, Yongseok Koh wrote:
> Fixes: f0d61f8f8953 ("net/mlx5: add Multi-Packet Rx support")
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>

Squashed into relevant commit in next-net, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx
  2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
                   ` (3 preceding siblings ...)
  2018-05-13  6:42 ` [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Shahaf Shuler
@ 2018-05-14 12:04 ` Ferruh Yigit
  4 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2018-05-14 12:04 UTC (permalink / raw)
  To: Yongseok Koh, shahafs, adrien.mazarguil, nelio.laranjeiro; +Cc: dev

On 5/12/2018 2:35 AM, Yongseok Koh wrote:
> Offset in a MPRQ buffer must be calculated before updating the stride
> index.
> 
> Fixes: f0d61f8f8953 ("net/mlx5: add Multi-Packet Rx support")
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>

Squashed into relevant commit in next-net, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-14 12:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-12  1:35 [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Yongseok Koh
2018-05-12  1:35 ` [dpdk-dev] [PATCH 2/4] net/mlx5: fix potential buffer overflow Yongseok Koh
2018-05-14 12:03   ` Ferruh Yigit
2018-05-12  1:35 ` [dpdk-dev] [PATCH 3/4] net/mlx5: use coherent I/O memory barrier Yongseok Koh
2018-05-12  1:35 ` [dpdk-dev] [PATCH 4/4] net/mlx5: use correct field in a union structure Yongseok Koh
2018-05-13  6:42 ` [dpdk-dev] [PATCH 1/4] net/mlx5: fix offset calculation of Multi-Packet Rx Shahaf Shuler
2018-05-14 12:04 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).