diff mbox series

realtek: fix RTL839x receive tag decoding

Message ID 20220909062813.1511575-1-bjorn@mork.no
State Accepted
Delegated to: Sander Vanheule
Headers show
Series realtek: fix RTL839x receive tag decoding | expand

Commit Message

Bjørn Mork Sept. 9, 2022, 6:28 a.m. UTC
The previous fixup was incomplete, and the offsets for the
queue and crc_error cpu_tag bitfields were still wrong on
RTL839x.

Fixes: 545c6113c93b ("realtek: fix RTL838x receive tag decoding")
Suggested-by: Jan Hoffmann <jan@3e8.eu>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
Jan pointed put that I missed two fields on the RTL839x. Sloppy. Fix
those as well.

This time even without complaints from checkpatch :-)

But build tested only.  I don't have any 839x and I don't know how
to verify these features anyway.


Bjørn

 .../realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sander Vanheule Sept. 9, 2022, 7:45 a.m. UTC | #1
On Fri, 2022-09-09 at 08:28 +0200, Bjørn Mork wrote:
> The previous fixup was incomplete, and the offsets for the
> queue and crc_error cpu_tag bitfields were still wrong on
> RTL839x.
> 
> Fixes: 545c6113c93b ("realtek: fix RTL838x receive tag decoding")
> Suggested-by: Jan Hoffmann <jan@3e8.eu>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
> ---
> Jan pointed put that I missed two fields on the RTL839x. Sloppy. Fix
> those as well.
> 
> This time even without complaints from checkpatch :-)
> 
> But build tested only.  I don't have any 839x and I don't know how
> to verify these features anyway.

+CC Andreas, Hiroshi, Luiz, Markus as rtl839x users.

For dsa_tag::queue, it looks like the (received) value is only ever used in log statements.

dsa_tag::crc_error is used to set sk_buff::ip_summed to either CHECKSUM_NONE or
CHECKSUM_UNNECESSARY. AFAICT invalid crc_error values could lead to invalid packets being marked as
valid (unlikely on a good connection), or redundant checksum calculations.

I think crc_error is the only one that might be causing issues, but probably not as bad as the issue
that was fixed with commit 545c6113c93b ("realtek: fix RTL838x receive tag decoding").

This patch is backed by the documentation, so if nobody is set up to check if it fixes anything, it
should be merged anyway.

Best,
Sander
Sander Vanheule Sept. 9, 2022, 8:22 p.m. UTC | #2
On Fri, 2022-09-09 at 08:28 +0200, Bjørn Mork wrote:
> The previous fixup was incomplete, and the offsets for the
> queue and crc_error cpu_tag bitfields were still wrong on
> RTL839x.
> 
> Fixes: 545c6113c93b ("realtek: fix RTL838x receive tag decoding")
> Suggested-by: Jan Hoffmann <jan@3e8.eu>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
> ---

I've gone ahead and just merged the patch. Up to the next fix!

Best,
Sander
Luiz Angelo Daros de Luca Sept. 15, 2022, 7:57 p.m. UTC | #3
> > The previous fixup was incomplete, and the offsets for the
> > queue and crc_error cpu_tag bitfields were still wrong on
> > RTL839x.
> >
> > Fixes: 545c6113c93b ("realtek: fix RTL838x receive tag decoding")
> > Suggested-by: Jan Hoffmann <jan@3e8.eu>
> > Signed-off-by: Bjørn Mork <bjorn@mork.no>
> > ---
> > Jan pointed put that I missed two fields on the RTL839x. Sloppy. Fix
> > those as well.
> >
> > This time even without complaints from checkpatch :-)
> >
> > But build tested only.  I don't have any 839x and I don't know how
> > to verify these features anyway.
>
> +CC Andreas, Hiroshi, Luiz, Markus as rtl839x users.

I was hoping this would fix the missing vlan tag for traffic that goes
through the switch.
I just tested https://github.com/openwrt/openwrt/pull/10643 rebased on
current master
and the issue is the same: tagged vlan to tagged vlan forwarded by the
switch is sent untagged while tagged traffic that goes
to/from the CPU works as expected. It does not seem to be related to
the received tag. It looks like the tag
is added correctly by the CPU but the switch is not configured
correctly to add a tag for traffic to a specific vlan.
I would bet it is the internal switch vlan setup, not the linux side.

BTW, it might be time to merge that PR as, AFAIK, this vlan issue
affects the SoC, not that specific device.

Regards,

Luiz
diff mbox series

Patch

diff --git a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
index d9ade6552698..e96c5a7216f8 100644
--- a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
+++ b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
@@ -282,9 +282,9 @@  bool rtl839x_decode_tag(struct p_hdr *h, struct dsa_tag *t)
 {
 	/* cpu_tag[0] is reserved. Fields are off-by-one */
 	t->reason = h->cpu_tag[5] & 0x1f;
-	t->queue = (h->cpu_tag[3] & 0xe000) >> 13;
+	t->queue = (h->cpu_tag[4] & 0xe000) >> 13;
 	t->port = h->cpu_tag[1] & 0x3f;
-	t->crc_error = h->cpu_tag[3] & BIT(2);
+	t->crc_error = h->cpu_tag[4] & BIT(6);
 
 	pr_debug("Reason: %d\n", t->reason);
 	if ((t->reason >= 7 && t->reason <= 13) || // NIC_RX_REASON_RMA