Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1384218rda; Mon, 23 Oct 2023 10:51:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVKtvg4eHMMlW5qoD7G+e3Cpz23djo1TBKbdCmuJQ4xSBfj2IL71QSQbd8Hu/0Sc9m6FHx X-Received: by 2002:a05:6a21:4886:b0:173:f8c9:a898 with SMTP id av6-20020a056a21488600b00173f8c9a898mr272295pzc.52.1698083487523; Mon, 23 Oct 2023 10:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698083487; cv=none; d=google.com; s=arc-20160816; b=LvE2fLAGOo3YWhixH5DYLgmXt2/aRov5AypMcut33c7cXKB/d6ZpBx92g/FZald/vb Y0QFgzSfu61UJnJoeCI3YCcdgPbewr94QHqd5hpstswOOHb8bwXnqJSHIi8Z6cRyZXB5 ex518TUUOuH0E8e7FWm3eg3KteQm52RIS2oOLvSR3jTOiz9jZX5UTCKXb8WvbAqMc1kF CBU/hRJHY88WZlW4f0SLb0tpql6MZuoSC4zPV7J16pT/5C8upIrqWumWOIelL7oyZznX RukaosgkfYDkATJgrvL/1RtS+qhyVAcRVIHHHg8PzWJEuG1nopqArcTaMt5y297GBFdL KpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3/iUMEFKo+Sriw48TJmEW/W6vROCpBV4Feg7wlAPFQ4=; fh=WKrlE/FBCh6S0p0cjULsqYvUKe/UlnCemNlM2pknmQI=; b=Kje9jMnCbfeBZ0VKNkRaT5bmsVqg3CytmdNSLeBlFdxtVkpazuESFP4S9etA/Zlhhq L3YEydn0er21rjRfr2WLeJWo4Ts9TmfRs5mdqwd/3no5ZWqZsDkzIkBimACIDThqyiRn p1+yt6VaIYPOQuJx/B+uv+7MmVw82AenuhqfKiMpctbGDYxPwowleWBqqAR/FF1rQCCM /Wga/WX21da1W5Xycvm5ugaWeffNEyByT8rQKsdSsT4i5SFEW/Wcf3bvtOAqbjbkUfjI HzIeIeMpi831aZWX2vxC/eV0ECfVQELRRREJQ/9MaroRmISr9+fU+yXBxc6YtdbFsiFx HV9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="Oh5Lik/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id a16-20020a63e410000000b00563d9ff5157si6994541pgi.547.2023.10.23.10.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b="Oh5Lik/M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id F319F8096A78; Mon, 23 Oct 2023 10:51:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230299AbjJWRvL (ORCPT + 99 others); Mon, 23 Oct 2023 13:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjJWRvJ (ORCPT ); Mon, 23 Oct 2023 13:51:09 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFF97D73; Mon, 23 Oct 2023 10:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=3/iUMEFKo+Sriw48TJmEW/W6vROCpBV4Feg7wlAPFQ4=; b=Oh5Lik/MMbUmhez2xPGcULw1FX oryyjioVyG+fhTipbc2g+Gl+a28EygKtCQTQPgFp+xoT9CuYZ57bCzc0j8xod7xE06qvAPXJuYOS0 yVdvaUgJa5SLxzg679Wv7j5fT8Hrmlu3exh4xc1sa7CEV9cuCJ+KiY78fgy7EI4sTGgE=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1quz4o-0033TQ-0V; Mon, 23 Oct 2023 19:50:54 +0200 Date: Mon, 23 Oct 2023 19:50:53 +0200 From: Andrew Lunn To: Romain Gantois Cc: davem@davemloft.net, Rob Herring , Krzysztof Kozlowski , Jakub Kicinski , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com, Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Vladimir Oltean , Luka Perkov , Robert Marko , Andy Gross , Bjorn Andersson , Konrad Dybcio , Maxime Chevallier Subject: Re: [PATCH net-next 3/5] net: ipqess: introduce the Qualcomm IPQESS driver Message-ID: References: <20231023155013.512999-1-romain.gantois@bootlin.com> <20231023155013.512999-4-romain.gantois@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231023155013.512999-4-romain.gantois@bootlin.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 10:51:25 -0700 (PDT) > +/* locking is handled by the caller */ > +static int ipqess_edma_rx_buf_alloc_napi(struct ipqess_edma_rx_ring *rx_ring) > +{ > + struct ipqess_edma_buf *buf = &rx_ring->buf[rx_ring->head]; > + > + buf->skb = napi_alloc_skb(&rx_ring->napi_rx, > + IPQESS_EDMA_RX_HEAD_BUFF_SIZE); You might want to look at using the page_pool code. Its shown to be more efficient for some drivers, e.g. the FEC. > +static int ipqess_edma_redirect(struct ipqess_edma_rx_ring *rx_ring, > + struct sk_buff *skb, int port_id) > +{ > + struct ipqess_port *port; > + > + if (port_id == 0) { > + /* The switch probably redirected an unknown frame to the CPU port > + * (IGMP,BC,unknown MC, unknown UC) > + */ > + return -EINVAL; > + } > + > + if (port_id < 0 || port_id > QCA8K_NUM_PORTS) { > + dev_warn(rx_ring->edma->sw->priv->dev, > + "received packet tagged with out-of-bounds port id %d\n", > + port_id); Maybe rate limit this? > +static int ipqess_port_set_mac_address(struct net_device *netdev, void *a) > +{ > + struct sockaddr *addr = a; > + int err; > + > + if (!is_valid_ether_addr(addr->sa_data)) > + return -EADDRNOTAVAIL; I would be surprised if that could happen. > +static int > +ipqess_port_fdb_do_dump(const unsigned char *addr, u16 vid, > + bool is_static, void *data) > +{ > + struct ipqess_port_dump_ctx *dump = data; > + u32 portid = NETLINK_CB(dump->cb->skb).portid; > + u32 seq = dump->cb->nlh->nlmsg_seq; > + struct nlmsghdr *nlh; > + struct ndmsg *ndm; It looks like you can reuse dsa_slave_port_fdb_do_dump(), if you export it. > +static int > +ipqess_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, > + struct net_device *dev, struct net_device *filter_dev, > + int *idx) > +{ > + struct ipqess_port *port = netdev_priv(dev); > + struct qca8k_priv *priv = port->sw->priv; > + struct ipqess_port_dump_ctx dump = { > + .dev = dev, > + .skb = skb, > + .cb = cb, > + .idx = *idx, > + }; And with a little bit of refactoring, you should be able to use the core of qca8k_port_fdb_dump(). All that seems to differ is how you get to the struct qca8k_priv *priv. That then makes me wounder if there is more code here which could be removed with a little refactoring of the DSA driver? > +static void ipqess_port_get_drvinfo(struct net_device *dev, > + struct ethtool_drvinfo *drvinfo) > +{ > + strscpy(drvinfo->driver, "qca8k-ipqess", sizeof(drvinfo->driver)); > + strscpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); If you leave this alone, it will contain the git hash of the kernel, which is more useful than 'N/A'. > + strscpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info)); > +} > + > +static int ipqess_port_get_eeprom_len(struct net_device *dev) > +{ > + return 0; > +} Is this actually useful? What does it default to if not provided? 42? > +static void ipqess_port_get_ethtool_stats(struct net_device *dev, > + struct ethtool_stats *stats, > + uint64_t *data) > +{ ... > + for (c = 0; c < priv->info->mib_count; c++) { > + mib = &ar8327_mib[c]; > + reg = QCA8K_PORT_MIB_COUNTER(port->index) + mib->offset; > + > + ret = qca8k_read(priv, reg, &val); > + if (ret < 0) > + continue; Given the switch is built in, is this fast? The 8k driver avoids doing register reads for this. > +static int ipqess_port_set_eee(struct net_device *dev, struct ethtool_eee *eee) > +{ > + struct ipqess_port *port = netdev_priv(dev); > + int ret; > + u32 lpi_en = QCA8K_REG_EEE_CTRL_LPI_EN(port->index); > + struct qca8k_priv *priv = port->sw->priv; > + u32 reg; > + > + /* Port's PHY and MAC both need to be EEE capable */ > + if (!dev->phydev || !port->pl) > + return -ENODEV; > + > + mutex_lock(&priv->reg_mutex); > + ret = qca8k_read(priv, QCA8K_REG_EEE_CTRL, ®); > + if (ret < 0) { > + mutex_unlock(&priv->reg_mutex); > + return ret; > + } > + > + if (eee->eee_enabled) > + reg |= lpi_en; > + else > + reg &= ~lpi_en; > + ret = qca8k_write(priv, QCA8K_REG_EEE_CTRL, reg); > + mutex_unlock(&priv->reg_mutex); Everybody gets EEE wrong. The best example to copy is mvneta. I also have a patchset which basically re-writes EEE in all the drivers and moves as much as possible into the core. Those patches may someday make it in. But until then, copy mvneta. Andrew