Fix the same issue as PF in commit 66364efcf958 ("net/txgbe: restrict
configuration of VLAN strip offload").

There is a hardware limitation that Rx ring config register is not
writable when Rx ring is enabled, i.e. the TXGBE_RXCFG_ENA bit is set.
But disabling the ring when there is traffic will cause ring get stuck.
So restrict the configuration of VLAN strip offload only if device is
started.

Fixes: aa1ae7941e71 ("net/txgbe: support VF VLAN")
Cc: sta...@dpdk.org

Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com>
---
 drivers/net/txgbe/txgbe_ethdev_vf.c | 31 +++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c 
b/drivers/net/txgbe/txgbe_ethdev_vf.c
index c0d8aa15b2..847febf8c3 100644
--- a/drivers/net/txgbe/txgbe_ethdev_vf.c
+++ b/drivers/net/txgbe/txgbe_ethdev_vf.c
@@ -935,7 +935,7 @@ txgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t 
vlan_id, int on)
 }
 
 static void
-txgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
+txgbevf_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on)
 {
        struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
        uint32_t ctrl;
@@ -946,20 +946,28 @@ txgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, 
uint16_t queue, int on)
                return;
 
        ctrl = rd32(hw, TXGBE_RXCFG(queue));
-       txgbe_dev_save_rx_queue(hw, queue);
        if (on)
                ctrl |= TXGBE_RXCFG_VLAN;
        else
                ctrl &= ~TXGBE_RXCFG_VLAN;
-       wr32(hw, TXGBE_RXCFG(queue), 0);
-       msec_delay(100);
-       txgbe_dev_store_rx_queue(hw, queue);
-       wr32m(hw, TXGBE_RXCFG(queue),
-               TXGBE_RXCFG_VLAN | TXGBE_RXCFG_ENA, ctrl);
+       wr32(hw, TXGBE_RXCFG(queue), ctrl);
 
        txgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
 }
 
+static void
+txgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
+{
+       struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
+
+       if (!hw->adapter_stopped) {
+               PMD_DRV_LOG(ERR, "Please stop port first");
+               return;
+       }
+
+       txgbevf_vlan_strip_q_set(dev, queue, on);
+}
+
 static int
 txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask)
 {
@@ -972,7 +980,7 @@ txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int 
mask)
                for (i = 0; i < dev->data->nb_rx_queues; i++) {
                        rxq = dev->data->rx_queues[i];
                        on = !!(rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP);
-                       txgbevf_vlan_strip_queue_set(dev, i, on);
+                       txgbevf_vlan_strip_q_set(dev, i, on);
                }
        }
 
@@ -982,6 +990,13 @@ txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int 
mask)
 static int
 txgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
+       struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
+
+       if (!hw->adapter_stopped && (mask & RTE_ETH_VLAN_STRIP_MASK)) {
+               PMD_DRV_LOG(ERR, "Please stop port first");
+               return -EPERM;
+       }
+
        txgbe_config_vlan_strip_on_all_queues(dev, mask);
 
        txgbevf_vlan_offload_config(dev, mask);
-- 
2.48.1

Reply via email to