From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E9BC45A0A for ; Tue, 14 Jul 2015 15:11:11 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 14 Jul 2015 06:11:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,471,1432623600"; d="scan'208";a="524035056" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jul 2015 06:11:06 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t6EDB51j023874; Tue, 14 Jul 2015 14:11:06 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t6EDB59Q018807; Tue, 14 Jul 2015 14:11:05 +0100 Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id t6EDB5eO018803; Tue, 14 Jul 2015 14:11:05 +0100 From: Bernard Iremonger To: dev@dpdk.org Date: Tue, 14 Jul 2015 14:10:57 +0100 Message-Id: <1436879459-18400-4-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1436879459-18400-1-git-send-email-bernard.iremonger@intel.com> References: <1436879459-18400-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH 3/5] virtio: add proper queue release X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2015 13:11:12 -0000 Add functions virtio_dev_queue_release(), virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release(). Signed-off-by: Stephen Hemminger Signed-off-by: Bernard Iremonger --- drivers/net/virtio/virtio_ethdev.c | 31 +++++++++++++------------------ drivers/net/virtio/virtio_ethdev.h | 8 +++++++- drivers/net/virtio/virtio_rxtx.c | 12 ++++++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b88f297..b32b3e9 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -80,9 +80,6 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev, static void virtio_set_hwaddr(struct virtio_hw *hw); static void virtio_get_hwaddr(struct virtio_hw *hw); -static void virtio_dev_rx_queue_release(__rte_unused void *rxq); -static void virtio_dev_tx_queue_release(__rte_unused void *txq); - static void virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void virtio_dev_stats_reset(struct rte_eth_dev *dev); static void virtio_dev_free_mbufs(struct rte_eth_dev *dev); @@ -240,6 +237,19 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) return 0; } +void +virtio_dev_queue_release(struct virtqueue *vq) { + struct virtio_hw *hw = vq->hw; + + if (vq) { + /* Select and deactivate the queue */ + VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id); + VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0); + + rte_free(vq); + } +} + int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, @@ -553,10 +563,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .stats_reset = virtio_dev_stats_reset, .link_update = virtio_dev_link_update, .rx_queue_setup = virtio_dev_rx_queue_setup, - /* meaningfull only to multiple queue */ .rx_queue_release = virtio_dev_rx_queue_release, .tx_queue_setup = virtio_dev_tx_queue_setup, - /* meaningfull only to multiple queue */ .tx_queue_release = virtio_dev_tx_queue_release, /* collect stats per queue */ .queue_stats_mapping_set = virtio_dev_queue_stats_mapping_set, @@ -1335,19 +1343,6 @@ rte_virtio_pmd_init(const char *name __rte_unused, } /* - * Only 1 queue is supported, no queue release related operation - */ -static void -virtio_dev_rx_queue_release(__rte_unused void *rxq) -{ -} - -static void -virtio_dev_tx_queue_release(__rte_unused void *txq) -{ -} - -/* * Configure virtio device * It returns 0 on success. */ diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index df2cb7d..3858b00 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,15 +84,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev, unsigned int socket_id, struct virtqueue **pvq); +void virtio_dev_queue_release(struct virtqueue *vq); + int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, uint16_t nb_rx_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool); +void virtio_dev_rx_queue_release(void *rxq); + int virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, uint16_t nb_tx_desc, unsigned int socket_id, const struct rte_eth_txconf *tx_conf); +void virtio_dev_tx_queue_release(void *txq); + uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 091c7fb..5388caa 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -401,6 +401,12 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, return 0; } +void +virtio_dev_rx_queue_release(void *rxq) +{ + virtio_dev_queue_release(rxq); +} + /* * struct rte_eth_dev *dev: Used to update dev * uint16_t nb_desc: Defaults to values read from config space @@ -455,6 +461,12 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, return 0; } +void +virtio_dev_tx_queue_release(void *txq) +{ + virtio_dev_queue_release(txq); +} + static void virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m) { -- 1.9.1