From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH 11/12] ftgmac100: Add support for fragmented tx
Date: Sat, 08 Apr 2017 09:19:09 +1000 [thread overview]
Message-ID: <1491607149.4166.165.camel@kernel.crashing.org> (raw)
In-Reply-To: <13383518-1602-e3e4-3ac5-4d44ac91be20@gmail.com>
On Fri, 2017-04-07 at 06:26 -0700, Florian Fainelli wrote:
>
> On 04/06/2017 08:31 PM, Benjamin Herrenschmidt wrote:
> > Add NETIF_F_SG and create multiple TX ring entries for skb fragments.
> >
> > On reclaim, the skb is only freed on the segment marked as "last".
> >
> > > > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> >
>
> [snip]
> >
> > > > - dma_unmap_single(priv->dev, map, skb_headlen(skb), DMA_TO_DEVICE);
> > > > + if (skb_shinfo(skb)->nr_frags == 0 && len < ETH_ZLEN)
> > + len = ETH_ZLEN;
>
> This is where skb_put_padto() would help you eliminate this test since
> you'd be dealing skb->len >= ETH_ZLEN.
Ok, thanks.
> > + dma_unmap_single(priv->dev, map, len, DMA_TO_DEVICE);
> > > > + } else {
> > > > + dma_unmap_page(priv->dev, map,
> > > > + ftgmac100_txdes_get_buffer_size(txdes),
> > > > + DMA_TO_DEVICE);
> > > > + }
> >
> > > > - dev_kfree_skb(skb);
> > > > + if (ftgmac100_txdes_get_last_segment(txdes))
> > + dev_kfree_skb(skb);
>
> This makes you do an uncached access to the descriptor, right? is there
> a way you could use bookeeping information to free the last fragment?
Not a big deal, it's handled in a subsequent patch. I have to read the
descriptor first word anyway to know the packet has been completed,
a further patch I just pass that info along to ftgmac100_free_tx_packet
> > priv->tx_skbs[pointer] = NULL;
> >
> > > > /* Clear txdes0 except end of ring bit, clear txdes1 as we
> > @@ -623,10 +642,9 @@ static void ftgmac100_tx_complete(struct ftgmac100 *priv)
> > static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
> > > > struct net_device *netdev)
> > {
> > > > - unsigned int len = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;
> > > > struct ftgmac100 *priv = netdev_priv(netdev);
> > > > - struct ftgmac100_txdes *txdes;
> > > > - unsigned int pointer;
> > > > + struct ftgmac100_txdes *txdes, *first;
> > > > + unsigned int pointer, nfrags, len, i, j;
> > > > dma_addr_t map;
> >
> > > > /* The HW doesn't pad small frames */
> > @@ -642,26 +660,35 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
> > > > goto drop;
> > > > }
> >
> > > > - map = dma_map_single(priv->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
> > > > - if (unlikely(dma_mapping_error(priv->dev, map))) {
> > > > - /* drop packet */
> > > > + /* Do we have a limit on #fragments ? I yet have to get a reply
> > > > + * from Aspeed. If there's one I haven't hit it.
> > > > + */
> > > > + nfrags = skb_shinfo(skb)->nr_frags;
> > +
> > > > + /* Get header len and pad for non-fragmented packets */
> > > > + len = skb_headlen(skb);
> > > > + if (nfrags == 0 && len < ETH_ZLEN)
> > + len = ETH_ZLEN;
>
> Same here skb_put_padto() would eliminate the test.
Yup, I'll fix that, thx.
> [snip]
>
> >
> > + dma_err:
> > > > + if (net_ratelimit())
> > + netdev_err(netdev, "map tx fragment failed\n");
>
> You may consider adding a software counter that tracks mapping failures
> (few drivers do that) in a subsequent set of changes.
Ok. I want to add a bunch of SW counters for other things too so
I'll add to the list.
Cheers,
Ben.
next prev parent reply other threads:[~2017-04-07 23:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-07 3:30 [PATCH 00/12] ftgmac100: Rework batch 3 - TX path Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 01/12] ftgmac100: Add a tx timeout handler Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 02/12] ftgmac100: Move ftgmac100_hard_start_xmit() around Benjamin Herrenschmidt
2017-04-07 10:09 ` Sergei Shtylyov
2017-04-07 23:14 ` Benjamin Herrenschmidt
2017-04-07 12:49 ` David Miller
2017-04-07 23:19 ` Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 03/12] ftgmac100: Merge ftgmac100_xmit() into ftgmac100_hard_start_xmit() Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 04/12] ftgmac100: Factor tx packet dropping path Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 05/12] ftgmac100: Pad small frames properly Benjamin Herrenschmidt
2017-04-07 13:05 ` Florian Fainelli
2017-04-07 23:15 ` Benjamin Herrenschmidt
2017-04-07 3:30 ` [PATCH 06/12] ftgmac100: Store tx skbs in a separate array Benjamin Herrenschmidt
2017-04-07 3:31 ` [PATCH 07/12] ftgmac100: Cleanup tx queue handling Benjamin Herrenschmidt
2017-04-07 3:31 ` [PATCH 08/12] ftgmac100: Move the barrier out of ftgmac100_txdes_set_dma_own() Benjamin Herrenschmidt
2017-04-07 3:31 ` [PATCH 09/12] ftgmac100: Split tx packet freeing from ftgmac100_tx_complete_packet() Benjamin Herrenschmidt
2017-04-07 3:31 ` [PATCH 10/12] ftgmac100: Don't clear tx desc fields unnecessarily Benjamin Herrenschmidt
2017-04-07 3:31 ` [PATCH 11/12] ftgmac100: Add support for fragmented tx Benjamin Herrenschmidt
2017-04-07 13:26 ` Florian Fainelli
2017-04-07 23:19 ` Benjamin Herrenschmidt [this message]
2017-04-07 3:31 ` [PATCH 12/12] ftgmac100: Remove tx descriptor accessors Benjamin Herrenschmidt
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=1491607149.4166.165.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
/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).