[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fc6ddc40-5277-09e5-0a7a-feb1ea4087ef@ti.com>
Date: Thu, 3 Dec 2020 19:19:48 +0530
From: Vignesh Raghavendra <vigneshr@...com>
To: Andrew Lunn <andrew@...n.ch>
CC: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Grygorii Strashko <grygorii.strashko@...com>,
Jonathan Corbet <corbet@....net>, Jiri Pirko <jiri@...dia.com>,
<netdev@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Linux ARM Mailing List <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH 3/4] net: ti: am65-cpsw-nuss: Add switchdev support
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
Powered by blists - more mailing lists