net/txgbe: fix link status when device stopped
[dpdk.git] / drivers / net / txgbe / txgbe_ethdev_vf.c
index 3a51237..18ed94b 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2015-2020
+ * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
  */
 
 #include <sys/queue.h>
@@ -627,6 +628,7 @@ txgbevf_dev_start(struct rte_eth_dev *dev)
                return err;
        }
        hw->mac.get_link_status = true;
+       hw->dev_start = true;
 
        /* negotiate mailbox API version to use with the PF. */
        txgbevf_negotiate_api(hw);
@@ -748,6 +750,7 @@ txgbevf_dev_stop(struct rte_eth_dev *dev)
        }
 
        adapter->rss_reta_updated = 0;
+       hw->dev_start = false;
 
        return 0;
 }
@@ -822,7 +825,7 @@ static void txgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
                        mask = 1;
                        for (j = 0; j < 32; j++) {
                                if (vfta & mask)
-                                       txgbe_set_vfta(hw, (i << 5) + j, 0,
+                                       hw->mac.set_vfta(hw, (i << 5) + j, 0,
                                                       on, false);
                                mask <<= 1;
                        }
@@ -1115,7 +1118,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 +1126,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