DPDK patches and discussions
 help / color / mirror / Atom feed
From: beilei.xing@intel.com
To: qi.z.zhang@intel.com
Cc: dev@dpdk.org, Jingjing Wu <jingjing.wu@intel.com>,
	Beilei Xing <beilei.xing@intel.com>
Subject: [PATCH v2 5/5] net/idpf: refine MTU setting
Date: Fri,  6 Jan 2023 09:05:01 +0000	[thread overview]
Message-ID: <20230106090501.9106-6-beilei.xing@intel.com> (raw)
In-Reply-To: <20230106090501.9106-1-beilei.xing@intel.com>

From: Jingjing Wu <jingjing.wu@intel.com>

This patch refines MTU configuration.

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/idpf/idpf_ethdev.c | 37 +++++++++++++++++++---------------
 drivers/net/idpf/idpf_ethdev.h |  1 +
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 89af27ca34..3f1b77144c 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -56,9 +56,9 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->max_rx_queues = adapter->caps->max_rx_q;
 	dev_info->max_tx_queues = adapter->caps->max_tx_q;
 	dev_info->min_rx_bufsize = IDPF_MIN_BUF_SIZE;
-	dev_info->max_rx_pktlen = IDPF_MAX_FRAME_SIZE;
+	dev_info->max_rx_pktlen = vport->max_mtu + IDPF_ETH_OVERHEAD;
 
-	dev_info->max_mtu = dev_info->max_rx_pktlen - IDPF_ETH_OVERHEAD;
+	dev_info->max_mtu = vport->max_mtu;
 	dev_info->min_mtu = RTE_ETHER_MIN_MTU;
 
 	dev_info->flow_type_rss_offloads = IDPF_RSS_OFFLOAD_ALL;
@@ -104,14 +104,23 @@ idpf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 }
 
 static int
-idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu __rte_unused)
+idpf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
+	struct idpf_vport *vport = dev->data->dev_private;
+
 	/* mtu setting is forbidden if port is start */
 	if (dev->data->dev_started) {
 		PMD_DRV_LOG(ERR, "port must be stopped before configuration");
 		return -EBUSY;
 	}
 
+	if (mtu > vport->max_mtu) {
+		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
+		return -EINVAL;
+	}
+
+	vport->max_pkt_len = mtu + IDPF_ETH_OVERHEAD;
+
 	return 0;
 }
 
@@ -381,6 +390,10 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	vport->max_pkt_len =
+		(dev->data->mtu == 0) ? IDPF_DEFAULT_MTU : dev->data->mtu +
+		IDPF_ETH_OVERHEAD;
+
 	return 0;
 }
 
@@ -513,39 +526,31 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 	vport->stopped = 0;
 
-	if (dev->data->mtu > vport->max_mtu) {
-		PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
-		ret = -EINVAL;
-		goto err_mtu;
-	}
-
-	vport->max_pkt_len = dev->data->mtu + IDPF_ETH_OVERHEAD;
-
 	req_vecs_num = IDPF_DFLT_Q_VEC_NUM;
 	if (req_vecs_num + adapter->used_vecs_num > num_allocated_vectors) {
 		PMD_DRV_LOG(ERR, "The accumulated request vectors' number should be less than %d",
 			    num_allocated_vectors);
 		ret = -EINVAL;
-		goto err_mtu;
+		goto err_vec;
 	}
 
 	ret = idpf_vc_alloc_vectors(vport, req_vecs_num);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
-		goto err_mtu;
+		goto err_vec;
 	}
 	adapter->used_vecs_num += req_vecs_num;
 
 	ret = idpf_config_rx_queues_irqs(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to configure irqs");
-		goto err_mtu;
+		goto err_vec;
 	}
 
 	ret = idpf_start_queues(dev);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Failed to start queues");
-		goto err_mtu;
+		goto err_vec;
 	}
 
 	idpf_set_rx_function(dev);
@@ -561,7 +566,7 @@ idpf_dev_start(struct rte_eth_dev *dev)
 
 err_vport:
 	idpf_stop_queues(dev);
-err_mtu:
+err_vec:
 	return ret;
 }
 
diff --git a/drivers/net/idpf/idpf_ethdev.h b/drivers/net/idpf/idpf_ethdev.h
index bf37d5184c..b0746e5041 100644
--- a/drivers/net/idpf/idpf_ethdev.h
+++ b/drivers/net/idpf/idpf_ethdev.h
@@ -39,6 +39,7 @@
 #define IDPF_MIN_BUF_SIZE	1024
 #define IDPF_MAX_FRAME_SIZE	9728
 #define IDPF_MIN_FRAME_SIZE	14
+#define IDPF_DEFAULT_MTU	RTE_ETHER_MTU
 
 #define IDPF_NUM_MACADDR_MAX	64
 
-- 
2.26.2


  parent reply	other threads:[~2023-01-06  9:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08  7:27 [PATCH 0/3] net/idpf: code refine beilei.xing
2022-12-08  7:27 ` [PATCH 1/3] net/idpf: remove vport req and recv info from adapter beilei.xing
2022-12-08  7:27 ` [PATCH 2/3] net/idpf: remove req vports " beilei.xing
2022-12-08  7:27 ` [PATCH 3/3] net/idpf: fix splitq xmit free beilei.xing
2023-01-06  9:04 ` [PATCH v2 0/5] net/idpf: code refine beilei.xing
2023-01-06  9:04   ` [PATCH v2 1/5] net/idpf: remove vport req and recv info from adapter beilei.xing
2023-01-06  9:04   ` [PATCH v2 2/5] net/idpf: remove req vports " beilei.xing
2023-01-06  9:04   ` [PATCH v2 3/5] net/idpf: fix splitq xmit free beilei.xing
2023-01-06  9:05   ` [PATCH v2 4/5] net/idpf: fix driver init symbols beilei.xing
2023-01-06  9:05   ` beilei.xing [this message]
2023-01-16  7:59   ` [PATCH v2 0/5] net/idpf: code refine Zhang, Qi Z

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=20230106090501.9106-6-beilei.xing@intel.com \
    --to=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.com \
    /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).