From nobody Sat Sep 23 19:28:39 2023 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 4RtK1s30CBz4v7NN for ; Sat, 23 Sep 2023 19:28:49 +0000 (UTC) (envelope-from ronald@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RtK1s2SMXz3FwJ; Sat, 23 Sep 2023 19:28:49 +0000 (UTC) (envelope-from ronald@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695497329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XKjmyZhJv0dOt9GOkPbLT8R6F1yANsj6DlSbF0nshXU=; b=jko8ruUpsHXzWLIu5GF8qqbP+lEo2aq+SWzdHS6EmCAcAA8pTt6CQOgcCPMjhu7Ll5EPxk o88a2vi7/9637a+lUoqZsz0ARJDHTdpUV2LxNClnXLF1LZivEaxuwyyVKvottzZ77FIzlD Opj8KFvkql6nhCjFKdGa8eprcfCl+Q3CATPJdDaToGAOhDtmXlLZuVtOUmF1jT6nJnmMKK eMRSD/RkDYwNyzv9MOFjJiBheqBj1YS/g/Hwg9vcKKcvcD3D12vUSx4eGOoGaPO2GrDJmB 9jpdal32XigP/L3fQuqUI83r4KnF0b2MyIQlJ1IG8cxQqrq8jN/E9eoI3BmrLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695497329; a=rsa-sha256; cv=none; b=a4o0RAUx7BK6uoDCRA4stEWzGs0RjmG6Buq8mDQelkQDiD5FEaz3WXeH7L0vlwcdK/rg3F cLWSVk4VznOboRL5upF4v8nywrLRy2USvVgaSiU6W7kigNtE0m9GREzet4F923iiR7dC3w ExHLfVilazOq2Zbngw3zJ45fdmi3w+OVngc1GCzjMPKj+rJwRt5SoIm+J0m0O+OAaEB11J tRoMlnORsmITSP4s+6IXyg+2Liztn0hax6LNwQWEQEcKQTl+LiwTxmI8va1xGL2JL4pnpz W/2ErDZ9uEzkDoEpSQpFPbeD2G3ZeLyvA5KBUV3TaY96Vt9Tu/Ed5kW/io7u7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695497329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XKjmyZhJv0dOt9GOkPbLT8R6F1yANsj6DlSbF0nshXU=; b=x5IEWoR0/Z7pI/AyCb/zWXPGHaeNtz1UunM9z2P1FVKrcU+z3H4jLaAMXIpm+12mz9W0qD LCSEo1OuMod6RWhPBpHs5FhB0UJ4xFoPqGU83A5hgiNr0oL9zCgaUTRQlVu5scRc+M5gOY izp8ED1UTKwEMWO0O04/jr2Ob++vR8WoZNrMWTkfp4sdR3doCeFxcjCIZDdcBGYospORq0 X698c+efylhY5vVqvYe6ulHuFuY7u4Lpk9jtXRxE6rrF9gXs+VhsKbHKZaJV7DzeMCNb5z 8zN+kFHlWnqTncRkA/qXWem47m0AWCmO3EC0a1wqutHkCPVU43dd6CIVhaMcIg== Received: from [IPV6:2001:1c00:2709:2010:dc87:f1a:49cd:cb73] (2001-1c00-2709-2010-dc87-0f1a-49cd-cb73.cable.dynamic.v6.ziggo.nl [IPv6:2001:1c00:2709:2010:dc87:f1a:49cd:cb73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: ronald/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RtK1r4qLMz1PwZ; Sat, 23 Sep 2023 19:28:48 +0000 (UTC) (envelope-from ronald@FreeBSD.org) Message-ID: <4951c134-39be-43de-0aa7-430a136d8b36@FreeBSD.org> Date: Sat, 23 Sep 2023 21:28:39 +0200 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 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: Getting a stable MAC address for a RPI CM3+ with ue0 interface To: Mike Karels , "Patrick M. Hausen" Cc: Mark Millard , freebsd-arm@freebsd.org References: <3C1032FF-B914-4863-8A03-759A8B4BE216@hausen.com> <77E70D30-8E7D-42DC-A041-3A783E1C6908@yahoo.com> <5205C76E-BAB4-4AB7-8A03-1E8A2D4353BB@hausen.com> <84C20AD4-1F37-414E-8808-60A2C9B621D9@karels.net> Content-Language: en-US From: Ronald Klop In-Reply-To: <84C20AD4-1F37-414E-8808-60A2C9B621D9@karels.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 9/20/23 22:02, Mike Karels wrote: > On 20 Sep 2023, at 14:49, Patrick M. Hausen wrote: > >> Hi all, >> >> some more research ... >> >>> Am 20.09.2023 um 21:05 schrieb Patrick M. Hausen : >>> No worky. >>> [...] >> >> >> I could not find any code in the network startup routines in userland that >> would generate and configure a random MAC address. So I looked for >> the driver. >> >> Apparently the TuringPi uses smsc(4), and there we have it straight from >> the driver source: >> >> ------------------- >> static void >> smsc_attach_post(struct usb_ether *ue) >> { >> [...] >> /* Attempt to get the mac address, if an EEPROM is not attached this >> * will just return FF:FF:FF:FF:FF:FF, so in such cases we invent a MAC >> * address based on urandom. >> */ >> [...] >> /* Initialise the chip for the first time */ >> smsc_chip_init(sc); >> } >> ------------------- >> >> So what we would really need is a tunable - one per driver or possibly a >> common one read and acted upon by all of the USB ethernet drivers ... > > There is a routine called ether_gen_addr(), which will generate an > Ethernet MAC based on the hostid and the interface name, both of which > are reasonably stable. Not very many drivers use it though. It > would probably be an improvement. > >> With no code on our side to perform anything, no wonder the RPI >> config files have no effect. > > It would seem wrong to me to have USB Ethernet drivers using an RPI-specific > mechanism. > >> Dang. That's frustrating. With aarch64 having been promoted to "tier 1" >> I really expected full support for all RPI platforms and related features >> and hardware. >> >> Or am I misreading that? I though that the Pi was *the* aarch64 platform, >> at least in numbers ... > > In numbers, probably. In support, no. > > Mike > >> Kind regards, >> Patrick > Would this work? diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c index 0a0268bfa1a2..4a7983a20717 100644 --- a/sys/dev/usb/net/if_smsc.c +++ b/sys/dev/usb/net/if_smsc.c @@ -1554,6 +1554,7 @@ static void smsc_attach_post(struct usb_ether *ue) { struct smsc_softc *sc = uether_getsc(ue); + struct ether_addr eaddr; uint32_t mac_h, mac_l; int err; @@ -1589,9 +1590,10 @@ smsc_attach_post(struct usb_ether *ue) err = usb_fdt_get_mac_addr(sc->sc_ue.ue_dev, &sc->sc_ue); #endif if ((err != 0) || (!ETHER_IS_VALID(sc->sc_ue.ue_eaddr))) { - read_random(sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN); - sc->sc_ue.ue_eaddr[0] &= ~0x01; /* unicast */ - sc->sc_ue.ue_eaddr[0] |= 0x02; /* locally administered */ + device_printf(ue->ue_dev, "No MAC address found. Using ether_gen_addr().\n"); + ether_gen_addr(ue->ue_ifp, &eaddr); + for (int i = 0; i < ETHER_ADDR_LEN; i++) + sc->sc_ue.ue_eaddr[i] = eaddr.octet[i]; } } I don't have the hardware so I can't test it. Regards, Ronald.