Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1758004rwd; Fri, 9 Jun 2023 01:29:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MA1KYAuAMn1kKE3S3OEkbSUfwVs4dtC5dUBRilc8eozGmY9z4k/q62LGIPYnijzxSxp1k X-Received: by 2002:a17:902:d2c4:b0:1b2:5070:c1c9 with SMTP id n4-20020a170902d2c400b001b25070c1c9mr542048plc.20.1686299379607; Fri, 09 Jun 2023 01:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686299379; cv=none; d=google.com; s=arc-20160816; b=N4EooyO+1VsaXbvEMcL+WjGkLmDKiC1vlyUoOSZ9yZRKjyrxbMtaF1+YJb7TCIp4lf R72tz7q5c64RQeY729+KwWb9dEHOaeZeY6AsX8P6EvfwSCCxOlKfwgjn/dAuFWjC2u7Q CQ2OvBuq36pHd1cn+vZiWrjnYlzn69jAlQbQ+IGTmKq23e7F1KfhzPeZzu1KXcXiYKYh pZwaDn7DL1m90GL6zPquDL3KwXVbPy+7lcVmc2seHEiQLuMnKZl5holiEUZDKCmMw1lA fvfBEDtRKVD+RjlEbkWx9jr8iPls4BNkMP4SoofbX3KBKayGgiGetHqLAdWIMtAe/zhT ER1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xqzfFr7NFXB0y0mQeicw6jY8bkfZtTdsIOq61oO/O+I=; b=H1etqB5dOExobJqBWcd50TdPWgB92Focc2AfoWhJJJwEy7I61iXFShF5ZuZ3IU9xya QyhQ1/jcPWj25wz74FpC7lgRrAPyualW3hYdGRYnNYsgDDy7RBZpFfh6dklw16PDa8Dl nPNbllbGUoremGkxhdC66TfGeaAPYQegq6WNLksdyB5oBSWCSLalRXWoyBiyNFAYRIjW GspAx6JRsY5H6pVwWIXQIClBQvqnl8Yyg05jWhGYyEhtm7WjzFYlh9giUCCvnJ/Z/gCO Ba0jOnRcN80658AsF3WDsiZL5rqYZVrF2+PolZwBjEp+UEluP3EeTmfG1gDsowNPvttG blMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hLuGGuY9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf8-20020a170902fb4800b001ae4e665c60si2321699plb.156.2023.06.09.01.29.27; Fri, 09 Jun 2023 01:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=hLuGGuY9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239930AbjFIIFu (ORCPT + 99 others); Fri, 9 Jun 2023 04:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbjFIIEi (ORCPT ); Fri, 9 Jun 2023 04:04:38 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A5349ED; Fri, 9 Jun 2023 01:03:23 -0700 (PDT) X-GND-Sasl: maxime.chevallier@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686297791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xqzfFr7NFXB0y0mQeicw6jY8bkfZtTdsIOq61oO/O+I=; b=hLuGGuY9Ac4PeFKCg9fKcmN9TaPbtvYLiSRfEO3AVccxKFkh8KcprOE7S1EEnNgtiQ1F97 YWV33SbSSfmjxNoKyjX2SKDfUor7bF5OU+svDskKIvf1m7RAtA3gXGzy9kFOpXT08AeXfP 3YsR7zFSzol0KzAwodZwwfny8A5lJ4QfLZd7JjliGXS75Pzcu7T2UBIV8ePo0WxilHqyha C+0VSNJXYumnVgXTCCo1qVzPKCvbe0WpQ54sZT0tBVc7ToDEEjgyGRtlwc88Ae9Je61jDO 9MKnBeu6gV+KG1v0FbCrjvVhA2W3RqMuImS7iyMZaCMXiTktI7pSCkKV/n8rlQ== X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com X-GND-Sasl: maxime.chevallier@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id AB357C000A; Fri, 9 Jun 2023 08:03:10 +0000 (UTC) From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Horatiu.Vultur@microchip.com, Allan.Nielsen@microchip.com, UNGLinuxDriver@microchip.com, Vladimir Oltean , Simon Horman Subject: [PATCH net v2 2/2] net: phylink: use a dedicated helper to parse usgmii control word Date: Fri, 9 Jun 2023 10:03:05 +0200 Message-Id: <20230609080305.546028-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609080305.546028-1-maxime.chevallier@bootlin.com> References: <20230609080305.546028-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Q-USGMII is a derivative of USGMII, that uses a specific formatting for the control word. The layout is close to the USXGMII control word, but doesn't support speeds over 1Gbps. Use a dedicated decoding logic for the USGMII control word, re-using USXGMII definitions but only considering 10/100/1000Mbps speeds Fixes: 5e61fe157a27 ("net: phy: Introduce QUSGMII PHY mode") Signed-off-by: Maxime Chevallier --- V1->V2: - Fix the decoding logic, by dropping the custom, wrong, speed mask - Fix a typo in the function doc ("expect" -> "except") - Slightly reword the commit log drivers/net/phy/phylink.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 590469261b98..b82d66e8dda2 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3359,6 +3359,41 @@ void phylink_decode_usxgmii_word(struct phylink_link_state *state, } EXPORT_SYMBOL_GPL(phylink_decode_usxgmii_word); +/** + * phylink_decode_usgmii_word() - decode the USGMII word from a MAC PCS + * @state: a pointer to a struct phylink_link_state. + * @lpa: a 16 bit value which stores the USGMII auto-negotiation word + * + * Helper for MAC PCS supporting the USGMII protocol and the auto-negotiation + * code word. Decode the USGMII code word and populate the corresponding fields + * (speed, duplex) into the phylink_link_state structure. The structure for this + * word is the same as the USXGMII word, except it only supports speeds up to + * 1Gbps. + */ +static void phylink_decode_usgmii_word(struct phylink_link_state *state, + uint16_t lpa) +{ + switch (lpa & MDIO_USXGMII_SPD_MASK) { + case MDIO_USXGMII_10: + state->speed = SPEED_10; + break; + case MDIO_USXGMII_100: + state->speed = SPEED_100; + break; + case MDIO_USXGMII_1000: + state->speed = SPEED_1000; + break; + default: + state->link = false; + return; + } + + if (lpa & MDIO_USXGMII_FULL_DUPLEX) + state->duplex = DUPLEX_FULL; + else + state->duplex = DUPLEX_HALF; +} + /** * phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers * @state: a pointer to a &struct phylink_link_state. @@ -3396,9 +3431,11 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state, case PHY_INTERFACE_MODE_SGMII: case PHY_INTERFACE_MODE_QSGMII: - case PHY_INTERFACE_MODE_QUSGMII: phylink_decode_sgmii_word(state, lpa); break; + case PHY_INTERFACE_MODE_QUSGMII: + phylink_decode_usgmii_word(state, lpa); + break; default: state->link = false; -- 2.40.1