Skip to contentSkip to conversation

net/ixgbe: check jumbo frame enable parameter

PATCH Superseded wei zhao 3 participants 7 messages Nov 1, 2018 – Nov 6, 2018 Network drivers

lore
Share & tools
lore

wei zhao

author
#0 lore raw

PATCH 1/1 net/ixgbe: check jumbo frame enable parameter

There is necessary to do some check of max packet size boundary for code safe when enable jumbo frame.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
drivers/net/ixgbe/ixgbe_rxtx.c +31 -0
index 2f0262a..d304dee 100644
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
+int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf->max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
 		maxfrs &= 0x0000FFFF;
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v2 1/1 net/ixgbe: check jumbo frame enable parameter

There is necessary to do some check of max packet size boundary for code safe in order to avoid error in register setting when enable jumbo.

---

v2:
-add more log infomation and fix build issue

---
 drivers/net/ixgbe/ixgbe_ethdev.c |  4 +---
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c   | 31 +++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +1 -3
index 5a2c351..d65a911 100644
@@ -173,8 +173,6 @@ static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint8_t is_rx);
 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 				 size_t fw_size);
-static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 				 struct rte_eth_dev_info *dev_info);
@@ -3692,7 +3690,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 		return 0;
 }
 
-static void
+void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
index d0b9396..a474be4 100644
@@ -727,6 +727,8 @@ int ixgbe_action_rss_same(const struct rte_flow_action_rss *comp,
 			  const struct rte_flow_action_rss *with);
 int ixgbe_config_rss_filter(struct rte_eth_dev *dev,
 		struct ixgbe_rte_flow_rss_conf *conf, bool add);
+void ixgbe_dev_info_get(struct rte_eth_dev *dev,
+			       struct rte_eth_dev_info *dev_info);
 
 static inline int
 ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
drivers/net/ixgbe/ixgbe_rxtx.c +31 -0
index 2f0262a..94051ca 100644
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
+static int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf->max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
 		maxfrs &= 0x0000FFFF;
Signature · 1 line
1.8.3.1
author
#2 lore raw

Add the background for this patch.
https://mails.dpdk.org/archives/dev/2018-November/117771.html
https://mails.dpdk.org/archives/dev/2018-November/117772.html

Quoted 116 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Thursday, November 1, 2018 4:29 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: [email protected]; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

There is necessary to do some check of max packet size boundary for code safe in order to avoid error in register setting when enable jumbo.

---

v2:
-add more log infomation and fix build issue

---
 drivers/net/ixgbe/ixgbe_ethdev.c |  4 +---
drivers/net/ixgbe/ixgbe_ethdev.h |  2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c   | 31
+++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -2
index 5a2c351..d65a911 100644
@@ -173,8 +173,6 @@ static int
 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint8_t is_rx);
 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 				 size_t fw_size);
-static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct

rte_eth_dev *dev); static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info); @@ -
3692,7 +3690,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
 		return 0;
 }
 
-static void
+void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info

*dev_info) {
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); diff --
git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index d0b9396..a474be4 100644

drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -727,6 +727,8 @@ int ixgbe_action_rss_same(const struct
 rte_flow_action_rss *comp,
 			  const struct rte_flow_action_rss *with);  int
 ixgbe_config_rss_filter(struct rte_eth_dev *dev,
 		struct ixgbe_rte_flow_rss_conf *conf, bool add);
+void ixgbe_dev_info_get(struct rte_eth_dev *dev,
+			       struct rte_eth_dev_info *dev_info);
 
 static inline int

ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info, diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 2f0262a..94051ca 100644

drivers/net/ixgbe/ixgbe_rxtx.c +31 -0
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
+static int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf-
 >max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);

maxfrs &= 0x0000FFFF;
--
1.8.3.1

#5 lore raw
In reply to wei zhao
Quoted 7 lines · On Thu, 1 Nov 2018 15:55:26 +0800 wei zhao <[email protected]> wrote:
drivers/net/ixgbe/ixgbe_rxtx.c +7 -0
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4841

Quoted 10 lines
drivers/net/ixgbe/ixgbe_rxtx.c +10 -0
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+

Yes, these checks are needed and for other devices as well. Why not add them into rte_ethdev instead?

author
#6 lore raw
Quoted 25 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Friday, November 2, 2018 1:46 AM
To: Zhao1, Wei <[email protected]>
Cc: [email protected]; [email protected]; Zhang, Qi Z <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: check jumbo frame enable parameter

