From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E00B4532E for ; Thu, 30 Nov 2017 10:47:29 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Nov 2017 01:47:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,341,1508828400"; d="scan'208";a="1250236774" Received: from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182]) by fmsmga002.fm.intel.com with ESMTP; 30 Nov 2017 01:47:27 -0800 From: Zhiyong Yang To: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com Cc: wei.w.wang@intel.com, jianfeng.tan@intel.com, Zhiyong Yang Date: Thu, 30 Nov 2017 17:46:51 +0800 Message-Id: <20171130094657.11470-6-zhiyong.yang@intel.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171130094657.11470-1-zhiyong.yang@intel.com> References: <20171130094657.11470-1-zhiyong.yang@intel.com> Subject: [dpdk-dev] [PATCH 05/11] net/vhostpci: add queue setup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Nov 2017 09:47:30 -0000 add the functions for setup the RX/TX queue. Signed-off-by: Zhiyong Yang --- 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