From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
<UNGLinuxDriver@microchip.com>
Subject: Re: [PATCH net 3/3] net: lan966x: Fix FDMA when MTU is changed
Date: Wed, 26 Oct 2022 20:35:27 +0200 [thread overview]
Message-ID: <20221026183527.z4zuihbk275gm4bi@soft-dev3-1> (raw)
In-Reply-To: <20221025193405.1c8f6e74@kernel.org>
The 10/25/2022 19:34, Jakub Kicinski wrote:
>
> On Sun, 23 Oct 2022 20:48:38 +0200 Horatiu Vultur wrote:
> > + mtu = lan_rd(lan966x, DEV_MAC_MAXLEN_CFG(port->chip_port));
>
> I'm slightly confused about the vlan situation, does this return the
> vlan hdr length when enabled?
No it doesn't.
> or vlans are always communicated out-of-band so don't need to count here?
Actually, the vlan hdr is actually in bound.
So there is a mistake in the code. The function lan966x_fdma_change_mtu
needs to take in consideration also the vlan header. It can have up to
two tags so it is needed twice.
Because if the vlan header is not taken in consideration, then there can
be a skb_panic when the frame is created in case there is no space
enough to put also the vlan header.
This can be reproduced with the following commands:
ip link set dev eth0 up
ip link set dev eth0 mtu 3794
ip link add name br0 type bridge vlan filtering
ip link set dev eth0 master br0
ip link set dev br0 up
Now send a frame with a the total size of 3816(contains ETH_HLEN + FCS +
VLAN_HELN).
>
> Unrelated potential issue I spotted:
>
> skb = build_skb(page_address(page), PAGE_SIZE << rx->page_order);
> if (unlikely(!skb))
> goto unmap_page;
>
> dma_unmap_single(lan966x->dev, (dma_addr_t)db->dataptr,
> FDMA_DCB_STATUS_BLOCKL(db->status),
> DMA_FROM_DEVICE);
>
> Are you sure it's legal to unmap with a different length than you
> mapped? Seems questionable - you can unmap & ask the unmap to skip
> the sync, then sync manually only the part that you care about - if you
> want to avoid full sync.
That is really good observation. I have looked at some other drivers and
all of them actually unmap with the same length that they used when they
mapped the page.
But the order of the operations should be like this:
---
dma_sync_single_for_cpu(lan966x->dev, (dma_addr_t)db->dataptr,
FDMA_DCB_STATUS_BLOCKL(db->status),
DMA_FROM_DEVICE);
skb = build_skb(page_address(page), PAGE_SIZE << rx->page_order);
if (unlikely(!skb))
goto unmap_page;
dma_unmap_single_attrs(lan966x->dev, (dma_addr_t)db->dataptr,
PAGE_SIZE << rx->page_order, DMA_FROM_DEVICE,
DMA_ATTR_SKIP_CPU_SYNC);
---
Because in this way, I get the data from HW, I build the skb with all
the initialization and then I unmapped without CPU sync because I have
already done that.
>
> What made me pause here is that you build_skb() and then unmap which is
> also odd because normally (if unmap was passed full len) unmap could
> wipe what build_skb() initialized.
--
/Horatiu
prev parent reply other threads:[~2022-10-26 18:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-23 18:48 [PATCH net 0/3] net: lan966x: Fixes for " Horatiu Vultur
2022-10-23 18:48 ` [PATCH net 1/3] net: lan966x: Fix the MTU calculation Horatiu Vultur
2022-10-23 18:48 ` [PATCH net 2/3] net: lan966x: Adjust maximum frame size when vlan is enabled/disabled Horatiu Vultur
2022-10-23 18:48 ` [PATCH net 3/3] net: lan966x: Fix FDMA when MTU is changed Horatiu Vultur
2022-10-26 2:34 ` Jakub Kicinski
2022-10-26 18:35 ` Horatiu Vultur [this message]
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=20221026183527.z4zuihbk275gm4bi@soft-dev3-1 \
--to=horatiu.vultur@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®