Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1356050pxk; Thu, 10 Sep 2020 13:22:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwZ8BT4IB6aPIlW2o+iaXf4c81lJtDVmDUBmoEUXCmuuHGDRh16nZBPj2jxXLDa15RTuX+ X-Received: by 2002:a17:906:46d5:: with SMTP id k21mr10406190ejs.247.1599769373133; Thu, 10 Sep 2020 13:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599769373; cv=none; d=google.com; s=arc-20160816; b=0ZkCcBpnvxKo9IkYdVfCDGVjCKozGkc23UK+MSguCGf237o+2bPJHliPt9srzwx/xt 0OjaOTQk/o35uaBTMKAEJ986Zt83RZQGeO87n8yj0W9ewc6UGUr2NU7UcwFO58oOy9IQ jk6YKZsFYk8ZljieACIHftWo92EZ1jQ+uQmGMdJMcQeiKNDf4H8imy6heOhkbkntzjNE YyBKcYSoELC0ypY5IJsWVRbjuvWDseUkKPeHSgXo3HrYVd+Li3eblvTjT+euBGg3eGm7 bJ7/VVOKAzEbjwQIQAiRIQAapgx6w7ydcJPxCs+st6Vw/AddUtqy1ey1G0Uq7m4Gq1A/ OBgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8cHfqe8ok53QMTwMzDehiqlm5Sn/5+DwGXEATgY8JDQ=; b=xL2EZz68G9tx9ExQ8enJ0uy+6/vsZoH8dc7fxPvD8TtUsPPfkz8X2zoQvJpLU63puN IiEAPLAOkjoqtCHgcY23t6H6SaX83p5zTUkiu1GEo6TPuSHLqrN2GPNqBkiA42Ymrb3k cPcP2i+wDUFEEoNeO2iVd1CWy5LIpq+xiqE9pPZ1vIvhvnylVLXXZgPMYgtyrjnxNBxE 8Zgub+1uBsdkWBfszDrdpSWJ9JuaYN6O3Z/g62L7jfUCmP+4Ljzbsx/jvj1rFwm49sM2 Yupcr4SCFP/QS844k5Y6gY6rrupl/tDmCrQ/bc52b0qiRqsWm8Qbbnv9fI4+cPlvOYag tHFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si4625271ejq.317.2020.09.10.13.22.30; Thu, 10 Sep 2020 13:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbgIJUVr (ORCPT + 99 others); Thu, 10 Sep 2020 16:21:47 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:56252 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgIJUUM (ORCPT ); Thu, 10 Sep 2020 16:20:12 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kGT2t-00E8FC-Be; Thu, 10 Sep 2020 22:19:51 +0200 Date: Thu, 10 Sep 2020 22:19:51 +0200 From: Andrew Lunn To: Oded Gabbay Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, SW_Drivers@habana.ai, gregkh@linuxfoundation.org, davem@davemloft.net, kuba@kernel.org, Omer Shpigelman Subject: Re: [PATCH 13/15] habanalabs/gaudi: Add ethtool support using coresight Message-ID: <20200910201951.GG3354160@lunn.ch> References: <20200910161126.30948-1-oded.gabbay@gmail.com> <20200910161126.30948-14-oded.gabbay@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910161126.30948-14-oded.gabbay@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int gaudi_nic_get_link_ksettings(struct net_device *netdev, > + struct ethtool_link_ksettings *cmd) > +{ > + struct gaudi_nic_device **ptr = netdev_priv(netdev); > + struct gaudi_nic_device *gaudi_nic = *ptr; > + struct hl_device *hdev = gaudi_nic->hdev; > + u32 port = gaudi_nic->port, speed = gaudi_nic->speed; Please go through the code and fixup Reverse Christmas tree. > + > + cmd->base.speed = speed; > + cmd->base.duplex = DUPLEX_FULL; > + > + ethtool_link_ksettings_zero_link_mode(cmd, supported); > + ethtool_link_ksettings_zero_link_mode(cmd, advertising); > + > + ethtool_add_mode(cmd, supported, 100000baseCR4_Full); > + ethtool_add_mode(cmd, supported, 100000baseSR4_Full); > + ethtool_add_mode(cmd, supported, 100000baseKR4_Full); > + ethtool_add_mode(cmd, supported, 100000baseLR4_ER4_Full); > + > + ethtool_add_mode(cmd, supported, 50000baseSR2_Full); > + ethtool_add_mode(cmd, supported, 50000baseCR2_Full); > + ethtool_add_mode(cmd, supported, 50000baseKR2_Full); > + > + if (speed == SPEED_100000) { > + ethtool_add_mode(cmd, advertising, 100000baseCR4_Full); > + ethtool_add_mode(cmd, advertising, 100000baseSR4_Full); > + ethtool_add_mode(cmd, advertising, 100000baseKR4_Full); > + ethtool_add_mode(cmd, advertising, 100000baseLR4_ER4_Full); > + > + cmd->base.port = PORT_FIBRE; > + > + ethtool_add_mode(cmd, supported, FIBRE); > + ethtool_add_mode(cmd, advertising, FIBRE); > + > + ethtool_add_mode(cmd, supported, Backplane); > + ethtool_add_mode(cmd, advertising, Backplane); > + } else if (speed == SPEED_50000) { > + ethtool_add_mode(cmd, advertising, 50000baseSR2_Full); > + ethtool_add_mode(cmd, advertising, 50000baseCR2_Full); > + ethtool_add_mode(cmd, advertising, 50000baseKR2_Full); > + } else { > + dev_err(hdev->dev, "unknown speed %d, port %d\n", speed, port); > + return -EFAULT; > + } > + > + ethtool_add_mode(cmd, supported, Autoneg); > + > + if (gaudi_nic->auto_neg_enable) { > + ethtool_add_mode(cmd, advertising, Autoneg); > + cmd->base.autoneg = AUTONEG_ENABLE; > + if (gaudi_nic->auto_neg_resolved) > + ethtool_add_mode(cmd, lp_advertising, Autoneg); > + } else { > + cmd->base.autoneg = AUTONEG_DISABLE; > + } > + > + ethtool_add_mode(cmd, supported, Pause); > + > + if (gaudi_nic->pfc_enable) > + ethtool_add_mode(cmd, advertising, Pause); > + > + return 0; > +} > + > +static int gaudi_nic_set_link_ksettings(struct net_device *netdev, > + const struct ethtool_link_ksettings *cmd) > +{ > + struct gaudi_nic_device **ptr = netdev_priv(netdev); > + struct gaudi_nic_device *gaudi_nic = *ptr; > + struct hl_device *hdev = gaudi_nic->hdev; > + u32 port = gaudi_nic->port; > + int rc = 0, speed = cmd->base.speed; > + bool auto_neg = cmd->base.autoneg == AUTONEG_ENABLE; It appears you only support speed and auto_neg. You should check that all other things which could be configured are empty, e.g. none of the bits are set in cmd->link_modes.advertising. If you are requested to configure something which is not supported, you need to return -EOPNOTSUPP. Andrew