From: Joel Stanley <joel@jms.id.au>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
Rob Herring <robh+dt@kernel.org>,
Stafford Horne <shorne@gmail.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Anton Blanchard <anton@ozlabs.org>,
Gabriel Somlo <gsomlo@gmail.com>, David Shah <dave@ds0.me>,
Karol Gugala <kgugala@antmicro.com>,
Mateusz Holenko <mholenko@antmicro.com>,
devicetree <devicetree@vger.kernel.org>,
Networking <netdev@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] net: Add driver for LiteX's LiteETH network interface
Date: Mon, 9 Aug 2021 12:03:36 +0000 [thread overview]
Message-ID: <CACPK8XcCjNWm=85uXX2tubP=WAgfF8ewqMAMWO_wJVeHB-U_0w@mail.gmail.com> (raw)
In-Reply-To: <20210806161030.52a7ae93@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Thanks for the review Jakub.
On Fri, 6 Aug 2021 at 23:10, Jakub Kicinski <kuba@kernel.org> wrote:
> > +static int liteeth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
> > +{
> > + struct liteeth *priv = netdev_priv(netdev);
> > + void __iomem *txbuffer;
> > + int ret;
> > + u8 val;
> > +
> > + /* Reject oversize packets */
> > + if (unlikely(skb->len > MAX_PKT_SIZE)) {
> > + if (net_ratelimit())
> > + netdev_dbg(netdev, "tx packet too big\n");
> > + goto drop;
> > + }
> > +
> > + txbuffer = priv->tx_base + priv->tx_slot * LITEETH_BUFFER_SIZE;
> > + memcpy_toio(txbuffer, skb->data, skb->len);
> > + writeb(priv->tx_slot, priv->base + LITEETH_READER_SLOT);
> > + writew(skb->len, priv->base + LITEETH_READER_LENGTH);
> > +
> > + ret = readl_poll_timeout_atomic(priv->base + LITEETH_READER_READY, val, val, 5, 1000);
>
> Why the need for poll if there is an interrupt?
> Why not stop the Tx queue once you're out of slots and restart
> it when the completion interrupt comes?
That makes sense.
In testing I have not been able to hit the LITEETH_READER_READY
not-ready state. I assume it's there to say that the slots are full.
>
> > + if (ret == -ETIMEDOUT) {
> > + netdev_err(netdev, "LITEETH_READER_READY timed out\n");
>
> ratelimit this as well, please
>
> > + goto drop;
> > + }
> > +
> > + writeb(1, priv->base + LITEETH_READER_START);
> > +
> > + netdev->stats.tx_bytes += skb->len;
>
> Please count bytes and packets in the same place
AFAIK we don't know the length when the interrupt comes in, so we need
to count both here in xmit?
>
> > + priv->tx_slot = (priv->tx_slot + 1) % priv->num_tx_slots;
> > + dev_kfree_skb_any(skb);
> > + return NETDEV_TX_OK;
> > +drop:
> > + /* Drop the packet */
> > + dev_kfree_skb_any(skb);
> > + netdev->stats.tx_dropped++;
> > +
> > + return NETDEV_TX_OK;
> > +}
next prev parent reply other threads:[~2021-08-09 12:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-06 5:49 [PATCH 0/2] net: Add LiteETH network driver Joel Stanley
2021-08-06 5:49 ` [PATCH 1/2] dt-bindings: net: Add bindings for LiteETH Joel Stanley
2021-08-06 17:07 ` Rob Herring
2021-08-07 19:05 ` Andrew Lunn
2021-08-09 7:59 ` Joel Stanley
2021-08-09 13:27 ` Andrew Lunn
2021-08-06 5:49 ` [PATCH 2/2] net: Add driver for LiteX's LiteETH network interface Joel Stanley
2021-08-06 11:48 ` Gabriel L. Somlo
[not found] ` <CA+96J6JxAkNd_QkVxfSdAJwWVLJTtSaDsCmVKw3KBfYySJytKA@mail.gmail.com>
2021-08-20 7:46 ` Joel Stanley
2021-08-06 23:10 ` Jakub Kicinski
2021-08-09 12:03 ` Joel Stanley [this message]
2021-08-09 16:16 ` Jakub Kicinski
2021-08-07 19:19 ` Andrew Lunn
2021-08-09 3:20 ` Joel Stanley
2021-08-09 13:09 ` Andrew Lunn
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='CACPK8XcCjNWm=85uXX2tubP=WAgfF8ewqMAMWO_wJVeHB-U_0w@mail.gmail.com' \
--to=joel@jms.id.au \
--cc=anton@ozlabs.org \
--cc=benh@kernel.crashing.org \
--cc=dave@ds0.me \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=gsomlo@gmail.com \
--cc=kgugala@antmicro.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mholenko@antmicro.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shorne@gmail.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;
as well as URLs for NNTP newsgroup(s).