From patchwork Mon Apr 29 10:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13646575 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 536CB376E5 for ; Mon, 29 Apr 2024 10:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.194.254.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386478; cv=none; b=WVCsL4TW+stQtOPaC7CSnUvkfOncOHLTx3YcYMzcv5COlPsiS6gTLYjYjxNiObc8sjSvKRM3bOO0kNdzH+BslYr4S56xHnCI579iMwmQwWBqKguus3hJf4turOpb7N4SlF9LoZpdll19k2dLJdju8vVjUW196cDU288RzwXhnYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386478; c=relaxed/simple; bh=UaMBmkSzMlXtIhCmidFFj12rxYatUMvs6mUquUoxlPQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pvCZZfkqO/azN6nGGv9fh5xIXjGb8FH2PT66vElMkX+bXcuNwhvGYwmIBfjlBDEqSkgFLvUQZL9JjA87Zl8zkml70hZwW7Pe4gIIXNB+21Ms7RTohWHMnUNfsOzYqYwHtw7yb/FY+qPW/AG0BpuSEv++cM1TxPEcjn2llTW46uU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com; spf=pass smtp.mailfrom=trustnetic.com; arc=none smtp.client-ip=18.194.254.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trustnetic.com X-QQ-mid: bizesmtpsz15t1714386339t0llpj X-QQ-Originating-IP: wozpXTH8htOrqX5xRKb2U5mF/dcj7Wg2xVyVyc/GgZs= Received: from lap-jiawenwu.trustnetic.com ( [125.120.150.70]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 29 Apr 2024 18:25:38 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: vCKdglClpVLcXH785aEIaSaMN7q6Vlb3mW/XLq0Azyw5Czm7FcNslx4ARfjWr R6stC+dwqW9zFXwCiL/VlCIkWFn2eGp8frAIoRU9dhyum4iXC5mVttU24CrTdEnqsLBpBxI Go0om3JG3kbrMYnJ5u3N6DI7mbsiBSvzRflT7TiSF5lWwbCpiuUbX1BrXGF7v78UM+tJonH tVK+epniN00FU9q2d+TRvfc0gEgzXvZYGnIicbGsyzugmqqELqxi/tw9ESIE35++zgZzN3c Zq2LYBuLM5GDYk1YZfNnOAJTLQPGCcQZc+RlNyraPCnznHL7uCpruqj9WcnPRMp3ALGYDws HDJnPeeFaxMS7Z5071fuUwWtmOzOaylJhkKhqcm1kLeCw73T6pdw2OF9P/mT0aQlYe3NcDo UO4bFsvTUS+I0/qvch35tA== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 8311698413773401071 From: Jiawen Wu To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rmk+kernel@armlinux.org.uk, andrew@lunn.ch, netdev@vger.kernel.org Cc: mengyuanlou@net-swift.com, duanqiangwen@net-swift.com, Jiawen Wu Subject: [PATCH net v2 1/4] net: wangxun: fix the incorrect display of queue number in statistics Date: Mon, 29 Apr 2024 18:25:16 +0800 Message-Id: <20240429102519.25096-2-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240429102519.25096-1-jiawenwu@trustnetic.com> References: <20240429102519.25096-1-jiawenwu@trustnetic.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org When using ethtool -S to print hardware statistics, the number of Rx/Tx queues printed is greater than the number of queues actually used. Fixes: 46b92e10d631 ("net: libwx: support hardware statistics") Signed-off-by: Jiawen Wu --- .../net/ethernet/wangxun/libwx/wx_ethtool.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c index cc3bec42ed8e..803c7f1da9a4 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c @@ -59,9 +59,12 @@ static const struct wx_stats wx_gstrings_stats[] = { int wx_get_sset_count(struct net_device *netdev, int sset) { + struct wx *wx = netdev_priv(netdev); + switch (sset) { case ETH_SS_STATS: - return WX_STATS_LEN; + return WX_STATS_LEN - (WX_NUM_RX_QUEUES - wx->num_tx_queues) * + (sizeof(struct wx_queue_stats) / sizeof(u64)) * 2; default: return -EOPNOTSUPP; } @@ -70,6 +73,7 @@ EXPORT_SYMBOL(wx_get_sset_count); void wx_get_strings(struct net_device *netdev, u32 stringset, u8 *data) { + struct wx *wx = netdev_priv(netdev); u8 *p = data; int i; @@ -77,11 +81,11 @@ void wx_get_strings(struct net_device *netdev, u32 stringset, u8 *data) case ETH_SS_STATS: for (i = 0; i < WX_GLOBAL_STATS_LEN; i++) ethtool_puts(&p, wx_gstrings_stats[i].stat_string); - for (i = 0; i < netdev->num_tx_queues; i++) { + for (i = 0; i < wx->num_tx_queues; i++) { ethtool_sprintf(&p, "tx_queue_%u_packets", i); ethtool_sprintf(&p, "tx_queue_%u_bytes", i); } - for (i = 0; i < WX_NUM_RX_QUEUES; i++) { + for (i = 0; i < wx->num_rx_queues; i++) { ethtool_sprintf(&p, "rx_queue_%u_packets", i); ethtool_sprintf(&p, "rx_queue_%u_bytes", i); } @@ -107,7 +111,7 @@ void wx_get_ethtool_stats(struct net_device *netdev, sizeof(u64)) ? *(u64 *)p : *(u32 *)p; } - for (j = 0; j < netdev->num_tx_queues; j++) { + for (j = 0; j < wx->num_tx_queues; j++) { ring = wx->tx_ring[j]; if (!ring) { data[i++] = 0; @@ -122,7 +126,7 @@ void wx_get_ethtool_stats(struct net_device *netdev, } while (u64_stats_fetch_retry(&ring->syncp, start)); i += 2; } - for (j = 0; j < WX_NUM_RX_QUEUES; j++) { + for (j = 0; j < wx->num_rx_queues; j++) { ring = wx->rx_ring[j]; if (!ring) { data[i++] = 0; @@ -177,13 +181,8 @@ void wx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) strscpy(info->driver, wx->driver_name, sizeof(info->driver)); strscpy(info->fw_version, wx->eeprom_id, sizeof(info->fw_version)); strscpy(info->bus_info, pci_name(wx->pdev), sizeof(info->bus_info)); - if (wx->num_tx_queues <= WX_NUM_TX_QUEUES) { - info->n_stats = WX_STATS_LEN - - (WX_NUM_TX_QUEUES - wx->num_tx_queues) * - (sizeof(struct wx_queue_stats) / sizeof(u64)) * 2; - } else { - info->n_stats = WX_STATS_LEN; - } + info->n_stats = WX_STATS_LEN - (WX_NUM_TX_QUEUES - wx->num_tx_queues) * + (sizeof(struct wx_queue_stats) / sizeof(u64)) * 2; } EXPORT_SYMBOL(wx_get_drvinfo); From patchwork Mon Apr 29 10:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13646572 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbg150.qq.com (smtpbg150.qq.com [18.132.163.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF29A5382 for ; Mon, 29 Apr 2024 10:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.132.163.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386461; cv=none; b=khT2BGstMV7X7/b17vteRUR72Dj72ew/WlmQtosN+82DsZPelPuBvml1wjb+5UbCNk7GTZ1VnCvuuTUfmfkgx/CIrsgUJfFX4mVoXf/0j4f2ERFpvO663I+mJY8vFi9MCNJYMY86BV/Jdi7zpHBhWDvSnKP3EZeLaEmv9ZN7cGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386461; c=relaxed/simple; bh=c1Pvz5bor76UIC4G1W7Qtphp4AFswvnk4C9b4WNAvew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=stZZQW3NNQiKTA5RmSR/L7HWiVoCZ15rNGW2PPmISPEVi6otQIS/gIXsKhCR1fH45360oJ9SvQyp+uNdViE57NmzP9z6A8+dinsUuMhCzZ6d18ezBzRNbbdGyqhvVoOo42DcvlXOvtQbiwURKK6pk1VYqc5HKLRS8NG/302+hC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com; spf=pass smtp.mailfrom=trustnetic.com; arc=none smtp.client-ip=18.132.163.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trustnetic.com X-QQ-mid: bizesmtpsz15t1714386343tnpm2c X-QQ-Originating-IP: sDTphYgYByCuezisPuKCWedjhJx9mRnKKtBlGzCp3UU= Received: from lap-jiawenwu.trustnetic.com ( [125.120.150.70]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 29 Apr 2024 18:25:42 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: H21jX+7aWYbN+T+OTv7ttKspaXt9NCa/0BwwC97zjb7M1WyFn4S83wDGy1RC+ j1wBAUYNRcoVPitC3395ksMur7GbjQdIl/ptDE7rXU8OFPumq11rmoTguk72ZEDjs9ZZUHX zglTUi3wDYKfTlq5uvlp2EXEI8PwovIvc8+/z7wq5L1R41/zu3F8zqOuUMJHyKTorSHjurn /4elmQXf4ad6pspO/R5qwHVJ4u/4fES6swW/9d9kbOFe1VVTt4wclrwLpoPCqUDphOXLGLY 0vddjvV8B+//vbxLHm0eVlqTAvYmOJrhqVlb0w0YJH42MHxxytxxSAWiVONirxTEu6p5xo8 iFNuobynzt0kBmubOIHyBQ5U9+zwCo6nIi14txL10y+VYv+lNa47FZlJEuLVjxf8vYkyr2p x83xyUevZGUnoy3EngNVBQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 1081951874092602875 From: Jiawen Wu To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rmk+kernel@armlinux.org.uk, andrew@lunn.ch, netdev@vger.kernel.org Cc: mengyuanlou@net-swift.com, duanqiangwen@net-swift.com, Jiawen Wu Subject: [PATCH net v2 2/4] net: wangxun: fix to change Rx features Date: Mon, 29 Apr 2024 18:25:17 +0800 Message-Id: <20240429102519.25096-3-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240429102519.25096-1-jiawenwu@trustnetic.com> References: <20240429102519.25096-1-jiawenwu@trustnetic.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org Fix the issue where some Rx features cannot be changed. When using ethtool -K to turn off rx offload, it returns error and displays "Could not change any device features". And netdev->features is not assigned a new value to actually configure the hardware. Fixes: 6dbedcffcf54 ("net: libwx: Implement xx_set_features ops") Signed-off-by: Jiawen Wu Reviewed-by: Simon Horman --- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c index 6fae161cbcb8..667a5675998c 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c @@ -2690,12 +2690,14 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features) wx->rss_enabled = false; } + netdev->features = features; + if (changed & (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX)) wx_set_rx_mode(netdev); - return 1; + return 0; } EXPORT_SYMBOL(wx_set_features); From patchwork Mon Apr 29 10:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13646574 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E22C1374E3 for ; Mon, 29 Apr 2024 10:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.254.200.128 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386478; cv=none; b=Aln72nIPEPnRNDFyNHGtxLXkrjyNzDb0LIwHn/cRc62wTfG1vO3dgP26kRLZMgt7IIsN8XOW2RsuU2qYzLoa/2gHx8eilFvObUnlAYZuVJbKTJS4XcxWBI+SxRtEKCNAjZoclgfCzdTjV05nrlsD5ZAYM4+QpCjACWajs3Maeok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386478; c=relaxed/simple; bh=puKM/F/ejiCdcBF0UKxXGBl0TZKGmVfO+iS4STG5KnY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ELwPH6xU4grXEYtzsOY3tLHdWvIN/biXv5atUdy2r3o/4jOYdgVjwzBhfI4K7HJ7dxMYXz2ZMHR/sNcHLEg/CmNAdVN1kPrwHShGpI8cXI9YCnWU6XWsdAXIAK321ilGqbY19fz+iJCMBtEkwHoNAA9MqxZDQyLsavwIN1tdugU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com; spf=pass smtp.mailfrom=trustnetic.com; arc=none smtp.client-ip=54.254.200.128 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trustnetic.com X-QQ-mid: bizesmtpsz15t1714386347tqml09 X-QQ-Originating-IP: WMfuFipb9zkSkV9gxcO+uNdSTKCnjlTzDN07ww5t3ho= Received: from lap-jiawenwu.trustnetic.com ( [125.120.150.70]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 29 Apr 2024 18:25:46 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: bQsUcYFpAAa3gskZs1tMbYWt1FaSIm+OPeZTtTenf2AUHplxG3PwRb+3wRoVD fa2l0b4gYcJJnH5M0PkFpdH4jak67zTfCf9d73bsMxtmUCRYKOQ1CqUjz/dlGst3G9c2fno OvWLAfMU9ztzFEMpUJTdMqsG9r3lNzSwyY6zw6KJ5NMZPh8dSSVP6WyAbEfVB8B68zpxb7/ YZO+Szsd3wRpCONJHWhCs6QI7UGT0fZjD3u7aAB7r6J5Grp7052dzCoj7bCEG3nMXG3/NC8 v956F57UboIgl2REwmH9rsqjZXz8u3lZqRZ9foEEBcsD864rUsvB+TEwzX3vLl5QrqNhJjF M0e0UxjUKLiOtE8Dx8vEAPTi8hwxMODi/F7JzHDfvgIhPytLQP5+jDPJhxkSUes9DqFtVom KlAcRbH6rBU= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 15531716025499074061 From: Jiawen Wu To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rmk+kernel@armlinux.org.uk, andrew@lunn.ch, netdev@vger.kernel.org Cc: mengyuanlou@net-swift.com, duanqiangwen@net-swift.com, Jiawen Wu Subject: [PATCH net v2 3/4] net: wangxun: match VLAN CTAG and STAG features Date: Mon, 29 Apr 2024 18:25:18 +0800 Message-Id: <20240429102519.25096-4-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240429102519.25096-1-jiawenwu@trustnetic.com> References: <20240429102519.25096-1-jiawenwu@trustnetic.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org Hardware requires VLAN CTAG and STAG configuration always matches. And whether VLAN CTAG or STAG changes, the configuration needs to be changed as well. Fixes: 6670f1ece2c8 ("net: txgbe: Add netdev features support") Signed-off-by: Jiawen Wu Reviewed-by: Sai Krishna --- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 46 +++++++++++++++++++ drivers/net/ethernet/wangxun/libwx/wx_lib.h | 2 + drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 + .../net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + 4 files changed, 50 insertions(+) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c index 667a5675998c..aefd78455468 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c @@ -2701,6 +2701,52 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features) } EXPORT_SYMBOL(wx_set_features); +netdev_features_t wx_fix_features(struct net_device *netdev, + netdev_features_t features) +{ + netdev_features_t changed = netdev->features ^ features; + + if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) { + if (features & NETIF_F_HW_VLAN_CTAG_FILTER) + features |= NETIF_F_HW_VLAN_STAG_FILTER; + else + features &= ~NETIF_F_HW_VLAN_STAG_FILTER; + } + if (changed & NETIF_F_HW_VLAN_STAG_FILTER) { + if (features & NETIF_F_HW_VLAN_STAG_FILTER) + features |= NETIF_F_HW_VLAN_CTAG_FILTER; + else + features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; + } + if (changed & NETIF_F_HW_VLAN_CTAG_RX) { + if (features & NETIF_F_HW_VLAN_CTAG_RX) + features |= NETIF_F_HW_VLAN_STAG_RX; + else + features &= ~NETIF_F_HW_VLAN_STAG_RX; + } + if (changed & NETIF_F_HW_VLAN_STAG_RX) { + if (features & NETIF_F_HW_VLAN_STAG_RX) + features |= NETIF_F_HW_VLAN_CTAG_RX; + else + features &= ~NETIF_F_HW_VLAN_CTAG_RX; + } + if (changed & NETIF_F_HW_VLAN_CTAG_TX) { + if (features & NETIF_F_HW_VLAN_CTAG_TX) + features |= NETIF_F_HW_VLAN_STAG_TX; + else + features &= ~NETIF_F_HW_VLAN_STAG_TX; + } + if (changed & NETIF_F_HW_VLAN_STAG_TX) { + if (features & NETIF_F_HW_VLAN_STAG_TX) + features |= NETIF_F_HW_VLAN_CTAG_TX; + else + features &= ~NETIF_F_HW_VLAN_CTAG_TX; + } + + return features; +} +EXPORT_SYMBOL(wx_fix_features); + void wx_set_ring(struct wx *wx, u32 new_tx_count, u32 new_rx_count, struct wx_ring *temp_ring) { diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.h b/drivers/net/ethernet/wangxun/libwx/wx_lib.h index ec909e876720..c41b29ea812f 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.h +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.h @@ -30,6 +30,8 @@ int wx_setup_resources(struct wx *wx); void wx_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats); int wx_set_features(struct net_device *netdev, netdev_features_t features); +netdev_features_t wx_fix_features(struct net_device *netdev, + netdev_features_t features); void wx_set_ring(struct wx *wx, u32 new_tx_count, u32 new_rx_count, struct wx_ring *temp_ring); diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index fdd6b4f70b7a..e894e01d030d 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -499,6 +499,7 @@ static const struct net_device_ops ngbe_netdev_ops = { .ndo_start_xmit = wx_xmit_frame, .ndo_set_rx_mode = wx_set_rx_mode, .ndo_set_features = wx_set_features, + .ndo_fix_features = wx_fix_features, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = wx_set_mac, .ndo_get_stats64 = wx_get_stats64, diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c index bd4624d14ca0..b3c0058b045d 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c @@ -428,6 +428,7 @@ static const struct net_device_ops txgbe_netdev_ops = { .ndo_start_xmit = wx_xmit_frame, .ndo_set_rx_mode = wx_set_rx_mode, .ndo_set_features = wx_set_features, + .ndo_fix_features = wx_fix_features, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = wx_set_mac, .ndo_get_stats64 = wx_get_stats64, From patchwork Mon Apr 29 10:25:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13646576 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 071D95382 for ; Mon, 29 Apr 2024 10:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.245.218.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386491; cv=none; b=s5ACrX1JffPZRX5RhczLdTXDVNkLkOBjVqwQS+ZA7F3H+auUjeyg4pwebYbKiOMZ0FMDV8TNhG4PD/Q6qax0X/x04d/1oyWcv6qw1xBDBFAbyFYVGIEPAXKbWJ7uT6efb8p3tcv2s0yu0t6psaLkU7vfvx2tBn7zzArRd4Gc7JM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714386491; c=relaxed/simple; bh=g5k1mtr4FpZegZxwdBiZSCn6C6/gBNdWHTtrsb2KyYY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B5Lz/8MLuzzB8zNqTjvB6JvNHe/69HCib1F703PwgVvpsKjNo3bhsxoOb6j096l43Ys1GdJJUq4Y7IUImZ15x1qIz/LSKWElZQC56GccAGMfvT6Mc9VxeDcSKXDIkDennnI0ezc8Wnt1MNtm4l0hFEmLqBGjpR6J4Djphba3fE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com; spf=pass smtp.mailfrom=trustnetic.com; arc=none smtp.client-ip=13.245.218.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=trustnetic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trustnetic.com X-QQ-mid: bizesmtpsz15t1714386351tqqhj5 X-QQ-Originating-IP: r5RiSFULgCTb5lvuVsPNXKmU3UWZBoLKeU6aGFrr2rw= Received: from lap-jiawenwu.trustnetic.com ( [125.120.150.70]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 29 Apr 2024 18:25:50 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: p4uWNzKzFj88ZDIAM7IFIf8s84wTf1ycI/bDc+Ttpy9QMbO+QCuvQidgEz1UR 2wXJIlB0Fjfe7a9mEeYOQ7ZzcVovX/36qoSDYD+fZFS+6ZRireGX5YEMQQxP4ItNvBxMUZ5 ZorqRrWYEjWbzjp2NVwk358Z3ypTgSz/teLGsD6DAxm2DSXwiAgs7DHUfOR1lv77llL1Vg/ fIAdInL8AFxzouUTDDxAY/ZVj1OXrtC8brAixLoHFQv+LeqMfevuMqvqnXYzm3c8BKoIpAx s1fgaSgq3b6qhs8sz4lG7PxV2ACtBUP7G9n1r34m13mKxncCt156fkYrzY1dZvv9dXIVD7S RZuK6q5SltpSBzU+V1v/GpxWO+A4vmyClshtRMq/rtaT+GuqQK+PK1FFCB0FutcYtn3Anxc G6I134m9uZ0= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 16345983470524713311 From: Jiawen Wu To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rmk+kernel@armlinux.org.uk, andrew@lunn.ch, netdev@vger.kernel.org Cc: mengyuanlou@net-swift.com, duanqiangwen@net-swift.com, Jiawen Wu Subject: [PATCH net v2 4/4] net: txgbe: fix to control VLAN strip Date: Mon, 29 Apr 2024 18:25:19 +0800 Message-Id: <20240429102519.25096-5-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240429102519.25096-1-jiawenwu@trustnetic.com> References: <20240429102519.25096-1-jiawenwu@trustnetic.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org When VLAN tag strip is changed to enable or disable, the hardware requires the Rx ring to be in a disabled state, otherwise the feature cannot be changed. Fixes: f3b03c655f67 ("net: wangxun: Implement vlan add and kill functions") Signed-off-by: Jiawen Wu Reviewed-by: Simon Horman --- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 2 ++ drivers/net/ethernet/wangxun/libwx/wx_lib.c | 6 ++-- drivers/net/ethernet/wangxun/libwx/wx_type.h | 22 ++++++++++++++ .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 18 +++++++---- .../ethernet/wangxun/txgbe/txgbe_ethtool.c | 18 +++++++---- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 30 +++++++++++++++++++ .../net/ethernet/wangxun/txgbe/txgbe_type.h | 1 + 7 files changed, 84 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c index 945c13d1a982..c09a6f744575 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c @@ -1958,6 +1958,8 @@ int wx_sw_init(struct wx *wx) return -ENOMEM; } + bitmap_zero(wx->state, WX_STATE_NBITS); + return 0; } EXPORT_SYMBOL(wx_sw_init); diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c index aefd78455468..ed6a168ff136 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c @@ -2692,9 +2692,9 @@ int wx_set_features(struct net_device *netdev, netdev_features_t features) netdev->features = features; - if (changed & - (NETIF_F_HW_VLAN_CTAG_RX | - NETIF_F_HW_VLAN_STAG_RX)) + if (wx->mac.type == wx_mac_sp && changed & NETIF_F_HW_VLAN_CTAG_RX) + wx->do_reset(netdev); + else if (changed & (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER)) wx_set_rx_mode(netdev); return 0; diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h index 1fdeb464d5f4..5aaf7b1fa2db 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_type.h +++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h @@ -982,8 +982,13 @@ struct wx_hw_stats { u64 qmprc; }; +enum wx_state { + WX_STATE_RESETTING, + WX_STATE_NBITS, /* must be last */ +}; struct wx { unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; + DECLARE_BITMAP(state, WX_STATE_NBITS); void *priv; u8 __iomem *hw_addr; @@ -1071,6 +1076,8 @@ struct wx { u64 hw_csum_rx_good; u64 hw_csum_rx_error; u64 alloc_rx_buff_failed; + + void (*do_reset)(struct net_device *netdev); }; #define WX_INTR_ALL (~0ULL) @@ -1131,4 +1138,19 @@ static inline struct wx *phylink_to_wx(struct phylink_config *config) return container_of(config, struct wx, phylink_config); } +static inline int wx_set_state_reset(struct wx *wx) +{ + u8 timeout = 50; + + while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) { + timeout--; + if (!timeout) + return -EBUSY; + + usleep_range(1000, 2000); + } + + return 0; +} + #endif /* _WX_TYPE_H_ */ diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c index 786a652ae64f..46a5a3e95202 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c @@ -52,7 +52,7 @@ static int ngbe_set_ringparam(struct net_device *netdev, struct wx *wx = netdev_priv(netdev); u32 new_rx_count, new_tx_count; struct wx_ring *temp_ring; - int i; + int i, err = 0; new_tx_count = clamp_t(u32, ring->tx_pending, WX_MIN_TXD, WX_MAX_TXD); new_tx_count = ALIGN(new_tx_count, WX_REQ_TX_DESCRIPTOR_MULTIPLE); @@ -64,6 +64,10 @@ static int ngbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count) return 0; + err = wx_set_state_reset(wx); + if (err) + return err; + if (!netif_running(wx->netdev)) { for (i = 0; i < wx->num_tx_queues; i++) wx->tx_ring[i]->count = new_tx_count; @@ -72,14 +76,16 @@ static int ngbe_set_ringparam(struct net_device *netdev, wx->tx_ring_count = new_tx_count; wx->rx_ring_count = new_rx_count; - return 0; + goto clear_reset; } /* allocate temporary buffer to store rings in */ i = max_t(int, wx->num_tx_queues, wx->num_rx_queues); temp_ring = kvmalloc_array(i, sizeof(struct wx_ring), GFP_KERNEL); - if (!temp_ring) - return -ENOMEM; + if (!temp_ring) { + err = -ENOMEM; + goto clear_reset; + } ngbe_down(wx); @@ -89,7 +95,9 @@ static int ngbe_set_ringparam(struct net_device *netdev, wx_configure(wx); ngbe_up(wx); - return 0; +clear_reset: + clear_bit(WX_STATE_RESETTING, wx->state); + return err; } static int ngbe_set_channels(struct net_device *dev, diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c index db675512ce4d..31fde3fa7c6b 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c @@ -19,7 +19,7 @@ static int txgbe_set_ringparam(struct net_device *netdev, struct wx *wx = netdev_priv(netdev); u32 new_rx_count, new_tx_count; struct wx_ring *temp_ring; - int i; + int i, err = 0; new_tx_count = clamp_t(u32, ring->tx_pending, WX_MIN_TXD, WX_MAX_TXD); new_tx_count = ALIGN(new_tx_count, WX_REQ_TX_DESCRIPTOR_MULTIPLE); @@ -31,6 +31,10 @@ static int txgbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count) return 0; + err = wx_set_state_reset(wx); + if (err) + return err; + if (!netif_running(wx->netdev)) { for (i = 0; i < wx->num_tx_queues; i++) wx->tx_ring[i]->count = new_tx_count; @@ -39,14 +43,16 @@ static int txgbe_set_ringparam(struct net_device *netdev, wx->tx_ring_count = new_tx_count; wx->rx_ring_count = new_rx_count; - return 0; + goto clear_reset; } /* allocate temporary buffer to store rings in */ i = max_t(int, wx->num_tx_queues, wx->num_rx_queues); temp_ring = kvmalloc_array(i, sizeof(struct wx_ring), GFP_KERNEL); - if (!temp_ring) - return -ENOMEM; + if (!temp_ring) { + err = -ENOMEM; + goto clear_reset; + } txgbe_down(wx); @@ -55,7 +61,9 @@ static int txgbe_set_ringparam(struct net_device *netdev, txgbe_up(wx); - return 0; +clear_reset: + clear_bit(WX_STATE_RESETTING, wx->state); + return err; } static int txgbe_set_channels(struct net_device *dev, diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c index b3c0058b045d..8c7a74981b90 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c @@ -269,6 +269,8 @@ static int txgbe_sw_init(struct wx *wx) wx->tx_work_limit = TXGBE_DEFAULT_TX_WORK; wx->rx_work_limit = TXGBE_DEFAULT_RX_WORK; + wx->do_reset = txgbe_do_reset; + return 0; } @@ -421,6 +423,34 @@ int txgbe_setup_tc(struct net_device *dev, u8 tc) return 0; } +static void txgbe_reinit_locked(struct wx *wx) +{ + int err = 0; + + netif_trans_update(wx->netdev); + + err = wx_set_state_reset(wx); + if (err) { + wx_err(wx, "wait device reset timeout\n"); + return; + } + + txgbe_down(wx); + txgbe_up(wx); + + clear_bit(WX_STATE_RESETTING, wx->state); +} + +void txgbe_do_reset(struct net_device *netdev) +{ + struct wx *wx = netdev_priv(netdev); + + if (netif_running(netdev)) + txgbe_reinit_locked(wx); + else + txgbe_reset(wx); +} + static const struct net_device_ops txgbe_netdev_ops = { .ndo_open = txgbe_open, .ndo_stop = txgbe_close, diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h index 1b4ff50d5857..f434a7865cb7 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h @@ -134,6 +134,7 @@ extern char txgbe_driver_name[]; void txgbe_down(struct wx *wx); void txgbe_up(struct wx *wx); int txgbe_setup_tc(struct net_device *dev, u8 tc); +void txgbe_do_reset(struct net_device *netdev); #define NODE_PROP(_NAME, _PROP) \ (const struct software_node) { \