From nobody Sat Oct 29 12:19:40 2022 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mzz4d2STbz4gw4X for ; Sat, 29 Oct 2022 12:19:45 +0000 (UTC) (envelope-from mike@karels.net) Received: from mail.karels.net (mail.karels.net [216.160.39.52]) by mx1.freebsd.org (Postfix) with ESMTP id 4Mzz4c3D4Fz3SnP for ; Sat, 29 Oct 2022 12:19:44 +0000 (UTC) (envelope-from mike@karels.net) Received: from mail.karels.net (localhost [127.0.0.1]) by mail.karels.net (8.16.1/8.16.1) with ESMTP id 29TCJfB3039331; Sat, 29 Oct 2022 07:19:43 -0500 (CDT) (envelope-from mike@karels.net) Received: from [10.0.2.130] ([10.0.1.1]) by mail.karels.net with ESMTPSA id aJZQLF0aXWOhmQAA4+wvSQ (envelope-from ); Sat, 29 Oct 2022 07:19:41 -0500 From: Mike Karels To: Ronald Klop Cc: freebsd-arm@freebsd.org Subject: Re: wake-on-lan lost from rpi4 (works on rpi3) Date: Sat, 29 Oct 2022 07:19:40 -0500 X-Mailer: MailMate (1.14r5921) Message-ID: <08463D8E-13F5-4EA2-A4F5-D2C45B90C0AA@karels.net> In-Reply-To: <2086140007.15494.1667020606677@localhost> References: <2086140007.15494.1667020606677@localhost> List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4Mzz4c3D4Fz3SnP X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of mike@karels.net designates 216.160.39.52 as permitted sender) smtp.mailfrom=mike@karels.net X-Spamd-Result: default: False [-3.17 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-0.999]; NEURAL_HAM_SHORT(-0.97)[-0.966]; R_SPF_ALLOW(-0.20)[+ip4:216.160.39.52]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; MLMMJ_DEST(0.00)[freebsd-arm@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; ASN(0.00)[asn:209, ipnet:216.160.36.0/22, country:US]; FREEFALL_USER(0.00)[mike]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[karels.net]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 29 Oct 2022, at 0:16, Ronald Klop wrote: > Van: Ronald Klop > Datum: 25 oktober 2022 20:32 > Aan: mike@karels.net > CC: freebsd-arm@freebsd.org > Onderwerp: Re: wake-on-lan lost from rpi4 (works on rpi3) > >> >> >> >> Van: Mike Karels Datum: dinsdag, 25 oktober 2022 18:11 >> Aan: Ronald Klop CC: freebsd-arm@freebsd.org >> Onderwerp: Re: wake-on-lan lost from rpi4 (works on rpi3) >>> >>> I wrote: >>>> On 25 Oct 2022, at 9:13, Ronald Klop wrote: >>> >>>>> Van: Mike Karels > > Datum: dinsdag, 25 oktober 2022 14:55 >>>>> Aan: Ronald Klop > > CC: freebsd-arm@freebsd.org >>>>> Onderwerp: Re: wake-on-lan lost from rpi4 (works on rpi3) >>>>>> >>>>>> On 25 Oct 2022, at 6:57, Ronald Klop wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> When I do "wake ue0 `cat /home/ronald/freenas.ethernet `" on my R= PI3B+ my NAS boots and tcpdump shows the following line on my rpi3 as wel= l as on my router. >>>>>>> 13:39:44.344111 IPX 00217046.6c:da:00:21:70:46.6cda > 00217046.6c= :da:00:21:70:46.6cda: ipx-#6cda 65505 >>>>>>> >>>>>>> When I do "wake genet0 `cat /home/ronald/freenas.ethernet `" on m= y RPI4 my NAS does not boot and tcpdump only show this on my rpi4 and *no= t* on my router. >>>>>>> 13:37:26.448251 IPX 00217046.6c:da:00:21:70:46.6cda > 00217046.6c= :da:00:21:70:46.6cda: ipx-#6cda 65505 >>>>>>> >>>>>>> Firewall ipfw does not indicate that it blocks anything. >>>>>>> >>>>>>> RPI4 runs: >>>>>>> FreeBSD rpi4 14.0-CURRENT FreeBSD 14.0-CURRENT #11 main-4f0c9b76c= f: Sat Aug 13 23:59:19 CEST 2022 ronald@rpi4:/home/ronald/dev/obj/hom= e/ronald/dev/freebsd/arm64.aarch64/sys/GENERIC-NODEBUG arm64 >>>>>>> >>>>>>> genet0: flags=3D8943 metric 0 mtu 1500 >>>>>>> options=3D68000b >>>>>>> >>>>>>> >>>>>>> RPI3 runs: >>>>>>> FreeBSD rpi3 13.1-RELEASE-p2 FreeBSD 13.1-RELEASE-p2 GENERIC arm6= 4 >>>>>>> >>>>>>> ue0: flags=3D8943 metric 0 mtu 1500 >>>>>>> options=3D80009 >>>>>>> >>>>>>> >>>>>>> Does genet0 not support these packages? >>>>>>> What can prevent this packet to go on the ethernet while tcpdump = still shows it is outgoing on the interface? >>>>>>> genet0 does have a vlan configured connected to a bridge0 for som= e jails >>>>>>> vlan3: flags=3D8943 metric 0 mtu 1500 >>>>>>> options=3D80000 >>>>>>> groups: vlan >>>>>>> vlan: 3 vlanproto: 802.1q vlanpcp: 0 parent interface: genet0 >>>>>>> >>>>>>> ue0 is itself connected to a bridge0 >>>>>> >>>>>> Is the RPI3 also on a vlan and bridge? >>>>>> >>>>>> Is the router (or switch) expecting the packet on the vlan? >>>>>> If so, maybe you need to send on vlan3 rather than genet0. >>>>>> >>>>>> The genet interface has some oddities about packet layouts; >>>>>> that could be hitting here. You could try disabling TCP TX >>>>>> checksum offload: ifconfig genet0 -txcsum -txcsum6; that >>>>>> simplifies some of the issues. >>>>>> >>>>>> Mike >>>>>> >>>>>>> Regards, >>>>>>> Ronald. >>>>> >>>>> >>>>> Hi, >>>>> >>>>> Thanks for the hint. I experimented some further. >>>>> >>>>> Disabling -txcsum -rxcsum didn't matter. >>> >>>> -rxcsum doesn't matter, but you need to do -txcsum6 as well as >>>> -txcsum. (See the code that calls gen_parse_tx.) >>> >>>>> But when I use bridge0 or vlan3 as device then it goes into the wir= e but on the VLAN which is not where my NAS is which I want to boot. >>>>> >>>>> Looking at the driver I found this interesting peace of code. >>>>> >>>>> static int >>>>> gen_parse_tx(struct mbuf *m, int csum_flags) { >>>>> ... >>>>> if (ether_type =3D=3D ETHERTYPE_IP) { >>>>> COPY(((struct ip *)p)->ip_hl << 2); >>>>> offset +=3D ((struct ip *)p)->ip_hl << 2; >>>>> } else if (ether_type =3D=3D ETHERTYPE_IPV6) { >>>>> COPY(sizeof(struct ip6_hdr)); >>>>> offset +=3D sizeof(struct ip6_hdr); >>>>> } else { >>>>> /* >>>>> * Unknown whether other cases require moving a head= er; >>>>> * ARP works without. >>>>> */ >>>>> } >>>>> ... >>>>> } >>>>> >>>>> There is also some code which handles EHTERTYPE_VLAN. >>>>> >>>>> I don't have time to start debugging this today. But would this rin= g a bell to anybody in connection to a wake-on-lan packet? >>> >>>> I ran some experiments with tx checksum disabled, and it seems to >>>> matter. I have a change for the last block you listed that might >>>> help, but I haven't tested it yet. >>> >>> This patch seems to work: >>> >>> diff --git a/sys/arm64/broadcom/genet/if_genet.c b/sys/arm64/broadcom= /genet/if_genet.c >>> index 327af8acbcdd..b7ab86e7931d 100644 >>> --- a/sys/arm64/broadcom/genet/if_genet.c >>> +++ b/sys/arm64/broadcom/genet/if_genet.c >>> @@ -1305,6 +1305,8 @@ gen_parse_tx(struct mbuf *m, int csum_flags) >>> * Unknown whether other cases require moving a header; >>> * ARP works without. >>> */ >>> + COPY(min(gen_tx_hdr_min, m->m_len)); >>> + offset +=3D min(gen_tx_hdr_min, m->m_len); >>> } >>> return (offset); >>> #undef COPY >>> >>> It needs an updated comment, but should be testable. >>> >>> Mike >>> >>>>> Regards, >>>>> Ronald. >>> >>> >> >> Hi, >> >> Thanks. Disabling both -txcsum and -txcsum6 works for me also. >> I can test your patch tommorow or on Thursday. I'm first testing a big= mongodb 6.0 patch I hope to commit soon and this build occupies my rpi4 = for some more hours. >> >> Regards, >> Ronald. >> > > > Hi, > > Your patch works for me. I can send wake-on-lan packets now. Should I t= est other specific things also? The patch affects anything that is not IPv4 or IPv6, including ARP (which seems to work). Anything else that writes via BPF would take the same path. I=E2=80=99m not thinking of much, though. I=E2=80=99ll go ahead and commit this. Mike > Regards, > > Ronald.