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=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 BB2FDC282C2 for ; Thu, 7 Feb 2019 20:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C2EE20663 for ; Thu, 7 Feb 2019 20:41:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aGYTCdSc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbfBGUl4 (ORCPT ); Thu, 7 Feb 2019 15:41:56 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38083 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727235AbfBGUlz (ORCPT ); Thu, 7 Feb 2019 15:41:55 -0500 Received: by mail-wm1-f65.google.com with SMTP id v26so1284878wmh.3 for ; Thu, 07 Feb 2019 12:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=c49A7dRJ9ZGXWeEqfmAdafIwf6taT2nALlpTEzTcLBw=; b=aGYTCdSc+ezXKA2oPseWKHLXHvCgVqua22VYAhN9l/Z84YpUN/evrv2PYuPR4AW9jP 2GtPZXio3NPyjxtu4ejkwSJ8O6aJIPNuGg3HCY/k1HrjDLQ556QHwbf8+MubRDy9gTpB rOMp5H9cYzRfT7ZlQRMr0+O6DZHFOlQIkHxNOTdzLP9JU+QqYznVqE5Lw1nvSxG5L3pi ctCrOHphQEOnW+cjPg5wa/+4JJ3GHVYZfJw9LDX/FmXNLmH2OSOKjmIZoSODn0lq17Q2 SDwTRcvjJ//rpy+0SQjWCASFKoHMTTojhu4qt44zFrn25J5o1pO+xuVXmiRPrWhPxRun PDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=c49A7dRJ9ZGXWeEqfmAdafIwf6taT2nALlpTEzTcLBw=; b=mOsmGz7G03Uv2kuqnRIeEasoWODh25ItF9H87oCh1LtsMGENdDSTxUslMtkhMkbvTL GCF7i5TYqu3JItt4qtxtOKQmWDPq8SBFAMdvPok5wF/DUIlNBpxhQkWs2ByVoAfSTO93 aJLOvkF6ZUeVy9zLz9v5igQAD5kCzpoxk1+fUMIg1zYVA3qG/Bo8XvPo30Z9IsAISw0O 3ENBRdYd0bKDGTFcg92EzQJQYpnt0iqmhUPgRpo3SWoTnYZ/5ikpGancKtcdpCKyozJs leJUdHZ08yd3tvtM7AQoqehtuc9f2TEL0FVKcbgZl7bnmUDDhNgSaR22ZujXL9ZF1lmZ 8Wiw== X-Gm-Message-State: AHQUAuacDBVy8y5lXX7eT8W1unRs8eP7noEyii55Dy9ZM/pFogaO9qTn ePWDovpN0UA/4IlaXSrbMKwdAStz X-Google-Smtp-Source: AHgI3IYSaNJsG2sAmljAsB/k0QcjIdQjyHtLQQIx7m3ALUPNgJtr9TWxohLle5wpQMbyfOgXiteprQ== X-Received: by 2002:a7b:c2a9:: with SMTP id c9mr9489469wmk.44.1549572112566; Thu, 07 Feb 2019 12:41:52 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:a906:e81:1a0f:97bd? (p200300EA8BF1E200A9060E811A0F97BD.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:a906:e81:1a0f:97bd]) by smtp.googlemail.com with ESMTPSA id j33sm53651076wre.91.2019.02.07.12.41.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 12:41:51 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v2 net-next] net: phy: let genphy_c45_read_link manage the devices to check To: Andrew Lunn , Florian Fainelli , David Miller , Russell King Cc: "netdev@vger.kernel.org" Message-ID: <7c00df20-b3e1-7ea9-2adb-004e6291d52c@gmail.com> Date: Thu, 7 Feb 2019 21:41:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Let genphy_c45_read_link manage the devices to check, this removes overhead from callers. Add C22EXT to the list of excluded devices because it doesn't implement the status register. According to the 802.3 clause 45 spec registers 29.0 - 29.4 are reserved. At the moment we have very few clause 45 PHY drivers, so we are lacking experience whether other drivers will have to exclude further devices, or may need to check PHY XS. If we should figure out that list of devices to check needs to be configurable, I think best will be to add a device list member to struct phy_driver. v2: - adjusted commit message - exclude also device C22EXT from link checking Signed-off-by: Heiner Kallweit --- drivers/net/phy/marvell10g.c | 10 +--------- drivers/net/phy/phy-c45.c | 18 ++++++++++-------- include/linux/phy.h | 2 +- include/uapi/linux/mdio.h | 2 ++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index 296a537cd..96a79c6c7 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -428,16 +428,8 @@ static int mv3310_read_10gbr_status(struct phy_device *phydev) static int mv3310_read_status(struct phy_device *phydev) { - u32 mmd_mask = phydev->c45_ids.devices_in_package; int val; - /* The vendor devads do not report link status. Avoid the PHYXS - * instance as there are three, and its status depends on the MAC - * being appropriately configured for the negotiated speed. - */ - mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2) | - BIT(MDIO_MMD_PHYXS)); - phydev->speed = SPEED_UNKNOWN; phydev->duplex = DUPLEX_UNKNOWN; linkmode_zero(phydev->lp_advertising); @@ -453,7 +445,7 @@ static int mv3310_read_status(struct phy_device *phydev) if (val & MDIO_STAT1_LSTATUS) return mv3310_read_10gbr_status(phydev); - val = genphy_c45_read_link(phydev, mmd_mask); + val = genphy_c45_read_link(phydev); if (val < 0) return val; diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index b09a5e134..eff9e5a4d 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -118,17 +118,24 @@ EXPORT_SYMBOL_GPL(genphy_c45_aneg_done); /** * genphy_c45_read_link - read the overall link status from the MMDs * @phydev: target phy_device struct - * @mmd_mask: MMDs to read status from * * Read the link status from the specified MMDs, and if they all indicate * that the link is up, set phydev->link to 1. If an error is encountered, * a negative errno will be returned, otherwise zero. */ -int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask) +int genphy_c45_read_link(struct phy_device *phydev) { + u32 mmd_mask = phydev->c45_ids.devices_in_package; int val, devad; bool link = true; + /* The vendor devads and C22EXT do not report link status. Avoid the + * PHYXS instance as its status may depend on the MAC being + * appropriately configured for the negotiated speed. + */ + mmd_mask &= ~(MDIO_DEVS_VEND1 | MDIO_DEVS_VEND2 | MDIO_DEVS_C22EXT | + MDIO_DEVS_PHYXS); + while (mmd_mask && link) { devad = __ffs(mmd_mask); mmd_mask &= ~BIT(devad); @@ -274,16 +281,11 @@ EXPORT_SYMBOL_GPL(gen10g_config_aneg); int gen10g_read_status(struct phy_device *phydev) { - u32 mmd_mask = phydev->c45_ids.devices_in_package; - /* For now just lie and say it's 10G all the time */ phydev->speed = SPEED_10000; phydev->duplex = DUPLEX_FULL; - /* Avoid reading the vendor MMDs */ - mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2)); - - return genphy_c45_read_link(phydev, mmd_mask); + return genphy_c45_read_link(phydev); } EXPORT_SYMBOL_GPL(gen10g_read_status); diff --git a/include/linux/phy.h b/include/linux/phy.h index 237dd0358..f41bf651f 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1094,7 +1094,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, /* Clause 45 PHY */ int genphy_c45_restart_aneg(struct phy_device *phydev); int genphy_c45_aneg_done(struct phy_device *phydev); -int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask); +int genphy_c45_read_link(struct phy_device *phydev); int genphy_c45_read_lpa(struct phy_device *phydev); int genphy_c45_read_pma(struct phy_device *phydev); int genphy_c45_pma_setup_forced(struct phy_device *phydev); diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h index d435b00d6..2e6e309f0 100644 --- a/include/uapi/linux/mdio.h +++ b/include/uapi/linux/mdio.h @@ -123,6 +123,8 @@ #define MDIO_DEVS_TC MDIO_DEVS_PRESENT(MDIO_MMD_TC) #define MDIO_DEVS_AN MDIO_DEVS_PRESENT(MDIO_MMD_AN) #define MDIO_DEVS_C22EXT MDIO_DEVS_PRESENT(MDIO_MMD_C22EXT) +#define MDIO_DEVS_VEND1 MDIO_DEVS_PRESENT(MDIO_MMD_VEND1) +#define MDIO_DEVS_VEND2 MDIO_DEVS_PRESENT(MDIO_MMD_VEND2) /* Control register 2. */ #define MDIO_PMA_CTRL2_TYPE 0x000f /* PMA/PMD type selection */ -- 2.20.1