Skip to content

Commit 4ff3495

Browse files
buytenhLennert Buytenhek
authored andcommitted
mv643xx_eth: enforce frequent hardware statistics polling
If we don't poll the hardware statistics counters at least once every ~34 seconds, overflow might occur without us noticing. So, set up a timer to poll the statistics counters at least once every 30 seconds. Signed-off-by: Lennert Buytenhek <[email protected]>
1 parent 4df89bd commit 4ff3495

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/net/mv643xx_eth.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ struct mv643xx_eth_private {
356356

357357
int phy_addr;
358358

359+
struct timer_list mib_counters_timer;
360+
spinlock_t mib_counters_lock;
359361
struct mib_counters mib_counters;
362+
360363
struct work_struct tx_timeout_task;
361364
struct mii_if_info mii;
362365

@@ -1176,6 +1179,7 @@ static void mib_counters_update(struct mv643xx_eth_private *mp)
11761179
{
11771180
struct mib_counters *p = &mp->mib_counters;
11781181

1182+
spin_lock(&mp->mib_counters_lock);
11791183
p->good_octets_received += mib_read(mp, 0x00);
11801184
p->good_octets_received += (u64)mib_read(mp, 0x04) << 32;
11811185
p->bad_octets_received += mib_read(mp, 0x08);
@@ -1208,6 +1212,16 @@ static void mib_counters_update(struct mv643xx_eth_private *mp)
12081212
p->bad_crc_event += mib_read(mp, 0x74);
12091213
p->collision += mib_read(mp, 0x78);
12101214
p->late_collision += mib_read(mp, 0x7c);
1215+
spin_unlock(&mp->mib_counters_lock);
1216+
1217+
mod_timer(&mp->mib_counters_timer, jiffies + 30 * HZ);
1218+
}
1219+
1220+
static void mib_counters_timer_wrapper(unsigned long _mp)
1221+
{
1222+
struct mv643xx_eth_private *mp = (void *)_mp;
1223+
1224+
mib_counters_update(mp);
12111225
}
12121226

12131227

@@ -2148,6 +2162,8 @@ static int mv643xx_eth_stop(struct net_device *dev)
21482162
wrl(mp, INT_MASK(mp->port_num), 0x00000000);
21492163
rdl(mp, INT_MASK(mp->port_num));
21502164

2165+
del_timer_sync(&mp->mib_counters_timer);
2166+
21512167
napi_disable(&mp->napi);
21522168

21532169
del_timer_sync(&mp->rx_oom);
@@ -2625,6 +2641,19 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
26252641
}
26262642
init_pscr(mp, pd->speed, pd->duplex);
26272643

2644+
2645+
mib_counters_clear(mp);
2646+
2647+
init_timer(&mp->mib_counters_timer);
2648+
mp->mib_counters_timer.data = (unsigned long)mp;
2649+
mp->mib_counters_timer.function = mib_counters_timer_wrapper;
2650+
mp->mib_counters_timer.expires = jiffies + 30 * HZ;
2651+
add_timer(&mp->mib_counters_timer);
2652+
2653+
spin_lock_init(&mp->mib_counters_lock);
2654+
2655+
INIT_WORK(&mp->tx_timeout_task, tx_timeout_task);
2656+
26282657
netif_napi_add(dev, &mp->napi, mv643xx_eth_poll, 128);
26292658

26302659
init_timer(&mp->rx_oom);

0 commit comments

Comments
 (0)