diff mbox series

[net-next,v3] r8169: use the extended tally counter available from RTL8125

Message ID a3b9d8d5-55e3-4881-ac47-aa98d1a86532@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] r8169: use the extended tally counter available from RTL8125 | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 5 maintainers not CCed: llvm@lists.linux.dev ndesaulniers@google.com nathan@kernel.org justinstitt@google.com morbo@google.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-12--12-00 (tests: 777)

Commit Message

Heiner Kallweit Oct. 11, 2024, 12:40 p.m. UTC
The new hw stat fields partially duplicate existing fields, but with a
larger field size now. Use these new fields to reduce the risk of
overflows. In addition add support for relevant new fields which are
available from RTL8125 only.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- added code for enabling the extended tally counter
- included relevant new fields 
v3:
- fixed a clang compiler warning
---
 drivers/net/ethernet/realtek/r8169_main.c | 40 ++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Oct. 11, 2024, 10:58 p.m. UTC | #1
On Fri, 11 Oct 2024 14:40:58 +0200 Heiner Kallweit wrote:
> +static const char rtl8125_gstrings[][ETH_GSTRING_LEN] = {
> +	"tx_bytes",
> +	"rx_bytes",

these I presume are covered by @get_eth_mac_stats ?

> +	"tx_pause_on",
> +	"tx_pause_off",
> +	"rx_pause_on",
> +	"rx_pause_off",

and if you want to add custom pause string you should first
implement @get_pause_stats
Heiner Kallweit Oct. 12, 2024, 9:43 p.m. UTC | #2
On 12.10.2024 00:58, Jakub Kicinski wrote:
> On Fri, 11 Oct 2024 14:40:58 +0200 Heiner Kallweit wrote:
>> +static const char rtl8125_gstrings[][ETH_GSTRING_LEN] = {
>> +	"tx_bytes",
>> +	"rx_bytes",
> 
> these I presume are covered by @get_eth_mac_stats ?
> 
>> +	"tx_pause_on",
>> +	"tx_pause_off",
>> +	"rx_pause_on",
>> +	"rx_pause_off",
> 
> and if you want to add custom pause string you should first
> implement @get_pause_stats

Thanks for the hints!
Heiner Kallweit Oct. 14, 2024, 8:48 p.m. UTC | #3
On 12.10.2024 00:58, Jakub Kicinski wrote:
> On Fri, 11 Oct 2024 14:40:58 +0200 Heiner Kallweit wrote:
>> +static const char rtl8125_gstrings[][ETH_GSTRING_LEN] = {
>> +	"tx_bytes",
>> +	"rx_bytes",
> 
> these I presume are covered by @get_eth_mac_stats ?
> 
>> +	"tx_pause_on",
>> +	"tx_pause_off",
>> +	"rx_pause_on",
>> +	"rx_pause_off",
> 
> and if you want to add custom pause string you should first
> implement @get_pause_stats

Please disregard this patch. Its successor is "r8169: implement
additional ethtool stats ops". I didn't make this a new version
of the original patch because the scope is quite different.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 1a2322824..8d869f757 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -1777,11 +1777,26 @@  static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
 	"tx_underrun",
 };
 
+static const char rtl8125_gstrings[][ETH_GSTRING_LEN] = {
+	"tx_bytes",
+	"rx_bytes",
+	"tx_pause_on",
+	"tx_pause_off",
+	"rx_pause_on",
+	"rx_pause_off",
+};
+
 static int rtl8169_get_sset_count(struct net_device *dev, int sset)
 {
+	struct rtl8169_private *tp = netdev_priv(dev);
+
 	switch (sset) {
 	case ETH_SS_STATS:
-		return ARRAY_SIZE(rtl8169_gstrings);
+		if (rtl_is_8125(tp))
+			return ARRAY_SIZE(rtl8169_gstrings) +
+			       ARRAY_SIZE(rtl8125_gstrings);
+		else
+			return ARRAY_SIZE(rtl8169_gstrings);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -1873,13 +1888,33 @@  static void rtl8169_get_ethtool_stats(struct net_device *dev,
 	data[10] = le32_to_cpu(counters->rx_multicast);
 	data[11] = le16_to_cpu(counters->tx_aborted);
 	data[12] = le16_to_cpu(counters->tx_underrun);
+
+	if (rtl_is_8125(tp)) {
+		data[5] = le32_to_cpu(counters->align_errors32);
+		data[10] = le64_to_cpu(counters->rx_multicast64);
+		data[11] = le32_to_cpu(counters->tx_aborted32);
+		data[12] = le32_to_cpu(counters->tx_underrun32);
+
+		data[13] = le64_to_cpu(counters->tx_octets);
+		data[14] = le64_to_cpu(counters->rx_octets);
+		data[15] = le32_to_cpu(counters->tx_pause_on);
+		data[16] = le32_to_cpu(counters->tx_pause_off);
+		data[17] = le32_to_cpu(counters->rx_pause_on);
+		data[18] = le32_to_cpu(counters->rx_pause_off);
+	}
 }
 
 static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
+	struct rtl8169_private *tp = netdev_priv(dev);
+
 	switch(stringset) {
 	case ETH_SS_STATS:
 		memcpy(data, rtl8169_gstrings, sizeof(rtl8169_gstrings));
+		if (rtl_is_8125(tp)) {
+			data += sizeof(rtl8169_gstrings);
+			memcpy(data, rtl8125_gstrings, sizeof(rtl8125_gstrings));
+		}
 		break;
 	}
 }
@@ -3894,6 +3929,9 @@  static void rtl_hw_start_8125(struct rtl8169_private *tp)
 		break;
 	}
 
+	/* enable extended tally counter */
+	r8168_mac_ocp_modify(tp, 0xea84, 0, BIT(1) | BIT(0));
+
 	rtl_hw_config(tp);
 }