| 302 | } |
| 303 | |
| 304 | static int |
| 305 | ntb_rxq_setup(struct rte_rawdev *dev, |
| 306 | uint16_t qp_id, |
| 307 | rte_rawdev_obj_t queue_conf, |
| 308 | size_t conf_size) |
| 309 | { |
| 310 | struct ntb_queue_conf *rxq_conf = queue_conf; |
| 311 | struct ntb_hw *hw = dev->dev_private; |
| 312 | struct ntb_rx_queue *rxq; |
| 313 | |
| 314 | if (conf_size != sizeof(*rxq_conf)) |
| 315 | return -EINVAL; |
| 316 | |
| 317 | /* Allocate the rx queue data structure */ |
| 318 | rxq = rte_zmalloc_socket("ntb rx queue", |
| 319 | sizeof(struct ntb_rx_queue), |
| 320 | RTE_CACHE_LINE_SIZE, |
| 321 | dev->socket_id); |
| 322 | if (!rxq) { |
| 323 | NTB_LOG(ERR, "Failed to allocate memory for " |
| 324 | "rx queue data structure."); |
| 325 | return -ENOMEM; |
| 326 | } |
| 327 | |
| 328 | if (rxq_conf->rx_mp == NULL) { |
| 329 | NTB_LOG(ERR, "Invalid null mempool pointer."); |
| 330 | return -EINVAL; |
| 331 | } |
| 332 | rxq->nb_rx_desc = rxq_conf->nb_desc; |
| 333 | rxq->mpool = rxq_conf->rx_mp; |
| 334 | rxq->port_id = dev->dev_id; |
| 335 | rxq->queue_id = qp_id; |
| 336 | rxq->hw = hw; |
| 337 | |
| 338 | /* Allocate the software ring. */ |
| 339 | rxq->sw_ring = |
| 340 | rte_zmalloc_socket("ntb rx sw ring", |
| 341 | sizeof(struct ntb_rx_entry) * |
| 342 | rxq->nb_rx_desc, |
| 343 | RTE_CACHE_LINE_SIZE, |
| 344 | dev->socket_id); |
| 345 | if (!rxq->sw_ring) { |
| 346 | ntb_rxq_release(rxq); |
| 347 | rxq = NULL; |
| 348 | NTB_LOG(ERR, "Failed to allocate memory for SW ring"); |
| 349 | return -ENOMEM; |
| 350 | } |
| 351 | |
| 352 | hw->rx_queues[qp_id] = rxq; |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | static void |
| 358 | ntb_txq_release_mbufs(struct ntb_tx_queue *q) |
no test coverage detected