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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 52B1EC83027 for ; Thu, 2 Sep 2021 16:42:36 +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 A3DC5610D2 for ; Thu, 2 Sep 2021 16:42:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A3DC5610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F41B1834D2; Thu, 2 Sep 2021 18:42:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bzQksMTU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B328B8348D; Thu, 2 Sep 2021 18:42:06 +0200 (CEST) Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) (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 D1E9D834AC for ; Thu, 2 Sep 2021 18:41:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ot1-x32a.google.com with SMTP id l7-20020a0568302b0700b0051c0181deebso3259309otv.12 for ; Thu, 02 Sep 2021 09:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aukcFgQYhvoOBo9rGNIasQSnRaQWhkT03M6MF9OQTyY=; b=bzQksMTUs14grv3QbW1H/KifNn64uXJbAGFzkz1YN0ztQwPf+7eYMR2b12wF64FRsL AnyUu3a9AGexc+fBwH32ydzOjMsx7IsRswHvWSTowxwvP8g6XVx3cCtW2GEyE4xTYHgT lAOSZd0A6PrDJqYgdOMACp7ybB1OXzKF8OMhY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aukcFgQYhvoOBo9rGNIasQSnRaQWhkT03M6MF9OQTyY=; b=HGQfBlOqcl+UmG5013aTeCqtWbAMI294p498PDZV4II2ONx5C4fkYwPUuGH7KhxUB5 TCFYlZ3us+fUIeB6jbCaY0IIJpnLvekNaG1KqH8alnAZsYd3jjITQwBinpJAub9eVtTZ z98bq9zD+KfOyXDjiStCDz5pywYkpsKZuCKqa84UMl1bRCESo9kqmSk8BPWxASuvbFxj nb53rcAsyoAkw5MgI1NlbIAvlXtcVSogA1687uNwhllbmvCizrw0yOX+oJGjvkTydugC GhGkstZFIXfB+cjSA49Ph7M1sQxtHL4eBmCbyGV5zSha1CCbYiIg6+xf8m7p5G5MSjyW WUSQ== X-Gm-Message-State: AOAM5306+tW8IP+W7+C+T8UACU46RxpY/AHiLJ6vwwrWdWOgnzD2AK4v DidAuCSx7lYrpV8eathHz95y9u40pL26bZgUhqcQ1n1x5gJLfQ== X-Google-Smtp-Source: ABdhPJwtDSNMSrDhlnf9z1YLfRKvhsgQ4KCD040VkkKBpvDBF7QmbetS6iHKvwLP2PB0iKjjuT05/nryi28adhLj0J0= X-Received: by 2002:a9d:7dd5:: with SMTP id k21mr3416654otn.54.1630600917151; Thu, 02 Sep 2021 09:41:57 -0700 (PDT) MIME-Version: 1.0 References: <20210806044910.23500-1-mibodhi@gmail.com> In-Reply-To: From: Simon Glass Date: Thu, 2 Sep 2021 10:41:07 -0600 Message-ID: Subject: Re: [PATCH 0/3] common: Add fdt network helper To: Tony Dinh Cc: U-Boot Mailing List , Stefan Roese , Ramon Fried , Joe Hershberger , Tom Rini Content-Type: text/plain; charset="UTF-8" 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 Hi Tony, On Wed, 1 Sept 2021 at 03:22, Tony Dinh wrote: > > Hey Simon, > > On Thu, Aug 26, 2021 at 9:00 PM Tony Dinh wrote: > > > > Hi Simon, > > > > On Tue, Aug 17, 2021 at 9:09 AM Simon Glass wrote: > > > > > > Hi Tony, > > > > > > On Sun, 15 Aug 2021 at 15:28, Tony Dinh wrote: > > > > > > > > Hi Simon, > > > > > > > > On Sun, Aug 15, 2021 at 7:10 AM Simon Glass wrote: > > > > > > > > > > Hi Tony, > > > > > > > > > > On Thu, 5 Aug 2021 at 22:49, Tony Dinh wrote: > > > > > > > > > > > > > > > > > > At the moment, there is no common fdt helper function specific to decoding network related > > > > > > information from FDTs. This new helper functional group fdt_support_net is intended to be used > > > > > > by board-specific code within U-Boot for various network related chores. > > > > > > > > > > > > In this patch, create the 1st function fdt_get_phy_addr to parse the device tree to find > > > > > > the PHY addess of a specific ethernet device. > > > > > > > > > > > > > > > > > > Tony Dinh (3): > > > > > > Add fdt network helper header file > > > > > > Add fdt network helper functions > > > > > > Add fdt network helper to Makefile > > > > > > > > > > > > common/Makefile | 2 +- > > > > > > common/fdt_support_net.c | 46 +++++++++++++++++++++++++++++++++++++++ > > > > > > include/fdt_support_net.h | 39 +++++++++++++++++++++++++++++++++ > > > > > > 3 files changed, 86 insertions(+), 1 deletion(-) > > > > > > create mode 100644 common/fdt_support_net.c > > > > > > create mode 100644 include/fdt_support_net.h > > > > > > > > > > Can this use livetre and also have some tests? > > > > > > > > I have not enabled livetree for any of the boards I have. So I just > > > > modeled this using the existing ./common/fdt_support.c! > > > > > > > > I do agree we should start using livetree in fdt helpers, if I > > > > understood it correctly, it should work for both flattree and > > > > > > OK good, yes that's right. > > > > > > > livetree. Perhaps we could have another patch series after this? I am > > > > preparing another Kirkwood board support patch that I could hold off > > > > submitting and enable livetree to use that as a vehicle for testing. > > > > > > I think it is better to use livetree in this patch. For testing, you > > > can use sandbox for testing (see for example test/dm/ofnode.c) > > > > > > Regards, > > > Simon > > > > It seems it is too time consuming to implement this using livetree > > calls (with my limited understanding about livetree). I spent a few > > hours reading ./include/dm/read.h and ./include/dm/ofnode.h, and it is > > not apparent to me which functions to use. I see that we have > > eth_get_dev_by_name(), that's a start. > > > > Do you have any objection if I submit this function as a patch to > > ./common/fdt_support.c? fdt_support.c file is all flatree > > implementation. And by the way, this new function fdt_get_phy_addr() > > has been tested with several Kirkwood boards that I have been > > converting to DM Ethernet. > > > > When the time comes that it's mandatory to convert all to livetree > > calls, I'll be glad to help. > > I know you're as busy as always ;) But I would appreciate either an > ACK or NACK on my proposal to submit this as a patch to > ./common/fdt_support.c. We should not be adding new functions that use flattree. If you are unsure which functions to use, please ask. But some examples: int ofnode_read_u32(ofnode node, const char *propname, u32 *outp); u32 ofnode_read_u32_default(ofnode ref, const char *propname, u32 def); const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep); const char *ofnode_read_string(ofnode node, const char *propname); It is easy enough to convert an offset into an ofnode and vice versa. For adding tests, see test/dm/ofnode.c for examples. https://u-boot.readthedocs.io/en/latest/develop/tests_sandbox.html To run a particular test, a quick way is: make sandbox_defconfig make ./u-boot -T -c "ut dm ofnode" ./u-boot -T -c "ut dm dm_test_ofnode_get_by_phandle" This bash function will run tests which match a particular string: function pyt { test/py/test.py -B sandbox --build-dir /tmp/b/sandbox ${1:+"-k $1"} } e.g to run all ofnode tests: $ pyt ofnode =============================== test session starts ================================ platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0 rootdir: /home/sjg/c/src/third_party/u-boot/files/test/py, configfile: pytest.ini plugins: forked-1.3.0, hypothesis-5.43.3, xdist-2.2.0 collected 843 items / 828 deselected / 15 selected test/py/tests/test_ut.py ............... [100%] ======================== 15 passed, 828 deselected in 0.67s ======================== Regards, Simon