From patchwork Thu Oct 28 17:00:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 12590621 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78FDDC433F5 for ; Thu, 28 Oct 2021 17:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 544D6610C8 for ; Thu, 28 Oct 2021 17:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbhJ1RCq (ORCPT ); Thu, 28 Oct 2021 13:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbhJ1RCp (ORCPT ); Thu, 28 Oct 2021 13:02:45 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC19C061570 for ; Thu, 28 Oct 2021 10:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QXxlQcSExTh09ijxffhRtrw9dCyNtlRHr/V+uRKs0Zs=; b=LpD0A3mHmIUTTrZJmZ8KUKIrOG 0GTP4ePUv6y17sKOH/LDARZSY+mxj9YfWrvnS3/n7jzhKVq1fueLuPOJwghK08YioDWwWjBrpOC1G 6+fBoAzYmeJVcwKhOtLHuoqh/lFbmoFFsLdciZMVoQfPNpmeIAHNS6PyXZiH94Ese5hGUJP7/LGOw 0JFmzP7DM1oG3flHWBz8EJw0o2MiTDZ6d52xkuGo215nrZ5gBTHFxO0iRLWnMaeJ4NaMn6EL4ZttK cVJH62wGeuScGKWuHmS2QmWGyMw0m/3Owv0XZyb0AVTZMYabUfU0xabAP4N1RvAMetyNiXjORwka/ 6HQygaKQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:46890 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mg8lC-0007oG-Qc; Thu, 28 Oct 2021 18:00:14 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mg8lC-0020Yn-DA; Thu, 28 Oct 2021 18:00:14 +0100 From: Russell King (Oracle) To: Andrew Lunn , Florian Fainelli , Vivien Didelot , Vladimir Oltean Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH net-next] net: dsa: populate supported_interfaces member MIME-Version: 1.0 MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 28 Oct 2021 18:00:14 +0100 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Add a new DSA switch operation, phylink_get_interfaces, which should fill in which PHY_INTERFACE_MODE_* are supported by given port. Use this before phylink_create() to fill phylinks supported_interfaces member, allowing phylink to determine which PHY_INTERFACE_MODEs are supported. Signed-off-by: Marek BehĂșn [tweaked patch and description to add more complete support -- rmk] Signed-off-by: Russell King Signed-off-by: Russell King (Oracle) --- include/net/dsa.h | 2 ++ net/dsa/port.c | 4 ++++ net/dsa/slave.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index badd214f7470..eff5c44ba377 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -645,6 +645,8 @@ struct dsa_switch_ops { /* * PHYLINK integration */ + void (*phylink_get_interfaces)(struct dsa_switch *ds, int port, + unsigned long *supported_interfaces); void (*phylink_validate)(struct dsa_switch *ds, int port, unsigned long *supported, struct phylink_link_state *state); diff --git a/net/dsa/port.c b/net/dsa/port.c index c0e630f7f0bd..f6f12ad2b525 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1168,6 +1168,10 @@ static int dsa_port_phylink_register(struct dsa_port *dp) dp->pl_config.type = PHYLINK_DEV; dp->pl_config.pcs_poll = ds->pcs_poll; + if (ds->ops->phylink_get_interfaces) + ds->ops->phylink_get_interfaces(ds, dp->index, + dp->pl_config.supported_interfaces); + dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode, &dsa_port_phylink_mac_ops); if (IS_ERR(dp->pl)) { diff --git a/net/dsa/slave.c b/net/dsa/slave.c index db066f0da4b5..ad61f6bc8886 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1871,6 +1871,10 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) dp->pl_config.poll_fixed_state = true; } + if (ds->ops->phylink_get_interfaces) + ds->ops->phylink_get_interfaces(ds, dp->index, + dp->pl_config.supported_interfaces); + dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode, &dsa_port_phylink_mac_ops); if (IS_ERR(dp->pl)) {