From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7F3D45BE5 for ; Mon, 28 Oct 2024 03:09:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A160740B8F; Mon, 28 Oct 2024 03:09:20 +0100 (CET) Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by mails.dpdk.org (Postfix) with ESMTP id 65B2040A87; Mon, 28 Oct 2024 03:09:18 +0100 (CET) X-QQ-mid: bizesmtpsz8t1730081341tzs12g4 X-QQ-Originating-IP: b/AXkS/dK+BwLLmCQAMYE+CD3KojtZMfzn5NuNqv+R0= Received: from wxdbg.localdomain.com ( [36.24.66.21]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 28 Oct 2024 10:08:59 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1418775142941140719 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu , stable@dpdk.org Subject: [PATCH v2 13/13] net/ngbe: restrict configuration of VLAN strip offload Date: Mon, 28 Oct 2024 10:31:47 +0800 Message-Id: <20241028023147.60157-14-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241028023147.60157-1-jiawenwu@trustnetic.com> References: <20241023064836.2017879-1-jiawenwu@trustnetic.com> <20241028023147.60157-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-QQ-XMAILINFO: NkHKfw09D6j8SEZnsxRIX1w+zGk8AjgcvQI6RkhdS6MrHrCX4HN81F/1 WEpX4uRFXNwRy4aD3Chfi0+fAaGeaEJtVT9y0HuvTr+pCZBmyRVdzOIu4G3gnfzyKrTetVd xDIFJCTqRyQcKLW0M/v2448cZ4tc6P2X93wU8USYFsyvQJKZQUNyzjW1KqMFvyIqYs69c3k Cyg7iwSl2NH206eT3LcZwTJ1pT7aJ9Lc1nz3BhvNcMNMFtlHc1LXqPJM1EkYq2T5cpZ+ufn h5uk7NCGtKgeac+c7TyBaWfvU6R5BPVH5d6q3Ou6kFpLlQ4+HPsWc1e7/KEFvZWfHHWvGxr Ci6n28L+RjkcG9HvH22b1sBDXu4WDtK2eP+BmChqkm/Eeur5277OQGBYZ6PE+Rp9m8z8Jt9 oYwl+RXpbXsW1OLQOFldMGeob8GB9iY93orqa+kXasjsBC4Auu5AAm0b+IXxMWQAu2i9jlg oGuEHgOcG2oeGAMYvJ4ZZfb7pbN9rA73M1SV3GaWaww3pSiY90yuSIn5B8kHnAxvcYwg3bS FKXPWYX/xSYXwNzg5oWABpw3q+dbXFYjJ8eueoFWWhpOpMOToY5l4UhC/5DJ1SUk2UGGt8O I+tdY5mdlydARtT5xUymFAlyjD9co+tp174foVkM/pHw1z5y0zc0IRn+9tOzowPfHDVqPHk n5c7wMyRy+9vy1WPaXwr35qKdRYc+7KKlq3lYrYLmhCSlUPoUd8EGALGjJ7Ug2NRV4oLVW8 ww8Pz8eD3vYhhQZs9l1XGQa1kiXyDi9I1XFHffBSgZGThVA+5+oN7zKHbLkf4DCvOmqLIM+ 0EbtIcMaBD/EWkTk/CrXfeJL8aNb6ynCv5UWu3uMd/n4odwNMnw4Plr9OM0ql1nimbfkZsn 7496FZUWRlC3c0fTATp+/J7O7cF+6Zmrk+JottDPKKbVjUh1WxJCpKQ7buXzOLT4F/zpYkV xZHuz98+ymg14kvm9fXAjR1pdATcl4h7CZAG1F8YXarWtxmYgnVS8d2T2 X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= X-QQ-RECHKSPAM: 0 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org There is a hardware limitation that Rx ring config register is not writable when Rx ring is enabled, i.e. the NGBE_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: 59b46438fdaa ("net/ngbe: support VLAN offload and VLAN filter") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/ngbe/ngbe_ethdev.c | 49 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index e7dc1c0f94..eef31af233 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -586,41 +586,25 @@ ngbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) } static void -ngbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on) +ngbe_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on) { - struct ngbe_hw *hw = ngbe_dev_hw(dev); - struct ngbe_rx_queue *rxq; - bool restart; - uint32_t rxcfg, rxbal, rxbah; - if (on) ngbe_vlan_hw_strip_enable(dev, queue); else ngbe_vlan_hw_strip_disable(dev, queue); +} - rxq = dev->data->rx_queues[queue]; - rxbal = rd32(hw, NGBE_RXBAL(rxq->reg_idx)); - rxbah = rd32(hw, NGBE_RXBAH(rxq->reg_idx)); - rxcfg = rd32(hw, NGBE_RXCFG(rxq->reg_idx)); - if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) { - restart = (rxcfg & NGBE_RXCFG_ENA) && - !(rxcfg & NGBE_RXCFG_VLAN); - rxcfg |= NGBE_RXCFG_VLAN; - } else { - restart = (rxcfg & NGBE_RXCFG_ENA) && - (rxcfg & NGBE_RXCFG_VLAN); - rxcfg &= ~NGBE_RXCFG_VLAN; - } - rxcfg &= ~NGBE_RXCFG_ENA; +static void +ngbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); - if (restart) { - /* set vlan strip for ring */ - ngbe_dev_rx_queue_stop(dev, queue); - wr32(hw, NGBE_RXBAL(rxq->reg_idx), rxbal); - wr32(hw, NGBE_RXBAH(rxq->reg_idx), rxbah); - wr32(hw, NGBE_RXCFG(rxq->reg_idx), rxcfg); - ngbe_dev_rx_queue_start(dev, queue); + if (!hw->adapter_stopped) { + PMD_DRV_LOG(ERR, "Please stop port first"); + return; } + + ngbe_vlan_strip_q_set(dev, queue, on); } static int @@ -846,9 +830,9 @@ ngbe_vlan_hw_strip_config(struct rte_eth_dev *dev) rxq = dev->data->rx_queues[i]; if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) - ngbe_vlan_hw_strip_enable(dev, i); + ngbe_vlan_strip_q_set(dev, i, 1); else - ngbe_vlan_hw_strip_disable(dev, i); + ngbe_vlan_strip_q_set(dev, i, 0); } } @@ -910,6 +894,13 @@ ngbe_vlan_offload_config(struct rte_eth_dev *dev, int mask) static int ngbe_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); ngbe_vlan_offload_config(dev, mask); -- 2.27.0