Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp76581lqq; Wed, 12 Jun 2024 17:35:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqLa0V8hC6843TU1AW0DtMB3c2gVmh/q5bn8k+WqDEELACofz8HpaiN7V2BZ679rD2N5t8ozCvpP3MI10jAI3cmE20lW59T2EuVVIqEg== X-Google-Smtp-Source: AGHT+IGMR1Meh7D8uwU8vXPSptEhgk+6zh1hYuvO4M/5vgA1iG4nPm07EoK/AtfKGDiDhb49dPT9 X-Received: by 2002:a05:620a:2586:b0:795:1eda:7f08 with SMTP id af79cd13be357-797f5dafda0mr368015985a.0.1718238941166; Wed, 12 Jun 2024 17:35:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718238941; cv=pass; d=google.com; s=arc-20160816; b=FvsRrAAzlbInDM3vtHSzDCVaKMKQGzqasTa09OosD2pl52MQocA3+LALTiPvvaUN/J HuSvv7EWEo0LuCCeuNV2hcq+kB6AbNbpEklfJcfhCb80xBkfeoOkIJtzUX6yCLCQ14P9 LC+7JS3QQGxhorWl7LfLXgdvZs4y5jgb31Lacv7Q/ndML4oc0ANEo53y3NzHVVHQs4Gu I/xFvJ/TCL6qbhZf8kWeXplxd0+JEb7Ql8la7WuBp0FvNEfPyls2pmAjiF8+VQjE70U6 QHjRhwdxL9RHGE4dWRY/03aGzePv5T2R1wEbwIp5VsV6zPSdLbo6HSwahN9wOcEy6YeI 7txQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=L8Er3x1Obf6zsMT/zRYaPuyo2adiVBV7o941XsowH/A=; fh=wTjlYgRKP2O73Dp0pl0D+l6DnKGxbMJEO4v2cDzkT8Y=; b=J8vl0DShHzNzwe0rsNsqsAVkSuuFm7BoRmQGX1vrUZbySrtFSPiF6GKmUNsTloo7DQ NevZXQxMN9Thh4O9oe1c0F6K+DVjxWdNLVgk8xuaiUBXjeqA9jw7AJAuezmagh2iAl4y nubqqfdi14+r1cm0mhPuivZOPivPI4tWdzcy7iHRy3JdlKmHOwr0Gltsx+CC/fMCaRsa oMQQSH2bMrWbQkPG3bkgGQQf4+RUsg3X988F9XoThZYg1pWSf7y38FHE/7IV3EIldDRh 8jkn60ktqLwuPrnVzM0nf87khvLTMWa31R3pVlELHgkYjnIqEl/jWUjahaOlyWBa11ak /yHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sldmAuZn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212408-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798aac9bf02si26418685a.84.2024.06.12.17.35.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:35:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sldmAuZn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-212408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212408-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DDBA61C216D7 for ; Thu, 13 Jun 2024 00:35:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D4208F54; Thu, 13 Jun 2024 00:35:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sldmAuZn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 581EC811; Thu, 13 Jun 2024 00:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718238907; cv=none; b=LV9b7KVCEmzrKAC8ZhppKnKwLmIjeiXYRjtA6WispQ7XhlBkoBYH998Yq/nCbe9wr2Z1oiLizwdnXp4TUTGNDtpYMp8RDkE1gNOD9lFiGG4s3wZl5eBk/m2rKpHLYrYH6+243slshl3rsQ9AF96NEDGp2yERNEgiVjmcCJhcoT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718238907; c=relaxed/simple; bh=7aFwdpvO8clQ9xKAqhUlOO2UkMwgfchXYP7k1Pjo6Vo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R3y3CI8cn8YWvi8Zemhg5+PNh0ezOS9Ty6iH8NSun07yd8yNzz7sQ5ID3J4EcOiU3GtO+UiE+20Ha3dgh0ec42QOQP2GBcu/LBkcqVlzM8/Gmkh8AFwv/zhep/yLFslJiK3HhSxh/PKbJUygY6dXgCEDFMKX23g00DmP+Iykseg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sldmAuZn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C1E7C116B1; Thu, 13 Jun 2024 00:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718238906; bh=7aFwdpvO8clQ9xKAqhUlOO2UkMwgfchXYP7k1Pjo6Vo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sldmAuZnJENedopcvWeRCvrXft2hCUcbTKilyv/5emcLiCG19LtMYKl2vfkT41URe Sp8F3O0p1RmCg86TkEMCXQIQNIZccbuWGV+5X0lYlqJEl1WejrmCRTNFgR8ZUklchq WWwMJKU5GKTSJA+bmQtrqcJamBmCJrs0aGUIDYiD34J9+1tkpSQAQSiV1ENjtb5F6B fFmE/SfBFmXPOkNkxRQQd2ROfKv1cn3Vw2vPyH7vV/bxGa/mpFo19X6p/XyVDt8xMB u0uup4U0Z5j28elLAuterpisNV/dFHo9yZ4jCowIRUjkXnKYzBNAWDsvEWOCOCk4eb 0HzIqviYZlVQg== Date: Wed, 12 Jun 2024 17:35:05 -0700 From: Jakub Kicinski To: Justin Lai Cc: , , , , , , , , , , Subject: Re: [PATCH net-next v20 10/13] rtase: Implement ethtool function Message-ID: <20240612173505.095c4117@kernel.org> In-Reply-To: <20240607084321.7254-11-justinlai0215@realtek.com> References: <20240607084321.7254-1-justinlai0215@realtek.com> <20240607084321.7254-11-justinlai0215@realtek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 7 Jun 2024 16:43:18 +0800 Justin Lai wrote: > Implement the ethtool function to support users to obtain network card > information, including obtaining various device settings, Report whether > physical link is up, Report pause parameters, Set pause parameters, > Return a set of strings that describe the requested objects, Get number > of strings that @get_strings will write, Return extended statistics > about the device. You don't implement get_strings any more. > +static void rtase_get_drvinfo(struct net_device *dev, > + struct ethtool_drvinfo *drvinfo) > +{ > + const struct rtase_private *tp = netdev_priv(dev); > + > + strscpy(drvinfo->driver, KBUILD_MODNAME, 32); sizeof(drvinfo->driver) instead of the literal 32? > + strscpy(drvinfo->bus_info, pci_name(tp->pdev), 32); Can you double check that overwriting these fields is actually needed? I think core will fill this in for you in ethtool_get_drvinfo() > + if ((value & (RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN)) == > + (RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN)) { > + pause->rx_pause = 1; > + pause->tx_pause = 1; > + } else if ((value & RTASE_FORCE_TXFLOW_EN)) { unnecessary parenthesis > + pause->tx_pause = 1; > + } else if ((value & RTASE_FORCE_RXFLOW_EN)) { same here > + pause->rx_pause = 1; > + } > +} > + > +static int rtase_set_pauseparam(struct net_device *dev, > + struct ethtool_pauseparam *pause) > +{ > + const struct rtase_private *tp = netdev_priv(dev); > + u16 value = rtase_r16(tp, RTASE_CPLUS_CMD); > + > + if (pause->autoneg) > + return -EOPNOTSUPP; > + > + value &= ~(RTASE_FORCE_TXFLOW_EN | RTASE_FORCE_RXFLOW_EN); > + > + if (pause->tx_pause) > + value |= RTASE_FORCE_TXFLOW_EN; > + > + if (pause->rx_pause) > + value |= RTASE_FORCE_RXFLOW_EN; > + > + rtase_w16(tp, RTASE_CPLUS_CMD, value); > + return 0; > +} > + > +static void rtase_get_eth_mac_stats(struct net_device *dev, > + struct ethtool_eth_mac_stats *stats) > +{ > + struct rtase_private *tp = netdev_priv(dev); > + const struct rtase_counters *counters; > + > + counters = tp->tally_vaddr; > + if (!counters) you fail probe if this is NULL, why check if here? > + return; > + > + rtase_dump_tally_counter(tp); > + > + stats->FramesTransmittedOK = le64_to_cpu(counters->tx_packets); > + stats->SingleCollisionFrames = le32_to_cpu(counters->tx_one_collision); > + stats->MultipleCollisionFrames = > + le32_to_cpu(counters->tx_multi_collision); > + stats->FramesReceivedOK = le64_to_cpu(counters->rx_packets); > + stats->FrameCheckSequenceErrors = le32_to_cpu(counters->rx_errors); You dont report this in rtase_get_stats64() as crc errors, are these really CRC / FCS errors or other errors? > + stats->AlignmentErrors = le16_to_cpu(counters->align_errors); > + stats->FramesAbortedDueToXSColls = le16_to_cpu(counters->tx_aborted); > + stats->FramesLostDueToIntMACXmitError = > + le64_to_cpu(counters->tx_errors); > + stats->FramesLostDueToIntMACRcvError = > + le16_to_cpu(counters->rx_missed); Are you sure this is the correct statistic to report as? What's the definition of rx_missed in the datasheet? Also is 16 bits enough for a packet counter at 5Gbps? Don't you have to periodically accumulate this counter so that it doesn't wrap around? > + stats->MulticastFramesReceivedOK = le32_to_cpu(counters->rx_multicast); > + stats->BroadcastFramesReceivedOK = le64_to_cpu(counters->rx_broadcast); > +} > + > +static const struct ethtool_ops rtase_ethtool_ops = { > + .get_drvinfo = rtase_get_drvinfo, > + .get_link = ethtool_op_get_link, > + .get_link_ksettings = rtase_get_settings, > + .get_pauseparam = rtase_get_pauseparam, > + .set_pauseparam = rtase_set_pauseparam, > + .get_eth_mac_stats = rtase_get_eth_mac_stats, > + .get_ts_info = ethtool_op_get_ts_info, > +}; > + > static void rtase_init_netdev_ops(struct net_device *dev) > { > dev->netdev_ops = &rtase_netdev_ops; > + dev->ethtool_ops = &rtase_ethtool_ops; > } > > static void rtase_reset_interrupt(struct pci_dev *pdev,