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

Function mlx4_rxq_attach

dpdk/drivers/net/mlx4/mlx4_rxq.c:486–637  ·  view source on GitHub ↗

* Attach a user to a Rx queue. * * Used when the resources of an Rx queue must be instantiated for it to * become in a usable state. * * This function increments the usage count of the Rx queue. * * @param rxq * Pointer to Rx queue structure. * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

484 * 0 on success, negative errno value otherwise and rte_errno is set.
485 */
486int
487mlx4_rxq_attach(struct rxq *rxq)
488{
489 if (rxq->usecnt++) {
490 MLX4_ASSERT(rxq->cq);
491 MLX4_ASSERT(rxq->wq);
492 MLX4_ASSERT(rxq->wqes);
493 MLX4_ASSERT(rxq->rq_db);
494 return 0;
495 }
496
497 struct mlx4_priv *priv = rxq->priv;
498 struct rte_eth_dev *dev = ETH_DEV(priv);
499 const uint32_t elts_n = 1 << rxq->elts_n;
500 const uint32_t sges_n = 1 << rxq->sges_n;
501 struct rte_mbuf *(*elts)[elts_n] = rxq->elts;
502 struct mlx4dv_obj mlxdv;
503 struct mlx4dv_rwq dv_rwq;
504 struct mlx4dv_cq dv_cq = { .comp_mask = MLX4DV_CQ_MASK_UAR, };
505 const char *msg;
506 struct ibv_cq *cq = NULL;
507 struct ibv_wq *wq = NULL;
508 uint32_t create_flags = 0;
509 uint32_t comp_mask = 0;
510 volatile struct mlx4_wqe_data_seg (*wqes)[];
511 unsigned int i;
512 int ret;
513
514 MLX4_ASSERT(rte_is_power_of_2(elts_n));
515 priv->verbs_alloc_ctx.type = MLX4_VERBS_ALLOC_TYPE_RX_QUEUE;
516 priv->verbs_alloc_ctx.obj = rxq;
517 cq = mlx4_glue->create_cq(priv->ctx, elts_n / sges_n, NULL,
518 rxq->channel, 0);
519 if (!cq) {
520 ret = ENOMEM;
521 msg = "CQ creation failure";
522 goto error;
523 }
524 /* By default, FCS (CRC) is stripped by hardware. */
525 if (rxq->crc_present) {
526 create_flags |= IBV_WQ_FLAGS_SCATTER_FCS;
527 comp_mask |= IBV_WQ_INIT_ATTR_FLAGS;
528 }
529 wq = mlx4_glue->create_wq
530 (priv->ctx,
531 &(struct ibv_wq_init_attr){
532 .wq_type = IBV_WQT_RQ,
533 .max_wr = elts_n / sges_n,
534 .max_sge = sges_n,
535 .pd = priv->pd,
536 .cq = cq,
537 .comp_mask = comp_mask,
538 .create_flags = create_flags,
539 });
540 if (!wq) {
541 ret = errno ? errno : EINVAL;
542 msg = "WQ creation failure";
543 goto error;

Callers 2

mlx4_rss_attachFunction · 0.85
mlx4_rss_initFunction · 0.85

Calls 5

mlx4_mr_update_mpFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_free_segFunction · 0.85
rte_pktmbuf_tailroomFunction · 0.85
rte_is_power_of_2Function · 0.50

Tested by

no test coverage detected