* Internal function to compute the number of used descriptors in an RX queue. * * @param rxq * The Rx queue. * * @return * The number of used Rx descriptor. */
| 73 | * The number of used Rx descriptor. |
| 74 | */ |
| 75 | static uint32_t |
| 76 | rx_queue_count(struct mlx5_rxq_data *rxq) |
| 77 | { |
| 78 | struct rxq_zip *zip = &rxq->zip; |
| 79 | volatile struct mlx5_cqe *cqe; |
| 80 | const unsigned int cqe_n = (1 << rxq->cqe_n); |
| 81 | const unsigned int sges_n = (1 << rxq->sges_n); |
| 82 | const unsigned int elts_n = (1 << rxq->elts_n); |
| 83 | const unsigned int strd_n = RTE_BIT32(rxq->log_strd_num); |
| 84 | const unsigned int cqe_cnt = cqe_n - 1; |
| 85 | unsigned int cq_ci, used; |
| 86 | |
| 87 | /* if we are processing a compressed cqe */ |
| 88 | if (zip->ai) { |
| 89 | used = zip->cqe_cnt - zip->ai; |
| 90 | cq_ci = zip->cq_ci; |
| 91 | } else { |
| 92 | used = 0; |
| 93 | cq_ci = rxq->cq_ci; |
| 94 | } |
| 95 | cqe = &(*rxq->cqes)[cq_ci & cqe_cnt]; |
| 96 | while (check_cqe(cqe, cqe_n, cq_ci) != MLX5_CQE_STATUS_HW_OWN) { |
| 97 | int8_t op_own; |
| 98 | unsigned int n; |
| 99 | |
| 100 | op_own = cqe->op_own; |
| 101 | if (MLX5_CQE_FORMAT(op_own) == MLX5_COMPRESSED) |
| 102 | n = rte_be_to_cpu_32(cqe->byte_cnt); |
| 103 | else |
| 104 | n = 1; |
| 105 | cq_ci += n; |
| 106 | used += n; |
| 107 | cqe = &(*rxq->cqes)[cq_ci & cqe_cnt]; |
| 108 | } |
| 109 | used = RTE_MIN(used * sges_n, elts_n * strd_n); |
| 110 | return used; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * DPDK callback to check the status of a Rx descriptor. |
no test coverage detected