| 1544 | } |
| 1545 | |
| 1546 | static int |
| 1547 | tap_rx_queue_setup(struct rte_eth_dev *dev, |
| 1548 | uint16_t rx_queue_id, |
| 1549 | uint16_t nb_rx_desc, |
| 1550 | unsigned int socket_id, |
| 1551 | const struct rte_eth_rxconf *rx_conf __rte_unused, |
| 1552 | struct rte_mempool *mp) |
| 1553 | { |
| 1554 | struct pmd_internals *internals = dev->data->dev_private; |
| 1555 | struct pmd_process_private *process_private = dev->process_private; |
| 1556 | struct rx_queue *rxq = &internals->rxq[rx_queue_id]; |
| 1557 | struct rte_mbuf **tmp = &rxq->pool; |
| 1558 | long iov_max = sysconf(_SC_IOV_MAX); |
| 1559 | |
| 1560 | if (iov_max <= 0) { |
| 1561 | TAP_LOG(WARNING, |
| 1562 | "_SC_IOV_MAX is not defined. Using %d as default", |
| 1563 | TAP_IOV_DEFAULT_MAX); |
| 1564 | iov_max = TAP_IOV_DEFAULT_MAX; |
| 1565 | } |
| 1566 | uint16_t nb_desc = RTE_MIN(nb_rx_desc, iov_max - 1); |
| 1567 | struct iovec (*iovecs)[nb_desc + 1]; |
| 1568 | int data_off = RTE_PKTMBUF_HEADROOM; |
| 1569 | int ret = 0; |
| 1570 | int fd; |
| 1571 | int i; |
| 1572 | |
| 1573 | if (rx_queue_id >= dev->data->nb_rx_queues || !mp) { |
| 1574 | TAP_LOG(WARNING, |
| 1575 | "nb_rx_queues %d too small or mempool NULL", |
| 1576 | dev->data->nb_rx_queues); |
| 1577 | return -1; |
| 1578 | } |
| 1579 | |
| 1580 | rxq->mp = mp; |
| 1581 | rxq->trigger_seen = 1; /* force initial burst */ |
| 1582 | rxq->in_port = dev->data->port_id; |
| 1583 | rxq->queue_id = rx_queue_id; |
| 1584 | rxq->nb_rx_desc = nb_desc; |
| 1585 | iovecs = rte_zmalloc_socket(dev->device->name, sizeof(*iovecs), 0, |
| 1586 | socket_id); |
| 1587 | if (!iovecs) { |
| 1588 | TAP_LOG(WARNING, |
| 1589 | "%s: Couldn't allocate %d RX descriptors", |
| 1590 | dev->device->name, nb_desc); |
| 1591 | return -ENOMEM; |
| 1592 | } |
| 1593 | rxq->iovecs = iovecs; |
| 1594 | |
| 1595 | dev->data->rx_queues[rx_queue_id] = rxq; |
| 1596 | fd = tap_setup_queue(dev, internals, rx_queue_id, 1); |
| 1597 | if (fd == -1) { |
| 1598 | ret = fd; |
| 1599 | goto error; |
| 1600 | } |
| 1601 | |
| 1602 | (*rxq->iovecs)[0].iov_len = sizeof(struct tun_pi); |
| 1603 | (*rxq->iovecs)[0].iov_base = &rxq->pi; |
nothing calls this directly
no test coverage detected