[dpdk-dev] [PATCH 05/11] net/vhostpci: add queue setup

Zhiyong Yang zhiyong.yang at intel.com
Thu Nov 30 10:46:51 CET 2017


add the functions for setup the RX/TX queue.

Signed-off-by: Zhiyong Yang <zhiyong.yang at intel.com>
---
 drivers/net/vhostpci/vhostpci_ethdev.c | 63 ++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/drivers/net/vhostpci/vhostpci_ethdev.c b/drivers/net/vhostpci/vhostpci_ethdev.c
index 873ff7482..068c19b2b 100644
--- a/drivers/net/vhostpci/vhostpci_ethdev.c
+++ b/drivers/net/vhostpci/vhostpci_ethdev.c
@@ -67,6 +67,19 @@ vhostpci_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 		struct rte_eth_link *link);
 
 static int
+vhostpci_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+		   uint16_t nb_rx_desc __rte_unused,
+		   unsigned int socket_id,
+		   const struct rte_eth_rxconf *rx_conf __rte_unused,
+		   struct rte_mempool *mb_pool);
+
+static int
+vhostpci_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+		   uint16_t nb_tx_desc __rte_unused,
+		   unsigned int socket_id,
+		   const struct rte_eth_txconf *tx_conf __rte_unused);
+
+static int
 vhostpci_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features);
 
 static int
@@ -87,6 +100,8 @@ static const struct eth_dev_ops vhostpci_eth_dev_ops = {
 	.dev_close               = vhostpci_dev_close,
 	.dev_infos_get		 = vhostpci_dev_info_get,
 	.dev_configure		 = vhostpci_dev_configure,
+	.rx_queue_setup		 = vhostpci_dev_rx_queue_setup,
+	.tx_queue_setup		 = vhostpci_dev_tx_queue_setup,
 };
 
 static inline bool
@@ -233,6 +248,54 @@ vhostpci_dev_configure(struct rte_eth_dev *dev __rte_unused)
 }
 
 static int
+vhostpci_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
+		uint16_t nb_rx_desc __rte_unused,
+		unsigned int socket_id,
+		const struct rte_eth_rxconf *rx_conf __rte_unused,
+		struct rte_mempool *mb_pool)
+{
+	struct vhostpci_queue *vq;
+	struct vhostpci_hw *hw = dev->data->dev_private;
+
+	vq = rte_zmalloc_socket(NULL, sizeof(struct vhostpci_queue),
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (vq == NULL) {
+		RTE_LOG(ERR, PMD, "Failed to allocate memory for rx queue\n");
+		return -ENOMEM;
+	}
+
+	vq->mb_pool = mb_pool;
+	vq->virtqueue_id = rx_queue_id * VTNET_QNUM + VTNET_TXQ;
+	vq->vpnet = hw->vpnet;
+	dev->data->rx_queues[rx_queue_id] = vq;
+
+	return 0;
+}
+
+static int
+vhostpci_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+		uint16_t nb_tx_desc __rte_unused,
+		unsigned int socket_id,
+		const struct rte_eth_txconf *tx_conf __rte_unused)
+{
+	struct vhostpci_queue *vq;
+	struct vhostpci_hw *hw = dev->data->dev_private;
+
+	vq = rte_zmalloc_socket(NULL, sizeof(struct vhostpci_queue),
+			RTE_CACHE_LINE_SIZE, socket_id);
+	if (vq == NULL) {
+		RTE_LOG(ERR, PMD, "Failed to allocate memory for tx queue\n");
+		return -ENOMEM;
+	}
+
+	vq->virtqueue_id = tx_queue_id * VTNET_QNUM  + VTNET_RXQ;
+	vq->vpnet = hw->vpnet;
+	dev->data->tx_queues[tx_queue_id] = vq;
+
+	return 0;
+}
+
+static int
 vhostpci_dev_atomic_write_link_status(struct rte_eth_dev *dev,
 		struct rte_eth_link *link)
 {
-- 
2.13.3



More information about the dev mailing list