Received: by 10.213.65.68 with SMTP id h4csp294762imn; Fri, 30 Mar 2018 05:47:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+idLmLFEBYJvmS6momND6UOT0GOyRDR24HZ7rFqEzpcuiJhrQMGjWecP1bVjGNhwjR9z2a X-Received: by 2002:a17:902:9a05:: with SMTP id v5-v6mr12154731plp.313.1522414037478; Fri, 30 Mar 2018 05:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522414037; cv=none; d=google.com; s=arc-20160816; b=dW1u83wHjywNFMs4u0FE6kCM+2D99bTslW7rvZHpZIVu+9XLko7hrknL+RgPdjepL8 H93ZUy/v/BY4JdKQyRCrX/7NQ9z+56WNYUbuv9cBKRMQYtURZidyz4wNpFhyCiHk7Qcr 72GN4Ier6YnTSPkbsfQtAGUBLAQXVsCMsSDTt3T/5lvq6kYCYMccZvymRaR2FALJ4U8Q fxH+RlIr11CuhKebj7R84UY7VPfxnxejqZOMcaSugHWpcr3wG6IT+zTzwgHPK79fJn8U VzCraN8+Jx7MMi2pb1oOx6r9GacC+BOUBx9sR1hf8nxJSyriHSGTEKTSdvEYCNWA1B6h FLEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=o8lFpUOGVv5floI/RWdBYPLKksqo2iNaz2b17nfRbQQ=; b=FtPcO0LhBHrUwk4YNk0HE+v/XkUKQcYlceH57tuZrdlD76v01l1LPEksaKRfdd1Dmf tzE5L6/xiVLrs2WYd4u1SVoRI9AIF+LiZa+jl/LgDILInlIHvQGIQN/m6LgV3KrCr0Vx cBvsOXPb2gMVL0npVa03HtBE9KVGMcxoH6/EwVRb7CjitrgBCrLlVxgg33fN//mOTnMR xVGcUJSGaxXDLvg9SlxZ/lHcgeMwHfEogT3AFTBTCr/McBbdQ+FPs59mR9AAntsl2srG 3UaIKcOChbdaqSg24MBIUty5BYZyMJSeQNcP0tL9OTa3+7/1c7eyEFl9obAPS0n4smtR zhiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si6126237pfm.416.2018.03.30.05.47.02; Fri, 30 Mar 2018 05:47:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752072AbeC3Mpw (ORCPT + 99 others); Fri, 30 Mar 2018 08:45:52 -0400 Received: from mail.bootlin.com ([62.4.15.54]:38166 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252AbeC3Mpu (ORCPT ); Fri, 30 Mar 2018 08:45:50 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 4FAE820829; Fri, 30 Mar 2018 14:45:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (242.171.71.37.rev.sfr.net [37.71.171.242]) by mail.bootlin.com (Postfix) with ESMTPSA id 1982120715; Fri, 30 Mar 2018 14:45:38 +0200 (CEST) Date: Fri, 30 Mar 2018 14:45:37 +0200 From: Alexandre Belloni To: Florian Fainelli Cc: "David S . Miller" , Allan Nielsen , razvan.stefanescu@nxp.com, po.liu@nxp.com, Thomas Petazzoni , Andrew Lunn , 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 Message-ID: <20180330124537.GC14180@piout.net> References: <20180323201117.8416-1-alexandre.belloni@bootlin.com> <20180323201117.8416-6-alexandre.belloni@bootlin.com> <1df0a932-f7c1-f1b5-9a35-3c16d0c551e5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1df0a932-f7c1-f1b5-9a35-3c16d0c551e5@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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