Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2851293imm; Fri, 24 Aug 2018 06:30:50 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaw2OsmJNbCrp3AgZ/eOEZtUfZP2V++ToP4wVT2quugVj0MSmUIIhNgkmSghyaNRgCREJps X-Received: by 2002:a62:20d8:: with SMTP id m85-v6mr2065727pfj.74.1535117450922; Fri, 24 Aug 2018 06:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535117450; cv=none; d=google.com; s=arc-20160816; b=WfBXITzZSYvg1Dfsk9s/BzKvy/XUzFyeKxuwmMwYAcgC14rnB2elF2ygTfD0UBNXlF 6sMztMJf01KWGYPhWCTiiH+bnQ94ROf7/zHhPCd5Jyz+ZUeYgBqaUBcRg0leJWK/TwQR /f06jjtmPTsi7UbPd2hG7JpcVO5dxZsnWOqTdZM4vDaE1YQrRsnbGhGvW+IQVbAZg9+b gQp2oN1BLyVS2OC0PYw4bFtAkFrG9FPewNE4AQ6fyxRq9tVBnhJrkYcqS2PZqqdDBvr/ 02HgYEPnlz2myNdjIxS7nqh2TjVhhF5m3q7F7Qfo/eKkkS3dyP71RIM0xt0fVeJk0RSB u29Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=c0GKwGgJ1LlURubCzM2qWe06aj9h0nQD8eqwLckRuAg=; b=b1r4otqgK844gsQ3tmwp2uNTqqZoGILPPXYeGIiOZvNy8xFiuDmarGTLnaxwTM2FUb rUpkGoxCvTKHNVzyKq6Krhi0/D9WTVv1DrcYzDw1Kythtt/asuHCgogXWiM4djj6ir9U PAD//AEEtAhViibpjspEJWEUZt2tZqwwgCeVhqCkMHJUbeMxLg+iIszdh+axU+rnSTus YNiKnoz73MsI90Hw7xj2egsWy8SLNpMEfRgaJ4Z2eeYGXYHE0HbfirGEKGB1pX/3Lb+O fwx+pdrGkDF+ZJoluBQoGVOnQvsC+xd36vpDS9vwuJ7oo/Ee49VDdvtlQyGUfQH3ybQJ i1ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=iouFstuW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si7487936pfi.99.2018.08.24.06.30.35; Fri, 24 Aug 2018 06:30:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=iouFstuW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728080AbeHXRDl (ORCPT + 99 others); Fri, 24 Aug 2018 13:03:41 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:42250 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbeHXRDl (ORCPT ); Fri, 24 Aug 2018 13:03:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=c0GKwGgJ1LlURubCzM2qWe06aj9h0nQD8eqwLckRuAg=; b=iouFstuWVNbtwgu9LEOicnQNhHGq6086muNjWjll7wQIwwpQ1KMGg5f4NB/VPB1q2mzDMa2HftqMDeuuKrNeZiC3Uutl0wY2KqUGgAXp3HGlSUK/ZCPPA/v6P+OQA71jH/KB7WeIchsYnCL1LC3REyffk4MPI2dE9o8GXPPKR+0=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1ftC93-0000cu-8h; Fri, 24 Aug 2018 15:28:57 +0200 Date: Fri, 24 Aug 2018 15:28:57 +0200 From: Andrew Lunn To: "lipeng (Y)" Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com Subject: Re: [PATCH NET 3/3] net: hns: add configuration constraints for 1000M half Message-ID: <20180824132857.GA1999@lunn.ch> References: <1535082143-122281-1-git-send-email-lipeng321@huawei.com> <1535082143-122281-4-git-send-email-lipeng321@huawei.com> <20180824034119.GA29111@lunn.ch> <194ac663-94d8-55e2-0231-a6be53e35f04@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <194ac663-94d8-55e2-0231-a6be53e35f04@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 24, 2018 at 02:39:36PM +0800, lipeng (Y) wrote: > > > On 2018/8/24 11:41, Andrew Lunn wrote: > >On Fri, Aug 24, 2018 at 11:42:23AM +0800, Peng Li wrote: > >>Hisilicon hip05 and hip06 board network card do not support > >>1000M half configuration. Driver can not config gmac as > >>1000M half. > >> > >>Signed-off-by: Peng Li > >Hi Peng > > > >Does the driver remove SUPPORTED_1000baseT_Half from > >phydev->supported? If you do that, the PHY should never negotiate > >this speed. > > > > Andrew > Hi, Andrew, > > The driver has removed SUPPORTED_1000baseT_Half from > > phydev->supported. > > the code is : > #define MAC_GMAC_SUPPORTED \ > (SUPPORTED_10baseT_Half \ > | SUPPORTED_10baseT_Full \ > | SUPPORTED_100baseT_Half \ > | SUPPORTED_100baseT_Full \ > | SUPPORTED_Autoneg) > h->if_support = MAC_GMAC_SUPPORTED; > h->if_support |= SUPPORTED_1000baseT_Full; > phydev->supported &= h->if_support; > > As gmac do not support 1000M half, we add this patch to > make sure that no users can set 1000M half in any case. Well, not quite. What this patch does is protect the hardware when it is asked to change to an unsupported mode. This patch has nothing to do with user APIs. The user API for setting link modes is hns_nic_set_link_ksettings(). What you do have is if (speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF) return -EINVAL; which should stop somebody setting up a fixed speed link at 1000Half. But you don't do anything with cmd->link_modes.advertising. However, when you call phy_ethtool_ksettings_set(), it gets AND'ed with phydev->supported, which you have already removed 1000Half from. So is this a patch for a theoretical problem? Or have you seen it happen? If it did happen, how did the user configure it to cause this problem? That user API needs to prevent it. Andrew