Skip to contentSkip to conversation

net/ixgbe: fix configuration of max frame size

PATCH Superseded Zhang,Alvin 4 participants 14 messages Jan 14, 2021 – Jan 19, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1. This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")
---
 drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +14 -11
index 833863a..b4282fd 100644
@@ -555,27 +555,30 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
-	uint32_t max_frs;
+	uint32_t max_frame = msgbuf[1];
+	uint32_t cur_frame_size;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > RTE_ETHER_MAX_LEN)
+			return -1;
+
+		return 0;
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
 		return -1;
 
-	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
-		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	cur_frame_size = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
+			 IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
+	if (cur_frame_size < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,8 +589,8 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
-		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
+		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS,
+				max_frame << IXGBE_MHADD_MFS_SHIFT);
 	}
 
 	return 0;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1. This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")
---
 drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +14 -11
index 833863a..4cedaa5 100644
@@ -555,27 +555,30 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
-	uint32_t max_frs;
+	uint32_t max_frame = msgbuf[1];
+	uint32_t cur_frame_size;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > dev->data->dev_conf.rxmode.max_rx_pkt_len)
+			return -1;
+
+		return 0;
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
 		return -1;
 
-	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
-		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	cur_frame_size = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
+			 IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
+	if (cur_frame_size < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,8 +589,8 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
-		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
+		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS,
+				max_frame << IXGBE_MHADD_MFS_SHIFT);
 	}
 
 	return 0;
Signature · 1 line
1.8.3.1
Tested-by on v2 1/1
#2 lore raw

Regards,
Xie Wei

Quoted 93 lines

-----Original Message-----
From: Zhang,Alvin [mailto:[email protected]]
Sent: Friday, January 15, 2021 10:31 AM
To: Guo, Jia <[email protected]>; Wang, Haiyue <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v2] net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1.
This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")
---
 drivers/net/ixgbe/ixgbe_pf.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +10 -8
index 833863a..4cedaa5 100644
@@ -555,27 +555,30 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused
 uint32_t vf, uint32_t *msgbuf)  {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
-	uint32_t new_mtu = msgbuf[1];
-	uint32_t max_frs;
+	uint32_t max_frame = msgbuf[1];
+	uint32_t cur_frame_size;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN +
 RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > dev->data-
 >dev_conf.rxmode.max_rx_pkt_len)
+			return -1;
+
+		return 0;
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame >
 RTE_ETHER_MAX_JUMBO_FRAME_LEN)
 		return -1;
 
-	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
-		   IXGBE_MHADD_MFS_MASK) >>
 IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	cur_frame_size = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
+			 IXGBE_MHADD_MFS_MASK) >>

IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +4 -3
+	if (cur_frame_size < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,8 +589,8 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
-		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
+		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS,
+				max_frame << IXGBE_MHADD_MFS_SHIFT);
 	}
 

return 0;
--
1.8.3.1

#3 lore raw

PATCH v3 1/1 net/ixgbe: fix configuration of max frame size

In reply to Zhang,Alvin

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1. This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.

---
 drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +10 -7
index 833863a..1ffde56 100644
@@ -555,17 +555,20 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > dev->data->dev_conf.rxmode.max_rx_pkt_len)
+			return -1;
+
+		return 0;
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
@@ -573,9 +576,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +589,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
Signature · 1 line
1.8.3.1
Tested-by on v3 1/1
#4 lore raw

Regards,
Xie Wei

Quoted 90 lines

-----Original Message-----
From: Zhang,Alvin [mailto:[email protected]]
Sent: Friday, January 15, 2021 3:00 PM
To: Guo, Jia <[email protected]>; Wang, Haiyue <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1.
This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.

---
 drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +7 -4
index 833863a..1ffde56 100644
@@ -555,17 +555,20 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused
 uint32_t vf, uint32_t *msgbuf)  {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN +
 RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > dev->data-
 >dev_conf.rxmode.max_rx_pkt_len)
+			return -1;
+
+		return 0;
+	}
drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame >

RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +576,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)

drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >>

IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +3 -4
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +589,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
--

