* [PATCH v3 1/5] net: docs: add missing features that can have stats
2025-09-11 23:40 [PATCH v3 0/5] ice: add standard stats Jacob Keller
@ 2025-09-11 23:40 ` Jacob Keller
2025-09-11 23:40 ` [PATCH v3 2/5] ice: implement ethtool standard stats Jacob Keller
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Jacob Keller @ 2025-09-11 23:40 UTC (permalink / raw)
To: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet, Jacob Keller
Cc: Jesse Brandeburg
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
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 <rrameshbabu@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
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 518284e287b0..66b0ef941457 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
-------
--
2.51.0.rc1.197.g6d975e95c9d7
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 2/5] ice: implement ethtool standard stats
2025-09-11 23:40 [PATCH v3 0/5] ice: add standard stats Jacob Keller
2025-09-11 23:40 ` [PATCH v3 1/5] net: docs: add missing features that can have stats Jacob Keller
@ 2025-09-11 23:40 ` Jacob Keller
2025-10-09 8:56 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-09-11 23:40 ` [PATCH v3 3/5] ice: add tracking of good transmit timestamps Jacob Keller
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Jacob Keller @ 2025-09-11 23:40 UTC (permalink / raw)
To: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet, Jacob Keller
Cc: Jesse Brandeburg
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
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 <marcin.szycik@linux.intel.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_type.h | 1 +
drivers/net/ethernet/intel/ice/ice_ethtool.c | 78 ++++++++++++++++++++++++++++
drivers/net/ethernet/intel/ice/ice_main.c | 3 ++
3 files changed, 82 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h
index 4213a2b9fa9d..1e82f4c40b32 100644
--- a/drivers/net/ethernet/intel/ice/ice_type.h
+++ b/drivers/net/ethernet/intel/ice/ice_type.h
@@ -1069,6 +1069,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 */
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 95587dd96c71..3d99c4a1e287 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -4655,6 +4655,81 @@ static void ice_get_fec_stats(struct net_device *netdev,
pi->lport, err);
}
+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;
+}
+
#define ICE_ETHTOOL_PFR (ETH_RESET_IRQ | ETH_RESET_DMA | \
ETH_RESET_FILTER | ETH_RESET_OFFLOAD)
@@ -4738,6 +4813,9 @@ static const struct ethtool_ops ice_ethtool_ops = {
.get_link_ksettings = ice_get_link_ksettings,
.set_link_ksettings = ice_set_link_ksettings,
.get_fec_stats = ice_get_fec_stats,
+ .get_eth_mac_stats = ice_get_eth_mac_stats,
+ .get_pause_stats = ice_get_pause_stats,
+ .get_rmon_stats = ice_get_rmon_stats,
.get_drvinfo = ice_get_drvinfo,
.get_regs_len = ice_get_regs_len,
.get_regs = ice_get_regs,
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 90d544a6a00e..249fd3c050eb 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -7113,6 +7113,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);
--
2.51.0.rc1.197.g6d975e95c9d7
^ permalink raw reply related [flat|nested] 11+ messages in thread* RE: [Intel-wired-lan] [PATCH v3 2/5] ice: implement ethtool standard stats
2025-09-11 23:40 ` [PATCH v3 2/5] ice: implement ethtool standard stats Jacob Keller
@ 2025-10-09 8:56 ` Loktionov, Aleksandr
0 siblings, 0 replies; 11+ messages in thread
From: Loktionov, Aleksandr @ 2025-10-09 8:56 UTC (permalink / raw)
To: Keller, Jacob E, Brandeburg, Jesse, Jakub Kicinski,
Hariprasad Kelam, Simon Horman, Marcin Szycik, Rahul Rameshbabu,
netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
linux-doc@vger.kernel.org, corbet@lwn.net, Keller, Jacob E
Cc: Jesse Brandeburg
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Jacob Keller
> Sent: Friday, September 12, 2025 1:41 AM
> To: Brandeburg, Jesse <jbrandeburg@cloudflare.com>; Jakub Kicinski
> <kuba@kernel.org>; Hariprasad Kelam <hkelam@marvell.com>; Simon Horman
> <horms@kernel.org>; Marcin Szycik <marcin.szycik@linux.intel.com>;
> Rahul Rameshbabu <rrameshbabu@nvidia.com>; netdev@vger.kernel.org;
> intel-wired-lan@lists.osuosl.org; linux-doc@vger.kernel.org;
> corbet@lwn.net; Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Subject: [Intel-wired-lan] [PATCH v3 2/5] ice: implement ethtool
> standard stats
>
> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
>
> 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 <marcin.szycik@linux.intel.com>
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Reviewed-by: Jakub Kicinski <kuba@kernel.org>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
...
> --
> 2.51.0.rc1.197.g6d975e95c9d7
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 3/5] ice: add tracking of good transmit timestamps
2025-09-11 23:40 [PATCH v3 0/5] ice: add standard stats Jacob Keller
2025-09-11 23:40 ` [PATCH v3 1/5] net: docs: add missing features that can have stats Jacob Keller
2025-09-11 23:40 ` [PATCH v3 2/5] ice: implement ethtool standard stats Jacob Keller
@ 2025-09-11 23:40 ` Jacob Keller
2025-10-09 8:52 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-09-11 23:40 ` [PATCH v3 4/5] ice: implement transmit hardware timestamp statistics Jacob Keller
2025-09-11 23:40 ` [PATCH v3 5/5] ice: refactor to use helpers Jacob Keller
4 siblings, 1 reply; 11+ messages in thread
From: Jacob Keller @ 2025-09-11 23:40 UTC (permalink / raw)
To: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet, Jacob Keller
Cc: Jesse Brandeburg
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
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 <jacob.e.keller@intel.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_ptp.h | 2 ++
drivers/net/ethernet/intel/ice/ice_ptp.c | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h
index 137f2070a2d9..27016aac4f1e 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.h
@@ -237,6 +237,7 @@ struct ice_ptp_pin_desc {
* @clock: pointer to registered PTP clock device
* @tstamp_config: hardware timestamping configuration
* @reset_time: kernel time after clock stop on reset
+ * @tx_hwtstamp_good: number of completed Tx timestamp requests
* @tx_hwtstamp_skipped: number of Tx time stamp requests skipped
* @tx_hwtstamp_timeouts: number of Tx skbs discarded with no time stamp
* @tx_hwtstamp_flushed: number of Tx skbs flushed due to interface closed
@@ -261,6 +262,7 @@ struct ice_ptp {
struct ptp_clock *clock;
struct kernel_hwtstamp_config tstamp_config;
u64 reset_time;
+ u64 tx_hwtstamp_good;
u32 tx_hwtstamp_skipped;
u32 tx_hwtstamp_timeouts;
u32 tx_hwtstamp_flushed;
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index 9b065709c899..d2ca9d7bcfc1 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -500,6 +500,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);
@@ -558,6 +561,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;
@@ -658,11 +662,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;
}
/**
--
2.51.0.rc1.197.g6d975e95c9d7
^ permalink raw reply related [flat|nested] 11+ messages in thread* RE: [Intel-wired-lan] [PATCH v3 3/5] ice: add tracking of good transmit timestamps
2025-09-11 23:40 ` [PATCH v3 3/5] ice: add tracking of good transmit timestamps Jacob Keller
@ 2025-10-09 8:52 ` Loktionov, Aleksandr
0 siblings, 0 replies; 11+ messages in thread
From: Loktionov, Aleksandr @ 2025-10-09 8:52 UTC (permalink / raw)
To: Keller, Jacob E, Brandeburg, Jesse, Jakub Kicinski,
Hariprasad Kelam, Simon Horman, Marcin Szycik, Rahul Rameshbabu,
netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
linux-doc@vger.kernel.org, corbet@lwn.net, Keller, Jacob E
Cc: Jesse Brandeburg
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Jacob Keller
> Sent: Friday, September 12, 2025 1:41 AM
> To: Brandeburg, Jesse <jbrandeburg@cloudflare.com>; Jakub Kicinski
> <kuba@kernel.org>; Hariprasad Kelam <hkelam@marvell.com>; Simon Horman
> <horms@kernel.org>; Marcin Szycik <marcin.szycik@linux.intel.com>;
> Rahul Rameshbabu <rrameshbabu@nvidia.com>; netdev@vger.kernel.org;
> intel-wired-lan@lists.osuosl.org; linux-doc@vger.kernel.org;
> corbet@lwn.net; Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Subject: [Intel-wired-lan] [PATCH v3 3/5] ice: add tracking of good
> transmit timestamps
>
> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
>
> 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 <jacob.e.keller@intel.com>
> Reviewed-by: Jakub Kicinski <kuba@kernel.org>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ptp.h | 2 ++
> drivers/net/ethernet/intel/ice/ice_ptp.c | 9 +++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h
> b/drivers/net/ethernet/intel/ice/ice_ptp.h
> index 137f2070a2d9..27016aac4f1e 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.h
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h
> @@ -237,6 +237,7 @@ struct ice_ptp_pin_desc {
> * @clock: pointer to registered PTP clock device
> * @tstamp_config: hardware timestamping configuration
> * @reset_time: kernel time after clock stop on reset
> + * @tx_hwtstamp_good: number of completed Tx timestamp requests
> * @tx_hwtstamp_skipped: number of Tx time stamp requests skipped
> * @tx_hwtstamp_timeouts: number of Tx skbs discarded with no time
> stamp
> * @tx_hwtstamp_flushed: number of Tx skbs flushed due to interface
> closed @@ -261,6 +262,7 @@ struct ice_ptp {
> struct ptp_clock *clock;
> struct kernel_hwtstamp_config tstamp_config;
> u64 reset_time;
> + u64 tx_hwtstamp_good;
> u32 tx_hwtstamp_skipped;
> u32 tx_hwtstamp_timeouts;
> u32 tx_hwtstamp_flushed;
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c
> b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 9b065709c899..d2ca9d7bcfc1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -500,6 +500,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);
> @@ -558,6 +561,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;
> @@ -658,11 +662,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;
> }
>
> /**
>
> --
> 2.51.0.rc1.197.g6d975e95c9d7
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3 4/5] ice: implement transmit hardware timestamp statistics
2025-09-11 23:40 [PATCH v3 0/5] ice: add standard stats Jacob Keller
` (2 preceding siblings ...)
2025-09-11 23:40 ` [PATCH v3 3/5] ice: add tracking of good transmit timestamps Jacob Keller
@ 2025-09-11 23:40 ` Jacob Keller
2025-09-11 23:40 ` [PATCH v3 5/5] ice: refactor to use helpers Jacob Keller
4 siblings, 0 replies; 11+ messages in thread
From: Jacob Keller @ 2025-09-11 23:40 UTC (permalink / raw)
To: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet, Jacob Keller
Cc: Jesse Brandeburg
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
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 <jacob.e.keller@intel.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
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 3d99c4a1e287..f8bb2d55b28c 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -4730,6 +4730,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;
+}
+
#define ICE_ETHTOOL_PFR (ETH_RESET_IRQ | ETH_RESET_DMA | \
ETH_RESET_FILTER | ETH_RESET_OFFLOAD)
@@ -4816,6 +4833,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,
.get_drvinfo = ice_get_drvinfo,
.get_regs_len = ice_get_regs_len,
.get_regs = ice_get_regs,
--
2.51.0.rc1.197.g6d975e95c9d7
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v3 5/5] ice: refactor to use helpers
2025-09-11 23:40 [PATCH v3 0/5] ice: add standard stats Jacob Keller
` (3 preceding siblings ...)
2025-09-11 23:40 ` [PATCH v3 4/5] ice: implement transmit hardware timestamp statistics Jacob Keller
@ 2025-09-11 23:40 ` Jacob Keller
2025-09-12 7:46 ` [Intel-wired-lan] " Przemek Kitszel
2025-09-13 9:07 ` Simon Horman
4 siblings, 2 replies; 11+ messages in thread
From: Jacob Keller @ 2025-09-11 23:40 UTC (permalink / raw)
To: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet, Jacob Keller
Cc: Jesse Brandeburg
From: Jesse Brandeburg <jesse.brandeburg@intel.com>
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.
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/ethernet/intel/ice/ice_ethtool.c | 48 ++++++++------------------
drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 8 ++---
drivers/net/ethernet/intel/ice/ice_lag.c | 3 +-
drivers/net/ethernet/intel/ice/ice_main.c | 10 ++----
drivers/net/ethernet/intel/ice/ice_ptp.c | 6 ++--
drivers/net/ethernet/intel/ice/ice_sriov.c | 3 +-
6 files changed, 24 insertions(+), 54 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index f8bb2d55b28c..0b99a7b863d8 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -794,8 +794,7 @@ static int ice_get_extended_regs(struct net_device *netdev, void *p)
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;
@@ -810,8 +809,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)
@@ -824,8 +822,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)
@@ -840,16 +837,14 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data)
static void ice_get_link_ext_stats(struct net_device *netdev,
struct ethtool_link_ext_stats *stats)
{
- struct ice_netdev_priv *np = netdev_priv(netdev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(netdev);
stats->link_down_events = pf->link_down_events;
}
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;
}
@@ -858,9 +853,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;
@@ -959,8 +952,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));
@@ -1277,9 +1269,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;
@@ -1368,8 +1359,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");
@@ -1397,9 +1387,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);
@@ -1723,9 +1712,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++) {
@@ -4413,9 +4400,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;
@@ -4487,12 +4472,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;
@@ -4768,8 +4751,7 @@ static void ice_get_ts_stats(struct net_device *netdev,
*/
static int ice_ethtool_reset(struct net_device *dev, u32 *flags)
{
- struct ice_netdev_priv *np = netdev_priv(dev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(dev);
enum ice_reset_req reset;
switch (*flags) {
diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
index fc94e189e52e..c2caee083ca7 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 aebf8e08a297..d2576d606e10 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -2177,8 +2177,7 @@ 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 = netdev_priv(lag->netdev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(lag->netdev);
ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
ice_clear_feature_support(pf, ICE_F_SRIOV_AA_LAG);
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 249fd3c050eb..9994a9479082 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -8043,9 +8043,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;
@@ -8115,8 +8113,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
u16 __always_unused flags,
struct netlink_ext_ack __always_unused *extack)
{
- struct ice_netdev_priv *np = netdev_priv(dev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(dev);
struct nlattr *attr, *br_spec;
struct ice_hw *hw = &pf->hw;
struct ice_sw *pf_sw;
@@ -9550,8 +9547,7 @@ ice_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch,
*/
int ice_open(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);
if (ice_is_reset_in_progress(pf->state)) {
netdev_err(netdev, "can't open net device while reset is in progress");
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index d2ca9d7bcfc1..9b9b408c0adb 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -2244,8 +2244,7 @@ static int ice_ptp_getcrosststamp(struct ptp_clock_info *info,
int ice_ptp_hwtstamp_get(struct net_device *netdev,
struct kernel_hwtstamp_config *config)
{
- struct ice_netdev_priv *np = netdev_priv(netdev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(netdev);
if (pf->ptp.state != ICE_PTP_READY)
return -EIO;
@@ -2316,8 +2315,7 @@ int ice_ptp_hwtstamp_set(struct net_device *netdev,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
{
- struct ice_netdev_priv *np = netdev_priv(netdev);
- struct ice_pf *pf = np->vsi->back;
+ struct ice_pf *pf = ice_netdev_to_pf(netdev);
int err;
if (pf->ptp.state != ICE_PTP_READY)
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index 843e82fd3bf9..6b1126ddb561 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -1190,8 +1190,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;
--
2.51.0.rc1.197.g6d975e95c9d7
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [Intel-wired-lan] [PATCH v3 5/5] ice: refactor to use helpers
2025-09-11 23:40 ` [PATCH v3 5/5] ice: refactor to use helpers Jacob Keller
@ 2025-09-12 7:46 ` Przemek Kitszel
2025-09-15 22:26 ` Jacob Keller
2025-09-13 9:07 ` Simon Horman
1 sibling, 1 reply; 11+ messages in thread
From: Przemek Kitszel @ 2025-09-12 7:46 UTC (permalink / raw)
To: Jacob Keller
Cc: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet
On 9/12/25 01:40, Jacob Keller wrote:
> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
>
> 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.
>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
no controversies here :)
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
(assuming this is for iwl-next)
> ---
> drivers/net/ethernet/intel/ice/ice_ethtool.c | 48 ++++++++------------------
> drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 8 ++---
> drivers/net/ethernet/intel/ice/ice_lag.c | 3 +-
> drivers/net/ethernet/intel/ice/ice_main.c | 10 ++----
> drivers/net/ethernet/intel/ice/ice_ptp.c | 6 ++--
> drivers/net/ethernet/intel/ice/ice_sriov.c | 3 +-
> 6 files changed, 24 insertions(+), 54 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index f8bb2d55b28c..0b99a7b863d8 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -794,8 +794,7 @@ static int ice_get_extended_regs(struct net_device *netdev, void *p)
> 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;
> @@ -810,8 +809,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)
> @@ -824,8 +822,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)
> @@ -840,16 +837,14 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data)
> static void ice_get_link_ext_stats(struct net_device *netdev,
> struct ethtool_link_ext_stats *stats)
> {
> - struct ice_netdev_priv *np = netdev_priv(netdev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(netdev);
>
> stats->link_down_events = pf->link_down_events;
> }
>
> 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;
> }
> @@ -858,9 +853,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;
> @@ -959,8 +952,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));
> @@ -1277,9 +1269,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;
> @@ -1368,8 +1359,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");
> @@ -1397,9 +1387,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);
> @@ -1723,9 +1712,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++) {
> @@ -4413,9 +4400,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;
> @@ -4487,12 +4472,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;
> @@ -4768,8 +4751,7 @@ static void ice_get_ts_stats(struct net_device *netdev,
> */
> static int ice_ethtool_reset(struct net_device *dev, u32 *flags)
> {
> - struct ice_netdev_priv *np = netdev_priv(dev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(dev);
> enum ice_reset_req reset;
>
> switch (*flags) {
> diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c
> index fc94e189e52e..c2caee083ca7 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 aebf8e08a297..d2576d606e10 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lag.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lag.c
> @@ -2177,8 +2177,7 @@ 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 = netdev_priv(lag->netdev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(lag->netdev);
>
> ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
> ice_clear_feature_support(pf, ICE_F_SRIOV_AA_LAG);
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 249fd3c050eb..9994a9479082 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -8043,9 +8043,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;
> @@ -8115,8 +8113,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
> u16 __always_unused flags,
> struct netlink_ext_ack __always_unused *extack)
> {
> - struct ice_netdev_priv *np = netdev_priv(dev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(dev);
> struct nlattr *attr, *br_spec;
> struct ice_hw *hw = &pf->hw;
> struct ice_sw *pf_sw;
> @@ -9550,8 +9547,7 @@ ice_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch,
> */
> int ice_open(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);
>
> if (ice_is_reset_in_progress(pf->state)) {
> netdev_err(netdev, "can't open net device while reset is in progress");
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index d2ca9d7bcfc1..9b9b408c0adb 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2244,8 +2244,7 @@ static int ice_ptp_getcrosststamp(struct ptp_clock_info *info,
> int ice_ptp_hwtstamp_get(struct net_device *netdev,
> struct kernel_hwtstamp_config *config)
> {
> - struct ice_netdev_priv *np = netdev_priv(netdev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(netdev);
>
> if (pf->ptp.state != ICE_PTP_READY)
> return -EIO;
> @@ -2316,8 +2315,7 @@ int ice_ptp_hwtstamp_set(struct net_device *netdev,
> struct kernel_hwtstamp_config *config,
> struct netlink_ext_ack *extack)
> {
> - struct ice_netdev_priv *np = netdev_priv(netdev);
> - struct ice_pf *pf = np->vsi->back;
> + struct ice_pf *pf = ice_netdev_to_pf(netdev);
> int err;
>
> if (pf->ptp.state != ICE_PTP_READY)
> diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
> index 843e82fd3bf9..6b1126ddb561 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
> @@ -1190,8 +1190,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;
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [Intel-wired-lan] [PATCH v3 5/5] ice: refactor to use helpers
2025-09-12 7:46 ` [Intel-wired-lan] " Przemek Kitszel
@ 2025-09-15 22:26 ` Jacob Keller
0 siblings, 0 replies; 11+ messages in thread
From: Jacob Keller @ 2025-09-15 22:26 UTC (permalink / raw)
To: Przemek Kitszel
Cc: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Simon Horman,
Marcin Szycik, Rahul Rameshbabu, netdev, intel-wired-lan,
linux-doc, corbet
[-- Attachment #1.1: Type: text/plain, Size: 709 bytes --]
On 9/12/2025 12:46 AM, Przemek Kitszel wrote:
> On 9/12/25 01:40, Jacob Keller wrote:
>> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
>>
>> 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.
>>
>> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
>> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>
> no controversies here :)
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> (assuming this is for iwl-next)
>
Yes. Forgot to b4 prep --add-prefix.... Woops.
Thanks,
Jake
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3 5/5] ice: refactor to use helpers
2025-09-11 23:40 ` [PATCH v3 5/5] ice: refactor to use helpers Jacob Keller
2025-09-12 7:46 ` [Intel-wired-lan] " Przemek Kitszel
@ 2025-09-13 9:07 ` Simon Horman
1 sibling, 0 replies; 11+ messages in thread
From: Simon Horman @ 2025-09-13 9:07 UTC (permalink / raw)
To: Jacob Keller
Cc: Jesse Brandeburg, Jakub Kicinski, Hariprasad Kelam, Marcin Szycik,
Rahul Rameshbabu, netdev, intel-wired-lan, linux-doc, corbet,
Jesse Brandeburg
On Thu, Sep 11, 2025 at 04:40:41PM -0700, Jacob Keller wrote:
> From: Jesse Brandeburg <jesse.brandeburg@intel.com>
>
> 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.
>
> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ethtool.c | 48 ++++++++------------------
> drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 8 ++---
> drivers/net/ethernet/intel/ice/ice_lag.c | 3 +-
> drivers/net/ethernet/intel/ice/ice_main.c | 10 ++----
> drivers/net/ethernet/intel/ice/ice_ptp.c | 6 ++--
> drivers/net/ethernet/intel/ice/ice_sriov.c | 3 +-
> 6 files changed, 24 insertions(+), 54 deletions(-)
Less is more :)
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread