All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Michal Kubecek <mkubecek@suse.cz>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Xiaoliang Yang <xiaoliang.yang_1@nxp.com>,
	Petr Machata <petrm@nvidia.com>,
	Danielle Ratson <danieller@nvidia.com>,
	Pranavi Somisetty <pranavi.somisetty@amd.com>,
	Harini Katakam <harini.katakam@amd.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Gerhard Engleder <gerhard@engleder-embedded.com>,
	Ferenc Fejes <ferenc.fejes@ericsson.com>,
	Aaron Conole <aconole@redhat.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net-next 3/9] net: enetc: only commit preemptible TCs to hardware when MM TX is active
Date: Thu, 20 Apr 2023 18:49:25 +0200	[thread overview]
Message-ID: <ZEFtFX9LXxcc+Umn@corigine.com> (raw)
In-Reply-To: <20230420163453.4moc7ie327g5rgfn@skbuf>

On Thu, Apr 20, 2023 at 07:34:53PM +0300, Vladimir Oltean wrote:
> On Thu, Apr 20, 2023 at 04:42:52PM +0200, Simon Horman wrote:
> > > +	/* This will time out after the standard value of 3 verification
> > > +	 * attempts. To not sleep forever, it relies on a non-zero verify_time,
> > > +	 * guarantee which is provided by the ethtool nlattr policy.
> > > +	 */
> > > +	return read_poll_timeout(enetc_port_rd, val,
> > > +				 ENETC_MMCSR_GET_VSTS(val) == 3,
> > 
> > nit: 3 is doing a lot of work here.
> >      As a follow-up, perhaps it could become part of an enum?
> 
> IMHO it's easy to abuse enums, when numbers could do just fine. I think
> that in context (seeing the entire enetc_ethtool.c), this is not as bad
> as just this patch makes it to be, because the other occurrence of
> ENETC_MMCSR_GET_VSTS() is:
> 
> 	switch (ENETC_MMCSR_GET_VSTS(val)) {
> 	case 0:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED;
> 		break;
> 	case 2:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING;
> 		break;
> 	case 3:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;
> 		break;
> 	case 4:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED;
> 		break;
> 	case 5:
> 	default:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;
> 		break;
> 	}
> 
> so it's immediately clear what the 3 represents (in vim I just press '*'
> to see the other occurrences of ENETC_MMCSR_GET_VSTS).

Thanks.

I did see the code above, and I do agree it is informational
wrt the meaning of the values.

> I considered it, but I don't feel an urgent necessity to add an enum here.
> Doing that would essentially transform the code into:
> 
> 	return read_poll_timeout(enetc_port_rd, val,
> 				 ENETC_MMCSR_GET_VSTS(val) == ENETC_MM_VSTS_SUCCEEDED,
> 
> 	switch (ENETC_MMCSR_GET_VSTS(val)) {
> 	case ENETC_MMCSR_VSTS_DISABLED:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_DISABLED;
> 		break;
> 	case ENETC_MMCSR_VSTS_VERIFYING:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING;
> 		break;
> 	case ENETC_MMCSR_VSTS_SUCCEEDED:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED;
> 		break;
> 	case ENETC_MMCSR_VSTS_FAILED:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_FAILED;
> 		break;
> 	case ENETC_MMCSR_VSTS_UNKNOWN:
> 	default:
> 		state->verify_status = ETHTOOL_MM_VERIFY_STATUS_UNKNOWN;
> 		break;
> 	}
> 
> which to my eye is more bloated.

I guess it's subjective.
I certainly don't feel strongly about this.
And I appreciate you taking the time to respond to my idea.

I have no objections to leaving this patch as is (with '3').

  reply	other threads:[~2023-04-20 16:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18 11:14 [PATCH v2 net-next 0/9] ethtool mm API consolidation Vladimir Oltean
2023-04-18 11:14 ` [PATCH v2 net-next 1/9] net: enetc: fix MAC Merge layer remaining enabled until a link down event Vladimir Oltean
2023-04-20 14:22   ` Simon Horman
2023-04-20 17:03     ` Vladimir Oltean
2023-04-21  9:01       ` Simon Horman
2023-04-18 11:14 ` [PATCH v2 net-next 2/9] net: enetc: report mm tx-active based on tx-enabled and verify-status Vladimir Oltean
2023-04-20 14:40   ` Simon Horman
2023-04-18 11:14 ` [PATCH v2 net-next 3/9] net: enetc: only commit preemptible TCs to hardware when MM TX is active Vladimir Oltean
2023-04-20 14:42   ` Simon Horman
2023-04-20 16:34     ` Vladimir Oltean
2023-04-20 16:49       ` Simon Horman [this message]
2023-04-18 11:14 ` [PATCH v2 net-next 4/9] net: enetc: include MAC Merge / FP registers in register dump Vladimir Oltean
2023-04-20 14:38   ` Simon Horman
2023-04-20 16:58     ` Vladimir Oltean
2023-04-21  9:03       ` Simon Horman
2023-04-18 11:14 ` [PATCH v2 net-next 5/9] net: ethtool: mm: sanitize some UAPI configurations Vladimir Oltean
2023-04-20 14:43   ` Simon Horman
2023-04-18 11:14 ` [PATCH v2 net-next 6/9] selftests: forwarding: sch_tbf_*: Add a pre-run hook Vladimir Oltean
2023-04-18 11:14 ` [PATCH v2 net-next 7/9] selftests: forwarding: generalize bail_on_lldpad from mlxsw Vladimir Oltean
2023-04-18 11:14 ` [PATCH v2 net-next 8/9] selftests: forwarding: introduce helper for standard ethtool counters Vladimir Oltean
2023-04-18 11:14 ` [PATCH v2 net-next 9/9] selftests: forwarding: add a test for MAC Merge layer Vladimir Oltean
2023-04-21  3:10 ` [PATCH v2 net-next 0/9] ethtool mm API consolidation patchwork-bot+netdevbpf

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=ZEFtFX9LXxcc+Umn@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=aconole@redhat.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ferenc.fejes@ericsson.com \
    --cc=gerhard@engleder-embedded.com \
    --cc=harini.katakam@amd.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=pranavi.somisetty@amd.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vladimir.oltean@nxp.com \
    --cc=xiaoliang.yang_1@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.