net/ixgbe: check the result of setting VF MTU

Message ID 20201202094806.11464-1-alvinx.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ixgbe: check the result of setting VF MTU |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
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-testing success Testing PASS

Commit Message

Alvin Zhang Dec. 2, 2020, 9:48 a.m. UTC
  From: Alvin Zhang <alvinx.zhang@intel.com>

If a VF request to set a invalid maximum packet length value,
The PF kernel driver may disable its reception.

This patch add codes to output information and return the error status.

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

Fixes: 12cd0cccc3db ("ixgbevf: allow to set MTU")
Cc: stable@dpdk.org
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
 drivers/net/ixgbe/ixgbe_rxtx.c   | 8 ++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)
  

Comments

Wang, Haiyue Dec. 2, 2020, 10:54 a.m. UTC | #1
> -----Original Message-----
> From: Zhang,Alvin <alvinx.zhang@intel.com>
> Sent: Wednesday, December 2, 2020 17:48
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH] net/ixgbe: check the result of setting VF MTU
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> If a VF request to set a invalid maximum packet length value,
> The PF kernel driver may disable its reception.
> 
> This patch add codes to output information and return the error status.
> 
> Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> 
> Fixes: 12cd0cccc3db ("ixgbevf: allow to set MTU")
> Cc: stable@dpdk.org
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
>  drivers/net/ixgbe/ixgbe_rxtx.c   | 8 ++++++--
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 1.8.3.1
  
Qi Zhang Dec. 11, 2020, 2:32 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wang, Haiyue
> Sent: Wednesday, December 2, 2020 6:55 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; Guo, Jia <jia.guo@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: check the result of setting VF MTU
> 
> > -----Original Message-----
> > From: Zhang,Alvin <alvinx.zhang@intel.com>
> > Sent: Wednesday, December 2, 2020 17:48
> > To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>
> > Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>;
> > stable@dpdk.org
> > Subject: [PATCH] net/ixgbe: check the result of setting VF MTU
> >
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > If a VF request to set a invalid maximum packet length value, The PF
> > kernel driver may disable its reception.
> >
> > This patch add codes to output information and return the error status.
> >
> > Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > Fixes: 12cd0cccc3db ("ixgbevf: allow to set MTU")
> > Cc: stable@dpdk.org
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
> >  drivers/net/ixgbe/ixgbe_rxtx.c   | 8 ++++++--
> >  2 files changed, 8 insertions(+), 3 deletions(-)
> >
> 
> Acked-by: Haiyue Wang <haiyue.wang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> > --
> > 1.8.3.1
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 9a47a8b..d7a1806 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -6555,7 +6555,8 @@  static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
 	 * prior to 3.11.33 which contains the following change:
 	 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
 	 */
-	ixgbevf_rlpml_set_vf(hw, max_frame);
+	if (ixgbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
 
 	/* update max frame size */
 	dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 6cfbb58..7bb8460 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -5634,8 +5634,12 @@  void ixgbe_configure_dcb(struct rte_eth_dev *dev)
 	 * ixgbevf_rlpml_set_vf even if jumbo frames are not used. This way,
 	 * VF packets received can work in all cases.
 	 */
-	ixgbevf_rlpml_set_vf(hw,
-		(uint16_t)dev->data->dev_conf.rxmode.max_rx_pkt_len);
+	if (ixgbevf_rlpml_set_vf(hw,
+	    (uint16_t)dev->data->dev_conf.rxmode.max_rx_pkt_len)) {
+		PMD_INIT_LOG(ERR, "Set max packet length to %d failed.",
+			     dev->data->dev_conf.rxmode.max_rx_pkt_len);
+		return -EINVAL;
+	}
 
 	/*
 	 * Assume no header split and no VLAN strip support