summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Iremonger <bernard.iremonger@intel.com>2015-07-15 14:51:02 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-07-19 22:24:42 +0200
commit5382b188fb8a6f2ffd5e9c884e53f84c526c8b50 (patch)
tree458fd36ad172cdc1248565e9f51061a52467423e
parent2f7fdb9d52f2134aec9c6ab96f11be79f326d8d3 (diff)
downloaddpdk-5382b188fb8a6f2ffd5e9c884e53f84c526c8b50.zip
dpdk-5382b188fb8a6f2ffd5e9c884e53f84c526c8b50.tar.gz
dpdk-5382b188fb8a6f2ffd5e9c884e53f84c526c8b50.tar.xz
virtio: add queue release
Add functions virtio_dev_queue_release(), virtio_dev_rx_queue_release() and virtio_dev_tx_queue_release(). Use queue_release in virtio_dev_uninit(). Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
-rw-r--r--drivers/net/virtio/virtio_ethdev.c35
-rw-r--r--drivers/net/virtio/virtio_ethdev.h8
-rw-r--r--drivers/net/virtio/virtio_rxtx.c12
3 files changed, 34 insertions, 21 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b88f297..4d5412a 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,20 @@ 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);
+ vq = NULL;
+ }
+}
+
int virtio_dev_queue_setup(struct rte_eth_dev *dev,
int queue_type,
uint16_t queue_idx,
@@ -553,10 +564,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,
@@ -1287,8 +1296,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
eth_dev->tx_pkt_burst = NULL;
eth_dev->rx_pkt_burst = NULL;
- rte_free(hw->cvq);
- hw->cvq = NULL;
+ virtio_dev_queue_release(hw->cvq);
rte_free(eth_dev->data->mac_addrs);
eth_dev->data->mac_addrs = NULL;
@@ -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)
{