Thread (26 messages) 26 messages, 5 authors, 2018-01-19
STALE3070d

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

From: Zhiyong Yang <hidden>
Date: 2017-11-30 09:47:29
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

add the functions for setup the RX/TX queue.

Signed-off-by: Zhiyong Yang <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help