From patchwork Thu May 27 20:45:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285325 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 0E0C3C47089 for ; Thu, 27 May 2021 20:45:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6AD5613E2 for ; Thu, 27 May 2021 20:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235760AbhE0UrR (ORCPT ); Thu, 27 May 2021 16:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235379AbhE0UrQ (ORCPT ); Thu, 27 May 2021 16:47:16 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1606FC061760 for ; Thu, 27 May 2021 13:45:42 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id e24so2274995eds.11 for ; Thu, 27 May 2021 13:45:41 -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=nkiW4cgqcNA2wnsGokaWDqLEeknOpooJwCUovxh3/t0=; b=Z4oTJB5Y74wha5BkSsO7Ho0Udg0OuV7TlLRz/9wZZ1TLuBpkCD3K7yFSKzB4NNmBI8 Gu3LzaUkgsjBf001vHgVrrddG6liaV/R9IepZFN/5j4ICE8LuVAhIwK2rQW0SqaMmp3t gPsynwyX2DaqlqJ2D20/DkF96P6HT9i0JS8IaMil86Is8v0Dww4Q1s11naTj+/kQ2SEn T3CCO9c+JjDNkZ1LfUE89bUenZv4XKoB89xBFwDPsdqHkqxgazi35qiv0SU7+rViw9e2 rsD/I+xB52ODKE7BGkAPfTNR+UbRoKcHy8K2GEnVJGs6knvhOUCRn1jGq0p89z3jk4uJ cpsA== 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=nkiW4cgqcNA2wnsGokaWDqLEeknOpooJwCUovxh3/t0=; b=UhlfOK2YkVRllEQD45IpR7/ZaYHi5C9EA5uJsYkWyRaBGDZhVbvNCyjvZHdD9cMvIi xvgPOr9w71rHWANmlTOy01NlXs+6ayKK9zrECKb/W81nyCfUavWXMWV3J5XaFk9TCjyG dU1g+BvTtxaLXbZt5ITqBdobqB0YCQeIZG39QxfnUWOZYoNs6DfzH3dZ8AjjQPn6pPhi OUGJ/yUPUggPWfNfOhVJ0TCwQMoYafOVSMfV6FsNdXNMAllCQUrE3PIPlzQ1q3eb6/iQ VgRbVOqRJHT3bW3rhxksmokBU5RnYfoHMOkr3T57Z4AhJ94oFtHsdwrl4UAR1kPFtg1s Ag7g== X-Gm-Message-State: AOAM531ynFOFVvhVL6nuULyMTXOhl7nhj/YulnguyNcNBx4wLNPJUA0K 18UIR2CJnZPmuSFW+7hxPRc= X-Google-Smtp-Source: ABdhPJyYByVl7G+keupLijkhy1dJY61aYv505FjG03VqtvoMIxDHTl0kXTm+v+je5fEhmwUVW5zeNg== X-Received: by 2002:a05:6402:14d2:: with SMTP id f18mr6478692edx.259.1622148339318; Thu, 27 May 2021 13:45:39 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:39 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 1/8] net: pcs: xpcs: delete shim definition for mdio_xpcs_get_ops() Date: Thu, 27 May 2021 23:45:21 +0300 Message-Id: <20210527204528.3490126-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean CONFIG_STMMAC_ETH selects CONFIG_PCS_XPCS, so there should be no situation where the shim should be needed. Signed-off-by: Vladimir Oltean --- include/linux/pcs/pcs-xpcs.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 5938ced805f4..c4d0a2c469c7 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -36,13 +36,6 @@ struct mdio_xpcs_ops { int enable); }; -#if IS_ENABLED(CONFIG_PCS_XPCS) struct mdio_xpcs_ops *mdio_xpcs_get_ops(void); -#else -static inline struct mdio_xpcs_ops *mdio_xpcs_get_ops(void) -{ - return NULL; -} -#endif #endif /* __LINUX_PCS_XPCS_H */ From patchwork Thu May 27 20:45:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285327 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 EB68FC4707F for ; Thu, 27 May 2021 20:45:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC23F613E2 for ; Thu, 27 May 2021 20:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235893AbhE0UrT (ORCPT ); Thu, 27 May 2021 16:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235625AbhE0UrQ (ORCPT ); Thu, 27 May 2021 16:47:16 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD2AC061574 for ; Thu, 27 May 2021 13:45:41 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id s6so2328493edu.10 for ; Thu, 27 May 2021 13:45:41 -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=53SMu8LKhmQZUryoy0jqx48MjLxIQReIM88wTX3mV8w=; b=swUc2jcnP4SChGY6LffqmpBufM725eWWzmx77Qqyu9AHgvULykuwAiBPS+aVMoamPt mT9jkJiBubRrT5NKMQR/bnFBy/IXsmuJk1z7dIq0/HC4W8WOcQnpsXWE7D8ci68igc0H dkMYB9ItFyBRDEw0hvcv4RKd9KNZ6rpM8gpsPFHlN1XGI9ZHN0dl0gpobVo9HFY0xitA oNivt9BtMLCBKT4HerXelpAOPf2ufd+Shtc1ER8Q0fpaMgK39rMZ1pGaHcwbQiM1Bbc4 zYTberBxjYvv37g1/gifa+Xtr8bSytasEjmSqKLh10sJMGaPwdFcS10/dedNoy2Kwh8+ G12Q== 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=53SMu8LKhmQZUryoy0jqx48MjLxIQReIM88wTX3mV8w=; b=uCkOfe2m+UEgbmri5cWHJRhj6aUZJx8g1KXfmxcqZcZrdinZ9v0oMlp+EhQ1YslHGs EmxC84S18Ym7zyLgABts4eOW+zCFWv1BcDRO62xoo0KlKo1RdFo3sel1kx3UWGKkit3s hQZ0/U6LkSiXSkGvitvGW0aR9GfEXkyN+OqN3owYSg0mD0IzRaCgxthkIZZsBZQlGuFw 0Zdca2gMtwBZ3TmfbRE2qf78C5zuoaLTKDElyRUowacuu3bJNSPyp5aKb23Xw0AoUtSG 7h5utehF5oJQ/t1rw2nejddNwoH1h91vJi0nmqoZum8rd7FL/uSGMeRrnYTuuf210mly VyuA== X-Gm-Message-State: AOAM532BIQENU0JKbKj6HyfKPiz0iVcUoneoOraQiSg0q/zW0de/FBbJ Yvz7lBOc/f7rJzbUDR8qOp4= X-Google-Smtp-Source: ABdhPJwBALV+ExtGz6uqliAjFXfKqzUxCKuQJImnmTpAt/P7fptpgcbToRDg9mfcRG/W1vj51sJnvw== X-Received: by 2002:aa7:d598:: with SMTP id r24mr6407675edq.250.1622148340500; Thu, 27 May 2021 13:45:40 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:40 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 2/8] net: pcs: xpcs: check for supported PHY interface modes in phylink_validate Date: Thu, 27 May 2021 23:45:22 +0300 Message-Id: <20210527204528.3490126-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean The supported PHY interface types are currently deduced by reading the PHY ID registers of the PCS, to determine whether it is an USXGMII, 10G-KR, XLGMII, SGMII PCS or whatever. Checking whether the PCS operates in a PHY interface mode compatible with the hardware capability is done only once: in xpcs_check_features, called from xpcs_probe - the deduced PHY interface mode is compared to what is specified in the device tree. But nothing prevents phylink from changing the state->interface as a result of plugging an SFP module with a different operating PHY interface type. This change deletes xpcs_check_features, removes the phy_interface_t argument from xpcs_probe, and moves the PHY interface type check inside the validate function, similar to what other drivers do. Signed-off-by: Vladimir Oltean --- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 5 +- drivers/net/pcs/pcs-xpcs.c | 63 ++++++++++--------- include/linux/pcs/pcs-xpcs.h | 5 +- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index e293bf1ce9f3..d12dfa60b8ea 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -512,7 +512,8 @@ int stmmac_mdio_register(struct net_device *ndev) /* Try to probe the XPCS by scanning all addresses. */ if (priv->hw->xpcs) { struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; - int ret, mode = priv->plat->phy_interface; + int ret; + max_addr = PHY_MAX_ADDR; xpcs->bus = new_bus; @@ -521,7 +522,7 @@ int stmmac_mdio_register(struct net_device *ndev) for (addr = 0; addr < max_addr; addr++) { xpcs->addr = addr; - ret = stmmac_xpcs_probe(priv, xpcs, mode); + ret = stmmac_xpcs_probe(priv, xpcs); if (!ret) { found = 1; break; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index aa985a5aae8d..71efd5ef69e5 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -662,6 +662,30 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state) { + bool valid_interface; + + if (state->interface == PHY_INTERFACE_MODE_NA) { + valid_interface = true; + } else { + struct xpcs_id *id = xpcs->id; + int i; + + valid_interface = false; + + for (i = 0; id->interface[i] != PHY_INTERFACE_MODE_MAX; i++) { + if (id->interface[i] != state->interface) + continue; + + valid_interface = true; + break; + } + } + + if (!valid_interface) { + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return 0; + } + linkmode_and(supported, supported, xpcs->supported); linkmode_and(state->advertising, state->advertising, xpcs->supported); return 0; @@ -910,43 +934,24 @@ static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs) return 0xffffffff; } -static bool xpcs_check_features(struct mdio_xpcs_args *xpcs, - struct xpcs_id *match, - phy_interface_t interface) -{ - int i; - - for (i = 0; match->interface[i] != PHY_INTERFACE_MODE_MAX; i++) { - if (match->interface[i] == interface) - break; - } - - if (match->interface[i] == PHY_INTERFACE_MODE_MAX) - return false; - - for (i = 0; match->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(match->supported[i], xpcs->supported); - - xpcs->an_mode = match->an_mode; - - return true; -} - -static int xpcs_probe(struct mdio_xpcs_args *xpcs, phy_interface_t interface) +static int xpcs_probe(struct mdio_xpcs_args *xpcs) { u32 xpcs_id = xpcs_get_id(xpcs); - struct xpcs_id *match = NULL; int i; for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { struct xpcs_id *entry = &xpcs_id_list[i]; - if ((xpcs_id & entry->mask) == entry->id) { - match = entry; + if ((xpcs_id & entry->mask) != entry->id) + continue; - if (xpcs_check_features(xpcs, match, interface)) - return xpcs_soft_reset(xpcs); - } + for (i = 0; entry->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(entry->supported[i], xpcs->supported); + + xpcs->id = entry; + xpcs->an_mode = entry->an_mode; + + return xpcs_soft_reset(xpcs); } return -ENODEV; diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index c4d0a2c469c7..e48636a1a078 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -14,9 +14,12 @@ #define DW_AN_C73 1 #define DW_AN_C37_SGMII 2 +struct xpcs_id; + struct mdio_xpcs_args { __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); struct mii_bus *bus; + struct xpcs_id *id; int addr; int an_mode; }; @@ -31,7 +34,7 @@ struct mdio_xpcs_ops { struct phylink_link_state *state); int (*link_up)(struct mdio_xpcs_args *xpcs, int speed, phy_interface_t interface); - int (*probe)(struct mdio_xpcs_args *xpcs, phy_interface_t interface); + int (*probe)(struct mdio_xpcs_args *xpcs); int (*config_eee)(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, int enable); }; From patchwork Thu May 27 20:45:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285329 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 C781BC4708A for ; Thu, 27 May 2021 20:45:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5B71611C2 for ; Thu, 27 May 2021 20:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235871AbhE0UrV (ORCPT ); Thu, 27 May 2021 16:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235792AbhE0UrS (ORCPT ); Thu, 27 May 2021 16:47:18 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1142BC061761 for ; Thu, 27 May 2021 13:45:43 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id g7so2368626edm.4 for ; Thu, 27 May 2021 13:45:42 -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=f3LXLy0RxWR9HBLo60bQO4krGpz/yZL++bJpVi6moh0=; b=KiLH/RjHXRiudeeWLmGLxFfwwNxpuUr5Xg+9fX+b6oAuvBFQJUob5llvDqNsO8F2Up WDo/E9PUS3HR6u7lWfj/jzJGy2K0k2JjAoAoN5PqADtksUgo8vPS23fqMYDqp5JVzT0P IdWPee2Hu1bQGj2kOmsh2XQKqjw1RrzgggMoSnIrnRKLmJdYyOb0KeMqjslFArrtwfoB /fYvIedoR7M1qw7Ig8NAA34bK0HxLktMZUvQlBYUxF95eqZNJ+WgOVhU/Nt8ZAmEsQxY BywgYgnS3ESkETO2UeWLb1qjE0D6LIBNDNPskNXIDL70APf7WXs8XArqztUX4izP/20G ctaQ== 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=f3LXLy0RxWR9HBLo60bQO4krGpz/yZL++bJpVi6moh0=; b=mwU6SaC6/8GK5IqeUx8nUl0zLHd97wukKS7VrjD5uCojhnOpsk/aDj5OVckoGxbmn8 STP4MQVYjs33sGVgeidoHCppGNArD/eESIBhBQ+38apeeeRK15sV0X04VnrvZcsfiKGg Oye+TvTZw4MAiw4q7QZNo95HWiVPgsV9Ue0idp/WHZjKZjradm/WTlaGYRfM1BtRT2wQ gcAmX1gQKoWinrEi6aT4mPE7OXZQkwJn7cG354eYEdsSmD7mb0wz0DkFUjTjYf2avhik iyaEQuI8/aZimt/JyPx1RM4hbj3dFa3yxFslDiSfWgHlI4F1lpdRkmYyds8e1KGphCZD DCtA== X-Gm-Message-State: AOAM532RXH4/qCdHJm7jfN0cSyTQF8lB47Z/VCm1eeCGKQdxbcyzpLIs W7AsPdQgvot3oWZAZ7277/4= X-Google-Smtp-Source: ABdhPJyIXKzYSMGSj4uJEl5i4yOI3WEVbysDrGcHEearUs0F0rTLxkFbpHTqTRnICFLMpmTQEkRtdw== X-Received: by 2002:a05:6402:5174:: with SMTP id d20mr6443295ede.248.1622148341586; Thu, 27 May 2021 13:45:41 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:41 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 3/8] net: pcs: xpcs: export xpcs_validate Date: Thu, 27 May 2021 23:45:23 +0300 Message-Id: <20210527204528.3490126-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean Calling a function pointer with a single implementation through struct mdio_xpcs_ops is clunky, and the stmmac_do_callback system forces this to return int, even though it always returns zero. Simply remove the "validate" function pointer from struct mdio_xpcs_ops and replace it with an exported xpcs_validate symbol which is called directly by stmmac. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 -- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 10 ++++------ include/linux/pcs/pcs-xpcs.h | 5 ++--- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 75a8b90c202a..a86b358feae9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -613,8 +613,6 @@ struct stmmac_mmc_ops { stmmac_do_void_callback(__priv, mmc, read, __args) /* XPCS callbacks */ -#define stmmac_xpcs_validate(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, validate, __args) #define stmmac_xpcs_config(__priv, __args...) \ stmmac_do_callback(__priv, xpcs, config, __args) #define stmmac_xpcs_get_state(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index bf9fe25fed69..d3d85d36e177 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -996,7 +996,7 @@ static void stmmac_validate(struct phylink_config *config, linkmode_andnot(state->advertising, state->advertising, mask); /* If PCS is supported, check which modes it supports. */ - stmmac_xpcs_validate(priv, &priv->hw->xpcs_args, supported, state); + xpcs_validate(&priv->hw->xpcs_args, supported, state); } static void stmmac_mac_pcs_get_state(struct phylink_config *config, diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 71efd5ef69e5..4c0093473470 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -658,9 +658,8 @@ static void xpcs_resolve_pma(struct mdio_xpcs_args *xpcs, } } -static int xpcs_validate(struct mdio_xpcs_args *xpcs, - unsigned long *supported, - struct phylink_link_state *state) +void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, + struct phylink_link_state *state) { bool valid_interface; @@ -683,13 +682,13 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs, if (!valid_interface) { bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return 0; + return; } linkmode_and(supported, supported, xpcs->supported); linkmode_and(state->advertising, state->advertising, xpcs->supported); - return 0; } +EXPORT_SYMBOL_GPL(xpcs_validate); static int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, int enable) @@ -958,7 +957,6 @@ static int xpcs_probe(struct mdio_xpcs_args *xpcs) } static struct mdio_xpcs_ops xpcs_ops = { - .validate = xpcs_validate, .config = xpcs_config, .get_state = xpcs_get_state, .link_up = xpcs_link_up, diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index e48636a1a078..56755b7895a0 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -25,9 +25,6 @@ struct mdio_xpcs_args { }; struct mdio_xpcs_ops { - int (*validate)(struct mdio_xpcs_args *xpcs, - unsigned long *supported, - struct phylink_link_state *state); int (*config)(struct mdio_xpcs_args *xpcs, const struct phylink_link_state *state); int (*get_state)(struct mdio_xpcs_args *xpcs, @@ -40,5 +37,7 @@ struct mdio_xpcs_ops { }; struct mdio_xpcs_ops *mdio_xpcs_get_ops(void); +void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, + struct phylink_link_state *state); #endif /* __LINUX_PCS_XPCS_H */ From patchwork Thu May 27 20:45:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285331 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 E2F46C47089 for ; Thu, 27 May 2021 20:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60EBA613E5 for ; Thu, 27 May 2021 20:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235957AbhE0UrW (ORCPT ); Thu, 27 May 2021 16:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235379AbhE0UrR (ORCPT ); Thu, 27 May 2021 16:47:17 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C1B1C061760 for ; Thu, 27 May 2021 13:45:44 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id e12so2160234ejt.3 for ; Thu, 27 May 2021 13:45:44 -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=ULokCP8CrAt8X07DxYMPf77UsfeHZ+VGXcJ7iXiuLUA=; b=a/O6ejA4x7BrxtMG+N3kMkUZsGb7DguweqVK0MLPhOLapJMfMHLi1EuT6t/i/Fgzzq ngQd62Lb08iu7PfB+jjkE8PJg5me+cnohc94uxwBW6YqXsxx3Sgy4GjwAFKNjrr2iG9u MujpTGXXgMToq1pqSiJ2J2QkgQoR6ru2HDYTYtK+qHZ5CxTMrmShOHDrUe/cGYwUV5DX QFU7KdtFWier3oEfyb8AVRcQ0kTx1T6R2Br2y0ggM10jhEzBecTFhm5EyDT1DViL7Mcc 8UzhsD7qR3KRKzwI9Y5T26ZuZPzZ3pupweyF64lOdGnD0QoxCdKYAB2bDC5eO4Rxi/Sk gC9w== 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=ULokCP8CrAt8X07DxYMPf77UsfeHZ+VGXcJ7iXiuLUA=; b=THhuoUNdMfAycdEMsif4VoeoMfA+BHvddt2fGjyAt35FHPxuxovQQgov109ufXxNaa T1tmpWIdjyBDpBXDXPK8twnd/bOX8wJ/RipQn42n/bLJT3DKpawzkchF1uLd+VqoaU40 2WeeTPoTVNpbSSvWvbw8MH02ut9xOI7Zfg2VTMKvlLQkV3Cl1YQHPPLXO+4jMfiXta3Y U5vUqI2PSDGmpbteHxu5ks6HO6cxdr9WComEycIODbKjrJMgsv10XfpNx94bxOAb6otf 18TrULzaQf+7G9Yv8k8tebWaEHpd2uv4vz/7YT2GWDzX1p4QNMWi781442T4CwxSpIZA Y20g== X-Gm-Message-State: AOAM530fagxJq0b0tQbMwbXhnLNPmp6dw2ZkPL9gbLmWm2rWDxyDuPE7 yaj4VG7RfA4QK4i6PIIoZoM= X-Google-Smtp-Source: ABdhPJw2XoA3cJnuY6Q90Tzm/e8RKDmjHfhXbfAUZxcMbZidWOo0yt6P1Jeb/y8UsHitd7sL4ou7Lw== X-Received: by 2002:a17:906:308d:: with SMTP id 13mr5677884ejv.554.1622148342700; Thu, 27 May 2021 13:45:42 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:42 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 4/8] net: pcs: export xpcs_config_eee Date: Thu, 27 May 2021 23:45:24 +0300 Message-Id: <20210527204528.3490126-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean There is no good reason why we need to go through: stmmac_xpcs_config_eee -> stmmac_do_callback -> mdio_xpcs_ops->config_eee -> xpcs_config_eee when we can simply call xpcs_config_eee. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 -- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 +++--- drivers/net/pcs/pcs-xpcs.c | 6 +++--- include/linux/pcs/pcs-xpcs.h | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index a86b358feae9..2d2843edaf21 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -621,8 +621,6 @@ struct stmmac_mmc_ops { stmmac_do_callback(__priv, xpcs, link_up, __args) #define stmmac_xpcs_probe(__priv, __args...) \ stmmac_do_callback(__priv, xpcs, probe, __args) -#define stmmac_xpcs_config_eee(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, config_eee, __args) struct stmmac_regs_off { u32 ptp_off; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 1f6d749fd9a3..72d2d575bbfe 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -720,9 +720,9 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev, netdev_warn(priv->dev, "Setting EEE tx-lpi is not supported\n"); - ret = stmmac_xpcs_config_eee(priv, &priv->hw->xpcs_args, - priv->plat->mult_fact_100ns, - edata->eee_enabled); + ret = xpcs_config_eee(&priv->hw->xpcs_args, + priv->plat->mult_fact_100ns, + edata->eee_enabled); if (ret) return ret; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 4c0093473470..a7851a8a219b 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -690,8 +690,8 @@ void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, } EXPORT_SYMBOL_GPL(xpcs_validate); -static int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, - int enable) +int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, + int enable) { int ret; @@ -722,6 +722,7 @@ static int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, ret |= DW_VR_MII_EEE_TRN_LPI; return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_EEE_MCTRL1, ret); } +EXPORT_SYMBOL_GPL(xpcs_config_eee); static int xpcs_config_aneg_c37_sgmii(struct mdio_xpcs_args *xpcs) { @@ -961,7 +962,6 @@ static struct mdio_xpcs_ops xpcs_ops = { .get_state = xpcs_get_state, .link_up = xpcs_link_up, .probe = xpcs_probe, - .config_eee = xpcs_config_eee, }; struct mdio_xpcs_ops *mdio_xpcs_get_ops(void) diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 56755b7895a0..203aafae9166 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -32,12 +32,12 @@ struct mdio_xpcs_ops { int (*link_up)(struct mdio_xpcs_args *xpcs, int speed, phy_interface_t interface); int (*probe)(struct mdio_xpcs_args *xpcs); - int (*config_eee)(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, - int enable); }; struct mdio_xpcs_ops *mdio_xpcs_get_ops(void); void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state); +int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, + int enable); #endif /* __LINUX_PCS_XPCS_H */ From patchwork Thu May 27 20:45:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285333 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 6622EC47089 for ; Thu, 27 May 2021 20:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BC88613E2 for ; Thu, 27 May 2021 20:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236267AbhE0UrZ (ORCPT ); Thu, 27 May 2021 16:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235897AbhE0UrU (ORCPT ); Thu, 27 May 2021 16:47:20 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC9FC061574 for ; Thu, 27 May 2021 13:45:45 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id z12so2240942ejw.0 for ; Thu, 27 May 2021 13:45:45 -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=zZrJAKistV6Q/B1No+cwqeXn71UQaxifsVS30S0BqGc=; b=ITvqgLUehzvzHiGeOl+5fnFIzos2/qmnGjfPbnG8+p/wky2ysQaYXYNy64+FB/YZU5 /O5EEaNmz20SheYA1aRRy38s+cICgFYAn1Ye3aUAIxzLsYCaY1HzKrZ3ozuqgxrGtsia JC5ZZfBPZvqhF1UqtKKuliyWIVeZk4UjlNb6IAm4gcfYJ9BNQq141qpA2LEmLOTab4kn gEwAG8Jdj0FaYVTjvv2d/d4Qmm8ySFklofTBR8DXMe23eY5eXYpiR4pGqhZZUs4lVeYD DM5Yza984EVEt5u4PUzn4GU7ZhHTsG/oWFqX7SUPj28MUMYV/NnH+SPuJpgEWtp62iL5 mi2w== 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=zZrJAKistV6Q/B1No+cwqeXn71UQaxifsVS30S0BqGc=; b=RcMmbJ/lk6mxR/5zW3w+1GIgpA99TuPqsj0nH1jGuVwah47n7J2rpTtWme0q0CDU39 kuH2pVV/ZNR5kXfOx1UMXnP3ULRx78EG7xkZHYlQOVlOn8oyAo3OnJw3B56scYSbeDNv +7TH0dQkzMGbJ4Q3DCe9+xke4C6cR8Q1ZBwKofxwzQKYKEfG6ulpkPTQbscVPycpmQ/I ZYbNE69K3VHdqtVg7A8mrW03Tc5n8ius4GZ5qUb2aMuMYYgmLSQxklm4OWz89+LXe3FH 82ROarTsnCJfxStw1wWme/FEBq/v7eWjTfj8nFbTSBQnsgP++/op2AyniwlSyKFxnjUu 4dgw== X-Gm-Message-State: AOAM531P8/W/jhEOZlwGCDdINZRIS1RKoPuqHzM/AkOetXpA9L/qVAT8 fu9wbqSP5GXQIQjM1h6KAmA= X-Google-Smtp-Source: ABdhPJxG1VMm5zuLTYuodIHjZWmyjo9fpn5BVeMzcpRjiy0YewA3eEewNwmswLOyX3pPNvaQWdvtLQ== X-Received: by 2002:a17:906:5448:: with SMTP id d8mr5889849ejp.248.1622148343944; Thu, 27 May 2021 13:45:43 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:43 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 5/8] net: pcs: xpcs: export xpcs_probe Date: Thu, 27 May 2021 23:45:25 +0300 Message-Id: <20210527204528.3490126-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean Similar to the other recently functions, it is not necessary for xpcs_probe to be a function pointer, so export it so that it can be called directly. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 -- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 4 ++-- include/linux/pcs/pcs-xpcs.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 2d2843edaf21..5014b260844b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -619,8 +619,6 @@ struct stmmac_mmc_ops { stmmac_do_callback(__priv, xpcs, get_state, __args) #define stmmac_xpcs_link_up(__priv, __args...) \ stmmac_do_callback(__priv, xpcs, link_up, __args) -#define stmmac_xpcs_probe(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, probe, __args) struct stmmac_regs_off { u32 ptp_off; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index d12dfa60b8ea..2af83d902ea1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -522,7 +522,7 @@ int stmmac_mdio_register(struct net_device *ndev) for (addr = 0; addr < max_addr; addr++) { xpcs->addr = addr; - ret = stmmac_xpcs_probe(priv, xpcs); + ret = xpcs_probe(xpcs); if (!ret) { found = 1; break; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index a7851a8a219b..4063dcc0f767 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -934,7 +934,7 @@ static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs) return 0xffffffff; } -static int xpcs_probe(struct mdio_xpcs_args *xpcs) +int xpcs_probe(struct mdio_xpcs_args *xpcs) { u32 xpcs_id = xpcs_get_id(xpcs); int i; @@ -956,12 +956,12 @@ static int xpcs_probe(struct mdio_xpcs_args *xpcs) return -ENODEV; } +EXPORT_SYMBOL_GPL(xpcs_probe); static struct mdio_xpcs_ops xpcs_ops = { .config = xpcs_config, .get_state = xpcs_get_state, .link_up = xpcs_link_up, - .probe = xpcs_probe, }; struct mdio_xpcs_ops *mdio_xpcs_get_ops(void) diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 203aafae9166..11585fa093cd 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -31,7 +31,6 @@ struct mdio_xpcs_ops { struct phylink_link_state *state); int (*link_up)(struct mdio_xpcs_args *xpcs, int speed, phy_interface_t interface); - int (*probe)(struct mdio_xpcs_args *xpcs); }; struct mdio_xpcs_ops *mdio_xpcs_get_ops(void); @@ -39,5 +38,6 @@ void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, int enable); +int xpcs_probe(struct mdio_xpcs_args *xpcs); #endif /* __LINUX_PCS_XPCS_H */ From patchwork Thu May 27 20:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285335 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 F0A32C4707F for ; Thu, 27 May 2021 20:45:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D156F613E3 for ; Thu, 27 May 2021 20:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236017AbhE0Ura (ORCPT ); Thu, 27 May 2021 16:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235876AbhE0UrV (ORCPT ); Thu, 27 May 2021 16:47:21 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD1AC0613CE for ; Thu, 27 May 2021 13:45:46 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id r23so2390095edw.1 for ; Thu, 27 May 2021 13:45:46 -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=Z/y7jaRU5tyTiLyd9RuocOi5t94X3yF17Me0njiV5Uo=; b=Z4CpJ+UCLJ0OlDXhOTqxonafJLpbvs/2mJbHbeb3WpxeRKIYYVSiTf8K8dtSMd8GmM XJ3ImdbvoXA4tVkdm2qnBSxIoaQ/jQ04Xhkm3YL9p9gC++xDzhkpoJH1v1m/xCsxLoRI amVsnqUFAzp3XNSMn/wbczL75PLOr/IVpmpyVTSC0Nrg2RRoqpYH5TcjR7w6oVYIHO1Z 6NptroNTqNeH7cVRIHJIucKIhTuypwZUi7L6H/r9mgmk9oyTZv9ppLAZyqwZ3aX2to0E aEDMp5wm/pzjkq1+NS6khb0A4LN7pwI6uF7hIDS0WkAF+945m5NxmhnWGQo5ee6CTaYa 2hTg== 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=Z/y7jaRU5tyTiLyd9RuocOi5t94X3yF17Me0njiV5Uo=; b=k3rm6pk981/VgrV3wLoqzbDk7Bo/+okZy8r95qt1efROMBhEsM4vRm1Lsfq8w7ncu0 weoQPjI3K8ayXeypU6vWYAaWfKahw0BiXBHSM72ohIBIhnXfWfjc2Jzst608f89o6Ht1 rJr8BpAb9vSdkpF/iYOglLcY1b5/d1MqiQUu5idXXnKi/16CuaxKNJMsLij6v7Q/miYa 99Dh/eSBkYgBjErbra+cGzKd9TNd1N73w1MpzxDglyMyIIaHTMZONfRUkSkrAPjtxwwv 3CxQ5y13bKzEpztpmnZGeYp70CwR6azi0tjn9L/oKX1k0doncSKRltw8TfpGiI2o9NtP koCg== X-Gm-Message-State: AOAM532ZUrc3RGw77mVtWk8Hu3dWevm7wuCrv6wI8Gq7ibzaQUzxG7yt Bo0egT6Ty1w9lczbpJuK2D4= X-Google-Smtp-Source: ABdhPJxErPm6F4+6VeVfQUd4pb0WVJ6+0BLES8al1dXY77AF+vleqZ3MRfXrbYwbPYiD4bU2U0BtHg== X-Received: by 2002:aa7:c91a:: with SMTP id b26mr6367906edt.350.1622148345194; Thu, 27 May 2021 13:45:45 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:44 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 6/8] net: pcs: xpcs: convert to phylink_pcs_ops Date: Thu, 27 May 2021 23:45:26 +0300 Message-Id: <20210527204528.3490126-7-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean Since all the remaining members of struct mdio_xpcs_ops have direct equivalents in struct phylink_pcs_ops, it is about time we remove it altogether. Since the phylink ops return void, we need to remove the error propagation from the various xpcs methods and simply print an error message where appropriate. Since xpcs_get_state_c73() detects link faults and attempts to reset the link on its own by calling xpcs_config(), but xpcs_config() now has a lot of phylink arguments which are not needed and cannot be simply fabricated by anybody else except phylink, the actual implementation has been moved into a smaller xpcs_do_config(). Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/common.h | 1 - drivers/net/ethernet/stmicro/stmmac/hwif.h | 8 -- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 37 ++------ .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +- drivers/net/pcs/pcs-xpcs.c | 94 +++++++++++-------- include/linux/pcs/pcs-xpcs.h | 11 +-- 6 files changed, 67 insertions(+), 94 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 619e3c0760d6..678f8ce62b8a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -503,7 +503,6 @@ struct mac_device_info { const struct stmmac_hwtimestamp *ptp; const struct stmmac_tc_ops *tc; const struct stmmac_mmc_ops *mmc; - const struct mdio_xpcs_ops *xpcs; struct mdio_xpcs_args xpcs_args; struct mii_regs mii; /* MII register Addresses */ struct mac_link link; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 5014b260844b..91f7592a0189 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -612,14 +612,6 @@ struct stmmac_mmc_ops { #define stmmac_mmc_read(__priv, __args...) \ stmmac_do_void_callback(__priv, mmc, read, __args) -/* XPCS callbacks */ -#define stmmac_xpcs_config(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, config, __args) -#define stmmac_xpcs_get_state(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, get_state, __args) -#define stmmac_xpcs_link_up(__priv, __args...) \ - stmmac_do_callback(__priv, xpcs, link_up, __args) - struct stmmac_regs_off { u32 ptp_off; u32 mmc_off; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d3d85d36e177..3ccf00ea77d5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -999,28 +999,6 @@ static void stmmac_validate(struct phylink_config *config, xpcs_validate(&priv->hw->xpcs_args, supported, state); } -static void stmmac_mac_pcs_get_state(struct phylink_config *config, - struct phylink_link_state *state) -{ - struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); - - state->link = 0; - stmmac_xpcs_get_state(priv, &priv->hw->xpcs_args, state); -} - -static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, - const struct phylink_link_state *state) -{ - struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); - - stmmac_xpcs_config(priv, &priv->hw->xpcs_args, state); -} - -static void stmmac_mac_an_restart(struct phylink_config *config) -{ - /* Not Supported */ -} - static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; @@ -1060,8 +1038,6 @@ static void stmmac_mac_link_up(struct phylink_config *config, struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); u32 ctrl; - stmmac_xpcs_link_up(priv, &priv->hw->xpcs_args, speed, interface); - ctrl = readl(priv->ioaddr + MAC_CTRL_REG); ctrl &= ~priv->hw->link.speed_mask; @@ -1154,9 +1130,6 @@ static void stmmac_mac_link_up(struct phylink_config *config, static const struct phylink_mac_ops stmmac_phylink_mac_ops = { .validate = stmmac_validate, - .mac_pcs_get_state = stmmac_mac_pcs_get_state, - .mac_config = stmmac_mac_config, - .mac_an_restart = stmmac_mac_an_restart, .mac_link_down = stmmac_mac_link_down, .mac_link_up = stmmac_mac_link_up, }; @@ -1230,6 +1203,7 @@ static int stmmac_init_phy(struct net_device *dev) static int stmmac_phy_setup(struct stmmac_priv *priv) { + struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node); int mode = priv->plat->phy_interface; struct phylink *phylink; @@ -1237,8 +1211,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type = PHYLINK_NETDEV; priv->phylink_config.pcs_poll = true; - priv->phylink_config.ovr_an_inband = - priv->plat->mdio_bus_data->xpcs_an_inband; + priv->phylink_config.ovr_an_inband = mdio_bus_data->xpcs_an_inband; if (!fwnode) fwnode = dev_fwnode(priv->device); @@ -1248,6 +1221,12 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) if (IS_ERR(phylink)) return PTR_ERR(phylink); + if (mdio_bus_data->has_xpcs) { + struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; + + phylink_set_pcs(phylink, &xpcs->pcs); + } + priv->phylink = phylink; return 0; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 2af83d902ea1..4a197b2fe26b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -444,14 +444,6 @@ int stmmac_mdio_register(struct net_device *ndev) max_addr = PHY_MAX_ADDR; } - if (mdio_bus_data->has_xpcs) { - priv->hw->xpcs = mdio_xpcs_get_ops(); - if (!priv->hw->xpcs) { - err = -ENODEV; - goto bus_register_fail; - } - } - if (mdio_bus_data->needs_reset) new_bus->reset = &stmmac_mdio_reset; @@ -510,7 +502,7 @@ int stmmac_mdio_register(struct net_device *ndev) } /* Try to probe the XPCS by scanning all addresses. */ - if (priv->hw->xpcs) { + if (mdio_bus_data->has_xpcs) { struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; int ret; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 4063dcc0f767..288abe8ddaf3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -103,6 +103,9 @@ /* VR MII EEE Control 1 defines */ #define DW_VR_MII_EEE_TRN_LPI BIT(0) /* Transparent Mode Enable */ +#define phylink_pcs_to_xpcs(pl_pcs) \ + container_of((pl_pcs), struct mdio_xpcs_args, pcs) + static const int xpcs_usxgmii_features[] = { ETHTOOL_LINK_MODE_Pause_BIT, ETHTOOL_LINK_MODE_Asym_Pause_BIT, @@ -385,7 +388,7 @@ static int xpcs_get_max_usxgmii_speed(const unsigned long *supported) return max; } -static int xpcs_config_usxgmii(struct mdio_xpcs_args *xpcs, int speed) +static void xpcs_config_usxgmii(struct mdio_xpcs_args *xpcs, int speed) { int ret, speed_sel; @@ -410,33 +413,40 @@ static int xpcs_config_usxgmii(struct mdio_xpcs_args *xpcs, int speed) break; default: /* Nothing to do here */ - return -EINVAL; + return; } ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); if (ret < 0) - return ret; + goto out; ret = xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_EN); if (ret < 0) - return ret; + goto out; ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1); if (ret < 0) - return ret; + goto out; ret &= ~DW_USXGMII_SS_MASK; ret |= speed_sel | DW_USXGMII_FULL; ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret); if (ret < 0) - return ret; + goto out; ret = xpcs_read_vpcs(xpcs, MDIO_CTRL1); if (ret < 0) - return ret; + goto out; + + ret = xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_RST); + if (ret < 0) + goto out; - return xpcs_write_vpcs(xpcs, MDIO_CTRL1, ret | DW_USXGMII_RST); + return; + +out: + pr_err("%s: XPCS access returned %pe\n", __func__, ERR_PTR(ret)); } static int _xpcs_config_aneg_c73(struct mdio_xpcs_args *xpcs) @@ -765,14 +775,13 @@ static int xpcs_config_aneg_c37_sgmii(struct mdio_xpcs_args *xpcs) return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret); } -static int xpcs_config(struct mdio_xpcs_args *xpcs, - const struct phylink_link_state *state) +static int xpcs_do_config(struct mdio_xpcs_args *xpcs, unsigned int mode) { int ret; switch (xpcs->an_mode) { case DW_AN_C73: - if (state->an_enabled) { + if (phylink_autoneg_inband(mode)) { ret = xpcs_config_aneg_c73(xpcs); if (ret) return ret; @@ -790,6 +799,16 @@ static int xpcs_config(struct mdio_xpcs_args *xpcs, return 0; } +static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising, + bool permit_pause_to_mac) +{ + struct mdio_xpcs_args *xpcs = phylink_pcs_to_xpcs(pcs); + + return xpcs_do_config(xpcs, mode); +} + static int xpcs_get_state_c73(struct mdio_xpcs_args *xpcs, struct phylink_link_state *state) { @@ -807,7 +826,7 @@ static int xpcs_get_state_c73(struct mdio_xpcs_args *xpcs, state->link = 0; - return xpcs_config(xpcs, state); + return xpcs_do_config(xpcs, MLO_AN_INBAND); } if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state)) { @@ -864,36 +883,40 @@ static int xpcs_get_state_c37_sgmii(struct mdio_xpcs_args *xpcs, return 0; } -static int xpcs_get_state(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state) +static void xpcs_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) { + struct mdio_xpcs_args *xpcs = phylink_pcs_to_xpcs(pcs); int ret; switch (xpcs->an_mode) { case DW_AN_C73: ret = xpcs_get_state_c73(xpcs, state); - if (ret) - return ret; + if (ret) { + pr_err("xpcs_get_state_c73 returned %pe\n", + ERR_PTR(ret)); + return; + } break; case DW_AN_C37_SGMII: ret = xpcs_get_state_c37_sgmii(xpcs, state); - if (ret) - return ret; + if (ret) { + pr_err("xpcs_get_state_c37_sgmii returned %pe\n", + ERR_PTR(ret)); + } break; default: - return -1; + return; } - - return 0; } -static int xpcs_link_up(struct mdio_xpcs_args *xpcs, int speed, - phy_interface_t interface) +static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex) { + struct mdio_xpcs_args *xpcs = phylink_pcs_to_xpcs(pcs); + if (interface == PHY_INTERFACE_MODE_USXGMII) return xpcs_config_usxgmii(xpcs, speed); - - return 0; } static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs) @@ -934,6 +957,12 @@ static u32 xpcs_get_id(struct mdio_xpcs_args *xpcs) return 0xffffffff; } +static const struct phylink_pcs_ops xpcs_phylink_ops = { + .pcs_config = xpcs_config, + .pcs_get_state = xpcs_get_state, + .pcs_link_up = xpcs_link_up, +}; + int xpcs_probe(struct mdio_xpcs_args *xpcs) { u32 xpcs_id = xpcs_get_id(xpcs); @@ -951,6 +980,9 @@ int xpcs_probe(struct mdio_xpcs_args *xpcs) xpcs->id = entry; xpcs->an_mode = entry->an_mode; + xpcs->pcs.ops = &xpcs_phylink_ops; + xpcs->pcs.poll = true; + return xpcs_soft_reset(xpcs); } @@ -958,16 +990,4 @@ int xpcs_probe(struct mdio_xpcs_args *xpcs) } EXPORT_SYMBOL_GPL(xpcs_probe); -static struct mdio_xpcs_ops xpcs_ops = { - .config = xpcs_config, - .get_state = xpcs_get_state, - .link_up = xpcs_link_up, -}; - -struct mdio_xpcs_ops *mdio_xpcs_get_ops(void) -{ - return &xpcs_ops; -} -EXPORT_SYMBOL_GPL(mdio_xpcs_get_ops); - MODULE_LICENSE("GPL v2"); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 11585fa093cd..eb74ab5b8138 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -18,22 +18,13 @@ struct xpcs_id; struct mdio_xpcs_args { __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); + struct phylink_pcs pcs; struct mii_bus *bus; struct xpcs_id *id; int addr; int an_mode; }; -struct mdio_xpcs_ops { - int (*config)(struct mdio_xpcs_args *xpcs, - const struct phylink_link_state *state); - int (*get_state)(struct mdio_xpcs_args *xpcs, - struct phylink_link_state *state); - int (*link_up)(struct mdio_xpcs_args *xpcs, int speed, - phy_interface_t interface); -}; - -struct mdio_xpcs_ops *mdio_xpcs_get_ops(void); void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, From patchwork Thu May 27 20:45:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285337 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 2C807C47089 for ; Thu, 27 May 2021 20:45:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C744613E6 for ; Thu, 27 May 2021 20:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236370AbhE0Urb (ORCPT ); Thu, 27 May 2021 16:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236052AbhE0UrW (ORCPT ); Thu, 27 May 2021 16:47:22 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0658C061574 for ; Thu, 27 May 2021 13:45:47 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id lg14so2095607ejb.9 for ; Thu, 27 May 2021 13:45:47 -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=KV4L5yPhusQwpn3Ky/Es1VhkJTPcXPa1gVI8rTgpDUo=; b=kPIa6phvPga725lveo2klEzb2aTPZvqSpOsgveBoV9Xo3y+MN8c8CoLCjpizrCTEvl YR01OWr4byDPtrF0Ht8N9wcJplkuC+OAgcPaQDueaN9M/HVBQ3dNCa/CtiDYfaAC0KSN fjSy4l9brDiLydNK79B1V8QqIfHe2oj9JwD6R+Gaypwo6zCe5sqRT/z6Sc7C5V6iSNYC pVmeSb8Zm1FxcjI7fxmC1af5621awz5M5yQ55Ba4P5aM+sDKr7f0BZ9xoXOu24czztEn tkS3HKX/DAEGjzgL8T10jJZb7T2VLxWuPuwDFVcSqbpDqYiWMowAW6uw621q1gzdhBEP Sx+g== 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=KV4L5yPhusQwpn3Ky/Es1VhkJTPcXPa1gVI8rTgpDUo=; b=Qz3PYIIPf59gM95KzN7ZRXJt739EOo6QAnS6fuXxAApmKv9jeDu3uygBLJi+y33z55 J3st6kBXOEJF6t5nIV4pgNLEQP4eyowUniFGXhUBwhXZ9ZA58TSTv2Am+LsPO8QREqEG T+Fns8nqClmtitIWTjtuX+xibeMp4eSzC6ypXpFCp3a80RXJapGBaWi704EqQyUuD4I5 /boWTjteXD+JdmpkBzpBQeaCBxcd83Qow6SI3z83YL3Qku9MXgpvxElFwiMwDloiFcKS v0QDlgaEwP+8FtG123ceFollyGKf2lIGGH2tXeD+3eiJdMCCWqTj0/7ie1yeSYwWzmoq 1jWQ== X-Gm-Message-State: AOAM530WagRQDl/iEVWO5xmsuog8P3NPG/PNORZL8xzCdsbopXFIXRIn t8qBqxPzGPClYWtG0HEiOTluQQFE/HM= X-Google-Smtp-Source: ABdhPJyighIHBKIxUGuLn5Doa2pKyhAV/MO6ZrQ1hViVCcyxTeJaz3dZ049ovYGzaVEyn7Nt6FKYdw== X-Received: by 2002:a17:907:2d0c:: with SMTP id gs12mr5856037ejc.173.1622148346390; Thu, 27 May 2021 13:45:46 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:46 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 7/8] net: pcs: xpcs: use mdiobus_c45_addr in xpcs_{read,write} Date: Thu, 27 May 2021 23:45:27 +0300 Message-Id: <20210527204528.3490126-8-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean Use the dedicated helper for abstracting away how the clause 45 address is packed in reg_addr. Signed-off-by: Vladimir Oltean --- drivers/net/pcs/pcs-xpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 288abe8ddaf3..e0a7e546f32b 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -220,14 +220,14 @@ static struct xpcs_id { static int xpcs_read(struct mdio_xpcs_args *xpcs, int dev, u32 reg) { - u32 reg_addr = MII_ADDR_C45 | dev << 16 | reg; + u32 reg_addr = mdiobus_c45_addr(dev, reg); return mdiobus_read(xpcs->bus, xpcs->addr, reg_addr); } static int xpcs_write(struct mdio_xpcs_args *xpcs, int dev, u32 reg, u16 val) { - u32 reg_addr = MII_ADDR_C45 | dev << 16 | reg; + u32 reg_addr = mdiobus_c45_addr(dev, reg); return mdiobus_write(xpcs->bus, xpcs->addr, reg_addr, val); } From patchwork Thu May 27 20:45:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12285339 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 X-Spam-Level: X-Spam-Status: No, score=-15.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,URIBL_BLOCKED,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 339EBC47089 for ; Thu, 27 May 2021 20:46:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D722613E3 for ; Thu, 27 May 2021 20:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236405AbhE0Urg (ORCPT ); Thu, 27 May 2021 16:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235937AbhE0UrX (ORCPT ); Thu, 27 May 2021 16:47:23 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15DBBC0613CE for ; Thu, 27 May 2021 13:45:49 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id df21so2369205edb.3 for ; Thu, 27 May 2021 13:45:49 -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=W5rl8REEJ4/iz/FjOyfS4x8Yt6ENcdcnVzy9PwH01O8=; b=bF6rSfzUaP0LM3dyWfVz06xS4XmPPomgyK7S+iKClSqb/PuAo5C5T4umQ5b5TuBjt0 O6oNlw2qyAzgrqRvxqpl3TUHnCGQmsdhixPXPLfd8A8t7j4kaLZoOFLWybBTqkfCcp+0 vzGiv+fDxxDXOcrfoHlKKki/+xcUyrayZMzvGwSgauOGfw/0yaJbjFmfMNKPt7sW8QkB p4mo7vDPEEor+ediT5NKOmOnlExqK/MiyQYWJxiYHt1Mb9417xOizRXOppyoJWmvVD+a Ya4EDpnRnXSv046kK0ppOU0CdwmRXX+ggfH3BoEhsebFVyeMkteAbAqbnwX4fKFE6yHq wP7w== 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=W5rl8REEJ4/iz/FjOyfS4x8Yt6ENcdcnVzy9PwH01O8=; b=bGsCH7PCH8l6+03cnFmtaO2E1N/5UOPMYDxpYG1X8etg4VPJB1nlfrwTdFnxntbH5U d1c64QyGsdVhQzUAivRh5W2Bnt3P+HSRFiDRWJ/pxCYiOjhG29K2YzXVpu9MEpQ+Onpl tVwPYTkzS0FWeu0fJ4H7tCbMNCvjjZE7jM4YCszZLWLAzGa2UYrP3BLbUOsVJfG0BkRl 3VVRPE73+xw7tyDk/jlJHLY21d/BH0eNcrGs+Avn5PwMi8/DIkKPzDicG65q2oL5FRLR 4WcZbwfigxyTfG955cIZ7WP11tugAVLEnJ+KdwHj+ff68i4QaoG6FgGjsxnpsrwRLrUq uU6Q== X-Gm-Message-State: AOAM531UTL7pjzZ0bxoRZqKLPs71Q+OppxGDg9vKpcRsC9sbOU9vHU/d ffIgWHzW8sfMmtAbTf0uHOQ= X-Google-Smtp-Source: ABdhPJwQ/agM+3oAJMru/9VU8zpvLbN2fu2OrP6F6ABwqzXakajnKY1DeDi0U0Ehmf2ClAcjj4oK2Q== X-Received: by 2002:a05:6402:50d2:: with SMTP id h18mr6427480edb.10.1622148347668; Thu, 27 May 2021 13:45:47 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id g11sm1654145edt.85.2021.05.27.13.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 13:45:47 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Ong Boon Leong , Michael Sit Wei Hong , Vladimir Oltean Subject: [RFC PATCH net-next 8/8] net: pcs: xpcs: convert to mdio_device Date: Thu, 27 May 2021 23:45:28 +0300 Message-Id: <20210527204528.3490126-9-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527204528.3490126-1-olteanv@gmail.com> References: <20210527204528.3490126-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Vladimir Oltean Unify the 2 existing PCS drivers (lynx and xpcs) by doing a similar thing on probe, which is to have a *_create function that takes a struct mdio_device * given by the caller, and builds a private PCS structure around that. This changes stmmac to hold only a pointer to the xpcs, as opposed to the full structure. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/common.h | 2 +- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 3 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +-- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 32 +++++++-------- drivers/net/pcs/pcs-xpcs.c | 40 ++++++++++++++----- include/linux/pcs/pcs-xpcs.h | 5 +-- 6 files changed, 54 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 678f8ce62b8a..8a83f9e1e95b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -503,7 +503,7 @@ struct mac_device_info { const struct stmmac_hwtimestamp *ptp; const struct stmmac_tc_ops *tc; const struct stmmac_mmc_ops *mmc; - struct mdio_xpcs_args xpcs_args; + struct mdio_xpcs_args *xpcs; struct mii_regs mii; /* MII register Addresses */ struct mac_link link; void __iomem *pcsr; /* vpointer to device CSRs */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 72d2d575bbfe..bd5de43cf925 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -720,8 +720,7 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev, netdev_warn(priv->dev, "Setting EEE tx-lpi is not supported\n"); - ret = xpcs_config_eee(&priv->hw->xpcs_args, - priv->plat->mult_fact_100ns, + ret = xpcs_config_eee(priv->hw->xpcs, priv->plat->mult_fact_100ns, edata->eee_enabled); if (ret) return ret; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3ccf00ea77d5..f46f6524aa18 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -996,7 +996,7 @@ static void stmmac_validate(struct phylink_config *config, linkmode_andnot(state->advertising, state->advertising, mask); /* If PCS is supported, check which modes it supports. */ - xpcs_validate(&priv->hw->xpcs_args, supported, state); + xpcs_validate(priv->hw->xpcs, supported, state); } static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) @@ -1222,7 +1222,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) return PTR_ERR(phylink); if (mdio_bus_data->has_xpcs) { - struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; + struct mdio_xpcs_args *xpcs = priv->hw->xpcs; phylink_set_pcs(phylink, &xpcs->pcs); } @@ -3625,7 +3625,7 @@ int stmmac_open(struct net_device *dev) if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI && - priv->hw->xpcs_args.an_mode != DW_AN_C73) { + priv->hw->xpcs->an_mode != DW_AN_C73) { ret = stmmac_init_phy(dev); if (ret) { netdev_err(priv->dev, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 4a197b2fe26b..c632d3f10102 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -503,25 +503,25 @@ int stmmac_mdio_register(struct net_device *ndev) /* Try to probe the XPCS by scanning all addresses. */ if (mdio_bus_data->has_xpcs) { - struct mdio_xpcs_args *xpcs = &priv->hw->xpcs_args; - int ret; - - max_addr = PHY_MAX_ADDR; - - xpcs->bus = new_bus; - - found = 0; - for (addr = 0; addr < max_addr; addr++) { - xpcs->addr = addr; - - ret = xpcs_probe(xpcs); - if (!ret) { - found = 1; - break; + struct mdio_device *mdiodev; + struct mdio_xpcs_args *xpcs; + + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + mdiodev = mdio_device_create(new_bus, addr); + if (IS_ERR(mdiodev)) + continue; + + xpcs = xpcs_create(mdiodev); + if (IS_ERR_OR_NULL(xpcs)) { + mdio_device_free(mdiodev); + continue; } + + priv->hw->xpcs = xpcs; + break; } - if (!found && !mdio_node) { + if (!priv->hw->xpcs) { dev_warn(dev, "No XPCS found\n"); err = -ENODEV; goto no_xpcs_found; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index e0a7e546f32b..194b79da547b 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -221,15 +221,19 @@ static struct xpcs_id { static int xpcs_read(struct mdio_xpcs_args *xpcs, int dev, u32 reg) { u32 reg_addr = mdiobus_c45_addr(dev, reg); + struct mii_bus *bus = xpcs->mdiodev->bus; + int addr = xpcs->mdiodev->addr; - return mdiobus_read(xpcs->bus, xpcs->addr, reg_addr); + return mdiobus_read(bus, addr, reg_addr); } static int xpcs_write(struct mdio_xpcs_args *xpcs, int dev, u32 reg, u16 val) { u32 reg_addr = mdiobus_c45_addr(dev, reg); + struct mii_bus *bus = xpcs->mdiodev->bus; + int addr = xpcs->mdiodev->addr; - return mdiobus_write(xpcs->bus, xpcs->addr, reg_addr, val); + return mdiobus_write(bus, addr, reg_addr, val); } static int xpcs_read_vendor(struct mdio_xpcs_args *xpcs, int dev, u32 reg) @@ -294,7 +298,7 @@ static int xpcs_soft_reset(struct mdio_xpcs_args *xpcs) #define xpcs_warn(__xpcs, __state, __args...) \ ({ \ if ((__state)->link) \ - dev_warn(&(__xpcs)->bus->dev, ##__args); \ + dev_warn(&(__xpcs)->mdiodev->dev, ##__args); \ }) static int xpcs_read_fault_c73(struct mdio_xpcs_args *xpcs, @@ -963,10 +967,19 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -int xpcs_probe(struct mdio_xpcs_args *xpcs) +struct mdio_xpcs_args *xpcs_create(struct mdio_device *mdiodev) { - u32 xpcs_id = xpcs_get_id(xpcs); - int i; + struct mdio_xpcs_args *xpcs; + u32 xpcs_id; + int i, ret; + + xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); + if (!xpcs) + return NULL; + + xpcs->mdiodev = mdiodev; + + xpcs_id = xpcs_get_id(xpcs); for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { struct xpcs_id *entry = &xpcs_id_list[i]; @@ -983,11 +996,20 @@ int xpcs_probe(struct mdio_xpcs_args *xpcs) xpcs->pcs.ops = &xpcs_phylink_ops; xpcs->pcs.poll = true; - return xpcs_soft_reset(xpcs); + ret = xpcs_soft_reset(xpcs); + if (ret) + goto out; + + return xpcs; } - return -ENODEV; + ret = -ENODEV; + +out: + kfree(xpcs); + + return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(xpcs_probe); +EXPORT_SYMBOL_GPL(xpcs_create); MODULE_LICENSE("GPL v2"); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index eb74ab5b8138..237f2198f709 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -18,10 +18,9 @@ struct xpcs_id; struct mdio_xpcs_args { __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); + struct mdio_device *mdiodev; struct phylink_pcs pcs; - struct mii_bus *bus; struct xpcs_id *id; - int addr; int an_mode; }; @@ -29,6 +28,6 @@ void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns, int enable); -int xpcs_probe(struct mdio_xpcs_args *xpcs); +struct mdio_xpcs_args *xpcs_create(struct mdio_device *mdiodev); #endif /* __LINUX_PCS_XPCS_H */