From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B3F8C48BCF for ; Sat, 12 Jun 2021 18:26:27 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CABF6120D for ; Sat, 12 Jun 2021 18:26:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CABF6120D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 06BA680563; Sat, 12 Jun 2021 20:26:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nIl8FMHI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E405780797; Sat, 12 Jun 2021 20:26:22 +0200 (CEST) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 274DB80377 for ; Sat, 12 Jun 2021 20:26:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-ed1-x535.google.com with SMTP id w21so40934800edv.3 for ; Sat, 12 Jun 2021 11:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:content-transfer-encoding:date:message-id:cc:subject :from:to:references:in-reply-to; bh=ql+3cS/5sQZuUgwItdxxE0MZowRiJjeoCT6h1CHWMfo=; b=nIl8FMHICCOqDb8CRqoRzgbThV3TsNG7Hu6VwYp0ISFSmhDyNDGVGm4wpnHDn9+hMc AfIzCFSFzThI2zbkGyORcp76Bwi6BV46NqjAyun+yv06InkKi255IO7uTiA+j2Zyq+0+ AHvUNIrl8zG6Nf6RL1HUklhTSE6BaJGUSxheMxCCt5mXJXl0dk5XlfQ+wqdA2Htl4yAB yp3s6dYscQ7x5LdtwxVSFITWd+hHClHYfddsnx2jwQuc+0IjScrU0YCYfacMKBSQeFJ9 /VFPiTkWo5vPhYbeGh++qUAWXOxJU3AvXB8IX9FSS1kf3tw/tFAGkEiPS1VqRwHUg2X+ FhcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:date :message-id:cc:subject:from:to:references:in-reply-to; bh=ql+3cS/5sQZuUgwItdxxE0MZowRiJjeoCT6h1CHWMfo=; b=eOo/KEv6qBLWPFkKUFDfSVS/X9MRkjbyUikZzijjuMzPEl64o5quZS0kFJvG5UxlSi +IHFmXgP7lx/81PCXu28RBiuCA2qMGPtfQVZ2piHl1HvjxYoP9utpOVKSPE0T2vHGcHR PAATqABNQ9Y0eXS9dJXL+nCxkYiXmp5A5pT4XtCyNalVHPtJTyfgWBm/YB0GJ5kzdYqr qQyz5UBFKAf1gOWB90e0k4qyQF3m6msgnERdbJHeDCUzCuHt4P2yGvimJSTgAPVehPfg jh3KClVuTpR//gOnZiEN9ASNbpHRCfaG2zdDp8ghrgQntWdHw+60GDicZbpIEy71oF5x 5YpQ== X-Gm-Message-State: AOAM531KerDDkdBojhlTgtb/fG8YTN/Ft/lgDeiDh9gRZGs5ExrUzpqP 9z9yaVZ8YIqo/olWrZk2bSo= X-Google-Smtp-Source: ABdhPJzjNmTpeo2VJVzPQeZoxLx3tzXb5GCIVos/SRTJeY/2+5kwRtfzFkB3vu0AMuCnAx79bBYftw== X-Received: by 2002:a05:6402:34c6:: with SMTP id w6mr9609720edc.174.1623522379800; Sat, 12 Jun 2021 11:26:19 -0700 (PDT) Received: from localhost ([2a00:a040:198:e68a::1004]) by smtp.gmail.com with ESMTPSA id d5sm4325375edt.49.2021.06.12.11.26.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Jun 2021 11:26:19 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sat, 12 Jun 2021 21:26:17 +0300 Message-Id: Cc: Subject: Re: [PATCH v2] cmd: net: add a 'net list' command to list network devs From: "Ramon Fried" To: "Tim Harvey" , , "Joe Hershberger" References: <20210611195259.6040-1-tharvey@gateworks.com> In-Reply-To: <20210611195259.6040-1-tharvey@gateworks.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Fri Jun 11, 2021 at 10:52 PM IDT, Tim Harvey wrote: > In a system with multiple network controllers it can be difficult > to know the names of the various devices available. This is especially > true for USB ether devices as they do not display device names upon > detection. > > This is being added as a net sub-system in case other commands may > want to be added or moved here. > > Example: > U-Boot > net > net - NET sub-system > > Usage: > net list - list available devices > > U-Boot > net list > eth0 : ethernet@2188000 00:d0:12:98:f5:47 active > eth1 : e1000#0 00:d0:12:98:f5:48 > eth2 : asix_eth 8c:ae:4c:f5:84:9d > eth3 : asix_eth 8c:ae:4c:f9:41:e3 > > Signed-off-by: Tim Harvey > Reviewed-by: Stefan Roese > Reviewed-by: Ramon Fried > > --- > v2: added Reviewed-by tags > --- > cmd/net.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/cmd/net.c b/cmd/net.c > index beb2877dfd..e51bc443f7 100644 > --- a/cmd/net.c > +++ b/cmd/net.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -480,3 +481,46 @@ U_BOOT_CMD( > ); > =20 > #endif /* CONFIG_CMD_LINK_LOCAL */ > + > +static int do_net_list(struct cmd_tbl *cmdtp, int flag, int argc, char > *const argv[]) > +{ > + const struct udevice *current =3D eth_get_dev(); > + unsigned char env_enetaddr[ARP_HLEN]; > + const struct udevice *dev; > + struct uclass *uc; > + > + uclass_id_foreach_dev(UCLASS_ETH, dev, uc) { > + eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr); > + printf("eth%d : %s %pM %s\n", dev_seq(dev), dev->name, env_enetaddr, > + current =3D=3D dev ? "active" : ""); > + } > + return CMD_RET_SUCCESS; > +} > + > +static struct cmd_tbl cmd_net[] =3D { > + U_BOOT_CMD_MKENT(list, 1, 0, do_net_list, "", ""), > +}; > + > +static int do_net(struct cmd_tbl *cmdtp, int flag, int argc, char > *const argv[]) > +{ > + struct cmd_tbl *cp; > + > + cp =3D find_cmd_tbl(argv[1], cmd_net, ARRAY_SIZE(cmd_net)); > + > + /* Drop the net command */ > + argc--; > + argv++; > + > + if (!cp || argc > cp->maxargs) > + return CMD_RET_USAGE; > + if (flag =3D=3D CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) > + return CMD_RET_SUCCESS; > + > + return cp->cmd(cmdtp, flag, argc, argv); > +} > + > +U_BOOT_CMD( > + net, 2, 1, do_net, > + "NET sub-system", > + "list - list available devices\n" > +); > -- > 2.17.1 Applied to u-boot-net/master, thanks! Best regards, Ramon Fried