[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250725192738.0fffece9@wsk>
Date: Fri, 25 Jul 2025 19:27:38 +0200
From: Lukasz Majewski <lukma@...x.de>
To: Simon Horman <horms@...nel.org>
Cc: Andrew Lunn <andrew+netdev@...n.ch>, davem@...emloft.net, Eric Dumazet
<edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>, Rob Herring <robh@...nel.org>, Krzysztof Kozlowski
<krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Shawn Guo
<shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix
Kernel Team <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>,
Richard Cochran <richardcochran@...il.com>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org, Stefan Wahren
<wahrenst@....net>
Subject: Re: [net-next v16 06/12] net: mtip: Add net_device_ops functions to
the L2 switch driver
Hi Simon,
> On Fri, Jul 25, 2025 at 12:33:12AM +0200, Lukasz Majewski wrote:
> > This patch provides callbacks for struct net_device_ops for MTIP
> > L2 switch.
> >
> > Signed-off-by: Lukasz Majewski <lukma@...x.de>
>
> ...
>
> > +static netdev_tx_t mtip_start_xmit_port(struct sk_buff *skb,
> > + struct net_device *dev,
> > int port) +{
> > + struct mtip_ndev_priv *priv = netdev_priv(dev);
> > + struct switch_enet_private *fep = priv->fep;
> > + unsigned short status;
> > + struct cbd_t *bdp;
> > + void *bufaddr;
> > +
> > + spin_lock_bh(&fep->hw_lock);
> > +
> > + if (!fep->link[0] && !fep->link[1]) {
> > + /* Link is down or autonegotiation is in progress.
> > */
> > + netif_stop_queue(dev);
> > + spin_unlock_bh(&fep->hw_lock);
> > + return NETDEV_TX_BUSY;
> > + }
> > +
> > + /* Fill in a Tx ring entry */
> > + bdp = fep->cur_tx;
> > + status = bdp->cbd_sc;
> > +
> > + if (status & BD_ENET_TX_READY) {
> > + /* All transmit buffers are full. Bail out.
> > + * This should not happen, since dev->tbusy should
> > be set.
> > + */
> > + netif_stop_queue(dev);
> > + dev_err_ratelimited(&fep->pdev->dev, "%s: tx queue
> > full!.\n",
> > + dev->name);
> > + spin_unlock(&fep->hw_lock);
>
> Sorry be the one to point out this needle in a haystack,
> but this should be spin_unlock_bh()
I must have overlooked it when working on the code.
Anyway, I need to wait if there are other comments from Jakub or Paolo
- as they had some comments (addressed already by this patch set) for
previous version.
>
> Flagged by Smatch.
>
> > + return NETDEV_TX_BUSY;
> > + }
> > +
> > + /* Clear all of the status flags */
> > + status &= ~BD_ENET_TX_STATS;
> > +
> > + /* Set buffer length and buffer pointer */
> > + bufaddr = skb->data;
> > + bdp->cbd_datlen = skb->len;
> > +
> > + /* On some FEC implementations data must be aligned on
> > + * 4-byte boundaries. Use bounce buffers to copy data
> > + * and get it aligned.spin
> > + */
> > + if ((unsigned long)bufaddr & MTIP_ALIGNMENT) {
> > + unsigned int index;
> > +
> > + index = bdp - fep->tx_bd_base;
> > + memcpy(fep->tx_bounce[index], skb->data, skb->len);
> > + bufaddr = fep->tx_bounce[index];
> > + }
> > +
> > + if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
> > + swap_buffer(bufaddr, skb->len);
> > +
> > + /* Push the data cache so the CPM does not get stale memory
> > + * data.
> > + */
> > + bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr,
> > + MTIP_SWITCH_TX_FRSIZE,
> > + DMA_TO_DEVICE);
> > + if (unlikely(dma_mapping_error(&fep->pdev->dev,
> > bdp->cbd_bufaddr))) {
> > + dev_err(&fep->pdev->dev,
> > + "Failed to map descriptor tx buffer\n");
> > + dev->stats.tx_dropped++;
> > + dev_kfree_skb_any(skb);
> > + goto err;
> > + }
> > +
> > + /* Save skb pointer. */
> > + fep->tx_skbuff[fep->skb_cur] = skb;
> > + fep->skb_cur = (fep->skb_cur + 1) & TX_RING_MOD_MASK;
> > +
> > + /* Send it on its way. Tell FEC it's ready, interrupt
> > when done,
> > + * it's the last BD of the frame, and to put the CRC on
> > the end.
> > + */
> > +
> > + status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR |
> > BD_ENET_TX_LAST |
> > + BD_ENET_TX_TC);
> > +
> > + /* Synchronize all descriptor writes */
> > + wmb();
> > + bdp->cbd_sc = status;
> > +
> > + skb_tx_timestamp(skb);
> > +
> > + /* Trigger transmission start */
> > + writel(MCF_ESW_TDAR_X_DES_ACTIVE, fep->hwp + ESW_TDAR);
> > +
> > + dev->stats.tx_bytes += skb->len;
> > + /* If this was the last BD in the ring,
> > + * start at the beginning again.
> > + */
> > + if (status & BD_ENET_TX_WRAP)
> > + bdp = fep->tx_bd_base;
> > + else
> > + bdp++;
> > +
> > + if (bdp == fep->dirty_tx) {
> > + fep->tx_full = 1;
> > + netif_stop_queue(dev);
> > + }
> > +
> > + fep->cur_tx = bdp;
> > + err:
> > + spin_unlock_bh(&fep->hw_lock);
> > +
> > + return NETDEV_TX_OK;
> > +}
>
> ...
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Johanna Denk,
Tabea Lutz HRB 165235 Munich, Office: Kirchenstr.5, D-82194
Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@...x.de
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists