Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp630164iog; Wed, 29 Jun 2022 07:12:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEs12rgdvzKgrf7AjdgFgwkH1LRregKnYg0Cda9W56BoHu+qoo/ozVWvwQMO0+usEKZTfi X-Received: by 2002:a17:902:aa47:b0:16b:8e4c:93d2 with SMTP id c7-20020a170902aa4700b0016b8e4c93d2mr9369230plr.27.1656511935464; Wed, 29 Jun 2022 07:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656511935; cv=none; d=google.com; s=arc-20160816; b=GBM0GgZCt2m6bRgzw3Mfl571lNmhzBoPAcbTKDi2jVXvd81qVLjYMgvMtMCbqLEmwG shjvejiFp+QIFMRzhbPWjFdU7KTboK+4w6aeI62ZyMoP8Tlic+HAhcYW8h1WQxF7HXrg O7fDLHkSzqYsxa/m3F44/VGnhC67D0v3CzLeQjK6RC4gG+ojd1PpwMpxOuxrs9ac6LrP VeMXj6v4xPPx8EFQXRxh01l0OsWhoHbIgYUD/SerR5IZtAQLvfCGwsVaWC/n5c2iZeW+ 5CKi7dfQANS2TcA6FRQqJraSQwxLygRAH0TMeJr00fMll1W1ZHBK3cBELk8SmyHT/dH8 nNow== 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 :message-id:date:subject:cc:to:from; bh=9hNu65gVkGqWApb5LEAOBDxmUXQql/2F8BIminM5BmE=; b=Ryv+JBXMKx3vV1WY6L2AElEx8R/N/PjWCvQdbpR+6/OLgxaddGpcuUv81L/E/Pa7fJ R+dADAlB1jCXAqIe0laP4MrbhtTDjCgZRdCfNMxrscC6exPI3YytIcfVNU0OsF03BsEP aw5yh8gu3m9q1R1fB35jZqWCz0dKlePxuQVbO3Yc/SVbuDi8Oti6hZnHDB53+aBSTyB0 P9sUB3qn+F5jv1X7VGWodqeCbFx5S1wfKCglgzmwH+7QmrMBhdy9N7DZYr6DD3w66MJk 4bk2N3nb/xf91j8Ibgm3Yvc9OxOnTIe+ujmF0sfLGsVVXREm98IWL1qRKjsSkfwUwsLi uYXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r17-20020aa79631000000b0051bac3bbca0si21996574pfg.174.2022.06.29.07.11.51; Wed, 29 Jun 2022 07:12:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233748AbiF2Nb0 (ORCPT + 99 others); Wed, 29 Jun 2022 09:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbiF2NbW (ORCPT ); Wed, 29 Jun 2022 09:31:22 -0400 Received: from out28-4.mail.aliyun.com (out28-4.mail.aliyun.com [115.124.28.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E8D535DF1; Wed, 29 Jun 2022 06:31:11 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08042336|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.398995-0.00148957-0.599516;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047192;MF=frank.sae@motor-comm.com;NM=1;PH=DS;RN=14;RT=14;SR=0;TI=SMTPD_---.OFYoJ3Y_1656509443; Received: from sunhua.motor-comm.com(mailfrom:Frank.Sae@motor-comm.com fp:SMTPD_---.OFYoJ3Y_1656509443) by smtp.aliyun-inc.com; Wed, 29 Jun 2022 21:31:07 +0800 From: Frank To: Peter Geis , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: yinghong.zhang@motor-comm.com, fei.zhang@motor-comm.com, hua.sun@motor-comm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Subject: Re: Re: [PATCH v2] net: phy: Add driver for Motorcomm yt8521 gigabit Date: Wed, 29 Jun 2022 21:30:12 +0800 Message-Id: <20220629133012.1840-1-Frank.Sae@motor-comm.com> X-Mailer: git-send-email 2.31.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 The poll mode of yt8521 phy is not support utp and fiber at same time, In other words, only utp or fiber can be connected at one time, and you can change to fiber or utp at next time. so in poll mode need to do both ( utp and fiber ) operation > > > > +int yt8521_config_aneg(struct phy_device *phydev) > > > > +{ > > > > + struct yt8521_priv *priv = phydev->priv; > > > > + u8 polling_mode = priv->polling_mode; > > > > + int old_page; > > > > + int ret; > > > > + > > > > + old_page = yt8521_read_page_with_lock(phydev); > > > > + if (old_page) > > > > + return old_page; > > > > + > > > > + if (polling_mode == YT8521_MODE_FIBER || > > > > + polling_mode == YT8521_MODE_POLL) { > > > > + ret = yt8521_write_page_with_lock(phydev, > > > > + YT8521_RSSR_FIBER_SPACE); > > > > + if (ret < 0) > > > > + goto err_restore_page; > > > > + > > > > + ret = genphy_config_aneg(phydev); > > > > + if (ret < 0) > > > > + goto err_restore_page; > > > > + } > > > > + > > > > + if (polling_mode == YT8521_MODE_UTP || > > > > + polling_mode == YT8521_MODE_POLL) { > > > > + ret = yt8521_write_page_with_lock(phydev, > > > > + YT8521_RSSR_UTP_SPACE); > > > > + if (ret < 0) > > > > + goto err_restore_page; > > > > + > > > > + ret = genphy_config_aneg(phydev); > > > > + if (ret < 0) > > > > + goto err_restore_page; > > > > + } > > > > > > Looks like this could be refactored to reduce duplication. > > > > > > > sure, as the reason said above, the same operation is required in both utp and > > fiber spaces. > > So you can probably pull the 'core' of this function out into a > helper, and then call it either with YT8521_RSSR_UTP_SPACE or > YT8521_RSSR_FIBER_SPACE. > > > > > + ret = !!(link_fiber | link_utp); > > > > > > Does this mean it can do both copper and fibre at the same time. And > > > whichever gives up first wins? > > > > Sure, the phy supports utp, fiber, and both. In the case of both, this driver > > supposes that fiber is of priority. > > It is generally not that simple. Fibre, you probably want 1000BaseX, > unless the fibre module is actually copper, and then you want > SGMII. So you need something to talk to the fibre module and ask it > what it is. That something is phylink. Phylink does not support both > copper and fibre at the same time for one MAC. Cheers and BR, Frank -- 2.31.0.windows.1