diff mbox series

[RFC,08/12] ravb: Add carrier_counters to struct ravb_hw_info

Message ID 20211005110642.3744-9-biju.das.jz@bp.renesas.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Add functional support for Gigabit Ethernet driver | expand

Checks

Context Check Description
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 1 maintainers not CCed: s.shtylyov@omp.ru
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Biju Das Oct. 5, 2021, 11:06 a.m. UTC
RZ/G2L E-MAC supports carrier counters.
Add a carrier_counter hw feature bit to struct ravb_hw_info
to add this feature only for RZ/G2L.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
RFC changes:
 * Added Sergey's Rb tag.
---
 drivers/net/ethernet/renesas/ravb.h      |  5 +++++
 drivers/net/ethernet/renesas/ravb_main.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)

Comments

Sergey Shtylyov Oct. 6, 2021, 4:41 p.m. UTC | #1
On 10/5/21 2:06 PM, Biju Das wrote:

> RZ/G2L E-MAC supports carrier counters.
> Add a carrier_counter hw feature bit to struct ravb_hw_info
> to add this feature only for RZ/G2L.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

[...]

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 8c7b2569c7dd..899e16c5eb1a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
[...]
@@ -1061,6 +1065,7 @@ struct ravb_hw_info {
 	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */



[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 42573eac82b9..c057de81ec58 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2075,6 +2075,18 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
>  		ravb_write(ndev, 0, TROCR);	/* (write clear) */
>  	}
>  
> +	if (info->carrier_counters) {
> +		nstats->collisions += ravb_read(ndev, CXR41);
> +		ravb_write(ndev, 0, CXR41);	/* (write clear) */
> +		nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
> +		ravb_write(ndev, 0, CXR42);	/* (write clear) */
> +
> +		nstats->tx_carrier_errors += ravb_read(ndev, CXR55);

   According to the manual, CXR55 counts RX events (carrier extension lost.

> +		ravb_write(ndev, 0, CXR55);	/* (write clear) */
> +		nstats->tx_carrier_errors += ravb_read(ndev, CXR56);

   And CXR56 counts receive events too...

> +		ravb_write(ndev, 0, CXR56);	/* (write clear) */
> +	}
> +
>  	nstats->rx_packets = stats0->rx_packets;
>  	nstats->tx_packets = stats0->tx_packets;
>  	nstats->rx_bytes = stats0->rx_bytes;
> @@ -2486,6 +2498,7 @@ static const struct ravb_hw_info gbeth_hw_info = {
>  	.aligned_tx = 1,
>  	.tx_counters = 1,
>  	.half_duplex = 1,
> +	.carrier_counters = 1,

   At least init it next to 'tx_counters'. :-)

[...]

MBR, Sergey
Sergey Shtylyov Oct. 6, 2021, 5 p.m. UTC | #2
On 10/6/21 7:41 PM, Sergey Shtylyov wrote:

>> RZ/G2L E-MAC supports carrier counters.
>> Add a carrier_counter hw feature bit to struct ravb_hw_info
>> to add this feature only for RZ/G2L.
>>
>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
>> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> [...]
> 
>> diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
>> index 8c7b2569c7dd..899e16c5eb1a 100644
>> --- a/drivers/net/ethernet/renesas/ravb.h
>> +++ b/drivers/net/ethernet/renesas/ravb.h
>> [...]
>> @@ -1061,6 +1065,7 @@ struct ravb_hw_info {
>>  	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
>>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
>>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
>> +	unsigned carrier_counters:1;	/* E-MAC has carrier counters */

   I thought I'd typed here that this field should be declared next to the 'tx_counters' field. :-)
 
[...]

MBR, Sergey
Biju Das Oct. 6, 2021, 5:21 p.m. UTC | #3
Hi Sergey,

Thanks for the feedback.

> Subject: Re: [RFC 08/12] ravb: Add carrier_counters to struct ravb_hw_info
> 
> On 10/5/21 2:06 PM, Biju Das wrote:
> 
> > RZ/G2L E-MAC supports carrier counters.
> > Add a carrier_counter hw feature bit to struct ravb_hw_info to add
> > this feature only for RZ/G2L.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> [...]
> 
> diff --git a/drivers/net/ethernet/renesas/ravb.h
> b/drivers/net/ethernet/renesas/ravb.h
> index 8c7b2569c7dd..899e16c5eb1a 100644
> --- a/drivers/net/ethernet/renesas/ravb.h
> +++ b/drivers/net/ethernet/renesas/ravb.h
> [...]
> @@ -1061,6 +1065,7 @@ struct ravb_hw_info {
>  	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet
> detection */
>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> +	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
> 
> 
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index 42573eac82b9..c057de81ec58 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -2075,6 +2075,18 @@ static struct net_device_stats
> *ravb_get_stats(struct net_device *ndev)
> >  		ravb_write(ndev, 0, TROCR);	/* (write clear) */
> >  	}
> >
> > +	if (info->carrier_counters) {
> > +		nstats->collisions += ravb_read(ndev, CXR41);
> > +		ravb_write(ndev, 0, CXR41);	/* (write clear) */
> > +		nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
> > +		ravb_write(ndev, 0, CXR42);	/* (write clear) */
> > +
> > +		nstats->tx_carrier_errors += ravb_read(ndev, CXR55);
> 
>    According to the manual, CXR55 counts RX events (carrier extension
> lost.

Agreed. will remove this from tx_carriers.

> 
> > +		ravb_write(ndev, 0, CXR55);	/* (write clear) */
> > +		nstats->tx_carrier_errors += ravb_read(ndev, CXR56);
> 
>    And CXR56 counts receive events too...

Agreed. will remove this from tx_carriers.


> 
> > +		ravb_write(ndev, 0, CXR56);	/* (write clear) */
> > +	}
> > +
> >  	nstats->rx_packets = stats0->rx_packets;
> >  	nstats->tx_packets = stats0->tx_packets;
> >  	nstats->rx_bytes = stats0->rx_bytes; @@ -2486,6 +2498,7 @@ static
> > const struct ravb_hw_info gbeth_hw_info = {
> >  	.aligned_tx = 1,
> >  	.tx_counters = 1,
> >  	.half_duplex = 1,
> > +	.carrier_counters = 1,
> 
>    At least init it next to 'tx_counters'. :-)

Agreed. wo;; move next to tx_counters.

Regards,
Biju

> 
> [...]
> 
> MBR, Sergey
Biju Das Oct. 6, 2021, 5:22 p.m. UTC | #4
Hi Sergey,

> Subject: Re: [RFC 08/12] ravb: Add carrier_counters to struct ravb_hw_info
> 
> On 10/6/21 7:41 PM, Sergey Shtylyov wrote:
> 
> >> RZ/G2L E-MAC supports carrier counters.
> >> Add a carrier_counter hw feature bit to struct ravb_hw_info to add
> >> this feature only for RZ/G2L.
> >>
> >> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> >> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> >
> > [...]
> >
> >> diff --git a/drivers/net/ethernet/renesas/ravb.h
> >> b/drivers/net/ethernet/renesas/ravb.h
> >> index 8c7b2569c7dd..899e16c5eb1a 100644
> >> --- a/drivers/net/ethernet/renesas/ravb.h
> >> +++ b/drivers/net/ethernet/renesas/ravb.h
> >> [...]
> >> @@ -1061,6 +1065,7 @@ struct ravb_hw_info {
> >>  	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
> >>  	unsigned magic_pkt:1;		/* E-MAC supports magic packet
> detection */
> >>  	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
> >> +	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
> 
>    I thought I'd typed here that this field should be declared next to the
> 'tx_counters' field. :-)

Agreed. Will move to 'tx_counters' field.

Regards,
Biju
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 8c7b2569c7dd..899e16c5eb1a 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -196,11 +196,15 @@  enum ravb_reg {
 	MAHR	= 0x05c0,
 	MALR	= 0x05c8,
 	TROCR	= 0x0700,	/* R-Car Gen3 and RZ/G2L only */
+	CXR41	= 0x0708,	/* RZ/G2L only */
+	CXR42	= 0x0710,	/* RZ/G2L only */
 	CEFCR	= 0x0740,
 	FRECR	= 0x0748,
 	TSFRCR	= 0x0750,
 	TLFRCR	= 0x0758,
 	RFCR	= 0x0760,
+	CXR55	= 0x0768,	/* RZ/G2L only */
+	CXR56	= 0x0770,	/* RZ/G2L only */
 	MAFCR	= 0x0778,
 	CSR0    = 0x0800,	/* RZ/G2L only */
 	CSR1    = 0x0804,	/* RZ/G2L only */
@@ -1061,6 +1065,7 @@  struct ravb_hw_info {
 	unsigned nc_queue:1;		/* AVB-DMAC has NC queue */
 	unsigned magic_pkt:1;		/* E-MAC supports magic packet detection */
 	unsigned half_duplex:1;		/* E-MAC supports half duplex mode */
+	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 42573eac82b9..c057de81ec58 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2075,6 +2075,18 @@  static struct net_device_stats *ravb_get_stats(struct net_device *ndev)
 		ravb_write(ndev, 0, TROCR);	/* (write clear) */
 	}
 
+	if (info->carrier_counters) {
+		nstats->collisions += ravb_read(ndev, CXR41);
+		ravb_write(ndev, 0, CXR41);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR42);
+		ravb_write(ndev, 0, CXR42);	/* (write clear) */
+
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR55);
+		ravb_write(ndev, 0, CXR55);	/* (write clear) */
+		nstats->tx_carrier_errors += ravb_read(ndev, CXR56);
+		ravb_write(ndev, 0, CXR56);	/* (write clear) */
+	}
+
 	nstats->rx_packets = stats0->rx_packets;
 	nstats->tx_packets = stats0->tx_packets;
 	nstats->rx_bytes = stats0->rx_bytes;
@@ -2486,6 +2498,7 @@  static const struct ravb_hw_info gbeth_hw_info = {
 	.aligned_tx = 1,
 	.tx_counters = 1,
 	.half_duplex = 1,
+	.carrier_counters = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {