diff mbox series

[net-next,1/3] net: ethernet: am65-cpsw: Add standard Ethernet MAC stats to ethtool

Message ID 20231113110708.137379-2-rogerq@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: am65-cpsw: Add ethtool standard MAC stats | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
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: 8 this patch: 8
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns WARNING: line length of 83 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

Commit Message

Roger Quadros Nov. 13, 2023, 11:07 a.m. UTC
Gets 'ethtool -S eth0 --groups eth-mac' command to work.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 26 +++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Andrew Lunn Nov. 13, 2023, 1:26 p.m. UTC | #1
On Mon, Nov 13, 2023 at 01:07:06PM +0200, Roger Quadros wrote:
> Gets 'ethtool -S eth0 --groups eth-mac' command to work.
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Simon Horman Nov. 13, 2023, 4:42 p.m. UTC | #2
On Mon, Nov 13, 2023 at 01:07:06PM +0200, Roger Quadros wrote:
> Gets 'ethtool -S eth0 --groups eth-mac' command to work.
> 
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>  drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 26 +++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
> index c51e2af91f69..ac7276f0f77a 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
> @@ -662,6 +662,31 @@ static void am65_cpsw_get_ethtool_stats(struct net_device *ndev,
>  					hw_stats[i].offset);
>  }
>  
> +static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
> +					struct ethtool_eth_mac_stats *s)
> +{
> +	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
> +	struct am65_cpsw_stats_regs *stats;

Hi Roger,

I think that stats needs an __iomem annotation
to address the issues flagged by Sparse.

drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15: warning: incorrect type in assignment (different address spaces)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15:    expected struct am65_cpsw_stats_regs *stats
drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15:    got void [noderef] __iomem *stat_base
drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34: warning: incorrect type in argument 1 (different address spaces)
drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34:    expected void const volatile [noderef] __iomem *addr
drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34:    got unsigned int *
...

> +
> +	stats = port->stat_base;
> +
> +	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
> +	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
> +	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
> +	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
> +	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
> +	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
> +	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
> +	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
> +	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
> +	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
> +	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
> +	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
> +	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
> +	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
> +	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
> +};
> +
>  static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
>  					 struct ethtool_ts_info *info)
>  {

...
Roger Quadros Nov. 14, 2023, 12:06 p.m. UTC | #3
On 13/11/2023 18:42, Simon Horman wrote:
> On Mon, Nov 13, 2023 at 01:07:06PM +0200, Roger Quadros wrote:
>> Gets 'ethtool -S eth0 --groups eth-mac' command to work.
>>
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
>> ---
>>  drivers/net/ethernet/ti/am65-cpsw-ethtool.c | 26 +++++++++++++++++++++
>>  1 file changed, 26 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>> index c51e2af91f69..ac7276f0f77a 100644
>> --- a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>> +++ b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
>> @@ -662,6 +662,31 @@ static void am65_cpsw_get_ethtool_stats(struct net_device *ndev,
>>  					hw_stats[i].offset);
>>  }
>>  
>> +static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
>> +					struct ethtool_eth_mac_stats *s)
>> +{
>> +	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
>> +	struct am65_cpsw_stats_regs *stats;
> 
> Hi Roger,
> 
> I think that stats needs an __iomem annotation
> to address the issues flagged by Sparse.
> 
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15: warning: incorrect type in assignment (different address spaces)
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15:    expected struct am65_cpsw_stats_regs *stats
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:671:15:    got void [noderef] __iomem *stat_base
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34: warning: incorrect type in argument 1 (different address spaces)
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34:    expected void const volatile [noderef] __iomem *addr
> drivers/net/ethernet/ti/am65-cpsw-ethtool.c:673:34:    got unsigned int *
> ...

Thanks for the catch Simon.
I'll fix it up.

> 
>> +
>> +	stats = port->stat_base;
>> +
>> +	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
>> +	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
>> +	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
>> +	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
>> +	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
>> +	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
>> +	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
>> +	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
>> +	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
>> +	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
>> +	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
>> +	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
>> +	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
>> +	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
>> +	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
>> +};
>> +
>>  static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
>>  					 struct ethtool_ts_info *info)
>>  {
> 
> ...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
index c51e2af91f69..ac7276f0f77a 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-ethtool.c
@@ -662,6 +662,31 @@  static void am65_cpsw_get_ethtool_stats(struct net_device *ndev,
 					hw_stats[i].offset);
 }
 
+static void am65_cpsw_get_eth_mac_stats(struct net_device *ndev,
+					struct ethtool_eth_mac_stats *s)
+{
+	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
+	struct am65_cpsw_stats_regs *stats;
+
+	stats = port->stat_base;
+
+	s->FramesTransmittedOK = readl_relaxed(&stats->tx_good_frames);
+	s->SingleCollisionFrames = readl_relaxed(&stats->tx_single_coll_frames);
+	s->MultipleCollisionFrames = readl_relaxed(&stats->tx_mult_coll_frames);
+	s->FramesReceivedOK = readl_relaxed(&stats->rx_good_frames);
+	s->FrameCheckSequenceErrors = readl_relaxed(&stats->rx_crc_errors);
+	s->AlignmentErrors = readl_relaxed(&stats->rx_align_code_errors);
+	s->OctetsTransmittedOK = readl_relaxed(&stats->tx_octets);
+	s->FramesWithDeferredXmissions = readl_relaxed(&stats->tx_deferred_frames);
+	s->LateCollisions = readl_relaxed(&stats->tx_late_collisions);
+	s->CarrierSenseErrors = readl_relaxed(&stats->tx_carrier_sense_errors);
+	s->OctetsReceivedOK = readl_relaxed(&stats->rx_octets);
+	s->MulticastFramesXmittedOK = readl_relaxed(&stats->tx_multicast_frames);
+	s->BroadcastFramesXmittedOK = readl_relaxed(&stats->tx_broadcast_frames);
+	s->MulticastFramesReceivedOK = readl_relaxed(&stats->rx_multicast_frames);
+	s->BroadcastFramesReceivedOK = readl_relaxed(&stats->rx_broadcast_frames);
+};
+
 static int am65_cpsw_get_ethtool_ts_info(struct net_device *ndev,
 					 struct ethtool_ts_info *info)
 {
@@ -729,6 +754,7 @@  const struct ethtool_ops am65_cpsw_ethtool_ops_slave = {
 	.get_sset_count		= am65_cpsw_get_sset_count,
 	.get_strings		= am65_cpsw_get_strings,
 	.get_ethtool_stats	= am65_cpsw_get_ethtool_stats,
+	.get_eth_mac_stats	= am65_cpsw_get_eth_mac_stats,
 	.get_ts_info		= am65_cpsw_get_ethtool_ts_info,
 	.get_priv_flags		= am65_cpsw_get_ethtool_priv_flags,
 	.set_priv_flags		= am65_cpsw_set_ethtool_priv_flags,