linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [net-next PATCH v2 08/15] net: dsa: qca8k: move fast age/MTU/port enable/disable functions to common code
Date: Tue, 19 Jul 2022 16:22:39 +0300	[thread overview]
Message-ID: <20220719132239.ubxzxvkzlbfi7xli@skbuf> (raw)
In-Reply-To: <20220719005726.8739-10-ansuelsmth@gmail.com> <20220719005726.8739-10-ansuelsmth@gmail.com>

On Tue, Jul 19, 2022 at 02:57:19AM +0200, Christian Marangi wrote:
> The same fast age, MTU and port enable/disable function are used by
> driver based on qca8k family switch.
> Move them to common code to make them accessible also by other drivers.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> +int
> +qca8k_port_enable(struct dsa_switch *ds, int port,
> +		  struct phy_device *phy)
> +{
> +	struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;

I think you can make slight tweaks to the code being moved (and document
them in the commit message). For example, in C, there is no type casting
necessary for void pointers (as evidenced by all other places which seem
to do just fine with "priv = ds->priv").

> +
> +	qca8k_port_set_status(priv, port, 1);
> +	priv->port_enabled_map |= BIT(port);
> +
> +	if (dsa_is_user_port(ds, port))
> +		phy_support_asym_pause(phy);
> +
> +	return 0;
> +}
> +
> +void
> +qca8k_port_disable(struct dsa_switch *ds, int port)
> +{
> +	struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
> +
> +	qca8k_port_set_status(priv, port, 0);
> +	priv->port_enabled_map &= ~BIT(port);
> +}
> +
> +int
> +qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> +{
> +	struct qca8k_priv *priv = ds->priv;
> +	int ret;
> +
> +	/* We have only have a general MTU setting.
> +	 * DSA always set the CPU port's MTU to the largest MTU of the slave
> +	 * ports.
> +	 * Setting MTU just for the CPU port is sufficient to correctly set a
> +	 * value for every port.
> +	 */
> +	if (!dsa_is_cpu_port(ds, port))
> +		return 0;
> +
> +	/* To change the MAX_FRAME_SIZE the cpu ports must be off or
> +	 * the switch panics.
> +	 * Turn off both cpu ports before applying the new value to prevent
> +	 * this.
> +	 */
> +	if (priv->port_enabled_map & BIT(0))
> +		qca8k_port_set_status(priv, 0, 0);
> +
> +	if (priv->port_enabled_map & BIT(6))
> +		qca8k_port_set_status(priv, 6, 0);
> +
> +	/* Include L2 header / FCS length */
> +	ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, new_mtu + ETH_HLEN + ETH_FCS_LEN);
> +
> +	if (priv->port_enabled_map & BIT(0))
> +		qca8k_port_set_status(priv, 0, 1);
> +
> +	if (priv->port_enabled_map & BIT(6))
> +		qca8k_port_set_status(priv, 6, 1);
> +
> +	return ret;
> +}
> +
> +int
> +qca8k_port_max_mtu(struct dsa_switch *ds, int port)
> +{
> +	return QCA8K_MAX_MTU;
> +}
> diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h
> index dd3072e2f23c..bc9078ae2b70 100644
> --- a/drivers/net/dsa/qca/qca8k.h
> +++ b/drivers/net/dsa/qca/qca8k.h
> @@ -469,4 +469,17 @@ int qca8k_port_bridge_join(struct dsa_switch *ds, int port,
>  void qca8k_port_bridge_leave(struct dsa_switch *ds, int port,
>  			     struct dsa_bridge bridge);
>  
> +/* Common fast age function */
> +void qca8k_port_fast_age(struct dsa_switch *ds, int port);
> +int qca8k_set_ageing_time(struct dsa_switch *ds, unsigned int msecs);
> +
> +/* Common port enable/disable function */
> +int qca8k_port_enable(struct dsa_switch *ds, int port,
> +		      struct phy_device *phy);
> +void qca8k_port_disable(struct dsa_switch *ds, int port);
> +
> +/* Common MTU function */
> +int qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu);
> +int qca8k_port_max_mtu(struct dsa_switch *ds, int port);
> +
>  #endif /* __QCA8K_H */
> -- 
> 2.36.1
> 


  reply	other threads:[~2022-07-19 14:07 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  0:57 [net-next PATCH v2 00/15] net: dsa: qca8k: code split for qca8k Christian Marangi
2022-07-19  0:57 ` [net-next PATCH v2 01/15] net: dsa: qca8k: make mib autocast feature optional Christian Marangi
2022-07-19 12:26   ` Vladimir Oltean
2022-07-19 12:29     ` Christian Marangi
2022-07-19 13:36       ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 02/15] net: dsa: qca8k: move mib struct to common code Christian Marangi
2022-07-19 12:36   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 03/15] net: dsa: qca8k: move qca8k read/write/rmw and reg table " Christian Marangi
2022-07-19 12:38   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 03/15] net: dsa: qca8k: move qca8kread/write/rmw " Christian Marangi
2022-07-19  1:00   ` Christian Marangi
2022-07-19  1:30     ` Jakub Kicinski
2022-07-19  1:16       ` Christian Marangi
2022-07-19 13:34         ` Vladimir Oltean
2022-07-19  1:32       ` Jakub Kicinski
2022-07-19  1:17         ` Christian Marangi
2022-07-19  0:57 ` [net-next PATCH v2 04/15] net: dsa: qca8k: move qca8k bulk read/write helper " Christian Marangi
2022-07-19 12:40   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 05/15] net: dsa: qca8k: move fdb/vlan/mib init functions " Christian Marangi
2022-07-19 13:13   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 06/15] net: dsa: qca8k: move port set status/eee/ethtool stats function " Christian Marangi
2022-07-19 13:14   ` Vladimir Oltean
2022-07-19 13:16     ` Christian Marangi
2022-07-19 13:18       ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 07/15] net: dsa: qca8k: move bridge functions " Christian Marangi
2022-07-19 13:16   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 08/15] net: dsa: qca8k: move fast age/MTU/port enable/disable " Christian Marangi
2022-07-19 13:22   ` Vladimir Oltean [this message]
2022-07-19  0:57 ` [net-next PATCH v2 09/15] net: dsa: qca8k: move port FDB function " Christian Marangi
2022-07-19  0:57 ` [net-next PATCH v2 10/15] net: dsa: qca8k: move port MDB functions " Christian Marangi
2022-07-19  0:57 ` [net-next PATCH v2 11/15] net: dsa: qca8k: move port mirror " Christian Marangi
2022-07-19 13:24   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 12/15] net: dsa: qca8k: move port VLAN " Christian Marangi
2022-07-19 13:25   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 13/15] net: dsa: qca8k: move port LAG " Christian Marangi
2022-07-19 13:26   ` Vladimir Oltean
2022-07-19  0:57 ` [net-next PATCH v2 14/15] net: dsa: qca8k: move read_switch_id function " Christian Marangi
2022-07-19  0:57 ` [net-next PATCH v2 15/15] net: dsa: qca8k: drop unnecessary exposed function and make them static Christian Marangi
2022-07-19 13:29   ` Vladimir Oltean
2022-07-19 13:35     ` Christian Marangi
2022-07-19 13:44       ` Vladimir Oltean
2022-07-19 13:47         ` Vladimir Oltean

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=20220719132239.ubxzxvkzlbfi7xli@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.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 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).