| 92 | } |
| 93 | |
| 94 | static int |
| 95 | bcmfs_queue_create(struct bcmfs_queue *queue, |
| 96 | struct bcmfs_qp_config *qp_conf, |
| 97 | uint16_t queue_pair_id, |
| 98 | enum bcmfs_queue_type qtype) |
| 99 | { |
| 100 | const struct rte_memzone *qp_mz; |
| 101 | char q_name[16]; |
| 102 | unsigned int align; |
| 103 | uint32_t queue_size_bytes; |
| 104 | int ret; |
| 105 | |
| 106 | if (qtype == BCMFS_RM_TXQ) { |
| 107 | strlcpy(q_name, txq_name, sizeof(q_name)); |
| 108 | align = 1U << FS_RING_BD_ALIGN_ORDER; |
| 109 | queue_size_bytes = qp_conf->nb_descriptors * |
| 110 | qp_conf->max_descs_req * FS_RING_DESC_SIZE; |
| 111 | queue_size_bytes = RTE_ALIGN_MUL_CEIL(queue_size_bytes, |
| 112 | FS_RING_PAGE_SIZE); |
| 113 | /* make queue size to multiple for 4K pages */ |
| 114 | } else if (qtype == BCMFS_RM_CPLQ) { |
| 115 | strlcpy(q_name, cmplq_name, sizeof(q_name)); |
| 116 | align = 1U << FS_RING_CMPL_ALIGN_ORDER; |
| 117 | |
| 118 | /* |
| 119 | * Memory size for cmpl + MSI |
| 120 | * For MSI allocate here itself and so we allocate twice |
| 121 | */ |
| 122 | queue_size_bytes = 2 * FS_RING_CMPL_SIZE; |
| 123 | } else { |
| 124 | BCMFS_LOG(ERR, "Invalid queue selection"); |
| 125 | return -EINVAL; |
| 126 | } |
| 127 | |
| 128 | queue->q_type = qtype; |
| 129 | |
| 130 | /* |
| 131 | * Allocate a memzone for the queue - create a unique name. |
| 132 | */ |
| 133 | snprintf(queue->memz_name, sizeof(queue->memz_name), |
| 134 | "%s_%d_%s_%d_%s", "bcmfs", qtype, "qp_mem", |
| 135 | queue_pair_id, q_name); |
| 136 | qp_mz = queue_dma_zone_reserve(queue->memz_name, queue_size_bytes, |
| 137 | 0, align); |
| 138 | if (qp_mz == NULL) { |
| 139 | BCMFS_LOG(ERR, "Failed to allocate ring memzone"); |
| 140 | return -ENOMEM; |
| 141 | } |
| 142 | |
| 143 | if (bcmfs_qp_check_queue_alignment(qp_mz->iova, align)) { |
| 144 | BCMFS_LOG(ERR, "Invalid alignment on queue create " |
| 145 | " 0x%" PRIx64, |
| 146 | queue->base_phys_addr); |
| 147 | ret = -EFAULT; |
| 148 | goto queue_create_err; |
| 149 | } |
| 150 | |
| 151 | queue->base_addr = (char *)qp_mz->addr; |
no test coverage detected