change some statistics to 64-bit
Wei Fang
maintainercover change some statistics to 64-bit
The port MAC counters of ENETC are 64-bit registers and the statistics of ethtool are also u64 type, so add enetc_port_rd64() helper function to read 64-bit statistics from these registers, and also change the statistics of ring to unsigned long type to be consistent with the statistics type in struct net_device_stats.
Wei Fang (3):
net: enetc: change the statistics of ring to unsigned long type
net: enetc: separate 64-bit counters from enetc_port_counters
net: enetc: read 64-bit statistics from port MAC counters
drivers/net/ethernet/freescale/enetc/enetc.h | 22 ++--- .../ethernet/freescale/enetc/enetc_ethtool.c | 99 +++++++++++-------- .../net/ethernet/freescale/enetc/enetc_hw.h | 1 + 3 files changed, 68 insertions(+), 54 deletions(-)
Signature · 1 line
2.34.1
Wei Fang
maintainerPATCH 1/3 net: enetc: change the statistics of ring to unsigned long type
The statistics of the ring are all unsigned int type, so the statistics will overflow quickly under heavy traffic. In addition, the statistics of struct net_device_stats are obtained from struct enetc_ring_stats, but the statistics of net_device_stats are all unsigned long type. Considering these two factors, the statistics of enetc_ring_stats are all changed to unsigned long type.
--- drivers/net/ethernet/freescale/enetc/enetc.h | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc.h +11 -11
@@ -96,17 +96,17 @@ struct enetc_rx_swbd {#define ENETC_TXBDS_MAX_NEEDED (x) ENETC_TXBDS_NEEDED((x) + 1)struct enetc_ring_stats { -unsigned int packets; -unsigned int bytes; -unsigned int rx_alloc_errs; -unsigned int xdp_drops; -unsigned int xdp_tx; -unsigned int xdp_tx_drops; -unsigned int xdp_redirect; -unsigned int xdp_redirect_failures; -unsigned int recycles; -unsigned int recycle_failures; -unsigned int win_drop; +unsigned long packets; +unsigned long bytes; +unsigned long rx_alloc_errs; +unsigned long xdp_drops; +unsigned long xdp_tx; +unsigned long xdp_tx_drops; +unsigned long xdp_redirect; +unsigned long xdp_redirect_failures; +unsigned long recycles; +unsigned long recycle_failures; +unsigned long win_drop; };struct enetc_xdp_data {
Signature · 1 line
2.34.1
RE: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
Quoted 3 lines
-----Original Message-----
From: Wei Fang <[email protected]>
Sent: Friday, June 20, 2025 1:22 PM
[...]
Quoted 10 lines
Subject: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
The statistics of the ring are all unsigned int type, so the statistics will overflow quickly under heavy traffic. In addition, the statistics of struct
net_device_statsare obtained from structenetc_ring_stats, but the statistics ofnet_device_statsare all unsigned long type. Considering these two factors, the statistics ofenetc_ring_statsare all changed to unsigned long type.
Quoted 2 lines
Signed-off-by Wei Fang <[email protected]>---
Simon Horman
reviewerRe: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
In reply to Wei FangQuoted 33 lines · Wei Fang
The statistics of the ring are all unsigned int type, so the statistics will overflow quickly under heavy traffic. In addition, the statistics of struct
net_device_statsare obtained from structenetc_ring_stats, but the statistics ofnet_device_statsare all unsigned long type. Considering these two factors, the statistics ofenetc_ring_statsare all changed to unsigned long type.Signed-off-by Wei Fang <[email protected]>--- drivers/net/ethernet/freescale/enetc/enetc.h | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)drivers/net/ethernet/freescale/enetc/enetc.h +2
-11@@ -96,17 +96,17 @@ struct enetc_rx_swbd {#define ENETC_TXBDS_MAX_NEEDED (x) ENETC_TXBDS_NEEDED((x) + 1)struct enetc_ring_stats { -unsigned int packets; -unsigned int bytes; -unsigned int rx_alloc_errs; -unsigned int xdp_drops; -unsigned int xdp_tx; -unsigned int xdp_tx_drops; -unsigned int xdp_redirect; -unsigned int xdp_redirect_failures; -unsigned int recycles; -unsigned int recycle_failures; -unsigned int win_drop; +unsigned long packets; +unsigned long bytes;
drivers/net/ethernet/freescale/enetc/enetc.h struct enetc_rx_swbd { · line 110
Quoted 10 lines
drivers/net/ethernet/freescale/enetc/enetc.h +9
-0+unsigned long rx_alloc_errs; +unsigned long xdp_drops; +unsigned long xdp_tx; +unsigned long xdp_tx_drops; +unsigned long xdp_redirect; +unsigned long xdp_redirect_failures; +unsigned long recycles; +unsigned long recycle_failures; +unsigned long win_drop; };
Hi Wei fang,
If the desire is for an unsigned 64 bit integer, then I think either u64 or unsigned long long would be good choices.
unsigned long may be 64bit or 32bit depending on the platform.
Wei Fang
maintainerRE: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
Quoted 27 lines
Quoted 14 lines
struct
enetc_ring_stats{drivers/net/ethernet/freescale/enetc/enetc.h +2
-11-unsigned int packets; -unsigned int bytes; -unsigned int rx_alloc_errs; -unsigned int xdp_drops; -unsigned int xdp_tx; -unsigned int xdp_tx_drops; -unsigned int xdp_redirect; -unsigned int xdp_redirect_failures; -unsigned int recycles; -unsigned int recycle_failures; -unsigned int win_drop; +unsigned long packets; +unsigned long bytes;drivers/net/ethernet/freescale/enetc/enetc.h struct enetc_rx_swbd { · line 110
Quoted 10 lines
drivers/net/ethernet/freescale/enetc/enetc.h +9
-0+unsigned long rx_alloc_errs; +unsigned long xdp_drops; +unsigned long xdp_tx; +unsigned long xdp_tx_drops; +unsigned long xdp_redirect; +unsigned long xdp_redirect_failures; +unsigned long recycles; +unsigned long recycle_failures; +unsigned long win_drop; };Hi Wei fang,
Quoted 4 lines
If the desire is for an unsigned 64 bit integer, then I think either u64 or unsigned long long would be good choices.
unsigned long may be 64bit or 32bit depending on the platform.
The use of unsigned long is to keep it consistent with the statistical value type in struct net_device_stats. Because some statistics in net_device_stats come from enetc_ring_stats.
#define NET_DEV_STAT(FIELD) \
union { \
unsigned long FIELD; \
atomic_long_t __##FIELD; \
}Simon Horman
reviewerRe: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
Quoted 36 lines · Wei Fang
Quoted 27 lines
Quoted 14 lines
struct
enetc_ring_stats{drivers/net/ethernet/freescale/enetc/enetc.h +2
-11-unsigned int packets; -unsigned int bytes; -unsigned int rx_alloc_errs; -unsigned int xdp_drops; -unsigned int xdp_tx; -unsigned int xdp_tx_drops; -unsigned int xdp_redirect; -unsigned int xdp_redirect_failures; -unsigned int recycles; -unsigned int recycle_failures; -unsigned int win_drop; +unsigned long packets; +unsigned long bytes;drivers/net/ethernet/freescale/enetc/enetc.h struct enetc_rx_swbd { · line 110
Quoted 10 lines
drivers/net/ethernet/freescale/enetc/enetc.h +9
-0+unsigned long rx_alloc_errs; +unsigned long xdp_drops; +unsigned long xdp_tx; +unsigned long xdp_tx_drops; +unsigned long xdp_redirect; +unsigned long xdp_redirect_failures; +unsigned long recycles; +unsigned long recycle_failures; +unsigned long win_drop; };Hi Wei fang,
Quoted 4 lines
If the desire is for an unsigned 64 bit integer, then I think either u64 or unsigned long long would be good choices.
unsigned long may be 64bit or 32bit depending on the platform.
The use of unsigned long is to keep it consistent with the statistical value type in struct
net_device_stats. Because some statistics innet_device_statscome fromenetc_ring_stats.
Quoted 5 lines
#define NET_DEV_STAT(FIELD) \
union { \
unsigned long FIELD; \
atomic_long_t __##FIELD; \
}Thanks, I understand. But in this case I think the patch description could be reworded - unsigned int and unsigned long are the same thing on some systems, and on such systems there is no overflow advantage of one over the other.
Wei Fang
maintainerRE: [PATCH net-next 1/3] net: enetc: change the statistics of ring to unsigned long type
Quoted 44 lines · Wei Fang
Quoted 27 lines
Quoted 27 lines
Quoted 14 lines
struct
enetc_ring_stats{drivers/net/ethernet/freescale/enetc/enetc.h +2
-11-unsigned int packets; -unsigned int bytes; -unsigned int rx_alloc_errs; -unsigned int xdp_drops; -unsigned int xdp_tx; -unsigned int xdp_tx_drops; -unsigned int xdp_redirect; -unsigned int xdp_redirect_failures; -unsigned int recycles; -unsigned int recycle_failures; -unsigned int win_drop; +unsigned long packets; +unsigned long bytes;drivers/net/ethernet/freescale/enetc/enetc.h struct enetc_rx_swbd { · line 110
Quoted 10 lines
drivers/net/ethernet/freescale/enetc/enetc.h +9
-0+unsigned long rx_alloc_errs; +unsigned long xdp_drops; +unsigned long xdp_tx; +unsigned long xdp_tx_drops; +unsigned long xdp_redirect; +unsigned long xdp_redirect_failures; +unsigned long recycles; +unsigned long recycle_failures; +unsigned long win_drop; };Hi Wei fang,
Quoted 1 line
Quoted 1 line
If the desire is for an unsigned 64 bit integer, then I think either u64 or
unsigned
Quoted 8 lines
Quoted 3 lines
long long would be good choices.
unsigned long may be 64bit or 32bit depending on the platform.
The use of unsigned long is to keep it consistent with the statistical value type in struct
net_device_stats. Because some statistics innet_device_statscome fromenetc_ring_stats.Quoted 5 lines
#define NET_DEV_STAT(FIELD) \ union { \ unsigned long FIELD; \ atomic_long_t __##FIELD; \ }
Quoted 4 lines
Thanks, I understand. But in this case I think the patch description could be reworded - unsigned int and unsigned long are the same thing on some systems, and on such systems there is no overflow advantage of one over the other.
Okay, I will improve the commit message. Actually both LS1028A and i.MX95 are arm64 architecture, so for these platforms using ENETC IP, unsigned long is 64-bit.
Wei Fang
maintainerPATCH 2/3 net: enetc: separate 64-bit counters from enetc_port_counters
In reply to Wei FangSome counters in enetc_port_counters are 32-bit registers, and some are 64-bit registers. But in the current driver, they are all read through enetc_port_rd(), which can only read a 32-bit value. Therefore, separate 64-bit counters (enetc_pm_counters) from enetc_port_counters and use enetc_port_rd64() to read the 64-bit statistics.
--- .../net/ethernet/freescale/enetc/enetc_ethtool.c | 15 ++++++++++++++- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +14 -1
@@ -142,7 +142,7 @@ static const struct {static const struct {int reg; char name[ETH_GSTRING_LEN] __nonstring; -} enetc_port_counters[] = { +} enetc_pm_counters[] = { {ENETC_PM_REOCT (0 ),"MAC rx ethernet octets" }, {ENETC_PM_RALN (0 ),"MAC rx alignment errors" }, {ENETC_PM_RXPF (0 ),"MAC rx valid pause frames" },
@@ -194,6 +194,12 @@ static const struct { { ENETC_PM_TSCOL(0), "MAC tx single collisions" }, { ENETC_PM_TLCOL(0), "MAC tx late collisions" }, { ENETC_PM_TECOL(0), "MAC tx excessive collisions" }, +}; + +static const struct { +int reg; + char name[ETH_GSTRING_LEN] __nonstring; +} enetc_port_counters[] = { {ENETC_UFDMF ,"SI MAC nomatch u-cast discards" }, {ENETC_MFDMF ,"SI MAC nomatch m-cast discards" }, { ENETC_PBFDSIR, "SI MAC nomatch b-cast discards" },
@@ -240,6 +246,7 @@ static int enetc_get_sset_count(struct net_device *ndev, int sset)return len; len +=ARRAY_SIZE (enetc_port_counters); + len +=ARRAY_SIZE (enetc_pm_counters);return len; }
@@ -266,6 +273,9 @@ static void enetc_get_strings(struct net_device *ndev, u32 stringset, u8 *data)for (i =0 ; i <ARRAY_SIZE (enetc_port_counters); i++)ethtool_cpy (&data, enetc_port_counters[i].name); +for (i =0 ; i <ARRAY_SIZE (enetc_pm_counters); i++) +ethtool_cpy (&data, enetc_pm_counters[i].name); +break ; } }
@@ -302,6 +312,9 @@ static void enetc_get_ethtool_stats(struct net_device *ndev,for (i =0 ; i <ARRAY_SIZE (enetc_port_counters); i++) data[o++] =enetc_port_rd (hw, enetc_port_counters[i].reg); + +for (i =0 ; i <ARRAY_SIZE (enetc_pm_counters); i++) + data[o++] =enetc_port_rd64 (hw, enetc_pm_counters[i].reg); } static void enetc_pause_stats(struct enetc_hw *hw, int mac,
drivers/net/ethernet/freescale/enetc/enetc_hw.h +1 -0
@@ -536,6 +536,7 @@ static inline u64 _enetc_rd_reg64_wa(void __iomem *reg)/* port register accessors - PF only */ #define enetc_port_rd (hw, off) enetc_rd_reg((hw)->port + (off))#define enetc_port_wr (hw, off, val) enetc_wr_reg((hw)->port + (off), val) +#define enetc_port_rd64 (hw, off) _enetc_rd_reg64_wa((hw)->port + (off))#define enetc_port_rd_mdio (hw, off) _enetc_rd_mdio_reg_wa((hw)->port + (off))#define enetc_port_wr_mdio (hw, off, val) _enetc_wr_mdio_reg_wa(\ (hw)->port + (off), val)
Signature · 1 line
2.34.1
RE: [PATCH net-next 2/3] net: enetc: separate 64-bit counters from enetc_port_counters
Quoted 3 lines
-----Original Message-----
From: Wei Fang <[email protected]>
Sent: Friday, June 20, 2025 1:22 PM
[...]
Quoted 11 lines
Subject: [PATCH net-next 2/3] net: enetc: separate 64-bit counters from
enetc_port_countersSome counters in
enetc_port_countersare 32-bit registers, and some are 64- bit registers. But in the current driver, they are all read throughenetc_port_rd(), which can only read a 32-bit value. Therefore, separate 64- bit counters (enetc_pm_counters) fromenetc_port_countersand useenetc_port_rd64()to read the 64-bit statistics.Signed-off-by Wei Fang <[email protected]>---
Simon Horman
reviewerRe: [PATCH net-next 2/3] net: enetc: separate 64-bit counters from enetc_port_counters
In reply to Wei FangQuoted 7 lines · Wei Fang
Some counters in
enetc_port_countersare 32-bit registers, and some are 64-bit registers. But in the current driver, they are all read throughenetc_port_rd(), which can only read a 32-bit value. Therefore, separate 64-bit counters (enetc_pm_counters) fromenetc_port_countersand useenetc_port_rd64()to read the 64-bit statistics.Signed-off-by Wei Fang <[email protected]>
This patch looks fine to me, as does the following one. However, they multiple sparse warnings relating
to endianness handling in the ioread32() version of _enetc_rd_reg64().
I've collected together my thoughts on that in the form of a patch. And I'd appreciate it if we could resolve this one way or another.
From: Simon Horman <[email protected]>
Subject: [PATCH RFC net] net: enetc: Correct endianness handling in
_enetc_rd_reg64
enetc_hw.h provides two versions of _enetc_rd_reg64. One which simply calls ioread64() when available.
And another that composes the 64-bit result from ioread32() calls.
In the second case the code appears to assume that each ioread32() call returns a little-endian value. The high and the low 32 bit values are then combined to make a 64-bit value which is then converted to host byte order.
However, both the bit shift and the logical or used to combine the two 32-bit values assume that they are operating on host-byte order entities. This seems broken and I assume that the code has only been tested on little endian systems.
Correct this by converting the 32-bit little endian values to host byte order before operating on them.
Also, use little endian types to store these values, to make the logic clearer and is moreover good practice.
Flagged by Sparse
---
I have marked this as RFC as I am unsure that the above is correct.
The version of _enetc_rd_reg64() that is a trivial wrapper around ioread64() assumes that the call to ioread64() returns a host byte order value?
If that is the case then is it also the case that the ioread32() calls, in this version of _enetc_rd_reg64() also return host byte order values. And if so, it is probably sufficient for this version to keep using u32 as the type for low, high, and tmp. And simply:
return high << 32 | low; --- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc_hw.h +5 -5
@@ -502,15 +502,15 @@ static inline u64 _enetc_rd_reg64(void __iomem *reg)/* using this to read out stats on 32b systems */ static inline u64 _enetc_rd_reg64 (void __iomem *reg) { -u32 low, high, tmp; +__le32 low, high, tmp;do { - high =ioread32 (reg +4 ); - low =ioread32 (reg); - tmp =ioread32 (reg +4 ); + high = (__force __le32 )ioread32 (reg +4 ); + low = (__force __le32 )ioread32 (reg); + tmp = (__force __le32 )ioread32 (reg +4 ); }while (high != tmp); -return le64_to_cpu ((__le64 )high <<32 | low); +return (u64 )le32_to_cpu (high) <<32 |le32_to_cpu (low); }#endif
Signature · 1 line
2.47.2
Wei Fang
maintainerRE: [PATCH net-next 2/3] net: enetc: separate 64-bit counters from enetc_port_counters
Quoted 28 lines
This patch looks fine to me, as does the following one. However, they multiple sparse warnings relating
to endianness handling in theioread32()version of_enetc_rd_reg64().I've collected together my thoughts on that in the form of a patch. And I'd appreciate it if we could resolve this one way or another.
From: Simon Horman <[email protected]>
Subject: [PATCH RFC net] net: enetc: Correct endianness handling in
_enetc_rd_reg64
enetc_hw.hprovides two versions of_enetc_rd_reg64. One which simply callsioread64()when available.
And another that composes the 64-bit result fromioread32()calls.In the second case the code appears to assume that each
ioread32()call returns a little-endian value. The high and the low 32 bit values are then combined to make a 64-bit value which is then converted to host byte order.However, both the bit shift and the logical or used to combine the two 32-bit values assume that they are operating on host-byte order entities. This seems broken and I assume that the code has only been tested on little endian systems.
Correct this by converting the 32-bit little endian values to host byte order before operating on them.
Quoted 7 lines
Also, use little endian types to store these values, to make the logic clearer and is moreover good practice.
Flagged by Sparse
Fixes 69c663660b06 ("net: enetc: Correct endianness handling in
_enetc_rd_reg64")
I think the fixes tag should be:
Quoted 7 lines
Signed-off-by Simon Horman <[email protected]>---
I have marked this as RFC as I am unsure that the above is correct.The version of
_enetc_rd_reg64()that is a trivial wrapper aroundioread64()assumes that the call toioread64()returns a host byte order value?
Yes, ioread64() returns a host endian value, below is the definition of ioread64() in include/asm-generic/io.h.
static inline u64 ioread64(const volatile void __iomem *addr)
{
return readq(addr);
}static inline u64 readq(const volatile void __iomem *addr)
{
u64 val;
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
__io_ar(val);
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
return val;
}And ioread32() is also defined similarly, so ioread32() also returns a host endian value.
static inline u32 ioread32(const volatile void __iomem *addr)
{
return readl(addr);
}static inline u32 readl(const volatile void __iomem *addr)
{
u32 val;
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
__io_ar(val);
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
return val;
}Quoted 7 lines
If that is the case then is it also the case that the
ioread32()calls, in this version of_enetc_rd_reg64()also return host byte order values. And if so, it is probably sufficient for this version to keep using u32 as the type for low, high, and tmp. And simply:return high << 32 | low;
Yes, this change is enough. BTW, currently, the platforms using ENETC are all arm64, so ioread64() is used to read registers. Therefore, it does not cause any problems in actual use. However, from the driver's perspective, it should indeed be fixed. Thanks very much.
Simon Horman
reviewerRe: [PATCH net-next 2/3] net: enetc: separate 64-bit counters from enetc_port_counters
Quoted 31 lines · Wei Fang
Quoted 31 lines
This patch looks fine to me, as does the following one. However, they multiple sparse warnings relating
to endianness handling in theioread32()version of_enetc_rd_reg64().I've collected together my thoughts on that in the form of a patch. And I'd appreciate it if we could resolve this one way or another.
From: Simon Horman <[email protected]>
Subject: [PATCH RFC net] net: enetc: Correct endianness handling in
_enetc_rd_reg64
enetc_hw.hprovides two versions of_enetc_rd_reg64. One which simply callsioread64()when available.
And another that composes the 64-bit result fromioread32()calls.In the second case the code appears to assume that each
ioread32()call returns a little-endian value. The high and the low 32 bit values are then combined to make a 64-bit value which is then converted to host byte order.However, both the bit shift and the logical or used to combine the two 32-bit values assume that they are operating on host-byte order entities. This seems broken and I assume that the code has only been tested on little endian systems.
Correct this by converting the 32-bit little endian values to host byte order before operating on them.
Also, use little endian types to store these values, to make the logic clearer and is moreover good practice.
Quoted 7 lines
Quoted 4 lines
Flagged by Sparse
Fixes 69c663660b06 ("net: enetc: Correct endianness handling in
_enetc_rd_reg64")I think the fixes tag should be:
Fixes 16eb4c85c964 ("enetc: Add ethtool statistics")
Yes, thanks. I did notice that too, but somehow I managed to post the wrong tag. Oops.
Quoted 54 lines
Quoted 8 lines
Signed-off-by Simon Horman <[email protected]>---
I have marked this as RFC as I am unsure that the above is correct.The version of
_enetc_rd_reg64()that is a trivial wrapper aroundioread64()assumes that the call toioread64()returns a host byte order value?Yes,
ioread64()returns a host endian value, below is the definition ofioread64()ininclude/asm-generic/io.h.static inline u64
ioread64(const volatile void __iomem *addr){ return readq(addr); }static inline u64
readq(const volatile void __iomem *addr){ u64 val; log_read_mmio(64, addr, _THIS_IP_, _RET_IP_); __io_br(); val = __le64_to_cpu((__le64 __force)__raw_readq(addr)); __io_ar(val); log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_); return val; }And
ioread32()is also defined similarly, soioread32()also returns a host endian value.static inline u32
ioread32(const volatile void __iomem *addr){ return readl(addr); }static inline u32
readl(const volatile void __iomem *addr){ u32 val; log_read_mmio(32, addr, _THIS_IP_, _RET_IP_); __io_br(); val = __le32_to_cpu((__le32 __force)__raw_readl(addr)); __io_ar(val); log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_); return val; }Quoted 6 lines
If that is the case then is it also the case that the
ioread32()calls, in this version of_enetc_rd_reg64()also return host byte order values. And if so, it is probably sufficient for this version to keep using u32 as the type for low, high, and tmp. And simply:
Quoted 6 lines
Quoted 1 line
return high << 32 | low;Yes, this change is enough. BTW, currently, the platforms using ENETC are all arm64, so
ioread64()is used to read registers. Therefore, it does not cause any problems in actual use. However, from the driver's perspective, it should indeed be fixed. Thanks very much.
Thanks.
I'll send out an updated patch.
Wei Fang
maintainerPATCH 3/3 net: enetc: read 64-bit statistics from port MAC counters
In reply to Wei FangThe counters of port MAC are all 64-bit registers, and the statistics of ethtool are u64 type, so replace enetc_port_rd() with enetc_port_rd64() to read 64-bit statistics.
--- .../ethernet/freescale/enetc/enetc_ethtool.c | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c +42 -42
@@ -320,8 +320,8 @@ static void enetc_get_ethtool_stats(struct net_device *ndev,static void enetc_pause_stats (struct enetc_hw *hw,int mac,struct ethtool_pause_stats *pause_stats) { - pause_stats->tx_pause_frames =enetc_port_rd (hw,ENETC_PM_TXPF (mac)); - pause_stats->rx_pause_frames =enetc_port_rd (hw,ENETC_PM_RXPF (mac)); + pause_stats->tx_pause_frames =enetc_port_rd64 (hw,ENETC_PM_TXPF (mac)); + pause_stats->rx_pause_frames =enetc_port_rd64 (hw,ENETC_PM_RXPF (mac)); } static void enetc_get_pause_stats(struct net_device *ndev,
@@ -348,31 +348,31 @@ static void enetc_get_pause_stats(struct net_device *ndev,static void enetc_mac_stats (struct enetc_hw *hw,int mac,struct ethtool_eth_mac_stats *s) { - s->FramesTransmittedOK =enetc_port_rd (hw,ENETC_PM_TFRM (mac)); - s->SingleCollisionFrames =enetc_port_rd (hw,ENETC_PM_TSCOL (mac)); - s->MultipleCollisionFrames =enetc_port_rd (hw,ENETC_PM_TMCOL (mac)); - s->FramesReceivedOK =enetc_port_rd (hw,ENETC_PM_RFRM (mac)); - s->FrameCheckSequenceErrors =enetc_port_rd (hw,ENETC_PM_RFCS (mac)); - s->AlignmentErrors =enetc_port_rd (hw,ENETC_PM_RALN (mac)); - s->OctetsTransmittedOK =enetc_port_rd (hw,ENETC_PM_TEOCT (mac)); - s->FramesWithDeferredXmissions =enetc_port_rd (hw,ENETC_PM_TDFR (mac)); - s->LateCollisions =enetc_port_rd (hw,ENETC_PM_TLCOL (mac)); - s->FramesAbortedDueToXSColls =enetc_port_rd (hw,ENETC_PM_TECOL (mac)); - s->FramesLostDueToIntMACXmitError =enetc_port_rd (hw,ENETC_PM_TERR (mac)); - s->CarrierSenseErrors =enetc_port_rd (hw,ENETC_PM_TCRSE (mac)); - s->OctetsReceivedOK =enetc_port_rd (hw,ENETC_PM_REOCT (mac)); - s->FramesLostDueToIntMACRcvError =enetc_port_rd (hw,ENETC_PM_RDRNTP (mac)); - s->MulticastFramesXmittedOK =enetc_port_rd (hw,ENETC_PM_TMCA (mac)); - s->BroadcastFramesXmittedOK =enetc_port_rd (hw,ENETC_PM_TBCA (mac)); - s->MulticastFramesReceivedOK =enetc_port_rd (hw,ENETC_PM_RMCA (mac)); - s->BroadcastFramesReceivedOK =enetc_port_rd (hw,ENETC_PM_RBCA (mac)); + s->FramesTransmittedOK =enetc_port_rd64 (hw,ENETC_PM_TFRM (mac)); + s->SingleCollisionFrames =enetc_port_rd64 (hw,ENETC_PM_TSCOL (mac)); + s->MultipleCollisionFrames =enetc_port_rd64 (hw,ENETC_PM_TMCOL (mac)); + s->FramesReceivedOK =enetc_port_rd64 (hw,ENETC_PM_RFRM (mac)); + s->FrameCheckSequenceErrors =enetc_port_rd64 (hw,ENETC_PM_RFCS (mac)); + s->AlignmentErrors =enetc_port_rd64 (hw,ENETC_PM_RALN (mac)); + s->OctetsTransmittedOK =enetc_port_rd64 (hw,ENETC_PM_TEOCT (mac)); + s->FramesWithDeferredXmissions =enetc_port_rd64 (hw,ENETC_PM_TDFR (mac)); + s->LateCollisions =enetc_port_rd64 (hw,ENETC_PM_TLCOL (mac)); + s->FramesAbortedDueToXSColls =enetc_port_rd64 (hw,ENETC_PM_TECOL (mac)); + s->FramesLostDueToIntMACXmitError =enetc_port_rd64 (hw,ENETC_PM_TERR (mac)); + s->CarrierSenseErrors =enetc_port_rd64 (hw,ENETC_PM_TCRSE (mac)); + s->OctetsReceivedOK =enetc_port_rd64 (hw,ENETC_PM_REOCT (mac)); + s->FramesLostDueToIntMACRcvError =enetc_port_rd64 (hw,ENETC_PM_RDRNTP (mac)); + s->MulticastFramesXmittedOK =enetc_port_rd64 (hw,ENETC_PM_TMCA (mac)); + s->BroadcastFramesXmittedOK =enetc_port_rd64 (hw,ENETC_PM_TBCA (mac)); + s->MulticastFramesReceivedOK =enetc_port_rd64 (hw,ENETC_PM_RMCA (mac)); + s->BroadcastFramesReceivedOK =enetc_port_rd64 (hw,ENETC_PM_RBCA (mac)); }static void enetc_ctrl_stats (struct enetc_hw *hw,int mac,struct ethtool_eth_ctrl_stats *s) { - s->MACControlFramesTransmitted =enetc_port_rd (hw,ENETC_PM_TCNP (mac)); - s->MACControlFramesReceived =enetc_port_rd (hw,ENETC_PM_RCNP (mac)); + s->MACControlFramesTransmitted =enetc_port_rd64 (hw,ENETC_PM_TCNP (mac)); + s->MACControlFramesReceived =enetc_port_rd64 (hw,ENETC_PM_RCNP (mac)); }static const struct ethtool_rmon_hist_range enetc_rmon_ranges[] = {
@@ -389,26 +389,26 @@ static const struct ethtool_rmon_hist_range enetc_rmon_ranges[] = {static void enetc_rmon_stats (struct enetc_hw *hw,int mac,struct ethtool_rmon_stats *s) { - s->undersize_pkts =enetc_port_rd (hw,ENETC_PM_RUND (mac)); - s->oversize_pkts =enetc_port_rd (hw,ENETC_PM_ROVR (mac)); - s->fragments =enetc_port_rd (hw,ENETC_PM_RFRG (mac)); - s->jabbers =enetc_port_rd (hw,ENETC_PM_RJBR (mac)); - - s->hist[0 ] =enetc_port_rd (hw,ENETC_PM_R64 (mac)); - s->hist[1 ] =enetc_port_rd (hw,ENETC_PM_R127 (mac)); - s->hist[2 ] =enetc_port_rd (hw,ENETC_PM_R255 (mac)); - s->hist[3 ] =enetc_port_rd (hw,ENETC_PM_R511 (mac)); - s->hist[4 ] =enetc_port_rd (hw,ENETC_PM_R1023 (mac)); - s->hist[5 ] =enetc_port_rd (hw,ENETC_PM_R1522 (mac)); - s->hist[6 ] =enetc_port_rd (hw,ENETC_PM_R1523X (mac)); - - s->hist_tx[0 ] =enetc_port_rd (hw,ENETC_PM_T64 (mac)); - s->hist_tx[1 ] =enetc_port_rd (hw,ENETC_PM_T127 (mac)); - s->hist_tx[2 ] =enetc_port_rd (hw,ENETC_PM_T255 (mac)); - s->hist_tx[3 ] =enetc_port_rd (hw,ENETC_PM_T511 (mac)); - s->hist_tx[4 ] =enetc_port_rd (hw,ENETC_PM_T1023 (mac)); - s->hist_tx[5 ] =enetc_port_rd (hw,ENETC_PM_T1522 (mac)); - s->hist_tx[6 ] =enetc_port_rd (hw,ENETC_PM_T1523X (mac)); + s->undersize_pkts =enetc_port_rd64 (hw,ENETC_PM_RUND (mac)); + s->oversize_pkts =enetc_port_rd64 (hw,ENETC_PM_ROVR (mac)); + s->fragments =enetc_port_rd64 (hw,ENETC_PM_RFRG (mac)); + s->jabbers =enetc_port_rd64 (hw,ENETC_PM_RJBR (mac)); + + s->hist[0 ] =enetc_port_rd64 (hw,ENETC_PM_R64 (mac)); + s->hist[1 ] =enetc_port_rd64 (hw,ENETC_PM_R127 (mac)); + s->hist[2 ] =enetc_port_rd64 (hw,ENETC_PM_R255 (mac)); + s->hist[3 ] =enetc_port_rd64 (hw,ENETC_PM_R511 (mac)); + s->hist[4 ] =enetc_port_rd64 (hw,ENETC_PM_R1023 (mac)); + s->hist[5 ] =enetc_port_rd64 (hw,ENETC_PM_R1522 (mac)); + s->hist[6 ] =enetc_port_rd64 (hw,ENETC_PM_R1523X (mac)); + + s->hist_tx[0 ] =enetc_port_rd64 (hw,ENETC_PM_T64 (mac)); + s->hist_tx[1 ] =enetc_port_rd64 (hw,ENETC_PM_T127 (mac)); + s->hist_tx[2 ] =enetc_port_rd64 (hw,ENETC_PM_T255 (mac)); + s->hist_tx[3 ] =enetc_port_rd64 (hw,ENETC_PM_T511 (mac)); + s->hist_tx[4 ] =enetc_port_rd64 (hw,ENETC_PM_T1023 (mac)); + s->hist_tx[5 ] =enetc_port_rd64 (hw,ENETC_PM_T1522 (mac)); + s->hist_tx[6 ] =enetc_port_rd64 (hw,ENETC_PM_T1523X (mac)); } static void enetc_get_eth_mac_stats(struct net_device *ndev,
Signature · 1 line
2.34.1
RE: [PATCH net-next 3/3] net: enetc: read 64-bit statistics from port MAC counters
Quoted 3 lines
-----Original Message-----
From: Wei Fang <[email protected]>
Sent: Friday, June 20, 2025 1:22 PM
[...]
Quoted 9 lines
Subject: [PATCH net-next 3/3] net: enetc: read 64-bit statistics from port MAC counters
The counters of port MAC are all 64-bit registers, and the statistics of ethtool are u64 type, so replace
enetc_port_rd()withenetc_port_rd64()to read 64- bit statistics.Signed-off-by Wei Fang <[email protected]>---