[27/28] net/mlx5: adjust the maximum LRO message size

Message ID 1563786795-14027-28-git-send-email-matan@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: support LRO |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad July 22, 2019, 9:13 a.m. UTC
  LRO message is contained in the MPRQ strides.
While the LRO message size cannot be bigger than 65280 according to the
PRM, the strides which contain it may be bigger than the maximum buffer
size allowed in dpdk mbuf - 0xFFFF.

Adjust the maximum LRO message size to avoid buffer length overflow.

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5.h     |  1 +
 drivers/net/mlx5/mlx5_rxq.c | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)
  

Comments

Slava Ovsiienko July 22, 2019, 9:23 a.m. UTC | #1
> -----Original Message-----
> From: Matan Azrad <matan@mellanox.com>
> Sent: Monday, July 22, 2019 12:13
> To: Shahaf Shuler <shahafs@mellanox.com>; Yongseok Koh
> <yskoh@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>
> Cc: dev@dpdk.org; Dekel Peled <dekelp@mellanox.com>
> Subject: [PATCH 27/28] net/mlx5: adjust the maximum LRO message size
> 
> LRO message is contained in the MPRQ strides.
> While the LRO message size cannot be bigger than 65280 according to the
> PRM, the strides which contain it may be bigger than the maximum buffer
> size allowed in dpdk mbuf - 0xFFFF.
> 
> Adjust the maximum LRO message size to avoid buffer length overflow.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>

Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
  

Patch

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1dc8b7c..24fe817 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -624,6 +624,7 @@  struct mlx5_priv {
 	struct ibv_flow_action *verbs_action;
 	/**< Verbs modify header action object. */
 	uint8_t ft_type; /**< Flow table type, Rx or Tx. */
+	uint8_t max_lro_msg_size;
 	/* Tags resources cache. */
 	uint32_t link_speed_capa; /* Link speed capabilities. */
 	struct mlx5_xstats_ctrl xstats_ctrl; /* Extended stats control. */
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 7c252e3..51b2f00 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1544,6 +1544,39 @@  struct mlx5_rxq_obj *
 }
 
 /**
+ * Adjust the maximum LRO massage size.
+ * LRO massage is contained in the MPRQ strides.
+ * While the LRO massage size cannot be bigger than 65280 according to the
+ * PRM, the strides which contain it may be bigger.
+ * Adjust the maximum LRO massage size to avoid the above option.
+ *
+ * @param dev
+ *   Pointer to Ethernet device.
+ * @param strd_n
+ *   Number of strides per WQE..
+ * @param strd_sz
+ *   The stride size.
+ */
+static void
+mlx5_max_lro_msg_size_adjust(struct rte_eth_dev *dev, uint32_t strd_n,
+			     uint32_t strd_sz)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	uint32_t max_buf_len = strd_sz * strd_n;
+
+	if (max_buf_len > (uint64_t)UINT16_MAX)
+		max_buf_len = RTE_ALIGN_FLOOR((uint32_t)UINT16_MAX, strd_sz);
+	max_buf_len /= 256;
+	max_buf_len = RTE_MIN(max_buf_len, (uint32_t)UINT8_MAX);
+	assert(max_buf_len);
+	if (priv->max_lro_msg_size)
+		priv->max_lro_msg_size =
+			RTE_MIN((uint32_t)priv->max_lro_msg_size, max_buf_len);
+	else
+		priv->max_lro_msg_size = max_buf_len;
+}
+
+/**
  * Create a DPDK Rx queue.
  *
  * @param dev
@@ -1626,6 +1659,8 @@  struct mlx5_rxq_ctrl *
 		tmpl->rxq.strd_headroom_en = strd_headroom_en;
 		tmpl->rxq.mprq_max_memcpy_len = RTE_MIN(mb_len -
 			    RTE_PKTMBUF_HEADROOM, config->mprq.max_memcpy_len);
+		mlx5_max_lro_msg_size_adjust(dev, (1 << tmpl->rxq.strd_num_n),
+					     (1 << tmpl->rxq.strd_sz_n));
 		DRV_LOG(DEBUG,
 			"port %u Rx queue %u: Multi-Packet RQ is enabled"
 			" strd_num_n = %u, strd_sz_n = %u",
@@ -2168,7 +2203,7 @@  struct mlx5_hrxq *
 		if (lro) {
 			tir_attr.lro_timeout_period_usecs =
 					priv->config.lro.timeout;
-			tir_attr.lro_max_msg_sz = 0xff;
+			tir_attr.lro_max_msg_sz = priv->max_lro_msg_size;
 			tir_attr.lro_enable_mask = lro;
 		}
 		tir = mlx5_devx_cmd_create_tir(priv->sh->ctx, &tir_attr);