All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Allan Nielsen <Allan.Nielsen@microsemi.com>,
	razvan.stefanescu@nxp.com, po.liu@nxp.com,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Andrew Lunn <andrew@lunn.ch>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH net-next 5/8] net: mscc: Add initial Ocelot switch support
Date: Fri, 30 Mar 2018 14:45:37 +0200	[thread overview]
Message-ID: <20180330124537.GC14180@piout.net> (raw)
In-Reply-To: <1df0a932-f7c1-f1b5-9a35-3c16d0c551e5@gmail.com>

On 23/03/2018 at 14:41:25 -0700, Florian Fainelli wrote:
> On 03/23/2018 01:11 PM, Alexandre Belloni wrote:
> > Add a driver for Microsemi Ocelot Ethernet switch support.
> > 
> > This makes two modules:
> > mscc_ocelot_common handles all the common features that doesn't depend on
> > how the switch is integrated in the SoC. Currently, it handles offloading
> > bridging to the hardware. ocelot_io.c handles register accesses. This is
> > unfortunately needed because the register layout is packed and then depends
> > on the number of ports available on the switch. The register definition
> > files are automatically generated.
> > 
> > ocelot_board handles the switch integration on the SoC and on the board.
> > 
> > Frame injection and extraction to/from the CPU port is currently done using
> > register accesses which is quite slow. DMA is possible but the port is not
> > able to absorb the whole switch bandwidth.
> > 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> Random drive by comments because this is quite a number of lines to review!
> 
> Overall, looks quite good for a first version. Out of curiosity, is
> there a particular switch test you ran this driver against? LNST?
> 

We have a really small custom test suite.

> > +	/* Add dummy CRC */
> > +	ocelot_write_rix(ocelot, 0, QS_INJ_WR, grp);
> > +	skb_tx_timestamp(skb);
> > +
> > +	dev->stats.tx_packets++;
> > +	dev->stats.tx_bytes += skb->len;
> > +	dev_kfree_skb_any(skb);
> 
> No interrupt to indicate transmit completion?
> 

No, unfortunately, the TX interrupts only indicates there is room to
start injecting frames, not that they have been transmitted.

