Commit 14db5b66 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Daniel Verkamp
Browse files

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: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/382620


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 7e4f3dbf
Loading
Loading
Loading
Loading
+28 −27
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@
#include "virtio_user/vhost.h"
#include "virtio_dev.h"
#include "virtio_pci.h"
#include "virtio_logs.h"

static void
virtio_init_vring(struct virtqueue *vq)
@@ -66,8 +65,6 @@ virtio_init_vring(struct virtqueue *vq)
	struct vring *vr = &vq->vq_ring;
	uint8_t *ring_mem = vq->vq_ring_virt_mem;

	PMD_INIT_FUNC_TRACE();

	/*
	 * 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;
	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
	 * Always power of 2 and if 0 virtqueue does not exist
	 */
	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) {
		PMD_INIT_LOG(ERR, "virtqueue does not exist");
		SPDK_ERRLOG("virtqueue %"PRIu16" does not exist\n", vtpci_queue_idx);
		return -EINVAL;
	}

	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;
	}

@@ -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,
				SOCKET_ID_ANY);
	if (vq == NULL) {
		PMD_INIT_LOG(ERR, "can not allocate vq");
		SPDK_ERRLOG("can not allocate vq\n");
		return -ENOMEM;
	}
	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);
	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);

	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_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);
	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);

	virtio_init_vring(vq);
@@ -168,7 +166,7 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
	vq->mz = mz;

	if (vtpci_ops(dev)->setup_queue(dev, vq) < 0) {
		PMD_INIT_LOG(ERR, "setup_queue failed");
		SPDK_ERRLOG("setup_queue failed\n");
		return -EINVAL;
	}

@@ -215,7 +213,7 @@ virtio_alloc_queues(struct virtio_dev *dev)

	dev->vqs = rte_zmalloc(NULL, sizeof(struct virtqueue *) * nr_vq, 0);
	if (!dev->vqs) {
		PMD_INIT_LOG(ERR, "failed to allocate vqs");
		SPDK_ERRLOG("failed to allocate %"PRIu16" vqs\n", nr_vq);
		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);
	int rc;

	PMD_INIT_LOG(DEBUG, "guest features = %" PRIx64, req_features);
	PMD_INIT_LOG(DEBUG, "device features = %" PRIx64, host_features);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "guest features = %" PRIx64 "\n", req_features);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "device features = %" PRIx64 "\n", host_features);

	rc = vtpci_ops(dev)->set_features(dev, req_features & host_features);
	if (rc != 0) {
		PMD_INIT_LOG(ERR, "failed to negotiate device features.");
		SPDK_ERRLOG("failed to negotiate device features.\n");
		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);
	if (!(vtpci_get_status(dev) & VIRTIO_CONFIG_S_FEATURES_OK)) {
		PMD_INIT_LOG(ERR,
			     "failed to set FEATURES_OK status!");
		SPDK_ERRLOG("failed to set FEATURES_OK status!\n");
		return -1;
	}

@@ -324,7 +322,7 @@ virtio_dev_start(struct virtio_dev *vdev)
	}
#endif

	PMD_INIT_LOG(DEBUG, "Notified backend at initialization");
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "Notified backend at initialization\n");

	vdev->started = 1;

@@ -383,7 +381,7 @@ virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct virtio_req **rx_pkts,
		cookie = (struct virtio_req *)vq->vq_descx[desc_idx].cookie;

		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);
			break;
		}
@@ -421,7 +419,8 @@ virtqueue_enqueue_xmit(struct virtqueue *vq, struct virtio_req *req)
	struct iovec *iov = req->iov;

	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,
			      "not enough free descriptors. requested %"PRIu32", got %"PRIu16"\n",
			      total_iovs, vq->vq_free_cnt);
		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 = 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++) {
		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]);

