The prev_pkt field in ice_txq_stats is used by ice_check_for_hung_subtask
as a way to detect potential Tx hangs due to missed interrupts.

The value is based on the packet count, but its an int and not really a
"statistic". The value is signed so that we can use -1 as a "no work
pending" value. A following change is going to refactor the stats to all
use the u64_stat_t type and accessor functions. Leaving prev_pkt as the
lone int feels a bit strange.

Instead, move it out of ice_txq_stats and place it in the ice_tx_ring. We
have 8 bytes still available in the 3rd cacheline, so this move saves a
small amount of memory. It also shouldn't impact the Tx path heavily since
its only accessed during initialization and the hang subtask.

Reviewed-by: Aleksandr Loktionov <[email protected]>
Signed-off-by: Jacob Keller <[email protected]>
---
 drivers/net/ethernet/intel/ice/ice_txrx.h | 3 ++-
 drivers/net/ethernet/intel/ice/ice_main.c | 6 +++---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h 
b/drivers/net/ethernet/intel/ice/ice_txrx.h
index 78fed538ea0f..aa0b74e45bba 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.h
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.h
@@ -138,7 +138,6 @@ struct ice_txq_stats {
        u64 restart_q;
        u64 tx_busy;
        u64 tx_linearize;
-       int prev_pkt; /* negative if no pending Tx descriptors */
 };
 
 struct ice_rxq_stats {
@@ -354,6 +353,8 @@ struct ice_tx_ring {
 
        u32 txq_teid;                   /* Added Tx queue TEID */
 
+       int prev_pkt; /* negative if no pending Tx descriptors */
+
 #define ICE_TX_FLAGS_RING_XDP          BIT(0)
 #define ICE_TX_FLAGS_RING_VLAN_L2TAG1  BIT(1)
 #define ICE_TX_FLAGS_RING_VLAN_L2TAG2  BIT(2)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 645a2113e8aa..df5da7b4ec62 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -160,7 +160,7 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)
                         * pending work.
                         */
                        packets = ring_stats->stats.pkts & INT_MAX;
-                       if (ring_stats->tx_stats.prev_pkt == packets) {
+                       if (tx_ring->prev_pkt == packets) {
                                /* Trigger sw interrupt to revive the queue */
                                ice_trigger_sw_intr(hw, tx_ring->q_vector);
                                continue;
@@ -170,8 +170,8 @@ static void ice_check_for_hang_subtask(struct ice_pf *pf)
                         * to ice_get_tx_pending()
                         */
                        smp_rmb();
-                       ring_stats->tx_stats.prev_pkt =
-                           ice_get_tx_pending(tx_ring) ? packets : -1;
+                       tx_ring->prev_pkt =
+                               ice_get_tx_pending(tx_ring) ? packets : -1;
                }
        }
 }
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c 
b/drivers/net/ethernet/intel/ice/ice_txrx.c
index ad76768a4232..30073ed9ca99 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -499,7 +499,7 @@ int ice_setup_tx_ring(struct ice_tx_ring *tx_ring)
 
        tx_ring->next_to_use = 0;
        tx_ring->next_to_clean = 0;
-       tx_ring->ring_stats->tx_stats.prev_pkt = -1;
+       tx_ring->prev_pkt = -1;
        return 0;
 
 err:

-- 
2.51.0.rc1.197.g6d975e95c9d7

Reply via email to