| 387 | } |
| 388 | |
| 389 | static int |
| 390 | ntb_txq_setup(struct rte_rawdev *dev, |
| 391 | uint16_t qp_id, |
| 392 | rte_rawdev_obj_t queue_conf, |
| 393 | size_t conf_size) |
| 394 | { |
| 395 | struct ntb_queue_conf *txq_conf = queue_conf; |
| 396 | struct ntb_hw *hw = dev->dev_private; |
| 397 | struct ntb_tx_queue *txq; |
| 398 | uint16_t i, prev; |
| 399 | |
| 400 | if (conf_size != sizeof(*txq_conf)) |
| 401 | return -EINVAL; |
| 402 | |
| 403 | /* Allocate the TX queue data structure. */ |
| 404 | txq = rte_zmalloc_socket("ntb tx queue", |
| 405 | sizeof(struct ntb_tx_queue), |
| 406 | RTE_CACHE_LINE_SIZE, |
| 407 | dev->socket_id); |
| 408 | if (!txq) { |
| 409 | NTB_LOG(ERR, "Failed to allocate memory for " |
| 410 | "tx queue structure"); |
| 411 | return -ENOMEM; |
| 412 | } |
| 413 | |
| 414 | txq->nb_tx_desc = txq_conf->nb_desc; |
| 415 | txq->port_id = dev->dev_id; |
| 416 | txq->queue_id = qp_id; |
| 417 | txq->hw = hw; |
| 418 | |
| 419 | /* Allocate software ring */ |
| 420 | txq->sw_ring = |
| 421 | rte_zmalloc_socket("ntb tx sw ring", |
| 422 | sizeof(struct ntb_tx_entry) * |
| 423 | txq->nb_tx_desc, |
| 424 | RTE_CACHE_LINE_SIZE, |
| 425 | dev->socket_id); |
| 426 | if (!txq->sw_ring) { |
| 427 | ntb_txq_release(txq); |
| 428 | txq = NULL; |
| 429 | NTB_LOG(ERR, "Failed to allocate memory for SW TX ring"); |
| 430 | return -ENOMEM; |
| 431 | } |
| 432 | |
| 433 | prev = txq->nb_tx_desc - 1; |
| 434 | for (i = 0; i < txq->nb_tx_desc; i++) { |
| 435 | txq->sw_ring[i].mbuf = NULL; |
| 436 | txq->sw_ring[i].last_id = i; |
| 437 | txq->sw_ring[prev].next_id = i; |
| 438 | prev = i; |
| 439 | } |
| 440 | |
| 441 | txq->tx_free_thresh = txq_conf->tx_free_thresh ? |
| 442 | txq_conf->tx_free_thresh : |
| 443 | NTB_DFLT_TX_FREE_THRESH; |
| 444 | if (txq->tx_free_thresh >= txq->nb_tx_desc - 3) { |
| 445 | NTB_LOG(ERR, "tx_free_thresh must be less than nb_desc - 3. " |
| 446 | "(tx_free_thresh=%u qp_id=%u)", txq->tx_free_thresh, |
no test coverage detected