| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | | -/* Copyright(c) 2013 - 2018 Intel Corporation. */ |
|---|
| 2 | +/* Copyright(c) 2013 - 2019 Intel Corporation. */ |
|---|
| 3 | 3 | |
|---|
| 4 | 4 | #include "fm10k.h" |
|---|
| 5 | 5 | #include "fm10k_vf.h" |
|---|
| .. | .. |
|---|
| 244 | 244 | } |
|---|
| 245 | 245 | |
|---|
| 246 | 246 | /* guarantee we have free space in the SM mailbox */ |
|---|
| 247 | | - if (!hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) { |
|---|
| 247 | + if (hw->mbx.state == FM10K_STATE_OPEN && |
|---|
| 248 | + !hw->mbx.ops.tx_ready(&hw->mbx, FM10K_VFMBX_MSG_MTU)) { |
|---|
| 248 | 249 | /* keep track of how many times this occurs */ |
|---|
| 249 | 250 | interface->hw_sm_mbx_full++; |
|---|
| 250 | 251 | |
|---|
| .. | .. |
|---|
| 320 | 321 | pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, &err_mask); |
|---|
| 321 | 322 | err_mask |= PCI_ERR_UNC_COMP_ABORT; |
|---|
| 322 | 323 | pci_write_config_dword(pdev, pos + PCI_ERR_UNCOR_MASK, err_mask); |
|---|
| 323 | | - |
|---|
| 324 | | - mmiowb(); |
|---|
| 325 | 324 | } |
|---|
| 326 | 325 | |
|---|
| 327 | 326 | int fm10k_iov_resume(struct pci_dev *pdev) |
|---|
| .. | .. |
|---|
| 427 | 426 | struct fm10k_iov_data *iov_data = interface->iov_data; |
|---|
| 428 | 427 | struct fm10k_hw *hw = &interface->hw; |
|---|
| 429 | 428 | size_t size; |
|---|
| 430 | | - int i, err; |
|---|
| 429 | + int i; |
|---|
| 431 | 430 | |
|---|
| 432 | 431 | /* return error if iov_data is already populated */ |
|---|
| 433 | 432 | if (iov_data) |
|---|
| .. | .. |
|---|
| 453 | 452 | /* loop through vf_info structures initializing each entry */ |
|---|
| 454 | 453 | for (i = 0; i < num_vfs; i++) { |
|---|
| 455 | 454 | struct fm10k_vf_info *vf_info = &iov_data->vf_info[i]; |
|---|
| 455 | + int err; |
|---|
| 456 | 456 | |
|---|
| 457 | 457 | /* Record VF VSI value */ |
|---|
| 458 | 458 | vf_info->vsi = i + 1; |
|---|
| .. | .. |
|---|
| 518 | 518 | } |
|---|
| 519 | 519 | |
|---|
| 520 | 520 | return num_vfs; |
|---|
| 521 | +} |
|---|
| 522 | + |
|---|
| 523 | +/** |
|---|
| 524 | + * fm10k_iov_update_stats - Update stats for all VFs |
|---|
| 525 | + * @interface: device private structure |
|---|
| 526 | + * |
|---|
| 527 | + * Updates the VF statistics for all enabled VFs. Expects to be called by |
|---|
| 528 | + * fm10k_update_stats and assumes that locking via the __FM10K_UPDATING_STATS |
|---|
| 529 | + * bit is already handled. |
|---|
| 530 | + */ |
|---|
| 531 | +void fm10k_iov_update_stats(struct fm10k_intfc *interface) |
|---|
| 532 | +{ |
|---|
| 533 | + struct fm10k_iov_data *iov_data = interface->iov_data; |
|---|
| 534 | + struct fm10k_hw *hw = &interface->hw; |
|---|
| 535 | + int i; |
|---|
| 536 | + |
|---|
| 537 | + if (!iov_data) |
|---|
| 538 | + return; |
|---|
| 539 | + |
|---|
| 540 | + for (i = 0; i < iov_data->num_vfs; i++) |
|---|
| 541 | + hw->iov.ops.update_stats(hw, iov_data->vf_info[i].stats, i); |
|---|
| 521 | 542 | } |
|---|
| 522 | 543 | |
|---|
| 523 | 544 | static inline void fm10k_reset_vf_info(struct fm10k_intfc *interface, |
|---|
| .. | .. |
|---|
| 650 | 671 | |
|---|
| 651 | 672 | return 0; |
|---|
| 652 | 673 | } |
|---|
| 674 | + |
|---|
| 675 | +int fm10k_ndo_get_vf_stats(struct net_device *netdev, |
|---|
| 676 | + int vf_idx, struct ifla_vf_stats *stats) |
|---|
| 677 | +{ |
|---|
| 678 | + struct fm10k_intfc *interface = netdev_priv(netdev); |
|---|
| 679 | + struct fm10k_iov_data *iov_data = interface->iov_data; |
|---|
| 680 | + struct fm10k_hw *hw = &interface->hw; |
|---|
| 681 | + struct fm10k_hw_stats_q *hw_stats; |
|---|
| 682 | + u32 idx, qpp; |
|---|
| 683 | + |
|---|
| 684 | + /* verify SR-IOV is active and that vf idx is valid */ |
|---|
| 685 | + if (!iov_data || vf_idx >= iov_data->num_vfs) |
|---|
| 686 | + return -EINVAL; |
|---|
| 687 | + |
|---|
| 688 | + qpp = fm10k_queues_per_pool(hw); |
|---|
| 689 | + hw_stats = iov_data->vf_info[vf_idx].stats; |
|---|
| 690 | + |
|---|
| 691 | + for (idx = 0; idx < qpp; idx++) { |
|---|
| 692 | + stats->rx_packets += hw_stats[idx].rx_packets.count; |
|---|
| 693 | + stats->tx_packets += hw_stats[idx].tx_packets.count; |
|---|
| 694 | + stats->rx_bytes += hw_stats[idx].rx_bytes.count; |
|---|
| 695 | + stats->tx_bytes += hw_stats[idx].tx_bytes.count; |
|---|
| 696 | + stats->rx_dropped += hw_stats[idx].rx_drops.count; |
|---|
| 697 | + } |
|---|
| 698 | + |
|---|
| 699 | + return 0; |
|---|
| 700 | +} |
|---|