| 1690 | }; |
| 1691 | |
| 1692 | static int |
| 1693 | virtio_dev_rss_init(struct rte_eth_dev *eth_dev) |
| 1694 | { |
| 1695 | struct virtio_hw *hw = eth_dev->data->dev_private; |
| 1696 | uint16_t nb_rx_queues = eth_dev->data->nb_rx_queues; |
| 1697 | struct rte_eth_rss_conf *rss_conf; |
| 1698 | int ret, i; |
| 1699 | |
| 1700 | if (!nb_rx_queues) { |
| 1701 | PMD_INIT_LOG(ERR, "Cannot init RSS if no Rx queues"); |
| 1702 | return -EINVAL; |
| 1703 | } |
| 1704 | |
| 1705 | rss_conf = ð_dev->data->dev_conf.rx_adv_conf.rss_conf; |
| 1706 | |
| 1707 | ret = virtio_dev_get_rss_config(hw, &hw->rss_hash_types); |
| 1708 | if (ret) |
| 1709 | return ret; |
| 1710 | |
| 1711 | if (rss_conf->rss_hf) { |
| 1712 | /* Ensure requested hash types are supported by the device */ |
| 1713 | if (rss_conf->rss_hf & ~virtio_to_ethdev_rss_offloads(hw->rss_hash_types)) |
| 1714 | return -EINVAL; |
| 1715 | |
| 1716 | hw->rss_hash_types = ethdev_to_virtio_rss_offloads(rss_conf->rss_hf); |
| 1717 | } |
| 1718 | |
| 1719 | if (!hw->rss_key) { |
| 1720 | /* Setup default RSS key if not already setup by the user */ |
| 1721 | hw->rss_key = rte_malloc_socket("rss_key", |
| 1722 | VIRTIO_NET_RSS_KEY_SIZE, 0, |
| 1723 | eth_dev->device->numa_node); |
| 1724 | if (!hw->rss_key) { |
| 1725 | PMD_INIT_LOG(ERR, "Failed to allocate RSS key"); |
| 1726 | return -ENOMEM; |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | if (rss_conf->rss_key && rss_conf->rss_key_len) { |
| 1731 | if (rss_conf->rss_key_len != VIRTIO_NET_RSS_KEY_SIZE) { |
| 1732 | PMD_INIT_LOG(ERR, "Driver only supports %u RSS key length", |
| 1733 | VIRTIO_NET_RSS_KEY_SIZE); |
| 1734 | return -EINVAL; |
| 1735 | } |
| 1736 | memcpy(hw->rss_key, rss_conf->rss_key, VIRTIO_NET_RSS_KEY_SIZE); |
| 1737 | } else { |
| 1738 | memcpy(hw->rss_key, rss_intel_key, VIRTIO_NET_RSS_KEY_SIZE); |
| 1739 | } |
| 1740 | |
| 1741 | if (!hw->rss_reta) { |
| 1742 | /* Setup default RSS reta if not already setup by the user */ |
| 1743 | hw->rss_reta = rte_zmalloc_socket("rss_reta", |
| 1744 | VIRTIO_NET_RSS_RETA_SIZE * sizeof(uint16_t), 0, |
| 1745 | eth_dev->device->numa_node); |
| 1746 | if (!hw->rss_reta) { |
| 1747 | PMD_INIT_LOG(ERR, "Failed to allocate RSS reta"); |
| 1748 | return -ENOMEM; |
| 1749 | } |
no test coverage detected