linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Jonathan Corbet <corbet@lwn.net>, Jiri Pirko <jiri@nvidia.com>,
	<netdev@vger.kernel.org>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Linux ARM Mailing List <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/4] net: ti: am65-cpsw-nuss: Add switchdev support
Date: Thu, 3 Dec 2020 19:19:48 +0530	[thread overview]
Message-ID: <fc6ddc40-5277-09e5-0a7a-feb1ea4087ef@ti.com> (raw)
In-Reply-To: <20201130172034.GF2073444@lunn.ch>



On 11/30/20 10:50 PM, Andrew Lunn wrote:
>> +static int am65_cpsw_port_stp_state_set(struct am65_cpsw_port *port,
>> +					struct switchdev_trans *trans, u8 state)
>> +{
>> +	struct am65_cpsw_common *cpsw = port->common;
>> +	u8 cpsw_state;
>> +	int ret = 0;
>> +
>> +	if (switchdev_trans_ph_prepare(trans))
>> +		return 0;
>> +
>> +	switch (state) {
>> +	case BR_STATE_FORWARDING:
>> +		cpsw_state = ALE_PORT_STATE_FORWARD;
>> +		break;
>> +	case BR_STATE_LEARNING:
>> +		cpsw_state = ALE_PORT_STATE_LEARN;
>> +		break;
>> +	case BR_STATE_DISABLED:
>> +		cpsw_state = ALE_PORT_STATE_DISABLE;
>> +		break;
>> +	case BR_STATE_LISTENING:
>> +	case BR_STATE_BLOCKING:
>> +		cpsw_state = ALE_PORT_STATE_BLOCK;
>> +		break;
>> +	default:
>> +		return -EOPNOTSUPP;
>> +	}
> 
> Strictly speaking, the:
> 
>> +	if (switchdev_trans_ph_prepare(trans))
>> +		return 0;
> 
> should be here. In the prepare phase, you are suppose to validate you
> can do the requested action, and return an error is not. In second
> phase, actually carrying out the action, you then never return an
> error.
> 
> But in this case, you are handling all the bridge states, so it should
> not matter.
> 

Yeah, since driver is interested in all STP states, I preferred to
terminate the function early for prepare phase. Adding switch statement
with just "return 0" for all states during prepare phase looked
redundant to me.

Thanks for the review!

Regards
Vignesh

  reply	other threads:[~2020-12-03 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  8:20 [PATCH 0/4] net: ti: am65-cpsw-nuss: Add switchdev driver Vignesh Raghavendra
2020-11-30  8:20 ` [PATCH 1/4] net: ti: am65-cpsw-nuss: Add devlink support Vignesh Raghavendra
2020-11-30 15:50   ` Andrew Lunn
2020-12-03  8:40     ` Vignesh Raghavendra
2020-12-03 14:18       ` Andrew Lunn
2020-12-03 16:22         ` Grygorii Strashko
2020-11-30  8:20 ` [PATCH 2/4] net: ti: am65-cpsw-nuss: Add netdevice notifiers Vignesh Raghavendra
2020-11-30  8:20 ` [PATCH 3/4] net: ti: am65-cpsw-nuss: Add switchdev support Vignesh Raghavendra
2020-11-30 17:20   ` Andrew Lunn
2020-12-03 13:49     ` Vignesh Raghavendra [this message]
2020-11-30  8:20 ` [PATCH 4/4] docs: networking: ti: Add driver doc for AM65 NUSS switch driver Vignesh Raghavendra

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=fc6ddc40-5277-09e5-0a7a-feb1ea4087ef@ti.com \
    --to=vigneshr@ti.com \
    --cc=andrew@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=grygorii.strashko@ti.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).