patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Rasesh Mody <rasesh.mody@cavium.com>
Cc: dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/qede: fix MTU set and max Rx length' has been queued to LTS release 17.11.1
Date: Thu,  1 Feb 2018 17:47:48 +0800	[thread overview]
Message-ID: <1517478479-12417-34-git-send-email-yliu@fridaylinux.org> (raw)
In-Reply-To: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org>

Hi,

FYI, your patch has been queued to LTS release 17.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/03/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 40a6c11a287ef759464fdbe8061c7b7a3bb76498 Mon Sep 17 00:00:00 2001
From: Rasesh Mody <rasesh.mody@cavium.com>
Date: Sat, 27 Jan 2018 13:15:30 -0800
Subject: [PATCH] net/qede: fix MTU set and max Rx length

[ upstream commit 9e334305178fd3715c17088632544bf58e5836a9 ]

This patch fixes issues related to MTU set and max_rx_pkt_len usage.
 - Adjust MTU during device configuration when jumbo is enabled

 - In qede_set_mtu():
   Return not supported for VF as currently we do not support it.

   Cache new mtu value in mtu_new for proper update.

   Add check for RXQ allocation before calculating RX buffer size
   if not allocated defer RX buffer size calculation till RXQ setup.

   Add check for before performing device start/stop.

 - Use max_rx_pkt_len appropriately

 - Change QEDE_ETH_OVERHEAD macro to adjust driver specifics

Fixes: 4c4bdadfa9e7 ("net/qede: refactoring multi-queue implementation")
Fixes: 9a6d30ae6d46 ("net/qede: refactoring vport handling code")
Fixes: 1ef4c3a5c1f7 ("net/qede: prevent crash while changing MTU dynamically")

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
---
 drivers/net/qede/qede_ethdev.c | 63 ++++++++++++++++++++++++++++--------------
 drivers/net/qede/qede_rxtx.c   |  6 ++--
 drivers/net/qede/qede_rxtx.h   |  2 +-
 3 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index b0c0997..de6e9e1 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -1347,18 +1347,24 @@ static int qede_dev_configure(struct rte_eth_dev *eth_dev)
 			return -ENOMEM;
 	}
 
+	/* If jumbo enabled adjust MTU */
+	if (eth_dev->data->dev_conf.rxmode.jumbo_frame)
+		eth_dev->data->mtu =
+				eth_dev->data->dev_conf.rxmode.max_rx_pkt_len -
+				ETHER_HDR_LEN - ETHER_CRC_LEN;
+
 	/* VF's MTU has to be set using vport-start where as
 	 * PF's MTU can be updated via vport-update.
 	 */
 	if (IS_VF(edev)) {
-		if (qede_start_vport(qdev, rxmode->max_rx_pkt_len))
+		if (qede_start_vport(qdev, eth_dev->data->mtu))
 			return -1;
 	} else {
-		if (qede_update_mtu(eth_dev, rxmode->max_rx_pkt_len))
+		if (qede_update_mtu(eth_dev, eth_dev->data->mtu))
 			return -1;
 	}
 
-	qdev->mtu = rxmode->max_rx_pkt_len;
+	qdev->mtu = eth_dev->data->mtu;
 	qdev->new_mtu = qdev->mtu;
 
 	/* Enable VLAN offloads by default */
@@ -2237,16 +2243,23 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
 	struct rte_eth_dev_info dev_info = {0};
 	struct qede_fastpath *fp;
+	uint32_t max_rx_pkt_len;
 	uint32_t frame_size;
 	uint16_t rx_buf_size;
 	uint16_t bufsz;
+	bool restart = false;
 	int i;
 
 	PMD_INIT_FUNC_TRACE(edev);
+	if (IS_VF(edev))
+		return -ENOTSUP;
 	qede_dev_info_get(dev, &dev_info);