1.8.3.1

#5 lore raw
In reply to Zhang,Alvin

Hi, Alvin

Quoted 9 lines

-----Original Message-----
From: Zhang,Alvin <[email protected]>
Sent: Friday, January 15, 2021 3:00 PM
To: Guo, Jia <[email protected]>; Wang, Haiyue <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size

Quoted 8 lines

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1.
This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

Why it should not return -1 and what is the kernel driver behaviors related with this patch?

Quoted 30 lines

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.

---
 drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +1 -2
index 833863a..1ffde56 100644
@@ -555,17 +555,20 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused
 uint32_t vf, uint32_t *msgbuf)  {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN +
 RTE_ETHER_CRC_LEN;

drivers/net/ixgbe/ixgbe_pf.c int ixgbe_pf_host_configure(struct rte_eth_dev · line 570

Quoted 10 lines
drivers/net/ixgbe/ixgbe_pf.c +2 -2
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		if (max_frame > dev->data-
 >dev_conf.rxmode.max_rx_pkt_len)

This condition is only for X540/X550?

drivers/net/ixgbe/ixgbe_pf.c int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) · line 571

Quoted 5 lines
drivers/net/ixgbe/ixgbe_pf.c +4 -0
+			return -1;
+
+		return 0;
+	}

Assume that return 0 means success to set vf lpe, return -1 means failed to set vf lpe. If it is not support in VF, why return 0?

Quoted 28 lines
drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame >

RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +576,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)

drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >>

IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +3 -4
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +589,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
--

1.8.3.1

#6 lore raw

Hi Guojia,
Thanks for you reply.

I will modify as we discussion.

Quoted 110 lines

-----Original Message-----
From: Guo, Jia <[email protected]>
Sent: Friday, January 15, 2021 4:15 PM
To: Zhang, AlvinX <[email protected]>; Wang, Haiyue <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: RE: [PATCH v3] net/ixgbe: fix configuration of max frame size

Hi, Alvin

Quoted 9 lines

-----Original Message-----
From: Zhang,Alvin <[email protected]>
Sent: Friday, January 15, 2021 3:00 PM
To: Guo, Jia <[email protected]>; Wang, Haiyue <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size

Quoted 8 lines

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, but if a VF requests to configure the frame size to that not bigger than RTE_ETHER_MAX_LEN, the PMD should not return -1.
This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

Why it should not return -1 and what is the kernel driver behaviors related with this patch?

Quoted 31 lines

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.

---
 drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ixgbe/ixgbe_pf.c index 833863a..1ffde56 100644

drivers/net/ixgbe/ixgbe_pf.c +0 -0
@@ -555,17 +555,20 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused

uint32_t vf, uint32_t *msgbuf) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-

Quoted 1 line

dev_private);

drivers/net/ixgbe/ixgbe_pf.c +1 -2
-uint32_t new_mtu = msgbuf[1];
+uint32_t max_frame = msgbuf[1];
 uint32_t max_frs;
 uint32_t hlreg0;
-int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 /* X540 and X550 support jumbo frames in IOV mode */  if
Quoted 1 line

(hw->mac.type != ixgbe_mac_X540 && hw->mac.type != ixgbe_mac_X550

&&

Quoted 6 lines

hw->mac.type != ixgbe_mac_X550EM_x &&

drivers/net/ixgbe/ixgbe_pf.c +2 -2
-hw->mac.type != ixgbe_mac_X550EM_a)
-return -1;
+hw->mac.type != ixgbe_mac_X550EM_a) {
+if (max_frame > dev->data-
Quoted 1 line

dev_conf.rxmode.max_rx_pkt_len)

This condition is only for X540/X550?

drivers/net/ixgbe/ixgbe_pf.c int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) · line 571

Quoted 5 lines
drivers/net/ixgbe/ixgbe_pf.c +4 -0
+return -1;
+
+return 0;
+}

Assume that return 0 means success to set vf lpe, return -1 means failed to set vf lpe. If it is not support in VF, why return 0?

Quoted 11 lines