@@ -527,8 +526,10 @@ virtio_xmit_pkts(struct virtqueue *vq, struct virtio_req *req)

	if (spdk_unlikely(virtqueue_kick_prepare(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;
}

SPDK_LOG_REGISTER_TRACE_FLAG("virtio_dev", SPDK_TRACE_VIRTIO_DEV)
+1 −2
Original line number Diff line number Diff line
@@ -43,8 +43,7 @@
#include <rte_memory.h>
#include <rte_mempool.h>

#include "virtio_logs.h"

#include "spdk_internal/log.h"
#include "spdk/likely.h"

/*
+0 −75
Original line number Diff line number Diff line
/*-
 *   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_ */
+34 −37
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include "spdk/mmio.h"

#include "virtio_pci.h"
#include "virtio_logs.h"

struct virtio_driver g_virtio_driver = {
	.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) >>
			(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;
	}

@@ -139,8 +138,7 @@ static int
legacy_set_features(struct virtio_dev *dev, uint64_t features)
{
	if ((features >> 32) != 0) {
		PMD_DRV_LOG(ERR,
			"only 32 bit features are allowed for legacy virtio!");
		SPDK_ERRLOG("only 32 bit features are allowed for legacy virtio!\n");
		return -1;
	}
	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);

	if ((features & (1ULL << VIRTIO_F_VERSION_1)) == 0) {
		PMD_INIT_LOG(ERR,
			     "VIRTIO_F_VERSION_1 feature is not enabled.");
		SPDK_ERRLOG("VIRTIO_F_VERSION_1 feature is not enabled.\n");
		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);

	PMD_INIT_LOG(DEBUG, "queue %u addresses:", vq->vq_queue_index);
	PMD_INIT_LOG(DEBUG, "\t desc_addr: %" PRIx64, desc_addr);
	PMD_INIT_LOG(DEBUG, "\t aval_addr: %" PRIx64, avail_addr);
	PMD_INIT_LOG(DEBUG, "\t used_addr: %" PRIx64, used_addr);
	PMD_INIT_LOG(DEBUG, "\t notify addr: %p (notify offset: %u)",
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "queue %"PRIu16" addresses:\n", vq->vq_queue_index);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t desc_addr: %" PRIx64 "\n", desc_addr);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t aval_addr: %" PRIx64 "\n", avail_addr);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t used_addr: %" PRIx64 "\n", used_addr);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "\t notify addr: %p (notify offset: %"PRIu16")\n",
		vq->notify_addr, notify_off);

	return 0;
@@ -524,25 +521,24 @@ get_cfg_addr(struct virtio_hw *hw, struct virtio_pci_cap *cap)
	uint32_t offset = cap->offset;

	if (bar > 5) {
		PMD_INIT_LOG(ERR, "invalid bar: %u", bar);
		SPDK_ERRLOG("invalid bar: %"PRIu8"\n", bar);
		return NULL;
	}

	if (offset + length < offset) {
		PMD_INIT_LOG(ERR, "offset(%u) + length(%u) overflows",
		SPDK_ERRLOG("offset(%"PRIu32") + length(%"PRIu32") overflows\n",
			offset, length);
		return NULL;
	}

	if (offset + length > hw->pci_bar[bar].len) {
		PMD_INIT_LOG(ERR,
			"invalid cap: overflows bar space: %u > %" PRIu64,
			offset + length, dev->mem_resource[bar].len);
		SPDK_ERRLOG("invalid cap: overflows bar space: %"PRIu32" > %"PRIu32"\n",
			    offset + length, hw->pci_bar[bar].len);
		return 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;
	}

@@ -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);
	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;
	}

	while (pos) {
		ret = spdk_pci_device_cfg_read(hw->pci_dev, &cap, sizeof(cap), pos);
		if (ret < 0) {
			PMD_INIT_LOG(ERR,
				"failed to read pci cap at pos: %x", pos);
			SPDK_ERRLOG("failed to read pci cap at pos: %"PRIx8"\n", pos);
			break;
		}

@@ -574,14 +569,14 @@ virtio_read_caps(struct virtio_hw *hw)
			hw->use_msix = 1;

		if (cap.cap_vndr != PCI_CAP_ID_VNDR) {
			PMD_INIT_LOG(DEBUG,
				"[%2x] skipping non VNDR cap id: %02x",
			SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI,
				      "[%2"PRIx8"] skipping non VNDR cap id: %02"PRIx8"\n",
				      pos, cap.cap_vndr);
			goto next;
		}

		PMD_INIT_LOG(DEBUG,
			"[%2x] cfg type: %u, bar: %u, offset: %04x, len: %u",
		SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI,
			      "[%2"PRIx8"] cfg type: %"PRIu8", bar: %"PRIu8", offset: %04"PRIx32", len: %"PRIu32"\n",
			      pos, cap.cfg_type, cap.bar, cap.offset, cap.length);

		switch (cap.cfg_type) {
@@ -607,16 +602,16 @@ next:

	if (hw->common_cfg == NULL || hw->notify_base == 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;
	}

	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);
	PMD_INIT_LOG(DEBUG, "device cfg mapped at: %p", hw->dev_cfg);
	PMD_INIT_LOG(DEBUG, "isr cfg mapped at: %p", hw->isr);
	PMD_INIT_LOG(DEBUG, "notify base: %p, notify off multiplier: %u",
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "common cfg mapped at: %p\n", hw->common_cfg);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "device cfg mapped at: %p\n", hw->dev_cfg);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "isr cfg mapped at: %p\n", hw->isr);
	SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_PCI, "notify base: %p, notify off multiplier: %u\n",
		hw->notify_base, hw->notify_off_multiplier);

	return 0;
