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.7 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 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 9E969C433F5 for ; Tue, 14 Sep 2021 09:24:50 +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 12D2D61056 for ; Tue, 14 Sep 2021 09:24:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 12D2D61056 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 4EBFE83143; Tue, 14 Sep 2021 11:24:42 +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="NpfJGsVD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 86F20831AC; Tue, 14 Sep 2021 11:24:32 +0200 (CEST) Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (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 528B4832E9 for ; Tue, 14 Sep 2021 11:24:19 +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-ot1-x329.google.com with SMTP id c19-20020a9d6153000000b0051829acbfc7so17479640otk.9 for ; Tue, 14 Sep 2021 02:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S4UMEJF9a6XALVt2rS1LF9DUXoAT8S6FOzQ76/1PkPs=; b=NpfJGsVDcZ5Ud72D006JAYQZDFdVmBobpFVU8QKWxoMkblDj4q8napq2tgYu8sg7DT tzXrVgOQ9K9HLPW1AfgCh+AxwjfAfF2ck++XPnxfEdW1j349i0z4XvC/UAMwuJtdjvvz g0qSJCVhlGy2QZXWZ027wCu5xUIu+eD1wRjFknlNDAUCIbpMV7VCOfPmVr/vbDj3RxkM psTtYiOgzLV8FZBEGLCmPH4lqpUpxATTxhdMLdhsmhQr5aks1tSL+wZ3a4NVC32hpyPs tpSSdYwHCB6MNEewzzLWKNmnWDzrYYh5kUiE40vpgBVdmpkLku8I3NGfoRP2beuO2jTC W0Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S4UMEJF9a6XALVt2rS1LF9DUXoAT8S6FOzQ76/1PkPs=; b=eRIRvQz7yRbSXlc8XCHR5CxKTzEAaIZYFe1TsYSwjUZoTgGU0ME5580kk23yp0vgpl QmHC33NPlQCkEibWKBz7ZumxKdIfCXKee0ny9+81ArZKeF8kHjTv7sHicNPeLYrmogNc 3SZQ25h3goSF7GePQd8Ls1qYMT93YPMSr3UZH3408oZ0FpP0EJ9QirEypvFlRnELNm5n 2uqKWD1tggKPfbqc/SgfbO4tco971BbDe89JREYzQycocfNvxNjkP0xQT4wJg8bAbSz/ ZfTWX0Awzv/3+PJ+0fr1IhIOPNtt/Cbjw/q6+G8lPfeaNRtSPvxlNAuqnbYZ9FmZwSDg uZ0g== X-Gm-Message-State: AOAM53080ptfl3IrsJBNUCctVxqX7oOQEDqSHfNM9JV+/EJRBharGYEh rcahky9Jpa4s1KLSB+van6Eo5T4AiDFgzZIRrho= X-Google-Smtp-Source: ABdhPJxs2JXXnlX4Ka0sqHAgWzc9cfOnSfFDzQzrh7arJiyvxwdULpK7zEb4NPFNsLYIUef7DBfWka0aHElbksqL22c= X-Received: by 2002:a05:6830:1d69:: with SMTP id l9mr13774337oti.154.1631611458010; Tue, 14 Sep 2021 02:24:18 -0700 (PDT) MIME-Version: 1.0 References: <20210824120043.3823931-1-vladimir.oltean@nxp.com> <20210824120043.3823931-5-vladimir.oltean@nxp.com> In-Reply-To: <20210824120043.3823931-5-vladimir.oltean@nxp.com> From: Ramon Fried Date: Tue, 14 Sep 2021 12:24:06 +0300 Message-ID: Subject: Re: [PATCH v2 4/6] net: dsa: introduce a .port_probe() method in struct dsa_ops To: Vladimir Oltean Cc: Joe Hershberger , U-Boot Mailing List , Claudiu Manoil , Michael Walle , Priyanka Jain 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 On Tue, Aug 24, 2021 at 3:01 PM Vladimir Oltean wrote: > > Some drivers might want to execute code for each port at probe time, as > opposed to executing code just-in-time for the port selected for > networking. > > To cater to that use case, introduce a .port_probe() callback method > into the DSA switch operations which is called for each available port, > at the end of dsa_port_probe(). > > Signed-off-by: Vladimir Oltean > Reviewed-by: Ramon Fried > Tested-by: Michael Walle > --- > include/net/dsa.h | 5 ++++- > net/dsa-uclass.c | 8 ++++++++ > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index 0f31a908c9d1..ab2a9dfbea2d 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -57,7 +57,8 @@ > /** > * struct dsa_ops - DSA operations > * > - * @port_enable: Initialize a switch port for I/O. > + * @port_probe: Initialize a switch port. > + * @port_enable: Enable I/O for a port. > * @port_disable: Disable I/O for a port. > * @xmit: Insert the DSA tag for transmission. > * DSA drivers receive a copy of the packet with headroom and > @@ -69,6 +70,8 @@ > * master including any additional headers. > */ > struct dsa_ops { > + int (*port_probe)(struct udevice *dev, int port, > + struct phy_device *phy); > int (*port_enable)(struct udevice *dev, int port, > struct phy_device *phy); > void (*port_disable)(struct udevice *dev, int port, > diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c > index dbd8558b6486..9b8ae1e82b92 100644 > --- a/net/dsa-uclass.c > +++ b/net/dsa-uclass.c > @@ -270,6 +270,7 @@ static void dsa_port_set_hwaddr(struct udevice *pdev, struct udevice *master) > static int dsa_port_probe(struct udevice *pdev) > { > struct udevice *dev = dev_get_parent(pdev); > + struct dsa_ops *ops = dsa_get_ops(dev); > struct dsa_port_pdata *port_pdata; > struct dsa_priv *dsa_priv; > struct udevice *master; > @@ -299,6 +300,13 @@ static int dsa_port_probe(struct udevice *pdev) > > dsa_port_set_hwaddr(pdev, master); > > + if (ops->port_probe) { > + err = ops->port_probe(dev, port_pdata->index, > + port_pdata->phy); > + if (err) > + return err; > + } > + > return 0; > } > > -- > 2.25.1 > Applied to u-boot-net/network-master Thanks, Ramon.