Quoted 12 lines · On Thu, 1 Nov 2018 15:55:26 +0800 wei zhao <[email protected]> wrote:
drivers/net/ixgbe/ixgbe_rxtx.c +12 -0
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}
+
+	/* check jumbo mode if needed */
Quoted 8 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4841

Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +5 -0
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;
+	}
+

Yes, these checks are needed and for other devices as well. Why not add them into rte_ethdev instead?

I am not familiar with NIC except ixgbe and i40e, I am not sure property of other NIC and rationality of these check....

#3 lore raw
In reply to Zhao1, Wei

Hi Wei:

Quoted 88 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Thursday, November 1, 2018 1:40 AM
To: [email protected]
Cc: [email protected]; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

Add the background for this patch.
https://mails.dpdk.org/archives/dev/2018-November/117771.html
https://mails.dpdk.org/archives/dev/2018-November/117772.html

Quoted 30 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Thursday, November 1, 2018 4:29 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: [email protected]; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

There is necessary to do some check of max packet size boundary for code safe in order to avoid error in register setting when enable jumbo.

---

v2:
-add more log infomation and fix build issue

---
 drivers/net/ixgbe/ixgbe_ethdev.c |  4 +---
drivers/net/ixgbe/ixgbe_ethdev.h |  2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c   | 31
+++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
index 5a2c351..d65a911 100644

drivers/net/ixgbe/ixgbe_ethdev.c static int · line 175

Quoted 3 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
@@ -173,8 +173,6 @@ static int
 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint8_t is_rx);
 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char

*fw_version,

Quoted 40 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0 -2
 				 size_t fw_size);
-static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct

rte_eth_dev *dev); static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info); @@ -
3692,7 +3690,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
 		return 0;
 }
 
-static void
+void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info

*dev_info) {
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); diff --
git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index d0b9396..a474be4 100644

drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -727,6 +727,8 @@ int ixgbe_action_rss_same(const struct
 rte_flow_action_rss *comp,
 			  const struct rte_flow_action_rss *with);  int
 ixgbe_config_rss_filter(struct rte_eth_dev *dev,
 		struct ixgbe_rte_flow_rss_conf *conf, bool add);
+void ixgbe_dev_info_get(struct rte_eth_dev *dev,
+			       struct rte_eth_dev_info *dev_info);
 
 static inline int

ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,

(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_rxtx.c index 2f0262a..94051ca 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
Quoted 3 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4819

Quoted 3 lines
drivers/net/ixgbe/ixgbe_rxtx.c +3 -0
+static int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)

it's better to return Boolean for this function

Quoted 10 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4829

Quoted 10 lines
drivers/net/ixgbe/ixgbe_rxtx.c +10 -0
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}

Why this is only needed for DEV_RX_OFFLOAD_JUMBO_FRAME?
And we will compare to ETHER_MAX_LEN which is a bigger value, this looks redundant.

Quoted 5 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4834

Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +5 -0
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}

dev_info.max_rx_pktlen = 15872, it should be replaced by a macro, then we don't need to call ixgbe_dev_info_get here. and why this is only needed for DEV_RX_OFFLOAD_JUMBO_FRAME?

Quoted 5 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4839

Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +5 -0
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;

And I agree with Stephen's comment,
Looks all of these is common for all drivers, it should be moved to ether layer.

Quoted 21 lines
Quoted 21 lines
drivers/net/ixgbe/ixgbe_rxtx.c +8 -0
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf-
 >max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);

maxfrs &= 0x0000FFFF;
--
1.8.3.1

author
#4 lore raw
Quoted 101 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Tuesday, November 6, 2018 12:34 AM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

Hi Wei:

Quoted 89 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Thursday, November 1, 2018 1:40 AM
To: [email protected]
Cc: [email protected]; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: RE: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

Add the background for this patch.
https://mails.dpdk.org/archives/dev/2018-November/117771.html
https://mails.dpdk.org/archives/dev/2018-November/117772.html

Quoted 30 lines

-----Original Message-----
From: Zhao1, Wei
Sent: Thursday, November 1, 2018 4:29 PM
To: Zhao1, Wei <[email protected]>; [email protected]
Cc: [email protected]; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Subject: [PATCH v2] net/ixgbe: check jumbo frame enable parameter

There is necessary to do some check of max packet size boundary for code safe in order to avoid error in register setting when enable jumbo.

---

v2:
-add more log infomation and fix build issue

---
 drivers/net/ixgbe/ixgbe_ethdev.c |  4 +---