@@ -634,7 +629,7 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)

	hw = calloc(1, sizeof(*hw));
	if (hw == NULL) {
		PMD_DRV_LOG(ERR, "calloc failed");
		SPDK_ERRLOG("calloc failed\n");
		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,
					     &bar_len);
		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;
		}

@@ -660,7 +655,7 @@ pci_enum_virtio_probe_cb(void *ctx, struct spdk_pci_device *pci_dev)
	 * virtio handling.
	 */
	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);
		if (rc != 0) {
			goto err;
@@ -714,7 +709,7 @@ vtpci_init(struct virtio_dev *vdev, const struct virtio_pci_ops *ops)
	}

	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;
	}

@@ -728,7 +723,7 @@ int
vtpci_enumerate_pci(void)
{
	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;
	}

@@ -746,3 +741,5 @@ vtpci_deinit(uint32_t id)
{
	g_virtio_driver.internal[id].vtpci_ops = NULL;
}

SPDK_LOG_REGISTER_TRACE_FLAG("virtio_pci", SPDK_TRACE_VIRTIO_PCI)
+7 −9
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@
#include <rte_alarm.h>

#include "virtio_dev.h"
#include "virtio_logs.h"
#include "virtio_pci.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,
		     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
virtio_user_write_dev_config(struct virtio_dev *vdev, size_t offset,
		      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
@@ -96,7 +95,7 @@ virtio_user_get_features(struct virtio_dev *vdev)
	uint64_t features;

	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;
	}

@@ -168,7 +167,7 @@ virtio_user_setup_queue(struct virtio_dev *vdev, struct virtqueue *vq)
	int kickfd;

	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;
	}

@@ -178,13 +177,13 @@ virtio_user_setup_queue(struct virtio_dev *vdev, struct virtqueue *vq)
	 */
	callfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
	if (callfd < 0) {
		PMD_DRV_LOG(ERR, "callfd error, %s", strerror(errno));
		SPDK_ERRLOG("callfd error, %s\n", strerror(errno));
		return -1;
	}

	kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
	if (kickfd < 0) {
		PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno));
		SPDK_ERRLOG("kickfd error, %s\n", strerror(errno));
		close(callfd);
		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);

	if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0)
		PMD_DRV_LOG(ERR, "failed to kick backend: %s",
			    strerror(errno));
		SPDK_ERRLOG("failed to kick backend: %s.\n", strerror(errno));
}

static void
Loading