diff mbox series

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

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

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Alvin Zhang Jan. 15, 2021, 7 a.m. UTC
From: Alvin Zhang <alvinx.zhang@intel.com>

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

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

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

Comments

Xie, WeiX Jan. 15, 2021, 7:34 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: Friday, January 15, 2021 3:00 PM
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>;
> Xie, WeiX <weix.xie@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
> index 833863a..1ffde56 100644
> --- a/drivers/net/ixgbe/ixgbe_pf.c
> +++ b/drivers/net/ixgbe/ixgbe_pf.c
> @@ -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);
>  	}
> 
> --
> 1.8.3.1
Guo, Jia Jan. 15, 2021, 8:15 a.m. UTC | #2
Hi, Alvin

> -----Original Message-----
> From: Zhang,Alvin <alvinx.zhang@intel.com>
> Sent: Friday, January 15, 2021 3:00 PM
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>;
> Xie, WeiX <weix.xie@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> 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?

> 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.
> ---
>  drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
> index 833863a..1ffde56 100644
> --- a/drivers/net/ixgbe/ixgbe_pf.c
> +++ b/drivers/net/ixgbe/ixgbe_pf.c
> @@ -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)

This condition is only for X540/X550?

> +			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?

>  	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);
>  	}
> 
> --
> 1.8.3.1
Alvin Zhang Jan. 15, 2021, 9:50 a.m. UTC | #3
Hi Guojia,
Thanks for you reply.

I will modify as we discussion.

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Friday, January 15, 2021 4:15 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; Wang, Haiyue
> <haiyue.wang@intel.com>; Xie, WeiX <weix.xie@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>; stable@dpdk.org
> Subject: RE: [PATCH v3] net/ixgbe: fix configuration of max frame size
> 
> Hi, Alvin
> 
> > -----Original Message-----
> > From: Zhang,Alvin <alvinx.zhang@intel.com>
> > Sent: Friday, January 15, 2021 3:00 PM
> > To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue
> > <haiyue.wang@intel.com>; Xie, WeiX <weix.xie@intel.com>
> > Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> > stable@dpdk.org
> > Subject: [PATCH v3] net/ixgbe: fix configuration of max frame size
> >
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > 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?
> 
> > 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.
> > ---
> >  drivers/net/ixgbe/ixgbe_pf.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_pf.c
> > b/drivers/net/ixgbe/ixgbe_pf.c index 833863a..1ffde56 100644
> > --- a/drivers/net/ixgbe/ixgbe_pf.c
> > +++ b/drivers/net/ixgbe/ixgbe_pf.c
> > @@ -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)
> 
> This condition is only for X540/X550?
> 
> > +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?
> 
> >  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);  }
> >
> > --
> > 1.8.3.1
>
diff mbox series

Patch

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