MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_tx_queue_pre_setup

Function mlx5_tx_queue_pre_setup

dpdk/drivers/net/mlx5/mlx5_txq.c:330–374  ·  view source on GitHub ↗

* Tx queue presetup checks. * * @param dev * Pointer to Ethernet device structure. * @param idx * Tx queue index. * @param desc * Number of descriptors to configure in queue. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

328 * 0 on success, a negative errno value otherwise and rte_errno is set.
329 */
330static int
331mlx5_tx_queue_pre_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t *desc)
332{
333 struct mlx5_priv *priv = dev->data->dev_private;
334
335 if (*desc > mlx5_dev_get_max_wq_size(priv->sh)) {
336 DRV_LOG(ERR,
337 "port %u number of descriptors requested for Tx queue"
338 " %u is more than supported",
339 dev->data->port_id, idx);
340 rte_errno = EINVAL;
341 return -EINVAL;
342 }
343 if (*desc <= MLX5_TX_COMP_THRESH) {
344 DRV_LOG(WARNING,
345 "port %u number of descriptors requested for Tx queue"
346 " %u must be higher than MLX5_TX_COMP_THRESH, using %u"
347 " instead of %u", dev->data->port_id, idx,
348 MLX5_TX_COMP_THRESH + 1, *desc);
349 *desc = MLX5_TX_COMP_THRESH + 1;
350 }
351 if (!rte_is_power_of_2(*desc)) {
352 *desc = 1 << log2above(*desc);
353 DRV_LOG(WARNING,
354 "port %u increased number of descriptors in Tx queue"
355 " %u to the next power of two (%d)",
356 dev->data->port_id, idx, *desc);
357 }
358 DRV_LOG(DEBUG, "port %u configuring queue %u for %u descriptors",
359 dev->data->port_id, idx, *desc);
360 if (idx >= priv->txqs_n) {
361 DRV_LOG(ERR, "port %u Tx queue index out of range (%u >= %u)",
362 dev->data->port_id, idx, priv->txqs_n);
363 rte_errno = EOVERFLOW;
364 return -rte_errno;
365 }
366 if (!mlx5_txq_releasable(dev, idx)) {
367 rte_errno = EBUSY;
368 DRV_LOG(ERR, "port %u unable to release queue index %u",
369 dev->data->port_id, idx);
370 return -rte_errno;
371 }
372 mlx5_txq_release(dev, idx);
373 return 0;
374}
375
376/**
377 * DPDK callback to configure a TX queue.

Callers 2

mlx5_tx_queue_setupFunction · 0.85

Calls 5

mlx5_dev_get_max_wq_sizeFunction · 0.85
log2aboveFunction · 0.85
mlx5_txq_releasableFunction · 0.85
mlx5_txq_releaseFunction · 0.85
rte_is_power_of_2Function · 0.50

Tested by

no test coverage detected