MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ntb_queue_init

Function ntb_queue_init

dpdk/drivers/raw/ntb/ntb.c:501–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501static int
502ntb_queue_init(struct rte_rawdev *dev, uint16_t qp_id)
503{
504 struct ntb_hw *hw = dev->dev_private;
505 struct ntb_rx_queue *rxq = hw->rx_queues[qp_id];
506 struct ntb_tx_queue *txq = hw->tx_queues[qp_id];
507 volatile struct ntb_header *local_hdr;
508 struct ntb_header *remote_hdr;
509 uint16_t q_size = hw->queue_size;
510 uint32_t hdr_offset;
511 void *bar_addr;
512 uint16_t i;
513
514 if (hw->ntb_ops->get_peer_mw_addr == NULL) {
515 NTB_LOG(ERR, "Getting peer mw addr is not supported.");
516 return -EINVAL;
517 }
518
519 /* Put queue info into the start of shared memory. */
520 hdr_offset = hw->hdr_size_per_queue * qp_id;
521 local_hdr = (volatile struct ntb_header *)
522 ((size_t)hw->mz[0]->addr + hdr_offset);
523 bar_addr = (*hw->ntb_ops->get_peer_mw_addr)(dev, 0);
524 if (bar_addr == NULL)
525 return -EINVAL;
526 remote_hdr = (struct ntb_header *)
527 ((size_t)bar_addr + hdr_offset);
528
529 /* rxq init. */
530 rxq->rx_desc_ring = (struct ntb_desc *)
531 (&remote_hdr->desc_ring);
532 rxq->rx_used_ring = (volatile struct ntb_used *)
533 (&local_hdr->desc_ring[q_size]);
534 rxq->avail_cnt = &remote_hdr->avail_cnt;
535 rxq->used_cnt = &local_hdr->used_cnt;
536
537 for (i = 0; i < rxq->nb_rx_desc - 1; i++) {
538 struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mpool);
539 if (unlikely(!mbuf)) {
540 NTB_LOG(ERR, "Failed to allocate mbuf for RX");
541 return -ENOMEM;
542 }
543 mbuf->port = dev->dev_id;
544
545 rxq->sw_ring[i].mbuf = mbuf;
546
547 rxq->rx_desc_ring[i].addr = rte_pktmbuf_mtod(mbuf, size_t);
548 rxq->rx_desc_ring[i].len = mbuf->buf_len - RTE_PKTMBUF_HEADROOM;
549 }
550 rte_wmb();
551 *rxq->avail_cnt = rxq->nb_rx_desc - 1;
552 rxq->last_avail = rxq->nb_rx_desc - 1;
553 rxq->last_used = 0;
554
555 /* txq init */
556 txq->tx_desc_ring = (volatile struct ntb_desc *)
557 (&local_hdr->desc_ring);
558 txq->tx_used_ring = (struct ntb_used *)

Callers 1

ntb_dev_startFunction · 0.85

Calls 1

rte_mbuf_raw_allocFunction · 0.85

Tested by

no test coverage detected