| 192 | } |
| 193 | |
| 194 | int |
| 195 | bcmfs_qp_setup(struct bcmfs_qp **qp_addr, |
| 196 | uint16_t queue_pair_id, |
| 197 | struct bcmfs_qp_config *qp_conf) |
| 198 | { |
| 199 | struct bcmfs_qp *qp; |
| 200 | uint32_t bmp_size; |
| 201 | uint32_t nb_descriptors = qp_conf->nb_descriptors; |
| 202 | uint16_t i; |
| 203 | int rc; |
| 204 | |
| 205 | if (nb_descriptors < FS_RM_MIN_REQS) { |
| 206 | BCMFS_LOG(ERR, "Can't create qp for %u descriptors", |
| 207 | nb_descriptors); |
| 208 | return -EINVAL; |
| 209 | } |
| 210 | |
| 211 | if (nb_descriptors > FS_RM_MAX_REQS) |
| 212 | nb_descriptors = FS_RM_MAX_REQS; |
| 213 | |
| 214 | if (qp_conf->iobase == NULL) { |
| 215 | BCMFS_LOG(ERR, "IO config space null"); |
| 216 | return -EINVAL; |
| 217 | } |
| 218 | |
| 219 | qp = rte_zmalloc_socket("BCM FS PMD qp metadata", |
| 220 | sizeof(*qp), RTE_CACHE_LINE_SIZE, |
| 221 | qp_conf->socket_id); |
| 222 | if (qp == NULL) { |
| 223 | BCMFS_LOG(ERR, "Failed to alloc mem for qp struct"); |
| 224 | return -ENOMEM; |
| 225 | } |
| 226 | |
| 227 | qp->qpair_id = queue_pair_id; |
| 228 | qp->ioreg = qp_conf->iobase; |
| 229 | qp->nb_descriptors = nb_descriptors; |
| 230 | qp->ops = qp_conf->ops; |
| 231 | |
| 232 | qp->stats.enqueued_count = 0; |
| 233 | qp->stats.dequeued_count = 0; |
| 234 | |
| 235 | rc = bcmfs_queue_create(&qp->tx_q, qp_conf, qp->qpair_id, |
| 236 | BCMFS_RM_TXQ); |
| 237 | if (rc) { |
| 238 | BCMFS_LOG(ERR, "Tx queue create failed queue_pair_id %u", |
| 239 | queue_pair_id); |
| 240 | goto create_err; |
| 241 | } |
| 242 | |
| 243 | rc = bcmfs_queue_create(&qp->cmpl_q, qp_conf, qp->qpair_id, |
| 244 | BCMFS_RM_CPLQ); |
| 245 | if (rc) { |
| 246 | BCMFS_LOG(ERR, "Cmpl queue create failed queue_pair_id= %u", |
| 247 | queue_pair_id); |
| 248 | goto q_create_err; |
| 249 | } |
| 250 | |
| 251 | /* ctx saving bitmap */ |
no test coverage detected