From patchwork Tue Apr 16 06:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13631362 X-Patchwork-Delegate: kuba@kernel.org Received: from bg5.exmail.qq.com (bg5.exmail.qq.com [43.154.197.177]) (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 8EC021E49D for ; Tue, 16 Apr 2024 06:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=43.154.197.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249202; cv=none; b=cUgZuAN4zjHhMSzTTmXSPIINNVD0Fn/9p8ag74hsjjAMCFwEPFO7pe4d50H8hz8YO78dzwblluWCQEKbqyMnSPi6Xr+kXGcCiOWvBvEQKvO50/vJ+VDoUfgxPt69M7t1JE07f5e99RD06YdShqgm/Clwowd4d7d1iuKWUek3EJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249202; c=relaxed/simple; bh=84W4/VSC8EgR7MavgN14T/xjQvFRS15y3wisyIOW2NY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L6NVEduUkRrT1XLPMEDzzpEvCFCwuUtL2mfVP6kf9AEOscLCEBYlDbsk5vB8STU+tqFULFQhDsZUbzxSLQzIljWj0RO8Af/gK1NrQgyy9Z8yCNxd6gm6ZgTPJjNgk2Yjs26PYP0WN9y762wI6USkoXEoywTuxadMvWHUtEWZOuQ= 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=43.154.197.177 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: bizesmtp88t1713249008t91m9pmw X-QQ-Originating-IP: 93RTpw930k7+K8yfwIbpURyp49p/cjo1gWMfMmh1NKs= Received: from lap-jiawenwu.trustnetic.com ( [125.119.246.177]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 14:30:07 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: GiL6AMY6vMBVcNHTqizpNXH4mD01zlKK3fAVKAyHhGPOt9WjVe70g8ptoQ2Wb OBUqimIKojlfMCXPTrWS1NZnvNILPEP5fVAB2v9O1pv9KCXU1FhL2RzJnyN3GkIgSBJBxgu FfMT41rJPcJ2nx26zCb1eLpBl3M3hxpSuqbNSozt0JTFFREZO6MPUYy/nohaglJTY/mY6wg OMHeboUKXQAkl2BtiC5mhS/A/q4vQ3XSP6HADcdS/By0Y12kTu51qY4bwtKfyYCV2GtV/tH glpEpfuTwxEmZz8jjWcStv6LCkJGuLiUP3YDqJpFy0/30b1KxvzcA1jaJTuuach1Cg5PqVw KRbHqrTaVbNjWtFUM3AlSEu8+wXsYIh2Kk2UmlXJyx96a5Kh/00BzQECWsdojixqTHyX7dH moPogAqp6e4= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 13564188104620174498 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 1/5] net: wangxun: fix the incorrect display of queue number in statistics Date: Tue, 16 Apr 2024 14:29:48 +0800 Message-Id: <20240416062952.14196-2-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240416062952.14196-1-jiawenwu@trustnetic.com> References: <20240416062952.14196-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: bizesmtp: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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c index cc3bec42ed8e..3847c909ba1a 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c @@ -59,9 +59,17 @@ 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; + if (wx->num_tx_queues <= WX_NUM_RX_QUEUES) { + return WX_STATS_LEN - + (WX_NUM_RX_QUEUES - wx->num_tx_queues) * + (sizeof(struct wx_queue_stats) / sizeof(u64)) * 2; + } else { + return WX_STATS_LEN; + } default: return -EOPNOTSUPP; } @@ -70,6 +78,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 +86,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 +116,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 +131,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; From patchwork Tue Apr 16 06:29:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13631357 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) (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 C7D23EEAB for ; Tue, 16 Apr 2024 06:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.204.34.129 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249134; cv=none; b=OM9EPC3BCQkb+oZHiL+gLmvTMs5KuMEik+zPcTxcSEYzMdn92uVcrJkEW4zY5wDUqOjyqNaQiPPh1L5anPIMTXN0ajPQtYO4bymlq3uEcoWXaVqIMyigqPwKeXZpYQYzUKdA0+NBsFsjhuC6CGfDCqKPAldXfEUA/nX5ELRdEmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249134; c=relaxed/simple; bh=I9NlJCrGWYknxzFJuEAMKKNKEzn9Y6o2XipBwQOUzpU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rq8Jl/DBzVRay40N6tUygpIxkcPRwSC/lUQuCk3tUxUZSB+iX0V07uWj4O6p528Iy7+qT0XQbSZp2ULpIrzcowZDL8ksZDSvNX0r2kUHkAiNma9hZOTalkB4mJsTGRckNrnFEfWvv6NLGj4lzamGTqwpttvm6750HlfiUxkvWsA= 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.204.34.129 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: bizesmtp88t1713249012t9podm90 X-QQ-Originating-IP: 7bFxeUF4S6HrGTS4dwigIYHShdpYgT8k6TphMBVBehE= Received: from lap-jiawenwu.trustnetic.com ( [125.119.246.177]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 14:30:11 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: RmDZc/K2LPFhQoYLMgbzg3Y6Wky8qVCKu6KDAv4QzWrF5rXMOxM2No2xBObby /OwKT+EJnQJg0bc9YIz5LQlw4Dzs3vCa/yNh0NCr/Zku+kwW7yFOc1Xxa2T7myRuEeohetJ SQNDgb/WfRwP5Xc/J75jNNxchIFJZZpDKJHUF8Zqrk9YwsheDRVekyGRnf8C2d7p8llOUH4 HWr/r8CE10hNPd5e45qvdAS9rOk4GyG/1YBT1bEBRmErN51w6dVDU7610MmMVlyQWMZMazx DLypOjEeO0lRvkpwJaekY6LDEa9jrZcRqjxIPNxyRxgpcyLEyEw285YaOvZIsOitTHGT6X/ IC7NIOpQf5gc0kCb6irHMzoypArCsYpG8+2wRUOnSPckMVMjIJlBLTXPVdl1Pbsw2MZl1Yw 5uuGlaveujg= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 4555667413392080334 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 2/5] net: wangxun: fix error statistics when the device is reset Date: Tue, 16 Apr 2024 14:29:49 +0800 Message-Id: <20240416062952.14196-3-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240416062952.14196-1-jiawenwu@trustnetic.com> References: <20240416062952.14196-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: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org Add flag for reset state to avoid reading statistics when hardware is reset. Fixes: 883b5984a5d2 ("net: wangxun: add ethtool_ops for ring parameters") Signed-off-by: Jiawen Wu --- drivers/net/ethernet/wangxun/libwx/wx_hw.c | 3 +++ drivers/net/ethernet/wangxun/libwx/wx_type.h | 6 +++++ .../net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 24 +++++++++++++++---- .../ethernet/wangxun/txgbe/txgbe_ethtool.c | 24 +++++++++++++++---- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c index 945c13d1a982..e4e6a14c4efc 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c @@ -2285,6 +2285,9 @@ void wx_update_stats(struct wx *wx) u64 restart_queue = 0, tx_busy = 0; u32 i; + if (test_bit(WX_STATE_RESETTING, wx->state)) + return; + /* gather some stats to the wx struct that are per queue */ for (i = 0; i < wx->num_rx_queues; i++) { struct wx_ring *rx_ring = wx->rx_ring[i]; diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h index 1fdeb464d5f4..3726ec2fec06 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_type.h +++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h @@ -982,8 +982,14 @@ 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; diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c index 786a652ae64f..0e85c5a6633e 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c @@ -52,7 +52,8 @@ 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; + u8 timeout = 50; + 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 +65,15 @@ static int ngbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count) return 0; + while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) { + timeout--; + if (!timeout) { + err = -EBUSY; + goto clear_reset; + } + usleep_range(1000, 2000); + } + if (!netif_running(wx->netdev)) { for (i = 0; i < wx->num_tx_queues; i++) wx->tx_ring[i]->count = new_tx_count; @@ -72,14 +82,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 +101,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..216599bbf9de 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c @@ -19,7 +19,8 @@ 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; + u8 timeout = 50; + 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 +32,15 @@ static int txgbe_set_ringparam(struct net_device *netdev, new_rx_count == wx->rx_ring_count) return 0; + while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) { + timeout--; + if (!timeout) { + err = -EBUSY; + goto clear_reset; + } + usleep_range(1000, 2000); + } + if (!netif_running(wx->netdev)) { for (i = 0; i < wx->num_tx_queues; i++) wx->tx_ring[i]->count = new_tx_count; @@ -39,14 +49,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 +67,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, From patchwork Tue Apr 16 06:29:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13631359 X-Patchwork-Delegate: kuba@kernel.org Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.124.171]) (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 07E106CDB9 for ; Tue, 16 Apr 2024 06:32:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.132.124.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249155; cv=none; b=h1kUcaHnnc8mGtBraLfw0kf4iDqq4SOBTFSPk3Gk1FRWAnA80be9jPAh8+oQ9IVx3M6uEiSZLCi8wEx19HpMau0KeRzOFHVW9+tq2iDv76+GbBgqsf/VbN3QVHoyVUBlw/PO3u+0nkdCLSR1tw279LyVd51HQ3cvWeQND910x9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249155; c=relaxed/simple; bh=9Vc71un514p74x18MImyplPgW3gmr/ZFsOoF7D/k5Hw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OoJJ50BZp69Nc7RZ6XJLM6KJYSYEoV7vRFN8XT/io/bwlBSSeo0eoKaCYAUOBkHf6FhhrFfUEnjlVtfM7sycFLatw9Si+4gsED0x1ddv83r2HDQIpxLwhaK8xv9yCN3dBZqJPc5gmR8e8U87GeJUiE7GOVuXHBlYmVtJsWxumMI= 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=114.132.124.171 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: bizesmtp88t1713249016tuhlww3k X-QQ-Originating-IP: GhTBCQNHGnDOXHKa5vE6fGaGAxBW5MKgVpNTE8EEn40= Received: from lap-jiawenwu.trustnetic.com ( [125.119.246.177]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 14:30:15 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: ixaqywFXUt+DpjwdxfM/94ROoUDHF/V8xc4CCC6hEDuQj9MxkEYw0c3/tyAoM VVPmzo5Cpc5+UpKh13gUQJ+BddGaDBW5h9AvQM2O537vWUwJJHP53MCGUpJy4IgDtdjMY+T nXOuKbcVfFDGqOPQEdrkitDo8aN2BSuOp40dbgN/1+NmhbTBiLn+ZZ+/cMRFF3RmFk/y3Wg 82pPv2p6KYFMa7ey9TzufrU6EQoS6sv/QafOS30qubagqYQRbph+LVya55SpNlWCwdLHBVA GchZVSwYWHl3rXfoa0b3xp0h3MxRGmu5ejB0XzYxbf1C77s1zBL0KSwxEv+ejpofrPqpq44 YV7dQAu0J1+NxgX2eO5O5qeIwmuHB3y1Ojo3mHPLGHBOZ7mltMHHIgHonkXfPi8lBtnh4my gfCvlzXXIPY= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 13933789540555387258 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 3/5] net: wangxun: fix to change Rx features Date: Tue, 16 Apr 2024 14:29:50 +0800 Message-Id: <20240416062952.14196-4-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240416062952.14196-1-jiawenwu@trustnetic.com> References: <20240416062952.14196-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: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org Fix the issue where some Rx features cannot be changed. Fixes: 6dbedcffcf54 ("net: libwx: Implement xx_set_features ops") Signed-off-by: Jiawen Wu --- 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 6dff2c85682d..5c511feb97f2 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 Tue Apr 16 06:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13631361 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) (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 8EA593D0AF for ; Tue, 16 Apr 2024 06:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.59.177.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249182; cv=none; b=hX1cIaZc+kaZTsysSFFodspeEv+OIcynKC4UiiDj9FS9J2ZYrFwMlWhXsJFyq0Az+2K83N/iMbDS+eCxRBOmK7AsJTi7SLxLV92nzDzF9ybSAKNRQeZAl+qo6ZQXcZsvJvQgTVUiAWCqvswqwZclqE498dZmKhPECSsL67zUjNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249182; c=relaxed/simple; bh=cMtoJuC6mXMJ6I9XWtS+fLSnKo5EA6VwtZfnWXVhHVU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LgPTpD3ttYZRF9onjH30nTHCUdmgfocORQMjMTihFkuMPPAd/kkMesy37z5lNrnmoTifJ0NtaV2jurZ5oAvxB2iPkU3TjMPJH55tr4zdmuOCiCa8MyF3lcTOs79KRSf1tmbf7lvZG4713T86fk0kgSYA6kXylteps9TxBqcz+js= 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=52.59.177.22 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: bizesmtp88t1713249020tcech5fe X-QQ-Originating-IP: kDF1XfxnlAyc7CQjLZvD7ao+nLfimiy6et72c4tXpqY= Received: from lap-jiawenwu.trustnetic.com ( [125.119.246.177]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 14:30:19 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: zA8e95lMvfBVGbMhaDo6YOp9xZoUCZNiD1mnA2PypbB2pCx9nKbkQ6v39dzFc Oo3IOL8U5Mdn4DrNG8gfrB38IgMQFZtfnR+nQH5ofHMrzIWMTgXfQ8cZkGHkG904PPdJAfx Vhjl55y44nXOSBVd+xrkm10nbuLHFFOUNa8cboMIIGixDSD7DBybhFYRa/RBWz/y9PKnTlN UrlhRNLTayH1y5HIAqxTgKUtLqNSYlA4HgdHCIlfWUD06T5hWT0nPFXxNvJaD10iT9hkwrb Dpn3cxS8hduC+7+o05wbP5ijjyiZigdqTR9OK2AzSO0f7ltcqOEpOHVDt+3SbrTlxduLece 5rH2Qv0zv+fwKD3GE5meRPG/H7pZ8lXGet24WGafIfglnVP6sH558A9eh6OuENgJVeyKKUG kUD77qVmc4o= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 2951019120719600918 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 4/5] net: wangxun: change NETIF_F_HW_VLAN_STAG_* to fixed features Date: Tue, 16 Apr 2024 14:29:51 +0800 Message-Id: <20240416062952.14196-5-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240416062952.14196-1-jiawenwu@trustnetic.com> References: <20240416062952.14196-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: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz8a-1 X-Patchwork-Delegate: kuba@kernel.org Because the hardware doesn't support the configuration of VLAN STAG, remove NETIF_F_HW_VLAN_STAG_* in netdev->features, and set their state to be consistent with NETIF_F_HW_VLAN_CTAG_*. Fixes: 6670f1ece2c8 ("net: txgbe: Add netdev features support") Signed-off-by: Jiawen Wu --- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 22 +++++++++++++++++++ drivers/net/ethernet/wangxun/libwx/wx_lib.h | 2 ++ drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 6 ++++- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 5 ++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c index 5c511feb97f2..40612cd29f1b 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c @@ -2701,6 +2701,28 @@ 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) +{ + if (features & NETIF_F_HW_VLAN_CTAG_FILTER) + features |= NETIF_F_HW_VLAN_STAG_FILTER; + else + features &= ~NETIF_F_HW_VLAN_STAG_FILTER; + + if (features & NETIF_F_HW_VLAN_CTAG_RX) + features |= NETIF_F_HW_VLAN_STAG_RX; + else + features &= ~NETIF_F_HW_VLAN_STAG_RX; + + if (features & NETIF_F_HW_VLAN_CTAG_TX) + features |= NETIF_F_HW_VLAN_STAG_TX; + else + features &= ~NETIF_F_HW_VLAN_STAG_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..12e47a1056d7 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, @@ -584,7 +585,10 @@ static int ngbe_probe(struct pci_dev *pdev, NETIF_F_RXHASH | NETIF_F_RXCSUM; netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_TSO_MANGLEID; netdev->vlan_features |= netdev->features; - netdev->features |= NETIF_F_IPV6_CSUM | NETIF_F_VLAN_FEATURES; + netdev->features |= NETIF_F_IPV6_CSUM; + netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | + NETIF_F_HW_VLAN_CTAG_RX | + NETIF_F_HW_VLAN_CTAG_TX; /* copy netdev features into list of user selectable features */ netdev->hw_features |= netdev->features | NETIF_F_RXALL; netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC; diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c index bd4624d14ca0..af0c548e52b0 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, @@ -547,7 +548,9 @@ static int txgbe_probe(struct pci_dev *pdev, netdev->features |= NETIF_F_SCTP_CRC; netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID; netdev->hw_enc_features |= netdev->vlan_features; - netdev->features |= NETIF_F_VLAN_FEATURES; + netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | + NETIF_F_HW_VLAN_CTAG_RX | + NETIF_F_HW_VLAN_CTAG_TX; /* copy netdev features into list of user selectable features */ netdev->hw_features |= netdev->features | NETIF_F_RXALL; netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC; From patchwork Tue Apr 16 06:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiawen Wu X-Patchwork-Id: 13631360 X-Patchwork-Delegate: kuba@kernel.org Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) (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 0022C3C47B for ; Tue, 16 Apr 2024 06:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.169.211.239 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249176; cv=none; b=fnkKJvJxFqxmnT494rLQfFAyXF324Y/6YBFu2IhFMhfjsnfy917rtdbNjb1if6h1hr/o0OZeU4+ji0QXYXKiLtaoWqZleZ4dT88mbQdZ3/bAAw1wusJrGdWs+fRNJZ7kNhB/OBabmkve6c6QZ8RZ7F9vPXGN4onzvVcI9PWLLQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713249176; c=relaxed/simple; bh=RtDbcB3T6m5txUI3o5zIcLhepWvDcWLRA7i0gtrHFIU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H8qNpeuGdfiHOAMyVTiyJn+T70nDIi4bPGKeqLLxu7cinHk3FGJck7R+KInunwO+E2HKJuS07cZKWDcSW8mIEbybX/VRIf8EipGDnc6UyaPqr8V+HghZxnqjKtjaqR+GjA6/thMIcKpMEtOFqsy0IhpRRVIdVyVB8j7IyZfk2iY= 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.169.211.239 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: bizesmtp88t1713249024t513y8j7 X-QQ-Originating-IP: YZFoSH9SVRKmEZuUcZzA+Rs3eZ3enCvBP0+6cEUIOOQ= Received: from lap-jiawenwu.trustnetic.com ( [125.119.246.177]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 14:30:22 +0800 (CST) X-QQ-SSF: 01400000000000L0Z000000A0000000 X-QQ-FEAT: YaLN/l1zgncoql3tWHXgwYKM1W3JEmEzeWXiU1FAlom5rNwf5ftk4HZWnMriA XzbADm7jMfPoJ/63KihfmYBTrg+eoIeMuBRQ/iSqQzpfszhkmjQc8xuHN+cghjAuNCxUQYx Y+PjEiQ1m5dL1OClh+kVFDxo4rmzTNGWrdzDzLZlb4cQ/xRWzr7ek7ztYOi7ks+9U32coS8 jXNIoFNkjZ9HhD8RtfcZAySw6WT2tto2j+d2isqAFEDFuJliMgqZTAiNnyrw6jFpU0VvLeK tqN/jyDrg1L72DYHKG0C1GGZOrorbCUSuC+b/nm32bVIIN4t0S4XSdBGZsRka9Xuk9ypmxE hvo715J4DwE4XUyE8Qn95rgkKhQyN4vpIMf8mgL4u2qWu8uWC/tTgnmcB69NYNvFXZkHO4F hOskqiTjAZg= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 18092454218291556876 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 5/5] net: txgbe: fix to control VLAN strip Date: Tue, 16 Apr 2024 14:29:52 +0800 Message-Id: <20240416062952.14196-6-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20240416062952.14196-1-jiawenwu@trustnetic.com> References: <20240416062952.14196-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: bizesmtp: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 --- .../net/ethernet/wangxun/txgbe/txgbe_main.c | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c index af0c548e52b0..2a6b35036fce 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_main.c @@ -421,13 +421,69 @@ int txgbe_setup_tc(struct net_device *dev, u8 tc) return 0; } +static void txgbe_reinit_locked(struct wx *wx) +{ + u8 timeout = 50; + + netif_trans_update(wx->netdev); + + while (test_and_set_bit(WX_STATE_RESETTING, wx->state)) { + timeout--; + if (!timeout) { + wx_err(wx, "wait device reset timeout\n"); + goto clear_reset; + } + usleep_range(1000, 2000); + } + + txgbe_down(wx); + txgbe_up(wx); + +clear_reset: + clear_bit(WX_STATE_RESETTING, wx->state); +} + +static 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 int txgbe_set_features(struct net_device *netdev, netdev_features_t features) +{ + netdev_features_t changed = netdev->features ^ features; + struct wx *wx = netdev_priv(netdev); + + if (features & NETIF_F_RXHASH) { + wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN, + WX_RDB_RA_CTL_RSS_EN); + wx->rss_enabled = true; + } else { + wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN, 0); + wx->rss_enabled = false; + } + + netdev->features = features; + + if (changed & NETIF_F_HW_VLAN_CTAG_RX) + txgbe_do_reset(netdev); + else if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) + wx_set_rx_mode(netdev); + + return 0; +} + static const struct net_device_ops txgbe_netdev_ops = { .ndo_open = txgbe_open, .ndo_stop = txgbe_close, .ndo_change_mtu = wx_change_mtu, .ndo_start_xmit = wx_xmit_frame, .ndo_set_rx_mode = wx_set_rx_mode, - .ndo_set_features = wx_set_features, + .ndo_set_features = txgbe_set_features, .ndo_fix_features = wx_fix_features, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = wx_set_mac,