From: Simon Horman <horms@kernel.org>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: netdev-bot+sashiko@kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horatiu.vultur@microchip.com,
steen.hegelund@microchip.com, UNGLinuxDriver@microchip.com,
ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me,
herve.codina@bootlin.com, arnd@arndb.de,
gregkh@linuxfoundation.org, mohsin.bashr@gmail.com,
richardcochran@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next v7 10/14] net: lan966x: add PCIe FDMA support
Date: Wed, 23 Sep 2026 19:07:30 +0100 [thread overview]
Message-ID: <20260923180730.GV13925@horms.kernel.org> (raw)
In-Reply-To: <20260923084538.wgkw2nt5ergoxcot@DEN-DL-M70577>
On Wed, Sep 23, 2026 at 10:45:38AM +0200, Daniel Machon wrote:
...
> > [Severity: Medium]
> > Is this path expected to work on a big-endian host?
> >
> > Until now the descriptor producer and the FDMA engine were both on the
> > little-endian SoC, so the native-endian descriptor layout in
> > drivers/net/ethernet/microchip/fdma/fdma_api.h was fine:
> >
> > struct fdma_db {
> > u64 dataptr;
> > u64 status;
> > };
> >
> > struct fdma_dcb {
> > u64 nextptr;
> > u64 info;
> > struct fdma_db db[FDMA_DB_MAX];
> > };
> >
> > With PCIe FDMA the descriptors live in host memory and are fetched by the
> > endpoint, so the host and the engine can disagree on byte order. The
> > translated addresses written here, and the status/info words written by
> > __fdma_db_add()/__fdma_dcb_add(), all go out in host byte order, and the
> > HW-written DONE/BLOCKL fields are read back the same way in
> > lan966x_fdma_pci_get_next_dcb() and lan966x_fdma_pci_rx_check_frame().
> >
> > CONFIG_MCHP_LAN966X_PCI in drivers/misc/Kconfig only has
> >
> > depends on PCI
> > depends on OF_OVERLAY
> >
> > so a big-endian host (e.g. powerpc) can select it. On such a host, would
> > the engine see byte-swapped nextptr/dataptr and length fields, i.e. would
> > RX/TX not work at all? Should the descriptor fields become explicit
> > little-endian types with accessors at the hardware boundary, or should the
> > Kconfig entry gain a little-endian dependency?
>
> Hmm. Never tested on PowerPC, not this driver nor the DT overlay mechanism it
> relies on for PCI deployment, which has only been exercised on ARM and x86 so
> far (AFAICT) [1].
>
> [1] https://lore.kernel.org/all/20240430183301.46568e35@bootlin.com/
I don't think that the baseline expectation is that drivers are tested
on big-endian systems, but rather that reasonable effort is made to ensure
that byte-order usage is correct.
In this case I suggest that will involve using __le64 instead of u64,
coupled with calling le64_to_cpu() and cpu_to_le64() as appropriate.
Sparse can aid with getting this right.
...
> > [Severity: Medium]
> > Is rx_bytes meant to count the frame as it arrived on the wire?
> >
> > By the time this runs, skb->len has already been reduced twice: the
> > skb_trim() above drops ETH_FCS_LEN, and eth_type_trans() pulls the
> > MAC header out of the linear region, so skb->len is short by at least
> > ETH_HLEN. If lan966x_hw_offload() ends up untagging a VLAN header,
> > that is another four bytes gone. So every packet delivered through
> > lan966x_fdma_pci_rx_get_frame() undercounts rx_bytes by 14 bytes or
> > more, which is visible to userspace via ip -s link.
> >
> > The frame length is available before any of that surgery happens --
> > data_len from FDMA_DCB_STATUS_BLOCKL(db->status), or skb->len right
> > after the skb_pull(skb, IFH_LEN_BYTES) -- so accounting could be done
> > there instead.
> >
> > I realise this mirrors what the existing register/page path in
> > lan966x_fdma.c does, so if the intent is to keep the two backends
> > byte-for-byte consistent, please say so; otherwise it would be good
> > not to copy the miscount into the new file.
>
> Not only lan966x, but sparx5 and lan969x does the exact same thing, increasing
> rx_bytes after headers are pulled. The undercount is real, but not visible to
> userspace. Both implementations (platform and PCI) read hardware counters directly
I'm a little unsure, but if it's consistent then I guess that is ok.
It's an old interface anyway.
next prev parent reply other threads:[~2026-09-23 18:07 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 11:33 [PATCH net-next v7 00/14] net: lan966x: add support for PCIe FDMA Daniel Machon
2026-09-18 11:33 ` [PATCH net-next v7 01/14] MAINTAINERS: add FDMA library to Sparx5 SoC entry Daniel Machon
2026-09-23 8:48 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 02/14] net: microchip: fdma: rename contiguous dataptr helpers Daniel Machon
2026-09-23 8:49 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 03/14] net: microchip: fdma: add PCIe ATU support Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 6:35 ` Daniel Machon
2026-09-23 8:51 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 04/14] net: lan966x: add FDMA LLP register write helper Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 7:07 ` Daniel Machon
2026-09-23 8:54 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 05/14] net: lan966x: export FDMA helpers for reuse Daniel Machon
2026-09-23 8:57 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 06/14] net: lan966x: use a dedicated device for DMA operations Daniel Machon
2026-09-23 8:59 ` Simon Horman
2026-09-18 11:33 ` [PATCH net-next v7 07/14] net: lan966x: add FDMA ops dispatch for PCIe support Daniel Machon
2026-09-23 9:00 ` Simon Horman
2026-09-18 11:34 ` [PATCH net-next v7 08/14] net: lan966x: clear FDMA interrupt stickies after switch reset Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 9:01 ` Simon Horman
2026-09-18 11:34 ` [PATCH net-next v7 09/14] net: lan966x: add shutdown callback to stop the FDMA on reboot Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 9:02 ` Simon Horman
2026-09-18 11:34 ` [PATCH net-next v7 10/14] net: lan966x: add PCIe FDMA support Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 8:45 ` Daniel Machon
2026-09-23 18:07 ` Simon Horman [this message]
2026-09-23 20:11 ` Daniel Machon
2026-09-18 11:34 ` [PATCH net-next v7 11/14] net: lan966x: add PCIe FDMA MTU change support Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 9:46 ` Daniel Machon
2026-09-23 19:39 ` Simon Horman
2026-09-23 20:07 ` Daniel Machon
2026-09-18 11:34 ` [PATCH net-next v7 12/14] net: lan966x: add PCIe FDMA XDP support Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-23 10:14 ` Daniel Machon
2026-09-18 11:34 ` [PATCH net-next v7 13/14] misc: lan966x-pci: dts: extend cpu reg to cover PCIE DBI space Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
2026-09-18 11:34 ` [PATCH net-next v7 14/14] misc: lan966x-pci: dts: add fdma interrupt to overlay Daniel Machon
2026-09-22 13:00 ` netdev-bot+sashiko
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=20260923180730.GV13925@horms.kernel.org \
--to=horms@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel.machon@microchip.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hawk@kernel.org \
--cc=herve.codina@bootlin.com \
--cc=horatiu.vultur@microchip.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mohsin.bashr@gmail.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sdf@fomichev.me \
--cc=steen.hegelund@microchip.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®