env: add pci_virtio.c

This patch only adds the pci_virtio.c file,
without changing any functionality. This
is required for future rte_virtio migration
to SPDK.

Change-Id: I7774cdfdaf8934fde588e25b5db5dd86a9cbfb3f
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/379484
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-09-21 17:11:06 +02:00 committed by Jim Harris
parent 5bea1429e9
commit d68001abd8
4 changed files with 82 additions and 1 deletions

View File

@ -302,6 +302,7 @@ typedef int (*spdk_pci_enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_dev)
int spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
int spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
int spdk_pci_virtio_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx);
struct spdk_pci_device *spdk_pci_get_device(struct spdk_pci_addr *pci_addr);
@ -340,6 +341,8 @@ int spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
struct spdk_pci_addr *pci_address);
int spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
struct spdk_pci_addr *pci_address);
int spdk_pci_virtio_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
struct spdk_pci_addr *pci_address);
int spdk_pci_device_cfg_read(struct spdk_pci_device *dev, void *value, uint32_t len,
uint32_t offset);

View File

@ -48,6 +48,7 @@ extern "C" {
#define SPDK_PCI_VID_INTEL 0x8086
#define SPDK_PCI_VID_MEMBLAZE 0x1c5f
#define SPDK_PCI_VID_VIRTUALBOX 0x80ee
#define SPDK_PCI_VID_VIRTIO 0x1af4
/**
* PCI class code for NVMe devices.
@ -114,6 +115,8 @@ extern "C" {
#define PCI_DEVICE_ID_INTEL_IOAT_SKX 0x2021
#define PCI_DEVICE_ID_VIRTIO_SCSI_MODERN 0x1004
#ifdef __cplusplus
}
#endif

View File

@ -36,7 +36,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
CFLAGS += $(ENV_CFLAGS)
C_SRCS = env.c memory.c pci.c vtophys.c init.c threads.c
C_SRCS += pci_nvme.c pci_ioat.c
C_SRCS += pci_nvme.c pci_ioat.c pci_virtio.c
LIBNAME = env_dpdk
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk

75
lib/env_dpdk/pci_virtio.c Normal file
View File

@ -0,0 +1,75 @@
/*-
* BSD LICENSE
*
* Copyright (c) Intel Corporation.
* 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.
*/
#include "env_internal.h"
#include "spdk/pci_ids.h"
static struct rte_pci_id virtio_pci_driver_id[] = {
{ RTE_PCI_DEVICE(SPDK_PCI_VID_VIRTIO, PCI_DEVICE_ID_VIRTIO_SCSI_MODERN) },
{ .vendor_id = 0, /* sentinel */ },
};
static struct spdk_pci_enum_ctx g_virtio_pci_drv = {
.driver = {
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
.id_table = virtio_pci_driver_id,
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
.probe = spdk_pci_device_init,
.remove = spdk_pci_device_fini,
.driver.name = "spdk_virtio",
#else
.devinit = spdk_pci_device_init,
.devuninit = spdk_pci_device_fini,
.name = "spdk_virtio",
#endif
},
.cb_fn = NULL,
.cb_arg = NULL,
.mtx = PTHREAD_MUTEX_INITIALIZER,
.is_registered = false,
};
int
spdk_pci_virtio_device_attach(spdk_pci_enum_cb enum_cb,
void *enum_ctx, struct spdk_pci_addr *pci_address)
{
return spdk_pci_device_attach(&g_virtio_pci_drv, enum_cb, enum_ctx, pci_address);
}
int
spdk_pci_virtio_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
{
return spdk_pci_enumerate(&g_virtio_pci_drv, enum_cb, enum_ctx);
}