rte_virtio: removed virtio_logs.h
Replaced old PMD_*LOG with * SPDK_WARNLOG * SPDK_ERRLOG * SPDK_DEBUGLOG Added 3 new trace flags: * virtio_dev - SPDK_TRACE_VIRTIO_DEV * virtio_pci - SPDK_TRACE_VIRTIO_PCI * virtio_user - SPDK_TRACE_VIRTIO_USER This patch also makes error messages to be printed on non-debug builds. Some messages should be still reworded, but that will be done in a separate patch. Change-Id: I2dd4c71dfce20cde0ef010a1d91ac6f166bb2c98 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/382620 Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
7e4f3dbfdc
commit
14db5b6646
@ -57,7 +57,6 @@
|
|||||||
#include "virtio_user/vhost.h"
|
#include "virtio_user/vhost.h"
|
||||||
#include "virtio_dev.h"
|
#include "virtio_dev.h"
|
||||||
#include "virtio_pci.h"
|
#include "virtio_pci.h"
|
||||||
#include "virtio_logs.h"
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virtio_init_vring(struct virtqueue *vq)
|
virtio_init_vring(struct virtqueue *vq)
|
||||||
@ -66,8 +65,6 @@ virtio_init_vring(struct virtqueue *vq)
|
|||||||
struct vring *vr = &vq->vq_ring;
|
struct vring *vr = &vq->vq_ring;
|
||||||
uint8_t *ring_mem = vq->vq_ring_virt_mem;
|
uint8_t *ring_mem = vq->vq_ring_virt_mem;
|
||||||
|
|
||||||
PMD_INIT_FUNC_TRACE();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reinitialise since virtio port might have been stopped and restarted
|
* Reinitialise since virtio port might have been stopped and restarted
|
||||||
*/
|
*/
|
||||||
@ -97,21 +94,22 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
|
|||||||
struct virtqueue *vq;
|
struct virtqueue *vq;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "setting up queue: %u", vtpci_queue_idx);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "setting up queue: %"PRIu16"\n", vtpci_queue_idx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the virtqueue size from the Queue Size field
|
* Read the virtqueue size from the Queue Size field
|
||||||
* Always power of 2 and if 0 virtqueue does not exist
|
* Always power of 2 and if 0 virtqueue does not exist
|
||||||
*/
|
*/
|
||||||
vq_size = vtpci_ops(dev)->get_queue_num(dev, vtpci_queue_idx);
|
vq_size = vtpci_ops(dev)->get_queue_num(dev, vtpci_queue_idx);
|
||||||
PMD_INIT_LOG(DEBUG, "vq_size: %u", vq_size);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vq_size: %u\n", vq_size);
|
||||||
if (vq_size == 0) {
|
if (vq_size == 0) {
|
||||||
PMD_INIT_LOG(ERR, "virtqueue does not exist");
|
SPDK_ERRLOG("virtqueue %"PRIu16" does not exist\n", vtpci_queue_idx);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rte_is_power_of_2(vq_size)) {
|
if (!rte_is_power_of_2(vq_size)) {
|
||||||
PMD_INIT_LOG(ERR, "virtqueue size is not powerof 2");
|
SPDK_ERRLOG("virtqueue %"PRIu16" size (%u) is not powerof 2\n",
|
||||||
|
vtpci_queue_idx, vq_size);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +123,7 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
|
|||||||
vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
|
vq = rte_zmalloc_socket(vq_name, size, RTE_CACHE_LINE_SIZE,
|
||||||
SOCKET_ID_ANY);
|
SOCKET_ID_ANY);
|
||||||
if (vq == NULL) {
|
if (vq == NULL) {
|
||||||
PMD_INIT_LOG(ERR, "can not allocate vq");
|
SPDK_ERRLOG("can not allocate vq\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
dev->vqs[vtpci_queue_idx] = vq;
|
dev->vqs[vtpci_queue_idx] = vq;
|
||||||
@ -139,7 +137,7 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
|
|||||||
*/
|
*/
|
||||||
size = vring_size(vq_size, VIRTIO_PCI_VRING_ALIGN);
|
size = vring_size(vq_size, VIRTIO_PCI_VRING_ALIGN);
|
||||||
vq->vq_ring_size = RTE_ALIGN_CEIL(size, VIRTIO_PCI_VRING_ALIGN);
|
vq->vq_ring_size = RTE_ALIGN_CEIL(size, VIRTIO_PCI_VRING_ALIGN);
|
||||||
PMD_INIT_LOG(DEBUG, "vring_size: %d, rounded_vring_size: %d",
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vring_size: %u, rounded_vring_size: %u\n",
|
||||||
size, vq->vq_ring_size);
|
size, vq->vq_ring_size);
|
||||||
|
|
||||||
mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
|
mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
|
||||||
@ -158,9 +156,9 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
|
|||||||
|
|
||||||
vq->vq_ring_mem = mz->phys_addr;
|
vq->vq_ring_mem = mz->phys_addr;
|
||||||
vq->vq_ring_virt_mem = mz->addr;
|
vq->vq_ring_virt_mem = mz->addr;
|
||||||
PMD_INIT_LOG(DEBUG, "vq->vq_ring_mem: 0x%" PRIx64,
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vq->vq_ring_mem: 0x%" PRIx64 "\n",
|
||||||
(uint64_t)mz->phys_addr);
|
(uint64_t)mz->phys_addr);
|
||||||
PMD_INIT_LOG(DEBUG, "vq->vq_ring_virt_mem: 0x%" PRIx64,
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vq->vq_ring_virt_mem: 0x%" PRIx64 "\n",
|
||||||
(uint64_t)(uintptr_t)mz->addr);
|
(uint64_t)(uintptr_t)mz->addr);
|
||||||
|
|
||||||
virtio_init_vring(vq);
|
virtio_init_vring(vq);
|
||||||
@ -168,7 +166,7 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
|
|||||||
vq->mz = mz;
|
vq->mz = mz;
|
||||||
|
|
||||||
if (vtpci_ops(dev)->setup_queue(dev, vq) < 0) {
|
if (vtpci_ops(dev)->setup_queue(dev, vq) < 0) {
|
||||||
PMD_INIT_LOG(ERR, "setup_queue failed");
|
SPDK_ERRLOG("setup_queue failed\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +213,7 @@ virtio_alloc_queues(struct virtio_dev *dev)
|
|||||||
|
|
||||||
dev->vqs = rte_zmalloc(NULL, sizeof(struct virtqueue *) * nr_vq, 0);
|
dev->vqs = rte_zmalloc(NULL, sizeof(struct virtqueue *) * nr_vq, 0);
|
||||||
if (!dev->vqs) {
|
if (!dev->vqs) {
|
||||||
PMD_INIT_LOG(ERR, "failed to allocate vqs");
|
SPDK_ERRLOG("failed to allocate %"PRIu16" vqs\n", nr_vq);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,21 +238,21 @@ virtio_negotiate_features(struct virtio_dev *dev, uint64_t req_features)
|
|||||||
uint64_t host_features = vtpci_ops(dev)->get_features(dev);
|
uint64_t host_features = vtpci_ops(dev)->get_features(dev);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "guest features = %" PRIx64, req_features);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "guest features = %" PRIx64 "\n", req_features);
|
||||||
PMD_INIT_LOG(DEBUG, "device features = %" PRIx64, host_features);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "device features = %" PRIx64 "\n", host_features);
|
||||||
|
|
||||||
rc = vtpci_ops(dev)->set_features(dev, req_features & host_features);
|
rc = vtpci_ops(dev)->set_features(dev, req_features & host_features);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
PMD_INIT_LOG(ERR, "failed to negotiate device features.");
|
SPDK_ERRLOG("failed to negotiate device features.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "negotiated features = %" PRIx64, dev->negotiated_features);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "negotiated features = %" PRIx64 "\n",
|
||||||
|
dev->negotiated_features);
|
||||||
|
|
||||||
vtpci_set_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
|
vtpci_set_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
|
||||||
if (!(vtpci_get_status(dev) & VIRTIO_CONFIG_S_FEATURES_OK)) {
|
if (!(vtpci_get_status(dev) & VIRTIO_CONFIG_S_FEATURES_OK)) {
|
||||||
PMD_INIT_LOG(ERR,
|
SPDK_ERRLOG("failed to set FEATURES_OK status!\n");
|
||||||
"failed to set FEATURES_OK status!");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +322,7 @@ virtio_dev_start(struct virtio_dev *vdev)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "Notified backend at initialization");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "Notified backend at initialization\n");
|
||||||
|
|
||||||
vdev->started = 1;
|
vdev->started = 1;
|
||||||
|
|
||||||
@ -383,8 +381,8 @@ virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct virtio_req **rx_pkts,
|
|||||||
cookie = (struct virtio_req *)vq->vq_descx[desc_idx].cookie;
|
cookie = (struct virtio_req *)vq->vq_descx[desc_idx].cookie;
|
||||||
|
|
||||||
if (spdk_unlikely(cookie == NULL)) {
|
if (spdk_unlikely(cookie == NULL)) {
|
||||||
PMD_DRV_LOG(ERR, "vring descriptor with no mbuf cookie at %u",
|
SPDK_WARNLOG("vring descriptor with no mbuf cookie at %"PRIu16"\n",
|
||||||
vq->vq_used_cons_idx);
|
vq->vq_used_cons_idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,8 +419,9 @@ virtqueue_enqueue_xmit(struct virtqueue *vq, struct virtio_req *req)
|
|||||||
struct iovec *iov = req->iov;
|
struct iovec *iov = req->iov;
|
||||||
|
|
||||||
if (total_iovs > vq->vq_free_cnt) {
|
if (total_iovs > vq->vq_free_cnt) {
|
||||||
PMD_DRV_LOG(ERR, "not enough free descriptors. requested %"PRIu32", got %"PRIu32"\n",
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV,
|
||||||
total_iovs, vq->vq_free_cnt);
|
"not enough free descriptors. requested %"PRIu32", got %"PRIu16"\n",
|
||||||
|
total_iovs, vq->vq_free_cnt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,12 +495,12 @@ virtio_recv_pkts(struct virtqueue *vq, struct virtio_req **reqs, uint16_t nb_pkt
|
|||||||
num = num - ((vq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
|
num = num - ((vq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
|
||||||
|
|
||||||
num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, num);
|
num = virtqueue_dequeue_burst_rx(vq, rcv_pkts, len, num);
|
||||||
PMD_RX_LOG(DEBUG, "used:%d dequeue:%d", nb_used, num);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "used:%"PRIu16" dequeue:%"PRIu16"\n", nb_used, num);
|
||||||
|
|
||||||
for (i = 0; i < num ; i++) {
|
for (i = 0; i < num ; i++) {
|
||||||
rxm = rcv_pkts[i];
|
rxm = rcv_pkts[i];
|
||||||
|
|
||||||
PMD_RX_LOG(DEBUG, "packet len:%d", len[i]);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "packet len:%"PRIu32"\n", len[i]);
|
||||||
|
|
||||||
rxm->data_transferred = (uint16_t)(len[i]);
|
rxm->data_transferred = (uint16_t)(len[i]);
|
||||||
|
|
||||||
@ -527,8 +526,10 @@ virtio_xmit_pkts(struct virtqueue *vq, struct virtio_req *req)
|
|||||||
|
|
||||||
if (spdk_unlikely(virtqueue_kick_prepare(vq))) {
|
if (spdk_unlikely(virtqueue_kick_prepare(vq))) {
|
||||||
vtpci_ops(vdev)->notify_queue(vdev, vq);
|
vtpci_ops(vdev)->notify_queue(vdev, vq);
|
||||||
PMD_TX_LOG(DEBUG, "Notified backend after xmit");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "Notified backend after xmit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPDK_LOG_REGISTER_TRACE_FLAG("virtio_dev", SPDK_TRACE_VIRTIO_DEV)
|
||||||
|
@ -43,8 +43,7 @@
|
|||||||
#include <rte_memory.h>
|
#include <rte_memory.h>
|
||||||
#include <rte_mempool.h>
|
#include <rte_mempool.h>
|
||||||
|
|
||||||
#include "virtio_logs.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
#include "spdk/likely.h"
|
#include "spdk/likely.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/*-
|
|
||||||
* BSD LICENSE
|
|
||||||
*
|
|
||||||
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* * Neither the name of Intel Corporation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VIRTIO_LOGS_H_
|
|
||||||
#define _VIRTIO_LOGS_H_
|
|
||||||
|
|
||||||
#include <rte_log.h>
|
|
||||||
|
|
||||||
/* Make sure DEBUG macro doesn't shadow DEBUG log level */
|
|
||||||
#ifdef DEBUG
|
|
||||||
#undef DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RTE_LIBRTE_VIRTIO_DEBUG_INIT
|
|
||||||
#define PMD_INIT_LOG(level, fmt, args...) \
|
|
||||||
RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
|
|
||||||
#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
|
|
||||||
#else
|
|
||||||
#define PMD_INIT_LOG(level, fmt, args...) do { } while(0)
|
|
||||||
#define PMD_INIT_FUNC_TRACE() do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RTE_LIBRTE_VIRTIO_DEBUG_RX
|
|
||||||
#define PMD_RX_LOG(level, fmt, args...) \
|
|
||||||
RTE_LOG(level, PMD, "%s() rx: " fmt "\n", __func__, ## args)
|
|
||||||
#else
|
|
||||||
#define PMD_RX_LOG(level, fmt, args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RTE_LIBRTE_VIRTIO_DEBUG_TX
|
|
||||||
#define PMD_TX_LOG(level, fmt, args...) \
|
|
||||||
RTE_LOG(level, PMD, "%s() tx: " fmt "\n", __func__, ## args)
|
|
||||||
#else
|
|
||||||
#define PMD_TX_LOG(level, fmt, args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef RTE_LIBRTE_VIRTIO_DEBUG_DRIVER
|
|
||||||
#define PMD_DRV_LOG(level, fmt, args...) \
|
|
||||||
RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
|
|
||||||
#else
|
|
||||||
#define PMD_DRV_LOG(level, fmt, args...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _VIRTIO_LOGS_H_ */
|
|
@ -37,7 +37,6 @@
|
|||||||
#include "spdk/mmio.h"
|
#include "spdk/mmio.h"
|
||||||
|
|
||||||
#include "virtio_pci.h"
|
#include "virtio_pci.h"
|
||||||
#include "virtio_logs.h"
|
|
||||||
|
|
||||||
struct virtio_driver g_virtio_driver = {
|
struct virtio_driver g_virtio_driver = {
|
||||||
.init_ctrlrs = TAILQ_HEAD_INITIALIZER(g_virtio_driver.init_ctrlrs),
|
.init_ctrlrs = TAILQ_HEAD_INITIALIZER(g_virtio_driver.init_ctrlrs),
|
||||||
@ -65,7 +64,7 @@ check_vq_phys_addr_ok(struct virtqueue *vq)
|
|||||||
*/
|
*/
|
||||||
if ((vq->vq_ring_mem + vq->vq_ring_size - 1) >>
|
if ((vq->vq_ring_mem + vq->vq_ring_size - 1) >>
|
||||||
(VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) {
|
(VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) {
|
||||||
PMD_INIT_LOG(ERR, "vring address shouldn't be above 16TB!");
|
SPDK_ERRLOG("vring address shouldn't be above 16TB!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +138,7 @@ static int
|
|||||||
legacy_set_features(struct virtio_dev *dev, uint64_t features)
|
legacy_set_features(struct virtio_dev *dev, uint64_t features)
|
||||||
{
|
{
|
||||||
if ((features >> 32) != 0) {
|
if ((features >> 32) != 0) {
|
||||||
PMD_DRV_LOG(ERR,
|
SPDK_ERRLOG("only 32 bit features are allowed for legacy virtio!\n");
|
||||||
"only 32 bit features are allowed for legacy virtio!");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rte_pci_ioport_write(vtpci_io(dev), &features, 4,
|
rte_pci_ioport_write(vtpci_io(dev), &features, 4,
|
||||||
@ -317,8 +315,7 @@ modern_set_features(struct virtio_dev *dev, uint64_t features)
|
|||||||
struct virtio_hw *hw = virtio_dev_get_hw(dev);
|
struct virtio_hw *hw = virtio_dev_get_hw(dev);
|
||||||
|
|
||||||
if ((features & (1ULL << VIRTIO_F_VERSION_1)) == 0) {
|
if ((features & (1ULL << VIRTIO_F_VERSION_1)) == 0) {
|
||||||
PMD_INIT_LOG(ERR,
|
SPDK_ERRLOG("VIRTIO_F_VERSION_1 feature is not enabled.\n");
|
||||||
"VIRTIO_F_VERSION_1 feature is not enabled.");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,11 +413,11 @@ modern_setup_queue(struct virtio_dev *dev, struct virtqueue *vq)
|
|||||||
|
|
||||||
spdk_mmio_write_2(&hw->common_cfg->queue_enable, 1);
|
spdk_mmio_write_2(&hw->common_cfg->queue_enable, 1);
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "queue %u addresses:", vq->vq_queue_index);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "queue %"PRIu16" addresses:\n", vq->vq_queue_index);
|
||||||
PMD_INIT_LOG(DEBUG, "\t desc_addr: %" PRIx64, desc_addr);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t desc_addr: %" PRIx64 "\n", desc_addr);
|
||||||
PMD_INIT_LOG(DEBUG, "\t aval_addr: %" PRIx64, avail_addr);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t aval_addr: %" PRIx64 "\n", avail_addr);
|
||||||
PMD_INIT_LOG(DEBUG, "\t used_addr: %" PRIx64, used_addr);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t used_addr: %" PRIx64 "\n", used_addr);
|
||||||
PMD_INIT_LOG(DEBUG, "\t notify addr: %p (notify offset: %u)",
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t notify addr: %p (notify offset: %"PRIu16")\n",
|
||||||
vq->notify_addr, notify_off);
|
vq->notify_addr, notify_off);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -524,25 +521,24 @@ get_cfg_addr(struct virtio_hw *hw, struct virtio_pci_cap *cap)
|
|||||||
uint32_t offset = cap->offset;
|
uint32_t offset = cap->offset;
|
||||||
|
|
||||||
if (bar > 5) {
|
if (bar > 5) {
|
||||||
PMD_INIT_LOG(ERR, "invalid bar: %u", bar);
|
SPDK_ERRLOG("invalid bar: %"PRIu8"\n", bar);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + length < offset) {
|
if (offset + length < offset) {
|
||||||
PMD_INIT_LOG(ERR, "offset(%u) + length(%u) overflows",
|
SPDK_ERRLOG("offset(%"PRIu32") + length(%"PRIu32") overflows\n",
|
||||||
offset, length);
|
offset, length);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + length > hw->pci_bar[bar].len) {
|
if (offset + length > hw->pci_bar[bar].len) {
|
||||||
PMD_INIT_LOG(ERR,
|
SPDK_ERRLOG("invalid cap: overflows bar space: %"PRIu32" > %"PRIu32"\n",
|
||||||
"invalid cap: overflows bar space: %u > %" PRIu64,
|
offset + length, hw->pci_bar[bar].len);
|
||||||
offset + length, dev->mem_resource[bar].len);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hw->pci_bar[bar].vaddr == NULL) {
|
if (hw->pci_bar[bar].vaddr == NULL) {
|
||||||
PMD_INIT_LOG(ERR, "bar %u base addr is NULL", bar);
|
SPDK_ERRLOG("bar %"PRIu8" base addr is NULL\n", bar);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,15 +554,14 @@ virtio_read_caps(struct virtio_hw *hw)
|
|||||||
|
|
||||||
ret = spdk_pci_device_cfg_read(hw->pci_dev, &pos, 1, PCI_CAPABILITY_LIST);
|
ret = spdk_pci_device_cfg_read(hw->pci_dev, &pos, 1, PCI_CAPABILITY_LIST);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PMD_INIT_LOG(DEBUG, "failed to read pci capability list");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "failed to read pci capability list\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pos) {
|
while (pos) {
|
||||||
ret = spdk_pci_device_cfg_read(hw->pci_dev, &cap, sizeof(cap), pos);
|
ret = spdk_pci_device_cfg_read(hw->pci_dev, &cap, sizeof(cap), pos);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PMD_INIT_LOG(ERR,
|
SPDK_ERRLOG("failed to read pci cap at pos: %"PRIx8"\n", pos);
|
||||||
"failed to read pci cap at pos: %x", pos);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,15 +569,15 @@ virtio_read_caps(struct virtio_hw *hw)
|
|||||||
hw->use_msix = 1;
|
hw->use_msix = 1;
|
||||||
|
|
||||||
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
|
if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
|
||||||
PMD_INIT_LOG(DEBUG,
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI,
|
||||||
"[%2x] skipping non VNDR cap id: %02x",
|
"[%2"PRIx8"] skipping non VNDR cap id: %02"PRIx8"\n",
|
||||||
pos, cap.cap_vndr);
|
pos, cap.cap_vndr);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG,
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI,
|
||||||
"[%2x] cfg type: %u, bar: %u, offset: %04x, len: %u",
|
"[%2"PRIx8"] cfg type: %"PRIu8", bar: %"PRIu8", offset: %04"PRIx32", len: %"PRIu32"\n",
|
||||||
pos, cap.cfg_type, cap.bar, cap.offset, cap.length);
|
pos, cap.cfg_type, cap.bar, cap.offset, cap.length);
|
||||||
|
|
||||||
switch (cap.cfg_type) {
|
switch (cap.cfg_type) {
|
||||||
case VIRTIO_PCI_CAP_COMMON_CFG:
|
case VIRTIO_PCI_CAP_COMMON_CFG:
|
||||||
@ -607,16 +602,16 @@ next:
|
|||||||
|
|
||||||
if (hw->common_cfg == NULL || hw->notify_base == NULL ||
|
if (hw->common_cfg == NULL || hw->notify_base == NULL ||
|
||||||
hw->dev_cfg == NULL || hw->isr == NULL) {
|
hw->dev_cfg == NULL || hw->isr == NULL) {
|
||||||
PMD_INIT_LOG(INFO, "no modern virtio pci device found.");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "no modern virtio pci device found.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PMD_INIT_LOG(INFO, "found modern virtio pci device.");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "found modern virtio pci device.\n");
|
||||||
|
|
||||||
PMD_INIT_LOG(DEBUG, "common cfg mapped at: %p", hw->common_cfg);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "common cfg mapped at: %p\n", hw->common_cfg);
|
||||||
PMD_INIT_LOG(DEBUG, "device cfg mapped at: %p", hw->dev_cfg);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "device cfg mapped at: %p\n", hw->dev_cfg);
|
||||||
PMD_INIT_LOG(DEBUG, "isr cfg mapped at: %p", hw->isr);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "isr cfg mapped at: %p\n", hw->isr);
|
||||||
PMD_INIT_LOG(DEBUG, "notify base: %p, notify off multiplier: %u",
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "notify base: %p, notify off multiplier: %u\n",
|
||||||
hw->notify_base, hw->notify_off_multiplier);
|
hw->notify_base, hw->notify_off_multiplier);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -634,7 +629,7 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
|
|
||||||
hw = calloc(1, sizeof(*hw));
|
hw = calloc(1, sizeof(*hw));
|
||||||
if (hw == NULL) {
|
if (hw == NULL) {
|
||||||
PMD_DRV_LOG(ERR, "calloc failed");
|
SPDK_ERRLOG("calloc failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +641,7 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
rc = spdk_pci_device_map_bar(pci_dev, i, (void *) &bar_vaddr, &bar_paddr,
|
rc = spdk_pci_device_map_bar(pci_dev, i, (void *) &bar_vaddr, &bar_paddr,
|
||||||
&bar_len);
|
&bar_len);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
PMD_DRV_LOG(ERR, "failed to memmap PCI BAR %d", i);
|
SPDK_ERRLOG("failed to memmap PCI BAR %u\n", i);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +655,7 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
* virtio handling.
|
* virtio handling.
|
||||||
*/
|
*/
|
||||||
if (virtio_read_caps(hw) == 0) {
|
if (virtio_read_caps(hw) == 0) {
|
||||||
PMD_INIT_LOG(INFO, "modern virtio pci detected.");
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "modern virtio pci detected.\n");
|
||||||
rc = vtpci_init(vdev, &modern_ops);
|
rc = vtpci_init(vdev, &modern_ops);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto err;
|
goto err;
|
||||||
@ -714,7 +709,7 @@ vtpci_init(struct virtio_dev *vdev, const struct virtio_pci_ops *ops)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vdev_num == VIRTIO_MAX_DEVICES) {
|
if (vdev_num == VIRTIO_MAX_DEVICES) {
|
||||||
PMD_INIT_LOG(ERR, "Max vhost device limit reached (%d).", VIRTIO_MAX_DEVICES);
|
SPDK_ERRLOG("Max vhost device limit reached (%u).\n", VIRTIO_MAX_DEVICES);
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -728,7 +723,7 @@ int
|
|||||||
vtpci_enumerate_pci(void)
|
vtpci_enumerate_pci(void)
|
||||||
{
|
{
|
||||||
if (!spdk_process_is_primary()) {
|
if (!spdk_process_is_primary()) {
|
||||||
PMD_INIT_LOG(INFO, "virtio_pci secondary process support is not implemented yet.");
|
SPDK_WARNLOG("virtio_pci secondary process support is not implemented yet.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,3 +741,5 @@ vtpci_deinit(uint32_t id)
|
|||||||
{
|
{
|
||||||
g_virtio_driver.internal[id].vtpci_ops = NULL;
|
g_virtio_driver.internal[id].vtpci_ops = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPDK_LOG_REGISTER_TRACE_FLAG("virtio_pci", SPDK_TRACE_VIRTIO_PCI)
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include <rte_alarm.h>
|
#include <rte_alarm.h>
|
||||||
|
|
||||||
#include "virtio_dev.h"
|
#include "virtio_dev.h"
|
||||||
#include "virtio_logs.h"
|
|
||||||
#include "virtio_pci.h"
|
#include "virtio_pci.h"
|
||||||
#include "virtio_user/virtio_user_dev.h"
|
#include "virtio_user/virtio_user_dev.h"
|
||||||
|
|
||||||
@ -57,14 +56,14 @@ static void
|
|||||||
virtio_user_read_dev_config(struct virtio_dev *vdev, size_t offset,
|
virtio_user_read_dev_config(struct virtio_dev *vdev, size_t offset,
|
||||||
void *dst, int length)
|
void *dst, int length)
|
||||||
{
|
{
|
||||||
PMD_DRV_LOG(ERR, "not supported offset=%zu, len=%d", offset, length);
|
SPDK_ERRLOG("not supported offset=%zu, len=%d\n", offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virtio_user_write_dev_config(struct virtio_dev *vdev, size_t offset,
|
virtio_user_write_dev_config(struct virtio_dev *vdev, size_t offset,
|
||||||
const void *src, int length)
|
const void *src, int length)
|
||||||
{
|
{
|
||||||
PMD_DRV_LOG(ERR, "not supported offset=%zu, len=%d", offset, length);
|
SPDK_ERRLOG("not supported offset=%zu, len=%d\n", offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -96,7 +95,7 @@ virtio_user_get_features(struct virtio_dev *vdev)
|
|||||||
uint64_t features;
|
uint64_t features;
|
||||||
|
|
||||||
if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES, &features) < 0) {
|
if (dev->ops->send_request(dev, VHOST_USER_GET_FEATURES, &features) < 0) {
|
||||||
PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno));
|
SPDK_ERRLOG("get_features failed: %s\n", strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ virtio_user_setup_queue(struct virtio_dev *vdev, struct virtqueue *vq)
|
|||||||
int kickfd;
|
int kickfd;
|
||||||
|
|
||||||
if (dev->callfds[queue_idx] != -1 || dev->kickfds[queue_idx] != -1) {
|
if (dev->callfds[queue_idx] != -1 || dev->kickfds[queue_idx] != -1) {
|
||||||
PMD_DRV_LOG(ERR, "queue %u already exists", queue_sel);
|
SPDK_ERRLOG("queue %"PRIu16" already exists\n", queue_idx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,13 +177,13 @@ virtio_user_setup_queue(struct virtio_dev *vdev, struct virtqueue *vq)
|
|||||||
*/
|
*/
|
||||||
callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||||
if (callfd < 0) {
|
if (callfd < 0) {
|
||||||
PMD_DRV_LOG(ERR, "callfd error, %s", strerror(errno));
|
SPDK_ERRLOG("callfd error, %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||||
if (kickfd < 0) {
|
if (kickfd < 0) {
|
||||||
PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
|
SPDK_ERRLOG("kickfd error, %s\n", strerror(errno));
|
||||||
close(callfd);
|
close(callfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -233,8 +232,7 @@ virtio_user_notify_queue(struct virtio_dev *vdev, struct virtqueue *vq)
|
|||||||
struct virtio_user_dev *dev = virtio_dev_get_user_dev(vdev);
|
struct virtio_user_dev *dev = virtio_dev_get_user_dev(vdev);
|
||||||
|
|
||||||
if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0)
|
if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0)
|
||||||
PMD_DRV_LOG(ERR, "failed to kick backend: %s",
|
SPDK_ERRLOG("failed to kick backend: %s.\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -38,8 +38,9 @@
|
|||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/ioctl.h>
|
#include <linux/ioctl.h>
|
||||||
|
|
||||||
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
#include "../virtio_pci.h"
|
#include "../virtio_pci.h"
|
||||||
#include "../virtio_logs.h"
|
|
||||||
|
|
||||||
struct vhost_vring_state {
|
struct vhost_vring_state {
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
@ -122,15 +122,15 @@ vhost_user_read(int fd, struct vhost_user_msg *msg)
|
|||||||
|
|
||||||
ret = recv(fd, (void *)msg, sz_hdr, 0);
|
ret = recv(fd, (void *)msg, sz_hdr, 0);
|
||||||
if (ret < sz_hdr) {
|
if (ret < sz_hdr) {
|
||||||
PMD_DRV_LOG(ERR, "Failed to recv msg hdr: %d instead of %d.",
|
SPDK_WARNLOG("Failed to recv msg hdr: %d instead of %d.\n",
|
||||||
ret, sz_hdr);
|
ret, sz_hdr);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* validate msg flags */
|
/* validate msg flags */
|
||||||
if (msg->flags != (valid_flags)) {
|
if (msg->flags != (valid_flags)) {
|
||||||
PMD_DRV_LOG(ERR, "Failed to recv msg: flags %x instead of %x.",
|
SPDK_WARNLOG("Failed to recv msg: flags %"PRIx32" instead of %"PRIx32".\n",
|
||||||
msg->flags, valid_flags);
|
msg->flags, valid_flags);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,9 +138,8 @@ vhost_user_read(int fd, struct vhost_user_msg *msg)
|
|||||||
if (sz_payload) {
|
if (sz_payload) {
|
||||||
ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0);
|
ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0);
|
||||||
if (ret < sz_payload) {
|
if (ret < sz_payload) {
|
||||||
PMD_DRV_LOG(ERR,
|
SPDK_WARNLOG("Failed to recv msg payload: %d instead of %"PRIu32".\n",
|
||||||
"Failed to recv msg payload: %d instead of %d.",
|
ret, msg->size);
|
||||||
ret, msg->size);
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,14 +176,14 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max)
|
|||||||
|
|
||||||
f = fopen("/proc/self/maps", "r");
|
f = fopen("/proc/self/maps", "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PMD_DRV_LOG(ERR, "cannot open /proc/self/maps");
|
SPDK_ERRLOG("cannot open /proc/self/maps\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||||
if (sscanf(buf, "%" PRIx64 "-%" PRIx64, &v_start, &v_end) < 2) {
|
if (sscanf(buf, "%" PRIx64 "-%" PRIx64, &v_start, &v_end) < 2) {
|
||||||
PMD_DRV_LOG(ERR, "Failed to parse address");
|
SPDK_ERRLOG("Failed to parse address\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +213,7 @@ get_hugepage_file_info(struct hugepage_file_info huges[], int max)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (idx >= max) {
|
if (idx >= max) {
|
||||||
PMD_DRV_LOG(ERR, "Exceed maximum of %d", max);
|
SPDK_ERRLOG("Exceed maximum of %d\n", max);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
huges[idx].addr = v_start;
|
huges[idx].addr = v_start;
|
||||||
@ -239,7 +238,7 @@ prepare_vhost_memory_user(struct vhost_user_msg *msg, int fds[])
|
|||||||
|
|
||||||
num = get_hugepage_file_info(huges, VHOST_MEMORY_MAX_NREGIONS);
|
num = get_hugepage_file_info(huges, VHOST_MEMORY_MAX_NREGIONS);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
PMD_INIT_LOG(ERR, "Failed to prepare memory for vhost-user");
|
SPDK_ERRLOG("Failed to prepare memory for vhost-user\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +290,7 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
|||||||
|
|
||||||
RTE_SET_USED(m);
|
RTE_SET_USED(m);
|
||||||
|
|
||||||
PMD_DRV_LOG(INFO, "%d = %s", req, vhost_msg_strings[req]);
|
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_USER, "sent message %d = %s\n", req, vhost_msg_strings[req]);
|
||||||
|
|
||||||
msg.request = req;
|
msg.request = req;
|
||||||
msg.flags = VHOST_USER_VERSION;
|
msg.flags = VHOST_USER_VERSION;
|
||||||
@ -357,13 +356,13 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PMD_DRV_LOG(ERR, "trying to send unhandled msg type");
|
SPDK_ERRLOG("trying to send unhandled msg type\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = VHOST_USER_HDR_SIZE + msg.size;
|
len = VHOST_USER_HDR_SIZE + msg.size;
|
||||||
if (vhost_user_write(vhostfd, &msg, len, fds, fd_num) < 0) {
|
if (vhost_user_write(vhostfd, &msg, len, fds, fd_num) < 0) {
|
||||||
PMD_DRV_LOG(ERR, "%s failed: %s",
|
SPDK_ERRLOG("%s failed: %s\n",
|
||||||
vhost_msg_strings[req], strerror(errno));
|
vhost_msg_strings[req], strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -374,13 +373,13 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
|||||||
|
|
||||||
if (need_reply) {
|
if (need_reply) {
|
||||||
if (vhost_user_read(vhostfd, &msg) < 0) {
|
if (vhost_user_read(vhostfd, &msg) < 0) {
|
||||||
PMD_DRV_LOG(ERR, "Received msg failed: %s",
|
SPDK_WARNLOG("Received msg failed: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req != msg.request) {
|
if (req != msg.request) {
|
||||||
PMD_DRV_LOG(ERR, "Received unexpected msg type");
|
SPDK_WARNLOG("Received unexpected msg type\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,21 +387,21 @@ vhost_user_sock(struct virtio_user_dev *dev,
|
|||||||
case VHOST_USER_GET_FEATURES:
|
case VHOST_USER_GET_FEATURES:
|
||||||
case VHOST_USER_GET_QUEUE_NUM:
|
case VHOST_USER_GET_QUEUE_NUM:
|
||||||
if (msg.size != sizeof(m.payload.u64)) {
|
if (msg.size != sizeof(m.payload.u64)) {
|
||||||
PMD_DRV_LOG(ERR, "Received bad msg size");
|
SPDK_WARNLOG("Received bad msg size\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*((__u64 *)arg) = msg.payload.u64;
|
*((__u64 *)arg) = msg.payload.u64;
|
||||||
break;
|
break;
|
||||||
case VHOST_USER_GET_VRING_BASE:
|
case VHOST_USER_GET_VRING_BASE:
|
||||||
if (msg.size != sizeof(m.payload.state)) {
|
if (msg.size != sizeof(m.payload.state)) {
|
||||||
PMD_DRV_LOG(ERR, "Received bad msg size");
|
SPDK_WARNLOG("Received bad msg size\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(arg, &msg.payload.state,
|
memcpy(arg, &msg.payload.state,
|
||||||
sizeof(struct vhost_vring_state));
|
sizeof(struct vhost_vring_state));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PMD_DRV_LOG(ERR, "Received unexpected msg type");
|
SPDK_WARNLOG("Received unexpected msg type\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,24 +426,24 @@ vhost_user_setup(struct virtio_user_dev *dev)
|
|||||||
|
|
||||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
PMD_DRV_LOG(ERR, "socket() error, %s", strerror(errno));
|
SPDK_ERRLOG("socket() error, %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flag = fcntl(fd, F_GETFD);
|
flag = fcntl(fd, F_GETFD);
|
||||||
if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
|
if (fcntl(fd, F_SETFD, flag | FD_CLOEXEC) < 0)
|
||||||
PMD_DRV_LOG(WARNING, "fcntl failed, %s", strerror(errno));
|
SPDK_ERRLOG("fcntl failed, %s\n", strerror(errno));
|
||||||
|
|
||||||
memset(&un, 0, sizeof(un));
|
memset(&un, 0, sizeof(un));
|
||||||
un.sun_family = AF_UNIX;
|
un.sun_family = AF_UNIX;
|
||||||
rc = snprintf(un.sun_path, sizeof(un.sun_path), "%s", dev->path);
|
rc = snprintf(un.sun_path, sizeof(un.sun_path), "%s", dev->path);
|
||||||
if (rc < 0 || (size_t)rc >= sizeof(un.sun_path)) {
|
if (rc < 0 || (size_t)rc >= sizeof(un.sun_path)) {
|
||||||
PMD_DRV_LOG(ERR, "socket path too long");
|
SPDK_ERRLOG("socket path too long\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (connect(fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
if (connect(fd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
||||||
PMD_DRV_LOG(ERR, "connect error, %s", strerror(errno));
|
SPDK_ERRLOG("connect error, %s\n", strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -457,3 +456,5 @@ struct virtio_user_backend_ops ops_user = {
|
|||||||
.setup = vhost_user_setup,
|
.setup = vhost_user_setup,
|
||||||
.send_request = vhost_user_sock,
|
.send_request = vhost_user_sock,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SPDK_LOG_REGISTER_TRACE_FLAG("virtio_user", SPDK_TRACE_VIRTIO_USER)
|
||||||
|
@ -119,7 +119,7 @@ virtio_user_queue_setup(struct virtio_user_dev *dev,
|
|||||||
|
|
||||||
for (i = 0; i < dev->vdev.max_queues; ++i) {
|
for (i = 0; i < dev->vdev.max_queues; ++i) {
|
||||||
if (fn(dev, i) < 0) {
|
if (fn(dev, i) < 0) {
|
||||||
PMD_DRV_LOG(INFO, "setup tx vq fails: %u", i);
|
SPDK_ERRLOG("setup tx vq fails: %"PRIu32".\n", i);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ virtio_user_dev_init(char *path, int queue_size)
|
|||||||
vdev->is_hw = 0;
|
vdev->is_hw = 0;
|
||||||
|
|
||||||
if (vtpci_init(vdev, &virtio_user_ops) != 0) {
|
if (vtpci_init(vdev, &virtio_user_ops) != 0) {
|
||||||
PMD_INIT_LOG(ERR, "Failed to init device: %s", path);
|
SPDK_ERRLOG("Failed to init device: %s\n", path);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,24 +197,24 @@ virtio_user_dev_init(char *path, int queue_size)
|
|||||||
dev->queue_size = queue_size;
|
dev->queue_size = queue_size;
|
||||||
|
|
||||||
if (virtio_user_dev_setup(dev) < 0) {
|
if (virtio_user_dev_setup(dev) < 0) {
|
||||||
PMD_INIT_LOG(ERR, "backend set up fails");
|
SPDK_ERRLOG("backend set up fails\n");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->ops->send_request(dev, VHOST_USER_GET_QUEUE_NUM, &max_queues) < 0) {
|
if (dev->ops->send_request(dev, VHOST_USER_GET_QUEUE_NUM, &max_queues) < 0) {
|
||||||
PMD_INIT_LOG(ERR, "get_queue_num fails: %s", strerror(errno));
|
SPDK_ERRLOG("get_queue_num fails: %s\n", strerror(errno));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_queues >= VIRTIO_MAX_VIRTQUEUES) {
|
if (max_queues >= VIRTIO_MAX_VIRTQUEUES) {
|
||||||
PMD_INIT_LOG(ERR, "invalid get_queue_num value: %lu", max_queues);
|
SPDK_ERRLOG("invalid get_queue_num value: %"PRIu64"\n", max_queues);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
vdev->max_queues = max_queues;
|
vdev->max_queues = max_queues;
|
||||||
|
|
||||||
if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL) < 0) {
|
if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER, NULL) < 0) {
|
||||||
PMD_INIT_LOG(ERR, "set_owner fails: %s", strerror(errno));
|
SPDK_ERRLOG("set_owner fails: %s\n", strerror(errno));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user