if (max_frame < RTE_ETHER_MIN_LEN || max_frame >
RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +576,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)

max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
IXGBE_MHADD_MFS_MASK) >>
IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +1 -1
-if (max_frs < new_mtu) {
+if (max_frs < max_frame) {
 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); -if (new_mtu >
Quoted 3 lines

RTE_ETHER_MAX_LEN) {
+if (max_frame > RTE_ETHER_MAX_LEN) {
dev->data->dev_conf.rxmode.offloads |=

DEV_RX_OFFLOAD_JUMBO_FRAME;

Quoted 12 lines

hlreg0 |= IXGBE_HLREG0_JUMBOEN;

drivers/net/ixgbe/ixgbe_pf.c +1 -2
@@ -586,7 +589,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 }
 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);  }
 
--

1.8.3.1

#7 lore raw

PATCH v4 1/1 net/ixgbe: fix configuration of max frame size

In reply to Zhang,Alvin

From: Alvin Zhang <[email protected]>

For 82599 NIC, jumbo frame feature is not supported in IOV mode, if a VF requests to configure the max frame size to that not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.

---
 drivers/net/ixgbe/ixgbe_pf.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +16 -7
index 833863a..911a145 100644
@@ -555,17 +555,26 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		/**
+		 * For Other NICs, set max packet length is not enabled,
+		 * but if the value is not bigger than that has been set
+		 * by PF, here return -1 will cause the VF to fail to
+		 * start.
+		 */
+		if (max_frame > dev->data->dev_conf.rxmode.max_rx_pkt_len)
+			return -1;
+
+		return 0;
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
@@ -573,9 +582,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +595,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH v5 1/1 net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.
V5: Add check for VF api version.

---
 drivers/net/ixgbe/ixgbe_pf.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +35 -8
index 833863a..793f970 100644
@@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 }
 
 static int
-ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
+ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		struct ixgbe_vf_info *vfinfo =
+			*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+		switch (vfinfo[vf].api_version) {
+		case ixgbe_mbox_api_11:
+		case ixgbe_mbox_api_12:
+		case ixgbe_mbox_api_13:
+			 /**
+			  * Version 1.1 supports jumbo frames on VFs if PF has
+			  * jumbo frames enabled which means legacy VFs are
+			  * disabled
+			  */
+			if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				break;
+			/* fall through */
+		default:
+			/**
+			 * If the PF or VF are running jumbo frames enabled,
+			 * return -1 since cannot support jumbo frames on
+			 * legacy VFs.
+			 */
+			if (max_frame > RTE_ETHER_MAX_LEN ||
+			    dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				return -1;
+			break;
+		}
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
@@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
Signature · 1 line
1.8.3.1
Tested-by on v5 1/1
#9 lore raw

Regards,
Xie Wei

Quoted 128 lines

-----Original Message-----
From: Zhang,Alvin [mailto:[email protected]]
Sent: Monday, January 18, 2021 1:04 PM
To: Guo, Jia <[email protected]>; Xie, WeiX <[email protected]>; Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v5] net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.
V5: Add check for VF api version.

---
 drivers/net/ixgbe/ixgbe_pf.c | 43
+++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +6 -5
index 833863a..793f970 100644
@@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  }
 
 static int
-ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf,
 uint32_t *msgbuf)
+ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t
+*msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN +
 RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		struct ixgbe_vf_info *vfinfo =
+			*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data-
Quoted 1 line

dev_private);

drivers/net/ixgbe/ixgbe_pf.c +7 -0
+
+		switch (vfinfo[vf].api_version) {
+		case ixgbe_mbox_api_11:
+		case ixgbe_mbox_api_12:
+		case ixgbe_mbox_api_13:
+			 /**
+			  * Version 1.1 supports jumbo frames on VFs if PF

has

drivers/net/ixgbe/ixgbe_pf.c +1 -0
+			  * jumbo frames enabled which means legacy VFs

are

drivers/net/ixgbe/ixgbe_pf.c +19 -0
+			  * disabled
+			  */
+			if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				break;
+			/* fall through */
+		default:
+			/**
+			 * If the PF or VF are running jumbo frames enabled,
+			 * return -1 since cannot support jumbo frames on
+			 * legacy VFs.
+			 */
+			if (max_frame > RTE_ETHER_MAX_LEN ||
+			    dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				return -1;
+			break;
+		}
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame >

RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)

drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >>

IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +3 -4
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
--

1.8.3.1

#10 lore raw

PATCH v6 1/1 net/ixgbe: fix configuration of max frame size

In reply to Zhang,Alvin

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.
V5: Add check for VF api version.
V6: Update notes.

---
 drivers/net/ixgbe/ixgbe_pf.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +35 -8
index 833863a..2762995 100644
@@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 }
 
 static int
-ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
+ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		struct ixgbe_vf_info *vfinfo =
+			*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+		switch (vfinfo[vf].api_version) {
+		case ixgbe_mbox_api_11:
+		case ixgbe_mbox_api_12:
+		case ixgbe_mbox_api_13:
+			 /**
+			  * Version 1.1&1.2&1.3 supports jumbo frames on VFs
+			  * if PF has jumbo frames enabled which means legacy
+			  * VFs are disabled.
+			  */
+			if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				break;
+			/* fall through */
+		default:
+			/**
+			 * If the PF or VF are running w/ jumbo frames enabled,
+			 * we return -1 as we cannot support jumbo frames on
+			 * legacy VFs.
+			 */
+			if (max_frame > RTE_ETHER_MAX_LEN ||
+			    dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				return -1;
+			break;
+		}
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
@@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
Signature · 1 line
1.8.3.1
Acked-by on v6 1/1
#11 lore raw
Quoted 131 lines

-----Original Message-----
From: Zhang,Alvin <[email protected]>
Sent: Monday, January 18, 2021 4:35 PM
To: Guo, Jia <[email protected]>; Xie, WeiX <[email protected]>; Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v6] net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than RTE_ETHER_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.
V5: Add check for VF api version.
V6: Update notes.

---
 drivers/net/ixgbe/ixgbe_pf.c | 43
+++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +6 -5
index 833863a..2762995 100644
@@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)  }
 
 static int
-ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf,
 uint32_t *msgbuf)
+ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t
+*msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data-
 >dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN +
 RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		struct ixgbe_vf_info *vfinfo =
+			*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data-
Quoted 1 line

dev_private);

drivers/net/ixgbe/ixgbe_pf.c +7 -0
+
+		switch (vfinfo[vf].api_version) {
+		case ixgbe_mbox_api_11:
+		case ixgbe_mbox_api_12:
+		case ixgbe_mbox_api_13:
+			 /**
+			  * Version 1.1&1.2&1.3 supports jumbo frames on

VFs

drivers/net/ixgbe/ixgbe_pf.c +1 -0
+			  * if PF has jumbo frames enabled which means

legacy

drivers/net/ixgbe/ixgbe_pf.c +9 -0
+			  * VFs are disabled.
+			  */
+			if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				break;
+			/* fall through */
+		default:
+			/**
+			 * If the PF or VF are running w/ jumbo frames

enabled,

drivers/net/ixgbe/ixgbe_pf.c +1 -0
+			 * we return -1 as we cannot support jumbo frames

on

drivers/net/ixgbe/ixgbe_pf.c +9 -0
+			 * legacy VFs.
+			 */
+			if (max_frame > RTE_ETHER_MAX_LEN ||
+			    dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    RTE_ETHER_MAX_LEN)
+				return -1;
+			break;
+		}
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame >

RTE_ETHER_MAX_JUMBO_FRAME_LEN) @@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)

drivers/net/ixgbe/ixgbe_pf.c +0 -0
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >>

IXGBE_MHADD_MFS_SHIFT;

