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=-15.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,USER_AGENT_GIT 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 B9FA5C11F67 for ; Tue, 29 Jun 2021 17:09:55 +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 4379E61DE9 for ; Tue, 29 Jun 2021 17:09:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4379E61DE9 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 57EC2831C7; Tue, 29 Jun 2021 19:09:28 +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="IJfQH0Rp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A4F23831B9; Tue, 29 Jun 2021 19:09:16 +0200 (CEST) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (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 8F198831B5 for ; Tue, 29 Jun 2021 19:09:13 +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=olteanv@gmail.com Received: by mail-ej1-x62e.google.com with SMTP id hc16so37448656ejc.12 for ; Tue, 29 Jun 2021 10:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1dGjwYYvz/fKQcEdM92cB99Ohnp3VKZM1k1GBQlZC2Y=; b=IJfQH0Rpm/rIJ5o66TWA033qikfGg45KFGVGYK8kvLHRG6Kej4dafZNT+h+C7AtCX/ xTdDITVMBrfzmgf2eebV2QzycOCYMpEHzGDzVFKvud8af2mFsR7b/n9poy1gLYG3C0z3 5nz2+Ys/Jmp1NQWjgwLsj34pWFGD7qxHDlsbeLoSH2ZCsxJA3xnRPhiuba5DGvu94nXE 1GuYuIN+UjC+SnUQmhKyheYmnCbfZxe2b7xd/3LnoX9TLi+V1M9aAxrEO/RU6N7UD9JJ C1W0IDgCbL5Qx0ldATGTdTDYOYtY9ewu8ZRCVWcFF3YzmP/V75qL57EaWmM8kGewEM3/ 0/Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1dGjwYYvz/fKQcEdM92cB99Ohnp3VKZM1k1GBQlZC2Y=; b=TEgvMb/vUgmza1C53WBWxdKyV2p3MHluESrSgt/TK67PB2SHpMcLVcFxl0iEH//Mlp ZK+r6VOMOSKGgIcl73R2fR/ePUiOAoNb+NMmC6LLHiiIRWqaRKDl/cpU2TPJw6K6UAR5 kMioPeU7uFnkeRt5cNFIthkJdYDbEmTniOWP5ucowpAEV9U0DOUUXTKka5Sl0heQE6RN K85ky1uT+XpmseJSiga9akIYzu23RFShObJP3KLdyAzVp30iRorv5Hl6QJNW9LHD4NdG AQoTlbVcYZcJynODjlsobKY7Yjes5gJkhJHg/OfVO/ko2IqAv4dbaPNeU7qel5HaqK9A 4+VQ== X-Gm-Message-State: AOAM532SCN9unwACKBl599EzPCYD8wJoJ83teJsffrhUqwqDKLWKYKeS /Ni90oaRWCwCAgwCyhdrdgA= X-Google-Smtp-Source: ABdhPJxSbyPjpa0XwOHRAvJ4/8QkD2a6h7aH4TuWqYP0rK8o2S6FXALg6gZTH52NYY+CeLgKMEeDNg== X-Received: by 2002:a17:907:9690:: with SMTP id hd16mr24247419ejc.251.1624986553276; Tue, 29 Jun 2021 10:09:13 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id h19sm9928525edt.87.2021.06.29.10.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 10:09:13 -0700 (PDT) From: Vladimir Oltean To: Joe Hershberger , Ramon Fried , u-boot@lists.denx.de Cc: Claudiu Manoil , Bin Meng , Alex Marginean , Michael Walle , Tim Harvey , Vladimir Oltean Subject: [PATCH 4/6] net: dsa: introduce a .port_probe() method in struct dsa_ops Date: Tue, 29 Jun 2021 20:08:37 +0300 Message-Id: <20210629170839.2583797-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210629170839.2583797-1-olteanv@gmail.com> References: <20210629170839.2583797-1-olteanv@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Vladimir Oltean 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 --- include/net/dsa.h | 5 ++++- net/dsa-uclass.c | 7 +++++++ 2 files changed, 11 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 e23da2ed0e95..1db723573e6c 100644 --- a/net/dsa-uclass.c +++ b/net/dsa-uclass.c @@ -263,6 +263,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; @@ -292,6 +293,12 @@ 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