Re: [PATCH 1/2] tg3: Move the [rt]x_dropped counters to tg3_napi

From: Alex Pakhunov
Date: Wed Nov 08 2023 - 13:18:27 EST


Hi,

> I think here we need to keep these counters accumulate across a reset:
>
> stats->rx_dropped = old_stats->rx_dropped + rx_dropped;
> stats->tx_dropped = old_stats->tx_dropped + tx_dropped;

Hm, tg3_halt() explicitly resets the HW counters:

```
if (tp->hw_stats) {
/* Save the stats across chip resets... */
tg3_get_nstats(tp, &tp->net_stats_prev);
tg3_get_estats(tp, &tp->estats_prev);

/* And make sure the next sample is new data */
memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats));
}
```

We sort of doing the same thing with clearing [tr]x_dropped in
tg3_init_rings() but it seems more confusing than helpful. First, why do we
handle different counters differently? Second, tg3_halt() is not always
followed by tg3_init_rings(), so the logic is not consistent.

Instead I think we should just not touch [tr]x_dropped in tg3_init_rings().
The counters will be set to zero when tg3 is allocated in tg3_init_one().
Hardware resets will not change tg3_napi::[tr]x_dropped since they are
purely software counters.

Alex.