From patchwork Thu Jun 6 22:46:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 13689018 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 E47B313C69B; Thu, 6 Jun 2024 22:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714035; cv=none; b=fB2Z/CfFF6kxAAQmx50PNitoFMk10HwVgJwbKsCmZ7h+dGsRMc7ZdgbenKS5ecpj9zKcG03N7hAY6ChUeExi+vXI04tC0efc3NpQ418vNyZ4LOoBxJ3GOGD8umALk2HmSFwI0C5AE32fAktvKr6nfQYg2nLRF8lGigS9vBMKJMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714035; c=relaxed/simple; bh=JwHQnooLsYQJEJd80jekD4Sd5j4++MqVQNbMLJLcE+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dLhCuIPMEshvJw61/zMwF8QEE45/gw65bjMS5cy67PAm2Tk3yh3aSEt6mg7VIXC6M15eor/kGccfRK8SYoOzT1OnFwVpNj+pBQurIWa1SsX+eqkTkE7E+I2lipen+IoAIkJXd4e9q3/3lJjqyDB2zWxpC4oF5tEaFEzWtNUpz1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gUfu1Yz0; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gUfu1Yz0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717714034; x=1749250034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JwHQnooLsYQJEJd80jekD4Sd5j4++MqVQNbMLJLcE+I=; b=gUfu1Yz0ls9VOFDzH4Pz4xV2PYo3LV3RidpGL3a1ktDu2slqtaXin9vT /b53oxDy75s5Ui0Ij2OYSgAlPs0+3PXJD5WtmyTMM79raRkYzHvhpFJvY +yMAeIRkM3sEe8GtpMFW42u/THpO5S0wkqEFlG1P+YXILYC91bOeXyQNb RmJcP3voyqjnvVG3kyXtFMRKmERw74PrwlwtMDwo4Ct9yFqMNz91IJcrk xaP0g+Zzru6fXyWFaw2c5bPIUO8a8ZT876EEAHhBzU6vfxJKTyexzQlVO 511u3eAkXeZDtgArgKNvJ9lajXL/Q1zdIwfia6eK2txNiVvA9EIQqy0op A==; X-CSE-ConnectionGUID: EOs+ciE3TfO8kWuzYQEXIg== X-CSE-MsgGUID: zZuBcGiRSmix8oxemzaqtg== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14224001" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14224001" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:11 -0700 X-CSE-ConnectionGUID: hSq34+ReTMSf+Ga1+VM6uQ== X-CSE-MsgGUID: GVlBoXQZQcKFnX4OC5EiAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38243833" Received: from jbrandeb-spr1.jf.intel.com ([10.166.28.233]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:11 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , corbet@lwn.net, linux-doc@vger.kernel.org, Rahul Rameshbabu , Jacob Keller , Jakub Kicinski Subject: [PATCH iwl-next v2 1/5] net: docs: add missing features that can have stats Date: Thu, 6 Jun 2024 15:46:55 -0700 Message-ID: <20240606224701.359706-2-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606224701.359706-1-jesse.brandeburg@intel.com> References: <20240606224701.359706-1-jesse.brandeburg@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org While trying to figure out ethtool -I | --include-statistics, I noticed some docs got missed when implementing commit 0e9c127729be ("ethtool: add interface to read Tx hardware timestamping statistics"). Fix up the docs to match the kernel code, and while there, sort them in alphabetical order. Cc: Rahul Rameshbabu Reviewed-by: Jacob Keller Reviewed-by: Rahul Rameshbabu Reviewed-by: Jakub Kicinski Signed-off-by: Jesse Brandeburg Reviewed-by: Simon Horman --- v2: fix up a mixup of backticks and quotes (Jakub) I didn't add a Fixes: tag because this is not an urgent kind of fix that should require backports. --- Documentation/networking/statistics.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/statistics.rst b/Documentation/networking/statistics.rst index 75e017dfa825..06f01c0cd65a 100644 --- a/Documentation/networking/statistics.rst +++ b/Documentation/networking/statistics.rst @@ -184,9 +184,11 @@ Protocol-related statistics can be requested in get commands by setting the `ETHTOOL_FLAG_STATS` flag in `ETHTOOL_A_HEADER_FLAGS`. Currently statistics are supported in the following commands: - - `ETHTOOL_MSG_PAUSE_GET` - `ETHTOOL_MSG_FEC_GET` + - `ETHTOOL_MSG_LINKSTATE_GET` - `ETHTOOL_MSG_MM_GET` + - `ETHTOOL_MSG_PAUSE_GET` + - `ETHTOOL_MSG_TSINFO_GET` debugfs ------- From patchwork Thu Jun 6 22:46:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 13689019 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 6347A13D8BE; Thu, 6 Jun 2024 22:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714036; cv=none; b=cQQHKusYCp/EzTkALP5fqfaEyPar8DINMQcJOn3U0YxHN76lV+lMbxzAiiiwy/926kLJsVg4N28eO5S8Z6pSMzt3+vJ8oWJmotF1MWyOECYYeYUKIdpJai3I+kpxd1uRvkQOj418ILPx5KCsz2Yur4T1CGXZ/JzM16I/+mwotrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714036; c=relaxed/simple; bh=svAUTzKkGC+kHc/rLGAMIv+fBkOndfX3PQZ5NKI7qpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tOPBehQgMwoUnmlcKJ6txmxnC8zkBDLaDTb9WP9N0iawU8APDSC0Qh9fIrp0j8VSTSuDpWAmVECrmaQt5c1y92IE1QdKfEzGSD0y6j9HUaklZICXKB8ileVynmGnp/D2IE+SQT8d4NO8jqpH2mWEDBNnALqFMkXhBF1jV4XZ7FU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XpVGfhyN; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XpVGfhyN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717714034; x=1749250034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=svAUTzKkGC+kHc/rLGAMIv+fBkOndfX3PQZ5NKI7qpU=; b=XpVGfhyNDVL4nIsX9sorIFKeIjEWYXeTAOw48h+pckqeTFJA8WUG2cQJ cAkW7d2vTfNCnd3XSMVWXXhujlR5JkyXLVtQis58nq57uKT3MytNfffZq VNGm2bBPuVroPqFrqWOKa5MqgnwBbnCjyXBu5S3LLMk4LAS35L6anJDQ1 ACGp7gVIXmWF0p+3Uy/JSUsbo2/Q8KYzZVGMCQ043FfIe5B5WUhMW8Oyg GtYVq8M/C/7K46rwjP+wdr3UW7WnAbsOEWsq0XGPnvb4INhhC1npC5gtc j45Uwn5tYS55a2gOk7IiAs9N2lyt3O/1Y1GFN5eabTk4kC+Le/0TedWSA g==; X-CSE-ConnectionGUID: H0Xg2XgIToW3FM2emSF8MA== X-CSE-MsgGUID: U7/RQ3gkR1ugQFGLanMpLg== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14224006" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14224006" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:11 -0700 X-CSE-ConnectionGUID: 6JcK29OMTbGGHw21LXkmhQ== X-CSE-MsgGUID: l9QUanyGT4uGKSYYm2uiHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38243837" Received: from jbrandeb-spr1.jf.intel.com ([10.166.28.233]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:11 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , corbet@lwn.net, linux-doc@vger.kernel.org, Marcin Szycik , Jacob Keller , Jakub Kicinski Subject: [PATCH iwl-next v2 2/5] ice: implement ethtool standard stats Date: Thu, 6 Jun 2024 15:46:56 -0700 Message-ID: <20240606224701.359706-3-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606224701.359706-1-jesse.brandeburg@intel.com> References: <20240606224701.359706-1-jesse.brandeburg@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add support for MAC/pause/RMON stats. This enables reporting hardware statistics in a common way via: ethtool -S eth0 --all-groups and ethtool --include-statistics --show-pause eth0 While doing so, add support for one new stat, receive length error (RLEC), which is extremely unlikely to happen since most L2 frames have a type/length field specifying a "type", and raw ethernet frames aren't used much any longer. NOTE: I didn't implement Ctrl aka control frame stats because the hardware doesn't seem to implement support. Reviewed-by: Marcin Szycik Reviewed-by: Jacob Keller Reviewed-by: Jakub Kicinski Signed-off-by: Jesse Brandeburg Reviewed-by: Simon Horman --- Example output: Standard stats for ens785f1np1: eth-mac-FramesTransmittedOK: 296 eth-mac-FramesReceivedOK: 339 eth-mac-FrameCheckSequenceErrors: 0 eth-mac-OctetsTransmittedOK: 70410 eth-mac-OctetsReceivedOK: 51414 eth-mac-MulticastFramesXmittedOK: 124 eth-mac-BroadcastFramesXmittedOK: 1 eth-mac-MulticastFramesReceivedOK: 164 eth-mac-BroadcastFramesReceivedOK: 3 eth-mac-InRangeLengthErrors: 0 eth-mac-FrameTooLongErrors: 0 rmon-etherStatsUndersizePkts: 0 rmon-etherStatsOversizePkts: 0 rmon-etherStatsFragments: 0 rmon-etherStatsJabbers: 0 rx-rmon-etherStatsPkts64Octets: 31 rx-rmon-etherStatsPkts65to127Octets: 265 rx-rmon-etherStatsPkts128to255Octets: 26 rx-rmon-etherStatsPkts256to511Octets: 7 rx-rmon-etherStatsPkts512to1023Octets: 1 rx-rmon-etherStatsPkts1024to1522Octets: 6 rx-rmon-etherStatsPkts1523to9522Octets: 3 tx-rmon-etherStatsPkts64Octets: 25 tx-rmon-etherStatsPkts65to127Octets: 255 tx-rmon-etherStatsPkts128to255Octets: 1 tx-rmon-etherStatsPkts256to511Octets: 2 tx-rmon-etherStatsPkts512to1023Octets: 1 tx-rmon-etherStatsPkts1024to1522Octets: 1 tx-rmon-etherStatsPkts1523to9522Octets: 11 and Pause parameters for ens785f0np0: Autonegotiate: on RX: off TX: off RX negotiated: off TX negotiated: off Statistics: tx_pause_frames: 0 rx_pause_frames: 0 --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 78 ++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_main.c | 3 + drivers/net/ethernet/intel/ice/ice_type.h | 1 + 3 files changed, 82 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 62c8205fceba..6f0a857f55c9 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -4282,6 +4282,81 @@ ice_get_module_eeprom(struct net_device *netdev, return 0; } +static void ice_get_eth_mac_stats(struct net_device *netdev, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct ice_hw_port_stats *ps = &pf->stats; + + mac_stats->FramesTransmittedOK = ps->eth.tx_unicast + + ps->eth.tx_multicast + + ps->eth.tx_broadcast; + mac_stats->FramesReceivedOK = ps->eth.rx_unicast + + ps->eth.rx_multicast + + ps->eth.rx_broadcast; + mac_stats->FrameCheckSequenceErrors = ps->crc_errors; + mac_stats->OctetsTransmittedOK = ps->eth.tx_bytes; + mac_stats->OctetsReceivedOK = ps->eth.rx_bytes; + mac_stats->MulticastFramesXmittedOK = ps->eth.tx_multicast; + mac_stats->BroadcastFramesXmittedOK = ps->eth.tx_broadcast; + mac_stats->MulticastFramesReceivedOK = ps->eth.rx_multicast; + mac_stats->BroadcastFramesReceivedOK = ps->eth.rx_broadcast; + mac_stats->InRangeLengthErrors = ps->rx_len_errors; + mac_stats->FrameTooLongErrors = ps->rx_oversize; +} + +static void ice_get_pause_stats(struct net_device *netdev, + struct ethtool_pause_stats *pause_stats) +{ + struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct ice_hw_port_stats *ps = &pf->stats; + + pause_stats->tx_pause_frames = ps->link_xon_tx + ps->link_xoff_tx; + pause_stats->rx_pause_frames = ps->link_xon_rx + ps->link_xoff_rx; +} + +static const struct ethtool_rmon_hist_range ice_rmon_ranges[] = { + { 0, 64 }, + { 65, 127 }, + { 128, 255 }, + { 256, 511 }, + { 512, 1023 }, + { 1024, 1522 }, + { 1523, 9522 }, + {} +}; + +static void ice_get_rmon_stats(struct net_device *netdev, + struct ethtool_rmon_stats *rmon, + const struct ethtool_rmon_hist_range **ranges) +{ + struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct ice_hw_port_stats *ps = &pf->stats; + + rmon->undersize_pkts = ps->rx_undersize; + rmon->oversize_pkts = ps->rx_oversize; + rmon->fragments = ps->rx_fragments; + rmon->jabbers = ps->rx_jabber; + + rmon->hist[0] = ps->rx_size_64; + rmon->hist[1] = ps->rx_size_127; + rmon->hist[2] = ps->rx_size_255; + rmon->hist[3] = ps->rx_size_511; + rmon->hist[4] = ps->rx_size_1023; + rmon->hist[5] = ps->rx_size_1522; + rmon->hist[6] = ps->rx_size_big; + + rmon->hist_tx[0] = ps->tx_size_64; + rmon->hist_tx[1] = ps->tx_size_127; + rmon->hist_tx[2] = ps->tx_size_255; + rmon->hist_tx[3] = ps->tx_size_511; + rmon->hist_tx[4] = ps->tx_size_1023; + rmon->hist_tx[5] = ps->tx_size_1522; + rmon->hist_tx[6] = ps->tx_size_big; + + *ranges = ice_rmon_ranges; +} + static const struct ethtool_ops ice_ethtool_ops = { .cap_rss_ctx_supported = true, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | @@ -4329,6 +4404,9 @@ static const struct ethtool_ops ice_ethtool_ops = { .set_fecparam = ice_set_fecparam, .get_module_info = ice_get_module_info, .get_module_eeprom = ice_get_module_eeprom, + .get_eth_mac_stats = ice_get_eth_mac_stats, + .get_pause_stats = ice_get_pause_stats, + .get_rmon_stats = ice_get_rmon_stats, }; static const struct ethtool_ops ice_ethtool_safe_mode_ops = { diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index f60c022f7960..4db3a6056f41 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7034,6 +7034,9 @@ void ice_update_pf_stats(struct ice_pf *pf) &prev_ps->mac_remote_faults, &cur_ps->mac_remote_faults); + ice_stat_update32(hw, GLPRT_RLEC(port), pf->stat_prev_loaded, + &prev_ps->rx_len_errors, &cur_ps->rx_len_errors); + ice_stat_update32(hw, GLPRT_RUC(port), pf->stat_prev_loaded, &prev_ps->rx_undersize, &cur_ps->rx_undersize); diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h index f0796a93f428..b156d01196e2 100644 --- a/drivers/net/ethernet/intel/ice/ice_type.h +++ b/drivers/net/ethernet/intel/ice/ice_type.h @@ -1007,6 +1007,7 @@ struct ice_hw_port_stats { u64 error_bytes; /* errbc */ u64 mac_local_faults; /* mlfc */ u64 mac_remote_faults; /* mrfc */ + u64 rx_len_errors; /* rlec */ u64 link_xon_rx; /* lxonrxc */ u64 link_xoff_rx; /* lxoffrxc */ u64 link_xon_tx; /* lxontxc */ From patchwork Thu Jun 6 22:46:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 13689020 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 D64F113DDC5; Thu, 6 Jun 2024 22:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; cv=none; b=HDFmAOVj7xYjlo5ErIQtouh2BPIXDjVUvaKelAFBSTwcHSLrhSoaj3pFvqk2ttVNhNzs7tczspcGxgMyT+tG3yHy7J/pe8PAcrxCsi8gufh/jTVzK7e/wunrsL55q13oKfSbcTNFwN8QdEIEONZS1VEcO0DDKOkmHaXE2ZZ4c9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; c=relaxed/simple; bh=IQbaN1PyCav0Y/g6MkJYTJ58TbA4AQLCkvXvbv1VlrM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W4Q1VWdXunEgsaQnEsA9djhanCgDuxZC3d8O4eOQvNvXuFYNI/kc3rOMZoosAvmfBhYfhZ9bfuQaTjry7JqhFaR2ga8Icvv2RgDIU+RuLb4lLJ4j980pxGVvSYBuIVGLgUrG1pGZBMsmeHzab8rILrWqdM6P6Ww6E8MN63q3xkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YJH7uAu+; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YJH7uAu+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717714036; x=1749250036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IQbaN1PyCav0Y/g6MkJYTJ58TbA4AQLCkvXvbv1VlrM=; b=YJH7uAu+YOHQa49nn/mHJDEnFRW0rHNKN5TGSp+ULboFZ24MvhZ2Ae/j L+Hd3Olj29V8F92WL5Occd8KT87UZLW7/q79c+hX3MA5DJ4gF0VthtOkp x3/yfgvG5vn6ajF3ptUs6rv/QLobQnsAw2dERyo4aermt73bsV1ijXyZI eD0K/C33QgUlLDD2VRkpLu2yccPta1i7Y0FVJPNgDoSmNaYPy0ncufCnI 9hmNAESFMRpQIqwRGtb1kCZaYUoTUYFStYMETORFHDgrS73x2KMKpBm/m Zas1vij6D0KrROje9l6K2kc8AZSy7oajORt2qfkiZzvB3eeVX/zVObSMq w==; X-CSE-ConnectionGUID: 1wH3fj/ySPOtYTInER4p+Q== X-CSE-MsgGUID: IPw/qyHiQm+ahikTtAxdCA== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14224010" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14224010" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:12 -0700 X-CSE-ConnectionGUID: Ka3nhXjBQ5KrvMiFuZ/iyw== X-CSE-MsgGUID: 71bnbA24R+CR341US9FiRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38243840" Received: from jbrandeb-spr1.jf.intel.com ([10.166.28.233]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:11 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , corbet@lwn.net, linux-doc@vger.kernel.org, Jacob Keller , Jakub Kicinski Subject: [PATCH iwl-next v2 3/5] ice: add tracking of good transmit timestamps Date: Thu, 6 Jun 2024 15:46:57 -0700 Message-ID: <20240606224701.359706-4-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606224701.359706-1-jesse.brandeburg@intel.com> References: <20240606224701.359706-1-jesse.brandeburg@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As a pre-requisite to implementing timestamp statistics, start tracking successful PTP timestamps. There already existed a trace event, but add a counter as well so it can be displayed by the next patch. Good count is a u64 as it is much more likely to be incremented. The existing error stats are all u32 as before, and are less likely so will wrap less. Reviewed-by: Jacob Keller Reviewed-by: Jakub Kicinski Signed-off-by: Jesse Brandeburg Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ice/ice_ptp.c | 9 +++++++++ drivers/net/ethernet/intel/ice/ice_ptp.h | 1 + 2 files changed, 10 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 0f17fc1181d2..ff0ba81d0694 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -628,6 +628,9 @@ void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx) if (tstamp) { shhwtstamps.hwtstamp = ns_to_ktime(tstamp); ice_trace(tx_tstamp_complete, skb, idx); + + /* Count the number of Tx timestamps that succeeded */ + pf->ptp.tx_hwtstamp_good++; } skb_tstamp_tx(skb, &shhwtstamps); @@ -686,6 +689,7 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) { struct ice_ptp_port *ptp_port; unsigned long flags; + u32 tstamp_good = 0; struct ice_pf *pf; struct ice_hw *hw; u64 tstamp_ready; @@ -786,11 +790,16 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) if (tstamp) { shhwtstamps.hwtstamp = ns_to_ktime(tstamp); ice_trace(tx_tstamp_complete, skb, idx); + + /* Count the number of Tx timestamps that succeeded */ + tstamp_good++; } skb_tstamp_tx(skb, &shhwtstamps); dev_kfree_skb_any(skb); } + + pf->ptp.tx_hwtstamp_good += tstamp_good; } /** diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 3af20025043a..2b15f2b58789 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -253,6 +253,7 @@ struct ice_ptp { struct ptp_clock *clock; struct hwtstamp_config tstamp_config; u64 reset_time; + u64 tx_hwtstamp_good; u32 tx_hwtstamp_skipped; u32 tx_hwtstamp_timeouts; u32 tx_hwtstamp_flushed; From patchwork Thu Jun 6 22:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 13689021 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 5184013E042; Thu, 6 Jun 2024 22:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; cv=none; b=Jv9jXh2o3h/574jy1uYZN0/FtBU/C0EPwrnQDWlj+Lc47LfrNAjISPw99ufybXIMRCqHS4WGDowtIyyJhRkrw2nweWNH9uWNgAokCmefgoI9ic7PoorlN/BpdNmDkrVooeGumyGuQdpwizzV/cbXlt8+4h8kBjtehPgYPYgd7GU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; c=relaxed/simple; bh=WJPwdnA8Lj4NLq97gnr8zSK5cfQQDsGNC1zvghOKkgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z7ksP0fD9CoH2pmuBvLVmbI3bxNwnSYIK9GAE9rDJwys2X+9TdSUAgLbymhWq4g6Jr8tL+Gxlz9Iv05zzi5G5zcoMsOCt3rk4qj2KAce4z9pGsb8/PW0yqOMk0241U/tivuWCLk40FgUMVx7BxoS2D1xDQ83FpBBLtlRek1SMdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iKKgyEW+; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iKKgyEW+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717714036; x=1749250036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WJPwdnA8Lj4NLq97gnr8zSK5cfQQDsGNC1zvghOKkgw=; b=iKKgyEW+Xx7LuOIQF5UnkZ785z6YzKljyAxhW/pvdwEPQw5Dqk1dGF45 ywrrkUshA3WsArelQVdp03/KER/wvUDVNQPZif7X9slGwRSeDy0u7ihnu aWkR2/JGnZYag0Ar/o1tk52Ru8ukAKj5tndomSwXF8fUNnWf/M3LYMa2M ouJAMqndeEoB0Y+bQpfiIGr15zOD3os5KXEo8rzg5vaJs08QWJ0roM8br cxtgI3wieU0mNlIYUh+ZSJzq5DghiULCJ5uuI1+EPYazUMFzX+lx+37u/ TVV0h6Gh4T/+zs2K8viXIVAXoLoHAAavzblg9Rm4b+LMvaXG9cnWrou7L A==; X-CSE-ConnectionGUID: CIOvW2YoRYqApOA42wjghg== X-CSE-MsgGUID: JncA2QNGQ2yJyZoHGovu3w== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14224014" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14224014" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:12 -0700 X-CSE-ConnectionGUID: Ruw+N1/qSvi/splh/Vr6bg== X-CSE-MsgGUID: +aZnIgdAR6CkgvddpW3EBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38243843" Received: from jbrandeb-spr1.jf.intel.com ([10.166.28.233]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:12 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , corbet@lwn.net, linux-doc@vger.kernel.org, Jacob Keller , Jakub Kicinski , Hariprasad Kelam Subject: [PATCH iwl-next v2 4/5] ice: implement transmit hardware timestamp statistics Date: Thu, 6 Jun 2024 15:46:58 -0700 Message-ID: <20240606224701.359706-5-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606224701.359706-1-jesse.brandeburg@intel.com> References: <20240606224701.359706-1-jesse.brandeburg@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The kernel now has common statistics for transmit timestamps, so implement them in the ice driver. use via ethtool -I -T eth0 Reviewed-by: Jacob Keller Reviewed-by: Jakub Kicinski Reviewed-by: Hariprasad Kelam Signed-off-by: Jesse Brandeburg Reviewed-by: Simon Horman --- $ sudo ethtool -I -T eth0 Time stamping parameters for eth0: Capabilities: hardware-transmit software-transmit hardware-receive software-receive software-system-clock hardware-raw-clock PTP Hardware Clock: 0 Hardware Transmit Timestamp Modes: off on Hardware Receive Filter Modes: none all Statistics: tx_pkts: 17 tx_lost: 0 tx_err: 0 --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 6f0a857f55c9..97a7a0632a1d 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -4357,6 +4357,23 @@ static void ice_get_rmon_stats(struct net_device *netdev, *ranges = ice_rmon_ranges; } +/* ice_get_ts_stats - provide timestamping stats + * @netdev: the netdevice pointer from ethtool + * @ts_stats: the ethtool data structure to fill in + */ +static void ice_get_ts_stats(struct net_device *netdev, + struct ethtool_ts_stats *ts_stats) +{ + struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct ice_ptp *ptp = &pf->ptp; + + ts_stats->pkts = ptp->tx_hwtstamp_good; + ts_stats->err = ptp->tx_hwtstamp_skipped + + ptp->tx_hwtstamp_flushed + + ptp->tx_hwtstamp_discarded; + ts_stats->lost = ptp->tx_hwtstamp_timeouts; +} + static const struct ethtool_ops ice_ethtool_ops = { .cap_rss_ctx_supported = true, .supported_coalesce_params = ETHTOOL_COALESCE_USECS | @@ -4407,6 +4424,7 @@ static const struct ethtool_ops ice_ethtool_ops = { .get_eth_mac_stats = ice_get_eth_mac_stats, .get_pause_stats = ice_get_pause_stats, .get_rmon_stats = ice_get_rmon_stats, + .get_ts_stats = ice_get_ts_stats, }; static const struct ethtool_ops ice_ethtool_safe_mode_ops = { From patchwork Thu Jun 6 22:46:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Brandeburg X-Patchwork-Id: 13689022 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 3785213E035; Thu, 6 Jun 2024 22:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; cv=none; b=Dw1xGczW/7sxuBn6HG3eGS/y0ySjdre6dKG73YUAXg6ZRTb4qoYPha6qC690Dh9kc0vC23H0Jx3LuaRygjdXTrlNKxlaSORm5wcVrPUvvxbR4Mu2IfSMtwtDjtooexXKCosV7RVeMcH81essVUVDN81qhWIR/hy8S5qqKSe4WWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717714037; c=relaxed/simple; bh=bJs0A7U00c7oKj2hmhzU3KoY/dE5B1Se23w5Fft/kQk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVAtkhkf05VBK2gqj3dW/6e6vPfXWg2IAfGXm0s3BIhm4ssocDxl9z3+et5ZPCwPVVhSgLAyZiRONxrY8IwqvXH/fyZUrHoEfrRRD10CsYw2JFXbKy6P+OpOixU62eTDo3uQ5eyF1o+sXbrPvo4r2hssVX1Vkj11CWiJteGiHxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=naYe9d+U; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="naYe9d+U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717714036; x=1749250036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bJs0A7U00c7oKj2hmhzU3KoY/dE5B1Se23w5Fft/kQk=; b=naYe9d+UbmHSYIPCOw1T5Q2CpZvjhbIWNjE7Qv1pM6ivKvHSA9DcP7Gc BaCsITI0XjiZGwdfQfQJFtNqNLc0uJOIWdL4jldeVckWoTjpVagwOsiGI fVURvO++bsAV0QBxsdI7iKYnGqalBgBeq6DFWof8KO3Mn49GzXxCNv/du yP9FFIHe49t3LsUzCJHM6MM/4N0iHzpbatx16vjnnVtb0CM+na+nvEGDV byoRvqr0r5GKURDiRYsGPtGCdQGCuh0JQ3SKqZOFSbqZKCcUqg0qcWy+d qd5yRfgCthd7LxVEXO6R+47BovRJ9vQVu0m+k90bkRd6Qu/+94ovdqA4S Q==; X-CSE-ConnectionGUID: wB1NjI3rTG6KYarEDq6oWA== X-CSE-MsgGUID: z6LRhGH7TFK+sNKzh1qS1A== X-IronPort-AV: E=McAfee;i="6600,9927,11095"; a="14224023" X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="14224023" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:12 -0700 X-CSE-ConnectionGUID: W0oErCYOTGmUGRXmPz73Fg== X-CSE-MsgGUID: UHpe3H35QQSOucNSDb8eyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,219,1712646000"; d="scan'208";a="38243847" Received: from jbrandeb-spr1.jf.intel.com ([10.166.28.233]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2024 15:47:12 -0700 From: Jesse Brandeburg To: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Cc: Jesse Brandeburg , corbet@lwn.net, linux-doc@vger.kernel.org, Jacob Keller , Przemek Kitszel , Jakub Kicinski Subject: [PATCH iwl-next v2 5/5] ice: refactor to use helpers Date: Thu, 6 Jun 2024 15:46:59 -0700 Message-ID: <20240606224701.359706-6-jesse.brandeburg@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240606224701.359706-1-jesse.brandeburg@intel.com> References: <20240606224701.359706-1-jesse.brandeburg@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the ice_netdev_to_pf() helper in more places and remove a bunch of boilerplate code. Not every instance could be replaced due to use of the netdev_priv() output or the vsi variable within a bunch of functions. Reviewed-by: Jacob Keller Reviewed-by: Przemek Kitszel Reviewed-by: Jakub Kicinski Signed-off-by: Jesse Brandeburg Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 42 ++++++------------- .../net/ethernet/intel/ice/ice_flex_pipe.c | 8 +--- drivers/net/ethernet/intel/ice/ice_lag.c | 5 +-- drivers/net/ethernet/intel/ice/ice_main.c | 7 +--- drivers/net/ethernet/intel/ice/ice_sriov.c | 3 +- 5 files changed, 19 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 97a7a0632a1d..2d307e7d9863 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -469,8 +469,7 @@ static int ice_get_regs_len(struct net_device __always_unused *netdev) static void ice_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_hw *hw = &pf->hw; u32 *regs_buf = (u32 *)p; unsigned int i; @@ -483,8 +482,7 @@ ice_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p) static u32 ice_get_msglevel(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); #ifndef CONFIG_DYNAMIC_DEBUG if (pf->hw.debug_mask) @@ -497,8 +495,7 @@ static u32 ice_get_msglevel(struct net_device *netdev) static void ice_set_msglevel(struct net_device *netdev, u32 data) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); #ifndef CONFIG_DYNAMIC_DEBUG if (ICE_DBG_USER & data) @@ -512,8 +509,7 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data) static int ice_get_eeprom_len(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); return (int)pf->hw.flash.flash_size; } @@ -522,9 +518,7 @@ static int ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom, u8 *bytes) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_hw *hw = &pf->hw; struct device *dev; int ret; @@ -623,8 +617,7 @@ static u64 ice_link_test(struct net_device *netdev) */ static u64 ice_eeprom_test(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); netdev_info(netdev, "EEPROM test\n"); return !!(ice_nvm_validate_checksum(&pf->hw)); @@ -938,9 +931,8 @@ static int ice_lbtest_receive_frames(struct ice_rx_ring *rx_ring) */ static u64 ice_loopback_test(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *orig_vsi = np->vsi, *test_vsi; - struct ice_pf *pf = orig_vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); + struct ice_vsi *test_vsi; u8 *tx_frame __free(kfree) = NULL; u8 broadcast[ETH_ALEN], ret = 0; int num_frames, valid_frames; @@ -1029,8 +1021,7 @@ static u64 ice_loopback_test(struct net_device *netdev) */ static u64 ice_intr_test(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); u16 swic_old = pf->sw_int_count; netdev_info(netdev, "interrupt test\n"); @@ -1058,9 +1049,8 @@ static void ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test, u64 *data) { - struct ice_netdev_priv *np = netdev_priv(netdev); + struct ice_pf *pf = ice_netdev_to_pf(netdev); bool if_running = netif_running(netdev); - struct ice_pf *pf = np->vsi->back; struct device *dev; dev = ice_pf_to_dev(pf); @@ -1384,9 +1374,7 @@ static int ice_nway_reset(struct net_device *netdev) */ static u32 ice_get_priv_flags(struct net_device *netdev) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); u32 i, ret_flags = 0; for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) { @@ -4128,9 +4116,7 @@ static int ice_get_module_info(struct net_device *netdev, struct ethtool_modinfo *modinfo) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_hw *hw = &pf->hw; u8 sff8472_comp = 0; u8 sff8472_swap = 0; @@ -4202,12 +4188,10 @@ static int ice_get_module_eeprom(struct net_device *netdev, struct ethtool_eeprom *ee, u8 *data) { - struct ice_netdev_priv *np = netdev_priv(netdev); + struct ice_pf *pf = ice_netdev_to_pf(netdev); #define SFF_READ_BLOCK_SIZE 8 u8 value[SFF_READ_BLOCK_SIZE] = { 0 }; u8 addr = ICE_I2C_EEPROM_DEV_ADDR; - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; struct ice_hw *hw = &pf->hw; bool is_sfp = false; unsigned int i, j; diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c index 20d5db88c99f..4c322bed716c 100644 --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c @@ -574,9 +574,7 @@ ice_destroy_tunnel(struct ice_hw *hw, u16 index, enum ice_tunnel_type type, int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table, unsigned int idx, struct udp_tunnel_info *ti) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); enum ice_tunnel_type tnl_type; int status; u16 index; @@ -598,9 +596,7 @@ int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table, int ice_udp_tunnel_unset_port(struct net_device *netdev, unsigned int table, unsigned int idx, struct udp_tunnel_info *ti) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); enum ice_tunnel_type tnl_type; int status; diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c index 1ccb572ce285..cdb0e59aeb26 100644 --- a/drivers/net/ethernet/intel/ice/ice_lag.c +++ b/drivers/net/ethernet/intel/ice/ice_lag.c @@ -1640,11 +1640,8 @@ static void ice_lag_chk_disabled_bond(struct ice_lag *lag, void *ptr) */ static void ice_lag_disable_sriov_bond(struct ice_lag *lag) { - struct ice_netdev_priv *np; - struct ice_pf *pf; + struct ice_pf *pf = ice_netdev_to_pf(lag->netdev); - np = netdev_priv(lag->netdev); - pf = np->vsi->back; ice_clear_feature_support(pf, ICE_F_SRIOV_LAG); } diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 4db3a6056f41..9d852b169ead 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -7798,8 +7798,7 @@ static int ice_change_mtu(struct net_device *netdev, int new_mtu) */ static int ice_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); switch (cmd) { case SIOCGHWTSTAMP: @@ -8027,9 +8026,7 @@ static int ice_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev, u32 filter_mask, int nlflags) { - struct ice_netdev_priv *np = netdev_priv(dev); - struct ice_vsi *vsi = np->vsi; - struct ice_pf *pf = vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(dev); u16 bmode; bmode = pf->first_sw->bridge_mode; diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c index 067712f4923f..adcc2f967bab 100644 --- a/drivers/net/ethernet/intel/ice/ice_sriov.c +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c @@ -1317,8 +1317,7 @@ ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) */ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena) { - struct ice_netdev_priv *np = netdev_priv(netdev); - struct ice_pf *pf = np->vsi->back; + struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_vsi *vf_vsi; struct device *dev; struct ice_vf *vf;