> 
> > +static int ocelot_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
> > +			  struct net_device *dev, const unsigned char *addr,
> > +			  u16 vid, u16 flags)
> > +{
> > +	struct ocelot_port *port = netdev_priv(dev);
> > +	struct ocelot *ocelot = port->ocelot;
> > +
> > +	if (!vid) {
> > +		if (!port->vlan_aware)
> > +			/* If the bridge is not VLAN aware and no VID was
> > +			 * provided, set it to 1 as bridges have a default VID
> > +			 * of 1. Otherwise the MAC entry wouldn't match incoming
> > +			 * packets as the VID would differ (0 != 1).
> > +			 */
> > +			vid = 1;
> > +		else
> > +			/* If the bridge is VLAN aware a VID must be provided as
> > +			 * otherwise the learnt entry wouldn't match any frame.
> > +			 */
> > +			return -EINVAL;
> > +	}
> 
> So if we are targeting vid = 0 we end-up with vid = 1 possibly?
> 

I've removed that part that is not needed for now and will rework when
sending VLAN support.

> > +	ocelot_write_gix(ocelot, port_cfg, ANA_PORT_PORT_CFG,
> > +			 ocelot_port->chip_port);
> > +
> > +	/* Apply FWD mask. The loop is needed to add/remove the current port as
> > +	 * a source for the other ports.
> > +	 */
> > +	for (port = 0; port < ocelot->num_phys_ports; port++) {
> > +		if (ocelot->bridge_fwd_mask & BIT(port)) {
> > +			unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(port);
> > +
> > +			for (i = 0; i < ocelot->num_phys_ports; i++) {
> > +				unsigned long bond_mask = ocelot->lags[i];
> > +
> > +				if (!bond_mask)
> > +					continue;
> > +
> > +				if (bond_mask & BIT(port)) {
> > +					mask &= ~bond_mask;
> > +					break;
> > +				}
> > +			}
> > +
> > +			ocelot_write_rix(ocelot,
> > +					 BIT(ocelot->num_phys_ports) | mask,
> > +					 ANA_PGID_PGID, PGID_SRC + port);
> > +		} else {
> > +			/* Only the CPU port, this is compatible with link
> > +			 * aggregation.
> > +			 */
> > +			ocelot_write_rix(ocelot,
> > +					 BIT(ocelot->num_phys_ports),
> > +					 ANA_PGID_PGID, PGID_SRC + port);
> > +		}
> 
> All of this sounds like it should be moved into the br_join/leave, this
> does not appear to be the right place to do that.
> 

No, I've triple checked because this is a comment that both Andrew and
you had. Once a port is added to the PGID MASK, it will start forwarding
frames so we really want that to happen only when the port is in
BR_STATE_FORWARDING state. Else, we may forward frames between the
addition of the port to the bridge and setting the port to the
BR_STATE_BLOCKING state.


-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2018-03-30 12:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23 20:11 [PATCH net-next 0/8] Microsemi Ocelot switch support Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 1/8] net: phy: Add initial support for Microsemi Ocelot internal PHYs Alexandre Belloni
2018-03-23 20:29   ` Andrew Lunn
2018-03-23 21:08   ` Florian Fainelli
2018-03-28 16:18     ` Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 2/8] dt-bindings: net: add DT bindings for Microsemi MIIM Alexandre Belloni
2018-03-23 21:46   ` Florian Fainelli
2018-03-23 20:11 ` [PATCH net-next 3/8] net: mscc: Add MDIO driver Alexandre Belloni
2018-03-23 20:49   ` Andrew Lunn
2018-03-29 14:05     ` Alexandre Belloni
2018-03-29 14:40       ` Andrew Lunn
2018-03-29 14:53         ` Alexandre Belloni
2018-03-29 14:57           ` Andrew Lunn
2018-03-23 21:51   ` Florian Fainelli
2018-03-29 14:14     ` Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 4/8] dt-bindings: net: add DT bindings for Microsemi Ocelot Switch Alexandre Belloni
2018-03-23 21:01   ` Andrew Lunn
2018-03-23 21:11   ` Florian Fainelli
2018-03-26 22:25     ` Rob Herring
2018-03-26 22:50       ` Andrew Lunn
2018-03-27  0:34         ` Rob Herring
2018-03-26 22:25   ` Rob Herring
2018-03-23 20:11 ` [PATCH net-next 5/8] net: mscc: Add initial Ocelot switch support Alexandre Belloni
2018-03-23 21:25   ` Andrew Lunn
2018-03-23 21:41   ` Florian Fainelli
2018-03-30 12:45     ` Alexandre Belloni [this message]
2018-03-30 13:54       ` Andrew Lunn
2018-03-30 14:16         ` Alexandre Belloni
2018-03-30 14:50           ` Andrew Lunn
2018-03-31 22:47             ` Florian Fainelli
2018-04-24 18:52             ` Alexandre Belloni
2018-03-26 19:13   ` kbuild test robot
2018-03-26 19:13     ` kbuild test robot
2018-03-26 19:13     ` kbuild test robot
2018-03-30  7:02   ` Razvan Stefanescu
2018-03-23 20:11 ` [PATCH net-next 6/8] MIPS: mscc: Add switch to ocelot Alexandre Belloni
2018-03-23 21:17   ` Florian Fainelli
2018-03-23 21:22     ` Alexandre Belloni
2018-03-23 21:33       ` Andrew Lunn
2018-03-23 21:44         ` Florian Fainelli
2018-03-23 22:06           ` Andrew Lunn
2018-03-23 22:11             ` Florian Fainelli
2018-03-24 14:48               ` Andrew Lunn
2018-03-23 20:11 ` [PATCH net-next 7/8] MIPS: mscc: connect phys to ports on ocelot_pcb123 Alexandre Belloni
2018-03-23 20:11 ` [PATCH net-next 8/8] MAINTAINERS: Add entry for Microsemi Ethernet switches Alexandre Belloni

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=20180330124537.GC14180@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=Allan.Nielsen@microsemi.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=netdev@vger.kernel.org \
    --cc=po.liu@nxp.com \
    --cc=razvan.stefanescu@nxp.com \
    --cc=thomas.petazzoni@bootlin.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.