[v5] net/ixgbe: fix configuration of max frame size

Message ID 20210118050341.1460-1-alvinx.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v5] net/ixgbe: fix configuration of max frame size |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing warning Testing issues

Commit Message

Alvin Zhang Jan. 18, 2021, 5:03 a.m. UTC
  From: Alvin Zhang <alvinx.zhang@intel.com>

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")
Cc: stable@dpdk.org

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
---

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(-)
  

Comments

Xie, WeiX Jan. 18, 2021, 5:58 a.m. UTC | #1
Tested-by:  Xie,WeiX < weix.xie@intel.com>

Regards,
Xie Wei

> -----Original Message-----
> From: Zhang,Alvin [mailto:alvinx.zhang@intel.com]
> Sent: Monday, January 18, 2021 1:04 PM
> To: Guo, Jia <jia.guo@intel.com>; Xie, WeiX <weix.xie@intel.com>; Wang,
> Haiyue <haiyue.wang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v5] net/ixgbe: fix configuration of max frame size
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
> index 833863a..793f970 100644
> --- a/drivers/net/ixgbe/ixgbe_pf.c
> +++ b/drivers/net/ixgbe/ixgbe_pf.c
> @@ -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);
>  	}
> 
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 833863a..793f970 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -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);
 	}