| 2484 | } |
| 2485 | |
| 2486 | int |
| 2487 | ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf, |
| 2488 | uint32_t tx_rate, uint64_t q_msk) |
| 2489 | { |
| 2490 | struct ixgbe_hw *hw; |
| 2491 | struct ixgbe_vf_info *vfinfo; |
| 2492 | struct rte_eth_link link; |
| 2493 | uint8_t nb_q_per_pool; |
| 2494 | uint32_t queue_stride; |
| 2495 | uint32_t queue_idx, idx = 0, vf_idx; |
| 2496 | uint32_t queue_end; |
| 2497 | uint16_t total_rate = 0; |
| 2498 | struct rte_pci_device *pci_dev; |
| 2499 | int ret; |
| 2500 | |
| 2501 | pci_dev = RTE_ETH_DEV_TO_PCI(dev); |
| 2502 | ret = rte_eth_link_get_nowait(dev->data->port_id, &link); |
| 2503 | if (ret < 0) |
| 2504 | return ret; |
| 2505 | |
| 2506 | if (vf >= pci_dev->max_vfs) |
| 2507 | return -EINVAL; |
| 2508 | |
| 2509 | if (tx_rate > link.link_speed) |
| 2510 | return -EINVAL; |
| 2511 | |
| 2512 | if (q_msk == 0) |
| 2513 | return 0; |
| 2514 | |
| 2515 | hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); |
| 2516 | vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private)); |
| 2517 | nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool; |
| 2518 | queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active; |
| 2519 | queue_idx = vf * queue_stride; |
| 2520 | queue_end = queue_idx + nb_q_per_pool - 1; |
| 2521 | if (queue_end >= hw->mac.max_tx_queues) |
| 2522 | return -EINVAL; |
| 2523 | |
| 2524 | if (vfinfo) { |
| 2525 | for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) { |
| 2526 | if (vf_idx == vf) |
| 2527 | continue; |
| 2528 | for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate); |
| 2529 | idx++) |
| 2530 | total_rate += vfinfo[vf_idx].tx_rate[idx]; |
| 2531 | } |
| 2532 | } else { |
| 2533 | return -EINVAL; |
| 2534 | } |
| 2535 | |
| 2536 | /* Store tx_rate for this vf. */ |
| 2537 | for (idx = 0; idx < nb_q_per_pool; idx++) { |
| 2538 | if (((uint64_t)0x1 << idx) & q_msk) { |
| 2539 | if (vfinfo[vf].tx_rate[idx] != tx_rate) |
| 2540 | vfinfo[vf].tx_rate[idx] = tx_rate; |
| 2541 | total_rate += tx_rate; |
| 2542 | } |
| 2543 | } |
no test coverage detected