drivers/net/ixgbe/ixgbe_ethdev.h |  2 ++
 drivers/net/ixgbe/ixgbe_rxtx.c   | 31
+++++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
index 5a2c351..d65a911 100644

drivers/net/ixgbe/ixgbe_ethdev.c static int · line 175

Quoted 3 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
@@ -173,8 +173,6 @@ static int
 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 					     uint8_t is_rx);
 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char

*fw_version,

Quoted 41 lines
drivers/net/ixgbe/ixgbe_ethdev.c +0 -2
 				 size_t fw_size);
-static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
-			       struct rte_eth_dev_info *dev_info);
 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct

rte_eth_dev *dev); static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
struct rte_eth_dev_info *dev_info); @@ -
3692,7 +3690,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused
struct rte_eth_dev *dev,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
 		return 0;
 }
 
-static void
+void
 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info

*dev_info) {
struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); diff --
git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index d0b9396..a474be4 100644

drivers/net/ixgbe/ixgbe_ethdev.h +2 -0
@@ -727,6 +727,8 @@ int ixgbe_action_rss_same(const struct
 rte_flow_action_rss *comp,
 			  const struct rte_flow_action_rss *with);  int
 ixgbe_config_rss_filter(struct rte_eth_dev *dev,
 		struct ixgbe_rte_flow_rss_conf *conf, bool add);
+void ixgbe_dev_info_get(struct rte_eth_dev *dev,
+			       struct rte_eth_dev_info *dev_info);
 
 static inline int

ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info
*filter_info, diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 2f0262a..94051ca 100644

drivers/net/ixgbe/ixgbe_rxtx.c +0 -0
@@ -4814,6 +4814,34 @@ void __attribute__((cold))
 	return 0;
 }
 
Quoted 5 lines
Quoted 3 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4819

Quoted 3 lines
drivers/net/ixgbe/ixgbe_rxtx.c +3 -0
+static int __attribute__((cold))
+ixgbe_dev_jumboenable_check(struct rte_eth_dev *dev,
+				uint16_t max_rx_pkt_len)

it's better to return Boolean for this function

Ok

Quoted 15 lines
Quoted 11 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4829

Quoted 11 lines
drivers/net/ixgbe/ixgbe_rxtx.c +10 -0
+{
+	struct rte_eth_dev_info dev_info;
+
+	ixgbe_dev_info_get(dev, &dev_info);
+
+	/* check that max packet size is within the allowed range */
+	if (max_rx_pkt_len < ETHER_MIN_MTU) {
+		PMD_INIT_LOG(ERR, "max packet size is too small.");
+		return -EINVAL;
+	}

Why this is only needed for DEV_RX_OFFLOAD_JUMBO_FRAME?
And we will compare to ETHER_MAX_LEN which is a bigger value, this looks redundant.

Ok, I will check that

Quoted 10 lines
Quoted 6 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4834

Quoted 6 lines
drivers/net/ixgbe/ixgbe_rxtx.c +5 -0
+
+	if (max_rx_pkt_len > dev_info.max_rx_pktlen) {
+		PMD_INIT_LOG(ERR, "max packet size is too big.");
+		return -EINVAL;
+	}

dev_info.max_rx_pktlen = 15872, it should be replaced by a macro, then we don't need to call ixgbe_dev_info_get here.
and why this is only needed for DEV_RX_OFFLOAD_JUMBO_FRAME?

Quoted 8 lines
Quoted 5 lines

drivers/net/ixgbe/ixgbe_rxtx.c void __attribute__((cold)) · line 4839

Quoted 5 lines
drivers/net/ixgbe/ixgbe_rxtx.c +5 -0
+
+	/* check jumbo mode if needed */
+	if (max_rx_pkt_len < ETHER_MAX_LEN) {
+		PMD_INIT_LOG(ERR, "No need to enable jumbo.");
+		return -EINVAL;

And I agree with Stephen's comment,
Looks all of these is common for all drivers, it should be moved to ether layer.

Ok, I will move to rte layer

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/net/ixgbe/ixgbe_rxtx.c +8 -0
+	}
+
+	return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -4865,6 +4893,9 @@ int __attribute__((cold))
 	 * Configure jumbo frame support, if any.
 	 */
 	if (rx_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
+		if (ixgbe_dev_jumboenable_check(dev, rx_conf-
 >max_rx_pkt_len))
+			return -EINVAL;
+
 		hlreg0 |= IXGBE_HLREG0_JUMBOEN;
 		maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);

maxfrs &= 0x0000FFFF;
--
1.8.3.1