Fix the same issue as PF in commit baca8ec066dc ("net/ngbe: 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: f47dc03c706f ("net/ngbe: add VLAN ops for VF device")
Cc: sta...@dpdk.org

Signed-off-by: Jiawen Wu <jiawe...@trustnetic.com>
---
 drivers/net/ngbe/ngbe_ethdev_vf.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ngbe/ngbe_ethdev_vf.c 
b/drivers/net/ngbe/ngbe_ethdev_vf.c
index 5d68f1602d..846bc981f6 100644
--- a/drivers/net/ngbe/ngbe_ethdev_vf.c
+++ b/drivers/net/ngbe/ngbe_ethdev_vf.c
@@ -828,7 +828,7 @@ ngbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t 
vlan_id, int on)
 }
 
 static void
-ngbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
+ngbevf_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on)
 {
        struct ngbe_hw *hw = ngbe_dev_hw(dev);
        uint32_t ctrl;
@@ -848,6 +848,19 @@ ngbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, 
uint16_t queue, int on)
        ngbe_vlan_hw_strip_bitmap_set(dev, queue, on);
 }
 
+static void
+ngbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
+{
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+       if (!hw->adapter_stopped) {
+               PMD_DRV_LOG(ERR, "Please stop port first");
+               return;
+       }
+
+       ngbevf_vlan_strip_q_set(dev, queue, on);
+}
+
 static int
 ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask)
 {
@@ -860,7 +873,7 @@ ngbevf_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);
-                       ngbevf_vlan_strip_queue_set(dev, i, on);
+                       ngbevf_vlan_strip_q_set(dev, i, on);
                }
        }
 
@@ -870,6 +883,13 @@ ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int 
mask)
 static int
 ngbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+
+       if (!hw->adapter_stopped && (mask & RTE_ETH_VLAN_STRIP_MASK)) {
+               PMD_DRV_LOG(ERR, "Please stop port first");
+               return -EPERM;
+       }
+
        ngbe_config_vlan_strip_on_all_queues(dev, mask);
 
        ngbevf_vlan_offload_config(dev, mask);
-- 
2.48.1

Reply via email to