drivers/net/ixgbe/ixgbe_pf.c +3 -4
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > RTE_ETHER_MAX_LEN) {
+		if (max_frame > RTE_ETHER_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
--

1.8.3.1

#12 lore raw

PATCH v7 1/1 net/ixgbe: fix configuration of max frame size

In reply to Zhang,Alvin

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than IXGBE_ETH_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

---

V3: Restore variable name from cur_frame_size to max_frs.
V4: Update git log and add notes.
V5: Add check for VF api version.
V6: Update notes.
V7: Fixed apply conflict issue.

---
 drivers/net/ixgbe/ixgbe_pf.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +35 -8
index 89698e8..15982af 100644
@@ -552,20 +552,47 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 }
 
 static int
-ixgbe_set_vf_lpe(struct rte_eth_dev *dev, __rte_unused uint32_t vf, uint32_t *msgbuf)
+ixgbe_set_vf_lpe(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t new_mtu = msgbuf[1];
+	uint32_t max_frame = msgbuf[1];
 	uint32_t max_frs;
 	uint32_t hlreg0;
-	int max_frame = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
 
 	/* X540 and X550 support jumbo frames in IOV mode */
 	if (hw->mac.type != ixgbe_mac_X540 &&
 		hw->mac.type != ixgbe_mac_X550 &&
 		hw->mac.type != ixgbe_mac_X550EM_x &&
-		hw->mac.type != ixgbe_mac_X550EM_a)
-		return -1;
+		hw->mac.type != ixgbe_mac_X550EM_a) {
+		struct ixgbe_vf_info *vfinfo =
+			*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+		switch (vfinfo[vf].api_version) {
+		case ixgbe_mbox_api_11:
+		case ixgbe_mbox_api_12:
+		case ixgbe_mbox_api_13:
+			 /**
+			  * Version 1.1&1.2&1.3 supports jumbo frames on VFs
+			  * if PF has jumbo frames enabled which means legacy
+			  * VFs are disabled.
+			  */
+			if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    IXGBE_ETH_MAX_LEN)
+				break;
+			/* fall through */
+		default:
+			/**
+			 * If the PF or VF are running w/ jumbo frames enabled,
+			 * we return -1 as we cannot support jumbo frames on
+			 * legacy VFs.
+			 */
+			if (max_frame > IXGBE_ETH_MAX_LEN ||
+			    dev->data->dev_conf.rxmode.max_rx_pkt_len >
+			    IXGBE_ETH_MAX_LEN)
+				return -1;
+			break;
+		}
+	}
 
 	if (max_frame < RTE_ETHER_MIN_LEN ||
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
@@ -573,9 +600,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 
 	max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
 		   IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
-	if (max_frs < new_mtu) {
+	if (max_frs < max_frame) {
 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-		if (new_mtu > IXGBE_ETH_MAX_LEN) {
+		if (max_frame > IXGBE_ETH_MAX_LEN) {
 			dev->data->dev_conf.rxmode.offloads |=
 				DEV_RX_OFFLOAD_JUMBO_FRAME;
 			hlreg0 |= IXGBE_HLREG0_JUMBOEN;
@@ -586,7 +613,7 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 		}
 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
 
-		max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
+		max_frs = max_frame << IXGBE_MHADD_MFS_SHIFT;
 		IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
 	}
 
Signature · 1 line
1.8.3.1
Applied
#13 lore raw
Quoted 19 lines

-----Original Message-----
From: Zhang,Alvin <[email protected]>
Sent: Tuesday, January 19, 2021 1:26 PM
To: Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>; [email protected]
Subject: [PATCH v7] net/ixgbe: fix configuration of max frame size

From: Alvin Zhang <[email protected]>

For some types of NIC, jumbo frame is not supported in IOV mode, so if a VF requests to configure the frame size to not bigger than IXGBE_ETH_MAX_LEN, the kernel driver returns 0, but the DPDK ixgbe PMD returens -1, this will cause the VF to fail to start when the PF driven by DPDK ixgbe PMD.

This patch keeps ixgbe PMD's handling mode consistent with kernel driver in above situation.

Quoted 8 lines

In addition, the value set by the command IXGBE_VF_SET_LPE represents the max frame size, not the mtu.

Fixes 1b9ea09c067b ("ixgbe: support X550")
Fixes 95a27b3ba5f5 ("net/ixgbe: enable jumbo frame for VF")

Applied to dpdk-next-net-intel.

Thanks
Qi