[v2,2/5] net/txgbe: fix VF MTU limit setting

Message ID 20210429103335.23060-3-jiawenwu@trustnetic.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Fixes and supports for txgbe |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jiawen Wu April 29, 2021, 10:33 a.m. UTC
  Add the dev_started check to remove the limitation of VF MTU setting.
When device is stopped, it is allowed to set MTU bigger than mbuf size.
Scattered rx may be enabled in next starting, exempt from setting in
EAL parameters.

Fixes: a2beaa4a769e ("net/txgbe: support VF MTU update")
Cc: stable@dpdk.org

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/txgbe/txgbe_ethdev_vf.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Ferruh Yigit April 29, 2021, 2:59 p.m. UTC | #1
On 4/29/2021 11:33 AM, Jiawen Wu wrote:
> Add the dev_started check to remove the limitation of VF MTU setting.
> When device is stopped, it is allowed to set MTU bigger than mbuf size.
> Scattered rx may be enabled in next starting, exempt from setting in
> EAL parameters.
> 

I have reworded the commit log, can you please check in next-net if it is alright.

> Fixes: a2beaa4a769e ("net/txgbe: support VF MTU update")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>

<...>
  
Jiawen Wu May 6, 2021, 1:43 a.m. UTC | #2
On April 29, 2021 11:00 PM, Ferruh Yigit wrote:
> On 4/29/2021 11:33 AM, Jiawen Wu wrote:
> > Add the dev_started check to remove the limitation of VF MTU setting.
> > When device is stopped, it is allowed to set MTU bigger than mbuf size.
> > Scattered rx may be enabled in next starting, exempt from setting in
> > EAL parameters.
> >
> 
> I have reworded the commit log, can you please check in next-net if it is alright.
> 
> > Fixes: a2beaa4a769e ("net/txgbe: support VF MTU update")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> 
> <...>

That's OK.
Thanks Ferruh.
  

Patch

diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c
index 3a5123733e..5597968e18 100644
--- a/drivers/net/txgbe/txgbe_ethdev_vf.c
+++ b/drivers/net/txgbe/txgbe_ethdev_vf.c
@@ -1115,7 +1115,7 @@  txgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct txgbe_hw *hw;
 	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
-	struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
+	struct rte_eth_dev_data *dev_data = dev->data;
 
 	hw = TXGBE_DEV_HW(dev);
 
@@ -1123,13 +1123,15 @@  txgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
 		return -EINVAL;
 
-	/* refuse mtu that requires the support of scattered packets when this
-	 * feature has not been enabled before.
+	/* If device is started, refuse mtu that requires the support of
+	 * scattered packets when this feature has not been enabled before.
 	 */
-	if (!(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) &&
+	if (dev_data->dev_started && !dev_data->scattered_rx &&
 	    (max_frame + 2 * TXGBE_VLAN_TAG_SIZE >
-	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+		PMD_INIT_LOG(ERR, "Stop port first.");
 		return -EINVAL;
+	}
 
 	/*
 	 * When supported by the underlying PF driver, use the TXGBE_VF_SET_MTU