-	frame_size = mtu + QEDE_ETH_OVERHEAD;
+	max_rx_pkt_len = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+	frame_size = max_rx_pkt_len + QEDE_ETH_OVERHEAD;
 	if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen)) {
-		DP_ERR(edev, "MTU %u out of range\n", mtu);
+		DP_ERR(edev, "MTU %u out of range, %u is maximum allowable\n",
+		       mtu, dev_info.max_rx_pktlen - ETHER_HDR_LEN -
+			ETHER_CRC_LEN - QEDE_ETH_OVERHEAD);
 		return -EINVAL;
 	}
 	if (!dev->data->scattered_rx &&
@@ -2260,29 +2273,39 @@ static int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 */
 	dev->rx_pkt_burst = qede_rxtx_pkts_dummy;
 	dev->tx_pkt_burst = qede_rxtx_pkts_dummy;
-	qede_dev_stop(dev);
+	if (dev->data->dev_started) {
+		dev->data->dev_started = 0;
+		qede_dev_stop(dev);
+		restart = true;
+	}
 	rte_delay_ms(1000);
-	qdev->mtu = mtu;
+	qdev->new_mtu = mtu;
 	/* Fix up RX buf size for all queues of the port */
 	for_each_rss(i) {
 		fp = &qdev->fp_array[i];
-		bufsz = (uint16_t)rte_pktmbuf_data_room_size(
-			fp->rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
-		if (dev->data->scattered_rx)
-			rx_buf_size = bufsz + QEDE_ETH_OVERHEAD;
-		else
-			rx_buf_size = mtu + QEDE_ETH_OVERHEAD;
-		rx_buf_size = QEDE_CEIL_TO_CACHE_LINE_SIZE(rx_buf_size);
-		fp->rxq->rx_buf_size = rx_buf_size;
-		DP_INFO(edev, "buf_size adjusted to %u\n", rx_buf_size);
-	}
-	qede_dev_start(dev);
-	if (frame_size > ETHER_MAX_LEN)
+		if (fp->rxq != NULL) {
+			bufsz = (uint16_t)rte_pktmbuf_data_room_size(
+				fp->rxq->mb_pool) - RTE_PKTMBUF_HEADROOM;
+			if (dev->data->scattered_rx)
+				rx_buf_size = bufsz + ETHER_HDR_LEN +
+					      ETHER_CRC_LEN + QEDE_ETH_OVERHEAD;
+			else
+				rx_buf_size = frame_size;
+			rx_buf_size = QEDE_CEIL_TO_CACHE_LINE_SIZE(rx_buf_size);
+			fp->rxq->rx_buf_size = rx_buf_size;
+			DP_INFO(edev, "buf_size adjusted to %u\n", rx_buf_size);
+		}
+	}
+	if (max_rx_pkt_len > ETHER_MAX_LEN)
 		dev->data->dev_conf.rxmode.jumbo_frame = 1;
 	else
 		dev->data->dev_conf.rxmode.jumbo_frame = 0;
+	if (!dev->data->dev_started && restart) {
+		qede_dev_start(dev);
+		dev->data->dev_started = 1;
+	}
 	/* update max frame size */
-	dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+	dev->data->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len;
 	/* Reassign back */
 	dev->rx_pkt_burst = qede_recv_pkts;
 	dev->tx_pkt_burst = qede_xmit_pkts;
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index a89d6c6..7efc19a 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -84,7 +84,6 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	rxq->port_id = dev->data->port_id;
 
 	max_rx_pkt_len = (uint16_t)rxmode->max_rx_pkt_len;
-	qdev->mtu = max_rx_pkt_len;
 
 	/* Fix up RX buffer size */
 	bufsz = (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
@@ -97,9 +96,10 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 	}
 
 	if (dev->data->scattered_rx)
-		rxq->rx_buf_size = bufsz + QEDE_ETH_OVERHEAD;
+		rxq->rx_buf_size = bufsz + ETHER_HDR_LEN +
+				   ETHER_CRC_LEN + QEDE_ETH_OVERHEAD;
 	else
-		rxq->rx_buf_size = qdev->mtu + QEDE_ETH_OVERHEAD;
+		rxq->rx_buf_size = max_rx_pkt_len + QEDE_ETH_OVERHEAD;
 	/* Align to cache-line size if needed */
 	rxq->rx_buf_size = QEDE_CEIL_TO_CACHE_LINE_SIZE(rxq->rx_buf_size);
 
diff --git a/drivers/net/qede/qede_rxtx.h b/drivers/net/qede/qede_rxtx.h
index acf9e47..ae88206 100644
--- a/drivers/net/qede/qede_rxtx.h
+++ b/drivers/net/qede/qede_rxtx.h
@@ -64,7 +64,7 @@
 #define QEDE_CEIL_TO_CACHE_LINE_SIZE(n) (((n) + (QEDE_FW_RX_ALIGN_END - 1)) & \
 					~(QEDE_FW_RX_ALIGN_END - 1))
 /* Note: QEDE_LLC_SNAP_HDR_LEN is optional */
