lkml.org 
[lkml]   [2023]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC net-next v3 5/6] net: phy: nxp-c45-tja11xx: add MACsec statistics
From


On 11.09.2023 15:00, Sabrina Dubroca wrote:
> 2023-09-06, 19:01:33 +0300, Radu Pirea (NXP OSS) wrote:
>> +
>> + nxp_c45_macsec_read(phydev, MACSEC_OPUS, &reg);
>> + dev_stats->OutPktsUntagged = reg;
>
> Can you read directly into OutPktsUntagged? It would make the code a
> little bit more readable.
>
> It's a bit unfortunate that all those stats read turn into 2 (or 4 for
> the 64b counters) reads. If the HW's value can be incremented while
> we're reading it we'll see an inconsistent value :(
>

The 32b reads are consistent. The inconsistency may appear when the
lower half of a 64b register overflows.

>> +
>> + nxp_c45_macsec_read(phydev, MACSEC_OOE1HS, &reg);
>> + stats->OutOctetsEncrypted = (u64)reg << 32;
>> + nxp_c45_macsec_read(phydev, MACSEC_OOE2HS, &reg);
>> + stats->OutOctetsEncrypted |= reg;
>
> Since you have a few 64b HW counters, I'd suggest a helper:
>
> stats->OutOctetsEncrypted = nxp_c45_macsec_read64(phydev, MACSEC_OOE1HS, MACSEC_OOE2HS);
>
>
> Or (more consistent with the 32b reads):
>
> nxp_c45_macsec_read64(phydev, MACSEC_OOE1HS, MACSEC_OOE2HS, &stats->OutOctetsEncrypted);
>
>

I will add two helper:
- nxp_c45_macsec_read32_64 - read 32bit counter into u64
- nxp_c45_macsec_read64 - read 64bit counter into u64

--
Radu P.

\
 
 \ /
  Last update: 2023-09-12 00:11    [W:0.152 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site