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

Function mlx5_txq_devx_obj_new

dpdk/drivers/net/mlx5/mlx5_devx.c:1453–1592  ·  view source on GitHub ↗

* Create the Tx queue DevX object. * * @param dev * Pointer to Ethernet device. * @param idx * Queue index in DPDK Tx queue array. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

1451 * 0 on success, a negative errno value otherwise and rte_errno is set.
1452 */
1453int
1454mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx)
1455{
1456 struct mlx5_priv *priv = dev->data->dev_private;
1457 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx];
1458 struct mlx5_txq_ctrl *txq_ctrl =
1459 container_of(txq_data, struct mlx5_txq_ctrl, txq);
1460
1461 if (txq_ctrl->is_hairpin)
1462 return mlx5_txq_obj_hairpin_new(dev, idx);
1463#if !defined(HAVE_MLX5DV_DEVX_UAR_OFFSET) && defined(HAVE_INFINIBAND_VERBS_H)
1464 DRV_LOG(ERR, "Port %u Tx queue %u cannot create with DevX, no UAR.",
1465 dev->data->port_id, idx);
1466 rte_errno = ENOMEM;
1467 return -rte_errno;
1468#else
1469 struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv));
1470 struct mlx5_dev_ctx_shared *sh = priv->sh;
1471 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj;
1472 struct mlx5_devx_cq_attr cq_attr = {
1473 .uar_page_id = mlx5_os_get_devx_uar_page_id(sh->tx_uar.obj),
1474 };
1475 uint32_t cqe_n, log_desc_n;
1476 uint32_t wqe_n, wqe_size;
1477 int ret = 0;
1478
1479 MLX5_ASSERT(txq_data);
1480 MLX5_ASSERT(txq_obj);
1481 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
1482 MLX5_ASSERT(ppriv);
1483 txq_obj->txq_ctrl = txq_ctrl;
1484 txq_obj->dev = dev;
1485 if (__rte_trace_point_fp_is_enabled() &&
1486 txq_data->offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)
1487 cqe_n = UINT16_MAX / 2 - 1;
1488 else
1489 cqe_n = (1UL << txq_data->elts_n) / MLX5_TX_COMP_THRESH +
1490 1 + MLX5_TX_COMP_THRESH_INLINE_DIV;
1491 log_desc_n = log2above(cqe_n);
1492 cqe_n = 1UL << log_desc_n;
1493 if (cqe_n > UINT16_MAX) {
1494 DRV_LOG(ERR, "Port %u Tx queue %u requests to many CQEs %u.",
1495 dev->data->port_id, txq_data->idx, cqe_n);
1496 rte_errno = EINVAL;
1497 return 0;
1498 }
1499 /* Create completion queue object with DevX. */
1500 ret = mlx5_devx_cq_create(sh->cdev->ctx, &txq_obj->cq_obj, log_desc_n,
1501 &cq_attr, priv->sh->numa_node);
1502 if (ret) {
1503 DRV_LOG(ERR, "Port %u Tx queue %u CQ creation failure.",
1504 dev->data->port_id, idx);
1505 goto error;
1506 }
1507 txq_data->cqe_n = log_desc_n;
1508 txq_data->cqe_s = cqe_n;
1509 txq_data->cqe_m = txq_data->cqe_s - 1;
1510 txq_data->cqes = txq_obj->cq_obj.cqes;

Callers

nothing calls this directly

Calls 11

mlx5_txq_obj_hairpin_newFunction · 0.85
rte_eal_process_typeFunction · 0.85
log2aboveFunction · 0.85
mlx5_devx_cq_createFunction · 0.85
mlx5_dev_get_max_wq_sizeFunction · 0.85
mlx5_txq_devx_modifyFunction · 0.85

Tested by

no test coverage detected