netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] dpaa2-eth: add ethtool MAC counters
Date: Thu, 7 Nov 2019 02:47:58 +0100	[thread overview]
Message-ID: <20191107014758.GA8978@lunn.ch> (raw)
In-Reply-To: <1573087748-31303-1-git-send-email-ioana.ciornei@nxp.com>

On Thu, Nov 07, 2019 at 02:49:08AM +0200, Ioana Ciornei wrote:
> +void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data)
> +{
> +	struct fsl_mc_device *dpmac_dev = mac->mc_dev;
> +	int i, err;
> +	u64 value;
> +
> +	for (i = 0; i < DPAA2_MAC_NUM_STATS; i++) {
> +		err = dpmac_get_counter(mac->mc_io, 0, dpmac_dev->mc_handle,
> +					i, &value);
> +		if (err) {
> +			netdev_err(mac->net_dev,
> +				   "dpmac_get_counter error %d\n", err);
> +			return;

Hi Ioana

I've seen quite a few drivers set *data to U64_MAX when there is an
error. A value like that should stand out. The kernel message might
not be seen.

> +/**
> + * dpmac_get_counter() - Read a specific DPMAC counter
> + * @mc_io:	Pointer to opaque I/O object
> + * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
> + * @token:	Token of DPMAC object
> + * @id:		The requested counter ID
> + * @value:	Returned counter value
> + *
> + * Return:	The requested counter; '0' otherwise.
> + */
> +int dpmac_get_counter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
> +		      enum dpmac_counter_id id, u64 *value)
> +{
> +	struct dpmac_cmd_get_counter *dpmac_cmd;
> +	struct dpmac_rsp_get_counter *dpmac_rsp;
> +	struct fsl_mc_command cmd = { 0 };
> +	int err = 0;
> +
> +	cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_COUNTER,
> +					  cmd_flags,
> +					  token);
> +	dpmac_cmd = (struct dpmac_cmd_get_counter *)cmd.params;
> +	dpmac_cmd->id = id;
> +
> +	err = mc_send_command(mc_io, &cmd);
> +	if (err)
> +		return err;
> +
> +	dpmac_rsp = (struct dpmac_rsp_get_counter *)cmd.params;
> +	*value = le64_to_cpu(dpmac_rsp->counter);
> +
> +	return 0;
> +}

How expensive is getting a single value? Is there a way to just get
them all in a single command? The ethtool API always returns them all,
so maybe you can optimise the firmware API to do the same?

   Andrew

  reply	other threads:[~2019-11-07  1:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07  0:49 [PATCH net-next] dpaa2-eth: add ethtool MAC counters Ioana Ciornei
2019-11-07  1:47 ` Andrew Lunn [this message]
2019-11-07  7:34   ` Ioana Ciornei
2019-11-07 13:01     ` Andrew Lunn

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=20191107014758.GA8978@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=ioana.ciornei@nxp.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).