All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: George McCollister <george.mccollister@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>
Cc: Rob Herring <robh@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v4 2/3] net: dsa: add Arrow SpeedChips XRS700x driver
Date: Thu, 14 Jan 2021 09:28:21 -0800	[thread overview]
Message-ID: <13473e91-d017-9d8a-e130-037d46ff225c@gmail.com> (raw)
In-Reply-To: <20210113145922.92848-3-george.mccollister@gmail.com>

On 1/13/21 6:59 AM, George McCollister wrote:
> Add a driver with initial support for the Arrow SpeedChips XRS7000
> series of gigabit Ethernet switch chips which are typically used in
> critical networking applications.
> 
> The switches have up to three RGMII ports and one RMII port.
> Management to the switches can be performed over i2c or mdio.
> 
> Support for advanced features such as PTP and
> HSR/PRP (IEC 62439-3 Clause 5 & 4) is not included in this patch and
> may be added at a later date.
> 
> Signed-off-by: George McCollister <george.mccollister@gmail.com>
> ---
[snip]

This looks ready to me, just a few nits and suggestions.


> +/* Add an inbound policy filter which matches the BPDU destination MAC
> + * and forwards to the CPU port. Leave the policy disabled, it will be
> + * enabled as needed.
> + */
> +static int xrs700x_port_add_bpdu_ipf(struct dsa_switch *ds, int port)
> +{
> +	struct xrs700x *priv = ds->priv;
> +	unsigned int val = 0;
> +	int i = 0;
> +	int ret;
> +
> +	/* Compare all 48 bits of the destination MAC address. */
> +	ret = regmap_write(priv->regmap, XRS_ETH_ADDR_CFG(port, 0), 48 << 2);
> +	if (ret)
> +		return ret;
> +
> +	/* match BPDU destination 01:80:c2:00:00:00 */
> +	ret = regmap_write(priv->regmap, XRS_ETH_ADDR_0(port, 0), 0x8001);
> +	if (ret)
> +		return ret;
> +
> +	ret = regmap_write(priv->regmap, XRS_ETH_ADDR_1(port, 0), 0xc2);
> +	if (ret)
> +		return ret;
> +
> +	ret = regmap_write(priv->regmap, XRS_ETH_ADDR_2(port, 0), 0x0);
> +	if (ret)
> +		return ret;

Not that this is likely to change, but you could write this as a for
loop and use eth_stp_addr from include/linux/etherdevice.h.

[snip]

> +static int xrs700x_port_setup(struct dsa_switch *ds, int port)
> +{
> +	bool cpu_port = dsa_is_cpu_port(ds, port);
> +	struct xrs700x *priv = ds->priv;
> +	unsigned int val = 0;
> +	int ret, i;
> +
> +	xrs700x_port_stp_state_set(ds, port, BR_STATE_DISABLED);

It looks like we should be standardizing at some point on having switch
drivers do just the global configuration in the ->setup() callback and
have the core call the ->port_disable() for each port except the CPU/DSA
ports, and finally let the actual port configuration bet done in
->port_enable(). What you have is fine for now and easy to change in the
future.

> +int xrs700x_switch_register(struct xrs700x *dev)
> +{
> +	int ret;
> +	int i;
> +
> +	ret = xrs700x_detect(dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = xrs700x_setup_regmap_range(dev);
> +	if (ret)
> +		return ret;
> +
> +	dev->ports = devm_kzalloc(dev->dev,
> +				  sizeof(*dev->ports) * dev->ds->num_ports,
> +				  GFP_KERNEL);
> +	if (!dev->ports)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < dev->ds->num_ports; i++) {
> +		ret = xrs700x_alloc_port_mib(dev, i);
> +		if (ret)
> +			return ret;

Nothing frees up the successfully allocated p->mib_data[] in case of
errors so you would be leaking here.

[snip]

> +
> +	/* Main DSA driver may not be started yet. */
> +	if (ret)
> +		return ret;
> +
> +	i2c_set_clientdata(i2c, dev);

I would be tempted to move this before "publishing" the device, probably
does not harm though, likewise for the MDIO stub.

[snip]

> +/* Switch Configuration Registers - VLAN */
> +#define XRS_VLAN(v)			(XRS_SWITCH_VLAN_BASE + 0x2 * (v))
> +
> +#define MAX_VLAN			4095

Can you use VLAN_N_VID - 1 here from include/linux/if_vlan.h?
-- 
Florian

  parent reply	other threads:[~2021-01-14 17:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 14:59 [PATCH net-next v4 0/3] Arrow SpeedChips XRS700x DSA Driver George McCollister
2021-01-13 14:59 ` [PATCH net-next v4 1/3] dsa: add support for Arrow XRS700x tag trailer George McCollister
2021-01-14  1:05   ` Vladimir Oltean
2021-01-14  1:48     ` Andrew Lunn
2021-01-14 15:03     ` George McCollister
2021-01-13 14:59 ` [PATCH net-next v4 2/3] net: dsa: add Arrow SpeedChips XRS700x driver George McCollister
2021-01-14  1:56   ` Vladimir Oltean
2021-01-14 16:53     ` George McCollister
2021-01-14 18:12       ` Andrew Lunn
2021-01-14 18:32       ` Vladimir Oltean
2021-01-14 18:47         ` George McCollister
2021-01-14 19:00           ` Vladimir Oltean
2021-01-14 17:28   ` Florian Fainelli [this message]
2021-01-14 18:35     ` George McCollister
2021-01-14 18:37       ` Florian Fainelli
2021-01-13 14:59 ` [PATCH net-next v4 3/3] dt-bindings: net: dsa: add bindings for xrs700x switches George McCollister

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=13473e91-d017-9d8a-e130-037d46ff225c@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=george.mccollister@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --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 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.