* Configure default RSS reta. * * @param dev * Pointer to Ethernet device structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 165 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 166 | */ |
| 167 | int |
| 168 | mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev) |
| 169 | { |
| 170 | struct mlx5_priv *priv = dev->data->dev_private; |
| 171 | unsigned int rxqs_n = dev->data->nb_rx_queues; |
| 172 | unsigned int i; |
| 173 | unsigned int j; |
| 174 | unsigned int reta_idx_n; |
| 175 | int ret = 0; |
| 176 | unsigned int *rss_queue_arr = NULL; |
| 177 | unsigned int rss_queue_n = 0; |
| 178 | |
| 179 | if (priv->skip_default_rss_reta) |
| 180 | return ret; |
| 181 | rss_queue_arr = mlx5_malloc(0, rxqs_n * sizeof(unsigned int), 0, |
| 182 | SOCKET_ID_ANY); |
| 183 | if (!rss_queue_arr) { |
| 184 | DRV_LOG(ERR, "port %u cannot allocate RSS queue list (%u)", |
| 185 | dev->data->port_id, rxqs_n); |
| 186 | rte_errno = ENOMEM; |
| 187 | return -rte_errno; |
| 188 | } |
| 189 | for (i = 0, j = 0; i < rxqs_n; i++) { |
| 190 | struct mlx5_rxq_ctrl *rxq_ctrl = mlx5_rxq_ctrl_get(dev, i); |
| 191 | |
| 192 | if (rxq_ctrl && !rxq_ctrl->is_hairpin) |
| 193 | rss_queue_arr[j++] = i; |
| 194 | } |
| 195 | rss_queue_n = j; |
| 196 | if (rss_queue_n > priv->sh->dev_cap.ind_table_max_size) { |
| 197 | DRV_LOG(ERR, "port %u cannot handle this many Rx queues (%u)", |
| 198 | dev->data->port_id, rss_queue_n); |
| 199 | rte_errno = EINVAL; |
| 200 | mlx5_free(rss_queue_arr); |
| 201 | return -rte_errno; |
| 202 | } |
| 203 | DRV_LOG(INFO, "port %u Rx queues number update: %u -> %u", |
| 204 | dev->data->port_id, priv->rxqs_n, rxqs_n); |
| 205 | priv->rxqs_n = rxqs_n; |
| 206 | /* |
| 207 | * If the requested number of RX queues is not a power of two, |
| 208 | * use the maximum indirection table size for better balancing. |
| 209 | * The result is always rounded to the next power of two. |
| 210 | */ |
| 211 | reta_idx_n = (1 << log2above((rss_queue_n & (rss_queue_n - 1)) ? |
| 212 | priv->sh->dev_cap.ind_table_max_size : |
| 213 | rss_queue_n)); |
| 214 | ret = mlx5_rss_reta_index_resize(dev, reta_idx_n); |
| 215 | if (ret) { |
| 216 | mlx5_free(rss_queue_arr); |
| 217 | return ret; |
| 218 | } |
| 219 | /* |
| 220 | * When the number of RX queues is not a power of two, |
| 221 | * the remaining table entries are padded with reused WQs |
| 222 | * and hashes are not spread uniformly. |
| 223 | */ |
| 224 | for (i = 0, j = 0; (i != reta_idx_n); ++i) { |
no test coverage detected