From: Andrew Lunn <andrew@lunn.ch>
To: Romain Gantois <romain.gantois@bootlin.com>
Cc: davem@davemloft.net, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, thomas.petazzoni@bootlin.com,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
linux-arm-kernel@lists.infradead.org,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Luka Perkov <luka.perkov@sartura.hr>,
Robert Marko <robert.marko@sartura.hr>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@somainline.org>,
Maxime Chevallier <maxime.chevallier@bootlin.com>
Subject: Re: [PATCH net-next 3/5] net: ipqess: introduce the Qualcomm IPQESS driver
Date: Mon, 23 Oct 2023 19:50:53 +0200 [thread overview]
Message-ID: <b8ac3558-b6f0-4658-b406-8ceba062a52c@lunn.ch> (raw)
In-Reply-To: <20231023155013.512999-4-romain.gantois@bootlin.com>
> +/* 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
next prev parent reply other threads:[~2023-10-23 17:51 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-23 15:50 [PATCH net-next 0/5] net: ipqess: introduce Qualcomm IPQESS driver Romain Gantois
2023-10-23 15:50 ` [PATCH net-next 1/5] net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet switch Romain Gantois
2023-10-23 17:37 ` Krzysztof Kozlowski
2023-10-24 8:01 ` Romain Gantois
2023-10-23 17:40 ` Rob Herring
2023-10-24 9:54 ` Romain Gantois
2023-10-24 9:56 ` Krzysztof Kozlowski
2023-10-24 10:05 ` Romain Gantois
2023-10-24 10:54 ` Krzysztof Kozlowski
2023-10-24 12:13 ` Romain Gantois
2023-10-23 15:50 ` [PATCH net-next 2/5] net: dsa: qca: Make the QCA8K hardware library available globally Romain Gantois
2023-10-23 16:40 ` Andrew Lunn
2023-10-23 15:50 ` [PATCH net-next 3/5] net: ipqess: introduce the Qualcomm IPQESS driver Romain Gantois
2023-10-23 17:50 ` Andrew Lunn [this message]
2023-10-24 9:16 ` Romain Gantois
2023-10-24 14:08 ` Andrew Lunn
2023-10-24 16:23 ` Robert Marko
2023-10-24 16:48 ` Andrew Lunn
2023-10-24 11:44 ` Wojciech Drewek
2023-10-24 15:55 ` kernel test robot
2023-10-23 15:50 ` [PATCH net-next 4/5] net: ipqess: add a PSGMII calibration procedure to the " Romain Gantois
2023-10-23 18:01 ` Andrew Lunn
2023-10-24 9:03 ` Romain Gantois
2023-10-24 14:13 ` Andrew Lunn
2023-10-24 16:49 ` Robert Marko
2023-10-23 15:50 ` [PATCH net-next 5/5] dts: qcom: ipq4019: Add description for the IPQ4019 ESS EDMA and switch Romain Gantois
2023-10-23 17:39 ` Krzysztof Kozlowski
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=b8ac3558-b6f0-4658-b406-8ceba062a52c@lunn.ch \
--to=andrew@lunn.ch \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=konrad.dybcio@somainline.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luka.perkov@sartura.hr \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robert.marko@sartura.hr \
--cc=robh+dt@kernel.org \
--cc=romain.gantois@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.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