From: Sabrina Dubroca <sd@queasysnail.net>
To: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@oss.nxp.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, richardcochran@gmail.com,
sebastian.tobuschat@nxp.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC net-next v3 5/6] net: phy: nxp-c45-tja11xx: add MACsec statistics
Date: Mon, 11 Sep 2023 14:00:51 +0200 [thread overview]
Message-ID: <ZP8Bc0KLTthSiKD-@hog> (raw)
In-Reply-To: <20230906160134.311993-6-radu-nicolae.pirea@oss.nxp.com>
2023-09-06, 19:01:33 +0300, Radu Pirea (NXP OSS) wrote:
> +static int nxp_c45_mdo_get_dev_stats(struct macsec_context *ctx)
> +{
> + struct phy_device *phydev = ctx->phydev;
> + struct nxp_c45_phy *priv = phydev->priv;
> + struct macsec_dev_stats *dev_stats;
> + struct nxp_c45_secy *phy_secy;
> + u32 reg = 0;
> +
> + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci);
> + if (IS_ERR(phy_secy))
> + return PTR_ERR(phy_secy);
> +
> + dev_stats = ctx->stats.dev_stats;
> + nxp_c45_select_secy(phydev, phy_secy->secy_id);
> +
> + nxp_c45_macsec_read(phydev, MACSEC_OPUS, ®);
> + 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 :(
> + nxp_c45_macsec_read(phydev, MACSEC_OPTLS, ®);
> + dev_stats->OutPktsTooLong = reg;
> + nxp_c45_macsec_read(phydev, MACSEC_INPBTS, ®);
> + dev_stats->InPktsBadTag = reg;
> +
> + nxp_c45_macsec_read(phydev, MACSEC_INPWTS, ®);
> + if (phy_secy->secy->validate_frames == MACSEC_VALIDATE_STRICT)
> + dev_stats->InPktsNoTag += reg;
> + else
> + dev_stats->InPktsUntagged += reg;
> +
> + nxp_c45_macsec_read(phydev, MACSEC_IPSNFS, ®);
> + if (phy_secy->secy->validate_frames == MACSEC_VALIDATE_STRICT)
> + dev_stats->InPktsNoSCI += reg;
> + else
> + dev_stats->InPktsUnknownSCI += reg;
> +
> + /* Always 0. */
> + dev_stats->InPktsOverrun = 0;
> +
> + return 0;
> +}
> +
> +static int nxp_c45_mdo_get_tx_sc_stats(struct macsec_context *ctx)
> +{
> + struct phy_device *phydev = ctx->phydev;
> + struct nxp_c45_phy *priv = phydev->priv;
> + struct macsec_tx_sa_stats tx_sa_stats;
> + struct macsec_tx_sc_stats *stats;
> + struct nxp_c45_secy *phy_secy;
> + struct nxp_c45_sa *pos, *tmp;
> + u32 reg = 0;
> +
> + phy_secy = nxp_c45_find_secy(&priv->macsec->secy_list, ctx->secy->sci);
> + if (IS_ERR(phy_secy))
> + return PTR_ERR(phy_secy);
> +
> + stats = ctx->stats.tx_sc_stats;
> + nxp_c45_select_secy(phydev, phy_secy->secy_id);
> +
> + nxp_c45_macsec_read(phydev, MACSEC_OOE1HS, ®);
> + stats->OutOctetsEncrypted = (u64)reg << 32;
> + nxp_c45_macsec_read(phydev, MACSEC_OOE2HS, ®);
> + 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);
--
Sabrina
next prev parent reply other threads:[~2023-09-11 22:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 16:01 [RFC net-next v3 0/6] Add MACsec support for TJA11XX C45 PHYs Radu Pirea (NXP OSS)
2023-09-06 16:01 ` [RFC net-next v3 1/6] net: macsec: move sci_to_cpu to macsec header Radu Pirea (NXP OSS)
2023-09-06 16:01 ` [RFC net-next v3 2/6] net: macsec: documentation for macsec_context and macsec_ops Radu Pirea (NXP OSS)
2023-09-06 16:01 ` [RFC net-next v3 3/6] net: macsec: introduce mdo_insert_tx_tag Radu Pirea (NXP OSS)
2023-09-06 16:01 ` [RFC net-next v3 4/6] net: phy: nxp-c45-tja11xx: add MACsec support Radu Pirea (NXP OSS)
2023-09-07 15:00 ` Simon Horman
2023-09-08 6:55 ` Radu Pirea (OSS)
2023-09-11 12:00 ` Sabrina Dubroca
2023-09-11 15:57 ` Radu Pirea (OSS)
2023-09-06 16:01 ` [RFC net-next v3 5/6] net: phy: nxp-c45-tja11xx: add MACsec statistics Radu Pirea (NXP OSS)
2023-09-11 12:00 ` Sabrina Dubroca [this message]
2023-09-11 15:04 ` Radu Pirea (OSS)
2023-09-06 16:01 ` [RFC net-next v3 6/6] net: phy: nxp-c45-tja11xx: implement mdo_insert_tx_tag Radu Pirea (NXP OSS)
2023-09-07 15:04 ` Simon Horman
2023-09-08 6:09 ` Radu Pirea (OSS)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZP8Bc0KLTthSiKD-@hog \
--to=sd@queasysnail.net \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radu-nicolae.pirea@oss.nxp.com \
--cc=richardcochran@gmail.com \
--cc=sebastian.tobuschat@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.