Skip to contentSkip to conversation

net: dlink: add Kconfig option for RMON registers

PATCH In review Moon Yeounsu 2 participants 4 messages May 19, 2025 – May 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dlink: add Kconfig option for RMON registers

This patch adds a Kconfig option to enable MMIO for RMON registers.

To read RMON registers, the code dw32(RmonStatMask, 0x0007ffff); must also be skipped, so this patch adds a preprocessor directive to that line as well.

On the D-Link DGE-550T Rev-A3, RMON statistics registers can be read correctly and statistic data can be collected. However, the behavior on other hardware is uncertain, and there may be undiscovered issues even on this device. Thus, the default setting is no, allowing users to enable it manually if necessary.

Tested-on: D-Link DGE-550T Rev-A3

---
 drivers/net/ethernet/dlink/Kconfig | 18 ++++++++++++++++++
 drivers/net/ethernet/dlink/dl2k.c  |  2 ++
 drivers/net/ethernet/dlink/dl2k.h  |  4 ++++
 3 files changed, 24 insertions(+)
drivers/net/ethernet/dlink/Kconfig +18 -0
index e9e13654812c..40c8c861c5a9 100644
@@ -32,4 +32,22 @@ config DL2K
 	  To compile this driver as a module, choose M here: the
 	  module will be called dl2k.
 
+if DL2K
+
+config DL2K_MMIO
+	bool "RMON MMIO"
+	depends on DL2K
+	default n
+	help
+	  Enable memory-mapped I/O for RMON registers.
+
+	  Since this feature may have potential issues,
+	  it should default to 'no'.
+
+	  If unsure, say N.
+
+endif # DL2K
+
 endif # NET_VENDOR_DLINK
+
+
drivers/net/ethernet/dlink/dl2k.c +2 -0
index 232e839a9d07..197142aa63ff 100644
@@ -576,7 +576,9 @@ static void rio_hw_init(struct net_device *dev)
 	dw8(TxDMAPollPeriod, 0xff);
 	dw8(RxDMABurstThresh, 0x30);
 	dw8(RxDMAUrgentThresh, 0x30);
+#ifndef MEM_MAPPING
 	dw32(RmonStatMask, 0x0007ffff);
+#endif
 	/* clear statistics */
 	clear_stats (dev);
 
drivers/net/ethernet/dlink/dl2k.h +4 -0
index 0e33e2eaae96..3a13068d89a2 100644
@@ -38,6 +38,10 @@
 #define TX_TOTAL_SIZE	TX_RING_SIZE*sizeof(struct netdev_desc)
 #define RX_TOTAL_SIZE	RX_RING_SIZE*sizeof(struct netdev_desc)
 
+#ifdef CONFIG_DL2K_MMIO
+#define MEM_MAPPING
+#endif
+
 /* Offsets to the device registers.
    Unlike software-only systems, device drivers interact with complex hardware.
    It's not useful to define symbolic names for every register bit in the
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 11 lines · On Tue, 20 May 2025 06:40:45 +0900 Moon Yeounsu wrote:

This patch adds a Kconfig option to enable MMIO for RMON registers.

To read RMON registers, the code dw32(RmonStatMask, 0x0007ffff); must also be skipped, so this patch adds a preprocessor directive to that line as well.

On the D-Link DGE-550T Rev-A3, RMON statistics registers can be read correctly and statistic data can be collected. However, the behavior on other hardware is uncertain, and there may be undiscovered issues even on this device. Thus, the default setting is no, allowing users to enable it manually if necessary.

Kconfig is not a great choice for chip specific logic. You should check some sort of chip ID register or PCI ID to match the chip version at runtime. Most users don't compile their own kernels.

Signature · 1 line
pw-bot: cr
#2 lore raw
Quoted 5 lines · Jakub Kicinski

On Tue, 20 May 2025 06:40:45 +0900 Moon Yeounsu wrote:
Kconfig is not a great choice for chip specific logic. You should check some sort of chip ID register or PCI ID to match the chip version at runtime. Most users don't compile their own kernels.

Just to confirm. are you suggesting that RMON MMIO should be enabled only on hardware known to support it correctly, instaed of exposing it via Kconfig?

Then, I'll drop the Kconfig option and enable RMON MMIO only for known-good devices via a runtime check. Currently, that's limited to DGE-550T (0x4000) with revision A3 (0x0c).

The dw32(RmonStatMask, 0x0007ffff); line will also be skipped accordingly.

Let me know if you have any concerns. Otherwise, I'll send a revisied patch.

Thank you for reviewing,
Yeounsu

maintainer
#3 lore raw
Quoted 11 lines · On Thu, 22 May 2025 15:20:55 +0900 Moon Yeounsu wrote:
Quoted 5 lines · Jakub Kicinski

On Tue, 20 May 2025 06:40:45 +0900 Moon Yeounsu wrote:
Kconfig is not a great choice for chip specific logic. You should check some sort of chip ID register or PCI ID to match the chip version at runtime. Most users don't compile their own kernels.

Just to confirm. are you suggesting that RMON MMIO should be enabled only on hardware known to support it correctly, instaed of exposing it via Kconfig?

Quoted 6 lines

Then, I'll drop the Kconfig option and enable RMON MMIO only for known-good devices via a runtime check. Currently, that's limited to DGE-550T (0x4000) with revision A3 (0x0c).

The dw32(RmonStatMask, 0x0007ffff); line will also be skipped accordingly.

Yes, sounds like that's along the lines of my suggestion.