All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vignesh Raghavendra <vigneshr@ti.com>
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: Mon, 30 Nov 2020 18:20:34 +0100	[thread overview]
Message-ID: <20201130172034.GF2073444@lunn.ch> (raw)
In-Reply-To: <20201130082046.16292-4-vigneshr@ti.com>

> +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.

    Andrew

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>,
	Jonathan Corbet <corbet@lwn.net>,
	netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jiri Pirko <jiri@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Linux ARM Mailing List <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/4] net: ti: am65-cpsw-nuss: Add switchdev support
Date: Mon, 30 Nov 2020 18:20:34 +0100	[thread overview]
Message-ID: <20201130172034.GF2073444@lunn.ch> (raw)
In-Reply-To: <20201130082046.16292-4-vigneshr@ti.com>

> +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.

    Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-11-30 17:21 UTC|newest]

Thread overview: 22+ 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 ` Vignesh Raghavendra
2020-11-30  8:20 ` [PATCH 1/4] net: ti: am65-cpsw-nuss: Add devlink support Vignesh Raghavendra
2020-11-30  8:20   ` Vignesh Raghavendra
2020-11-30 15:50   ` Andrew Lunn
2020-11-30 15:50     ` Andrew Lunn
2020-12-03  8:40     ` Vignesh Raghavendra
2020-12-03  8:40       ` Vignesh Raghavendra
2020-12-03 14:18       ` Andrew Lunn
2020-12-03 14:18         ` Andrew Lunn
2020-12-03 16:22         ` Grygorii Strashko
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   ` Vignesh Raghavendra
2020-11-30  8:20 ` [PATCH 3/4] net: ti: am65-cpsw-nuss: Add switchdev support Vignesh Raghavendra
2020-11-30  8:20   ` Vignesh Raghavendra
2020-11-30 17:20   ` Andrew Lunn [this message]
2020-11-30 17:20     ` Andrew Lunn
2020-12-03 13:49     ` Vignesh Raghavendra
2020-12-03 13:49       ` Vignesh Raghavendra
2020-11-30  8:20 ` [PATCH 4/4] docs: networking: ti: Add driver doc for AM65 NUSS switch driver Vignesh Raghavendra
2020-11-30  8:20   ` 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=20201130172034.GF2073444@lunn.ch \
    --to=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 \
    --cc=vigneshr@ti.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.