.. | .. |
---|
313 | 313 | |
---|
314 | 314 | edev->ops->get_vport_stats(edev->cdev, &stats); |
---|
315 | 315 | |
---|
| 316 | + spin_lock(&edev->stats_lock); |
---|
| 317 | + |
---|
316 | 318 | p_common->no_buff_discards = stats.common.no_buff_discards; |
---|
317 | 319 | p_common->packet_too_big_discard = stats.common.packet_too_big_discard; |
---|
318 | 320 | p_common->ttl0_discard = stats.common.ttl0_discard; |
---|
.. | .. |
---|
410 | 412 | p_ah->tx_1519_to_max_byte_packets = |
---|
411 | 413 | stats.ah.tx_1519_to_max_byte_packets; |
---|
412 | 414 | } |
---|
| 415 | + |
---|
| 416 | + spin_unlock(&edev->stats_lock); |
---|
413 | 417 | } |
---|
414 | 418 | |
---|
415 | 419 | static void qede_get_stats64(struct net_device *dev, |
---|
.. | .. |
---|
418 | 422 | struct qede_dev *edev = netdev_priv(dev); |
---|
419 | 423 | struct qede_stats_common *p_common; |
---|
420 | 424 | |
---|
421 | | - qede_fill_by_demand_stats(edev); |
---|
422 | 425 | p_common = &edev->stats.common; |
---|
| 426 | + |
---|
| 427 | + spin_lock(&edev->stats_lock); |
---|
423 | 428 | |
---|
424 | 429 | stats->rx_packets = p_common->rx_ucast_pkts + p_common->rx_mcast_pkts + |
---|
425 | 430 | p_common->rx_bcast_pkts; |
---|
.. | .. |
---|
440 | 445 | stats->collisions = edev->stats.bb.tx_total_collisions; |
---|
441 | 446 | stats->rx_crc_errors = p_common->rx_crc_errors; |
---|
442 | 447 | stats->rx_frame_errors = p_common->rx_align_errors; |
---|
| 448 | + |
---|
| 449 | + spin_unlock(&edev->stats_lock); |
---|
443 | 450 | } |
---|
444 | 451 | |
---|
445 | 452 | #ifdef CONFIG_QED_SRIOV |
---|
.. | .. |
---|
1001 | 1008 | rtnl_unlock(); |
---|
1002 | 1009 | } |
---|
1003 | 1010 | |
---|
| 1011 | +static void qede_periodic_task(struct work_struct *work) |
---|
| 1012 | +{ |
---|
| 1013 | + struct qede_dev *edev = container_of(work, struct qede_dev, |
---|
| 1014 | + periodic_task.work); |
---|
| 1015 | + |
---|
| 1016 | + qede_fill_by_demand_stats(edev); |
---|
| 1017 | + schedule_delayed_work(&edev->periodic_task, edev->stats_coal_ticks); |
---|
| 1018 | +} |
---|
| 1019 | + |
---|
| 1020 | +static void qede_init_periodic_task(struct qede_dev *edev) |
---|
| 1021 | +{ |
---|
| 1022 | + INIT_DELAYED_WORK(&edev->periodic_task, qede_periodic_task); |
---|
| 1023 | + spin_lock_init(&edev->stats_lock); |
---|
| 1024 | + edev->stats_coal_usecs = USEC_PER_SEC; |
---|
| 1025 | + edev->stats_coal_ticks = usecs_to_jiffies(USEC_PER_SEC); |
---|
| 1026 | +} |
---|
| 1027 | + |
---|
1004 | 1028 | static void qede_sp_task(struct work_struct *work) |
---|
1005 | 1029 | { |
---|
1006 | 1030 | struct qede_dev *edev = container_of(work, struct qede_dev, |
---|
.. | .. |
---|
1020 | 1044 | */ |
---|
1021 | 1045 | |
---|
1022 | 1046 | if (test_and_clear_bit(QEDE_SP_RECOVERY, &edev->sp_flags)) { |
---|
| 1047 | + cancel_delayed_work_sync(&edev->periodic_task); |
---|
1023 | 1048 | #ifdef CONFIG_QED_SRIOV |
---|
1024 | 1049 | /* SRIOV must be disabled outside the lock to avoid a deadlock. |
---|
1025 | 1050 | * The recovery of the active VFs is currently not supported. |
---|
.. | .. |
---|
1216 | 1241 | */ |
---|
1217 | 1242 | INIT_DELAYED_WORK(&edev->sp_task, qede_sp_task); |
---|
1218 | 1243 | mutex_init(&edev->qede_lock); |
---|
| 1244 | + qede_init_periodic_task(edev); |
---|
1219 | 1245 | |
---|
1220 | 1246 | rc = register_netdev(edev->ndev); |
---|
1221 | 1247 | if (rc) { |
---|
.. | .. |
---|
1240 | 1266 | edev->rx_copybreak = QEDE_RX_HDR_SIZE; |
---|
1241 | 1267 | |
---|
1242 | 1268 | qede_log_probe(edev); |
---|
| 1269 | + |
---|
| 1270 | + /* retain user config (for example - after recovery) */ |
---|
| 1271 | + if (edev->stats_coal_usecs) |
---|
| 1272 | + schedule_delayed_work(&edev->periodic_task, 0); |
---|
| 1273 | + |
---|
1243 | 1274 | return 0; |
---|
1244 | 1275 | |
---|
1245 | 1276 | err4: |
---|
.. | .. |
---|
1308 | 1339 | unregister_netdev(ndev); |
---|
1309 | 1340 | |
---|
1310 | 1341 | cancel_delayed_work_sync(&edev->sp_task); |
---|
| 1342 | + cancel_delayed_work_sync(&edev->periodic_task); |
---|
1311 | 1343 | |
---|
1312 | 1344 | edev->ops->common->set_power_state(cdev, PCI_D0); |
---|
1313 | 1345 | |
---|