-#define QEDE_ETH_OVERHEAD	((ETHER_HDR_LEN) + ((2 * QEDE_VLAN_TAG_SIZE)) \
+#define QEDE_ETH_OVERHEAD	(((2 * QEDE_VLAN_TAG_SIZE)) - (ETHER_CRC_LEN) \
 				+ (QEDE_LLC_SNAP_HDR_LEN))
 
 #define QEDE_RSS_OFFLOAD_ALL    (ETH_RSS_IPV4			|\
-- 
2.7.4

  parent reply	other threads:[~2018-02-01  9:49 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01  9:47 [dpdk-stable] patch 'event/sw: fix debug logging config option' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'service: fix possible mem leak on initialize' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cmdline: fix dynamic tokens parsing' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cmdline: avoid garbage in unused fields of parsed result' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'keepalive: fix state alignment' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'log: fix memory leak in regexp level set' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'eal/arm64: remove the braces in memory barrier macros' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'mbuf: fix NULL freeing when debug enabled' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix out-of-bounds access' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix parameter type' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'cryptodev: fix session pointer cast' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix null auth algo overwrite' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix return value of start operation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/enic: fix crash due to static max number of queues' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/e1000: fix null pointer check' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/i40e: fix memory leak' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix missing RSS capability' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix flow item validation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region cache lookup' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region cache last index' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/mlx5: fix memory region boundary checks' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ena: do not set Tx L4 offloads in Rx path' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio-user: fix crash as features change' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix Rx and Tx handler selection for ARM32' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix queue flushing with vector Rx enabled' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/virtio: fix memory leak when reinitializing device' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/i40e: fix VF Rx interrupt enabling' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ixgbe: " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/e1000: " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/bnxt: fix size of Tx ring in HW' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/bnxt: fix number of pools for RSS' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/qede: check tunnel L3 header' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/qede: fix tunnel header size in Tx BD configuration' " Yuanhan Liu
2018-02-01  9:47 ` Yuanhan Liu [this message]
2018-02-01  9:47 ` [dpdk-stable] patch 'eal/ppc: remove the braces in memory barrier macros' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/dpaa2_sec: fix enum conversion for GCM' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'mk: support renamed Makefile in external project' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/scheduler: fix strncpy' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'ethdev: fix port data reset timing' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'ethdev: fix port id allocation' " Yuanhan Liu
2018-02-11  2:46   ` Yuanhan Liu
2018-02-11  6:40     ` Matan Azrad
2018-02-11  6:54       ` Yuanhan Liu
2018-02-11  7:15         ` Matan Azrad
2018-02-01  9:47 ` [dpdk-stable] patch 'app/testpmd: fix port validation' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'net/ixgbe: fix reset error handling' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'examples/bond: fix vdev name' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'crypto/qat: fix allocation check and leak' " Yuanhan Liu
2018-02-01  9:47 ` [dpdk-stable] patch 'examples/bond: check mbuf allocation' " Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517478479-12417-34-git-send-email-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=rasesh.mody@cavium.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).