env: split PCI drivers into individual files
Change the PCI enumeration API to individual functions per device type so that only the drivers that are actually in use get linked into the final executable. All of the common code is still shared internally in the env_dpdk library. Change-Id: I2ba83afe59202a510f999a0674e23e60b6581221 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
dfe9fa9bea
commit
f93fd72680
@ -167,11 +167,6 @@ void spdk_vtophys_register(void *vaddr, uint64_t len);
|
||||
*/
|
||||
void spdk_vtophys_unregister(void *vaddr, uint64_t len);
|
||||
|
||||
enum spdk_pci_device_type {
|
||||
SPDK_PCI_DEVICE_NVME,
|
||||
SPDK_PCI_DEVICE_IOAT,
|
||||
};
|
||||
|
||||
struct spdk_pci_addr {
|
||||
uint16_t domain;
|
||||
uint8_t bus;
|
||||
@ -188,9 +183,8 @@ struct spdk_pci_id {
|
||||
|
||||
typedef int (*spdk_pci_enum_cb)(void *enum_ctx, struct spdk_pci_device *pci_dev);
|
||||
|
||||
int spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx);
|
||||
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_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
||||
@ -213,9 +207,11 @@ struct spdk_pci_id spdk_pci_device_get_id(struct spdk_pci_device *dev);
|
||||
int spdk_pci_device_get_serial_number(struct spdk_pci_device *dev, char *sn, size_t len);
|
||||
int spdk_pci_device_claim(const struct spdk_pci_addr *pci_addr);
|
||||
void spdk_pci_device_detach(struct spdk_pci_device *device);
|
||||
int spdk_pci_device_attach(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx, struct spdk_pci_addr *pci_addres);
|
||||
|
||||
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_device_cfg_read8(struct spdk_pci_device *dev, uint8_t *value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_write8(struct spdk_pci_device *dev, uint8_t value, uint32_t offset);
|
||||
|
@ -36,6 +36,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(DPDK_INC)
|
||||
C_SRCS = env.c pci.c vtophys.c
|
||||
C_SRCS += pci_nvme.c pci_ioat.c
|
||||
LIBNAME = env_dpdk
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
73
lib/env_dpdk/env_internal.h
Normal file
73
lib/env_dpdk/env_internal.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_ENV_INTERNAL_H
|
||||
#define SPDK_ENV_INTERNAL_H
|
||||
|
||||
#define spdk_pci_device rte_pci_device
|
||||
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <rte_config.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_version.h>
|
||||
#include <rte_dev.h>
|
||||
|
||||
struct spdk_pci_enum_ctx {
|
||||
struct rte_pci_driver driver;
|
||||
spdk_pci_enum_cb cb_fn;
|
||||
void *cb_arg;
|
||||
pthread_mutex_t mtx;
|
||||
};
|
||||
|
||||
int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device);
|
||||
int spdk_pci_device_fini(struct rte_pci_device *device);
|
||||
|
||||
int spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
int spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx, spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||
struct spdk_pci_addr *pci_address);
|
||||
|
||||
#endif
|
@ -31,112 +31,16 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <rte_config.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_version.h>
|
||||
#include <rte_dev.h>
|
||||
|
||||
#define spdk_pci_device rte_pci_device
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/pciio.h>
|
||||
#endif
|
||||
#include "env_internal.h"
|
||||
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/pci_ids.h"
|
||||
|
||||
#define SYSFS_PCI_DRIVERS "/sys/bus/pci/drivers"
|
||||
|
||||
#define PCI_CFG_SIZE 256
|
||||
#define PCI_EXT_CAP_ID_SN 0x03
|
||||
|
||||
struct spdk_pci_enum_ctx {
|
||||
struct rte_pci_driver driver;
|
||||
spdk_pci_enum_cb cb_fn;
|
||||
void *cb_arg;
|
||||
pthread_mutex_t mtx;
|
||||
};
|
||||
|
||||
static struct rte_pci_id nvme_pci_driver_id[] = {
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 1)
|
||||
{
|
||||
.class_id = SPDK_PCI_CLASS_NVME,
|
||||
.vendor_id = PCI_ANY_ID,
|
||||
.device_id = PCI_ANY_ID,
|
||||
.subsystem_vendor_id = PCI_ANY_ID,
|
||||
.subsystem_device_id = PCI_ANY_ID,
|
||||
},
|
||||
#else
|
||||
{RTE_PCI_DEVICE(0x8086, 0x0953)},
|
||||
#endif
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
#define SPDK_IOAT_PCI_DEVICE(DEVICE_ID) RTE_PCI_DEVICE(SPDK_PCI_VID_INTEL, DEVICE_ID)
|
||||
static struct rte_pci_id ioat_driver_id[] = {
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB9)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW9)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX9)},
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static int
|
||||
int
|
||||
spdk_pci_device_init(struct rte_pci_driver *driver,
|
||||
struct rte_pci_device *device)
|
||||
{
|
||||
@ -163,108 +67,12 @@ spdk_pci_device_init(struct rte_pci_driver *driver,
|
||||
return ctx->cb_fn(ctx->cb_arg, (struct spdk_pci_device *)device);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
spdk_pci_device_fini(struct rte_pci_device *device)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
||||
.id_table = nvme_pci_driver_id,
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
.name = "spdk_nvme",
|
||||
#endif
|
||||
},
|
||||
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
RTE_PMD_REGISTER_PCI(spdk_nvme, g_nvme_pci_drv.driver);
|
||||
#else
|
||||
static int
|
||||
spdk_nvme_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
||||
{
|
||||
rte_eal_pci_register(&g_nvme_pci_drv.driver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rte_driver g_nvme_drv = {
|
||||
.type = PMD_PDEV,
|
||||
.init = spdk_nvme_drv_register,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
||||
PMD_REGISTER_DRIVER(g_nvme_drv, spdk_nvme);
|
||||
#else
|
||||
PMD_REGISTER_DRIVER(g_nvme_drv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
||||
.id_table = ioat_driver_id,
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
.name = "spdk_ioat",
|
||||
#endif
|
||||
},
|
||||
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
RTE_PMD_REGISTER_PCI(spdk_ioat, g_ioat_pci_drv.driver);
|
||||
#else
|
||||
static int
|
||||
spdk_ioat_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
||||
{
|
||||
rte_eal_pci_register(&g_ioat_pci_drv.driver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rte_driver g_ioat_drv = {
|
||||
.type = PMD_PDEV,
|
||||
.init = spdk_ioat_drv_register,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
||||
PMD_REGISTER_DRIVER(g_ioat_drv, spdk_ioat);
|
||||
#else
|
||||
PMD_REGISTER_DRIVER(g_ioat_drv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static struct spdk_pci_enum_ctx *
|
||||
spdk_pci_find_driver(enum spdk_pci_device_type type)
|
||||
{
|
||||
if (type == SPDK_PCI_DEVICE_NVME) {
|
||||
return &g_nvme_pci_drv;
|
||||
} else if (type == SPDK_PCI_DEVICE_IOAT) {
|
||||
return &g_ioat_pci_drv;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
spdk_pci_device_detach(struct spdk_pci_device *device)
|
||||
{
|
||||
@ -275,17 +83,11 @@ spdk_pci_device_detach(struct spdk_pci_device *device)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_attach(enum spdk_pci_device_type type,
|
||||
spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
||||
{
|
||||
struct rte_pci_addr addr;
|
||||
struct spdk_pci_enum_ctx *ctx;
|
||||
|
||||
ctx = spdk_pci_find_driver(type);
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr.domain = pci_address->domain;
|
||||
addr.bus = pci_address->bus;
|
||||
@ -316,16 +118,10 @@ spdk_pci_device_attach(enum spdk_pci_device_type type,
|
||||
* and rte_eal_pci_probe simultaneously.
|
||||
*/
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx)
|
||||
{
|
||||
struct spdk_pci_enum_ctx *ctx = spdk_pci_find_driver(type);
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&ctx->mtx);
|
||||
|
||||
ctx->cb_fn = enum_cb;
|
||||
|
142
lib/env_dpdk/pci_ioat.c
Normal file
142
lib/env_dpdk/pci_ioat.c
Normal file
@ -0,0 +1,142 @@
|
||||
/*-
|
||||
* 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"
|
||||
|
||||
#define SPDK_IOAT_PCI_DEVICE(DEVICE_ID) RTE_PCI_DEVICE(SPDK_PCI_VID_INTEL, DEVICE_ID)
|
||||
static struct rte_pci_id ioat_driver_id[] = {
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_SNB8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_IVB9)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_HSW9)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BWD3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDXDE3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX0)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX1)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX2)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX3)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX4)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX5)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX6)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX7)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX8)},
|
||||
{SPDK_IOAT_PCI_DEVICE(PCI_DEVICE_ID_INTEL_IOAT_BDX9)},
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
||||
.id_table = ioat_driver_id,
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
.name = "spdk_ioat",
|
||||
#endif
|
||||
},
|
||||
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
RTE_PMD_REGISTER_PCI(spdk_ioat, g_ioat_pci_drv.driver);
|
||||
#else
|
||||
static int
|
||||
spdk_ioat_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
||||
{
|
||||
rte_eal_pci_register(&g_ioat_pci_drv.driver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rte_driver g_ioat_drv = {
|
||||
.type = PMD_PDEV,
|
||||
.init = spdk_ioat_drv_register,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
||||
PMD_REGISTER_DRIVER(g_ioat_drv, spdk_ioat);
|
||||
#else
|
||||
PMD_REGISTER_DRIVER(g_ioat_drv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
spdk_pci_ioat_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||
struct spdk_pci_addr *pci_address)
|
||||
{
|
||||
return spdk_pci_device_attach(&g_ioat_pci_drv, enum_cb, enum_ctx, pci_address);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
|
||||
{
|
||||
return spdk_pci_enumerate(&g_ioat_pci_drv, enum_cb, enum_ctx);
|
||||
}
|
106
lib/env_dpdk/pci_nvme.c
Normal file
106
lib/env_dpdk/pci_nvme.c
Normal file
@ -0,0 +1,106 @@
|
||||
/*-
|
||||
* 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 nvme_pci_driver_id[] = {
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 1)
|
||||
{
|
||||
.class_id = SPDK_PCI_CLASS_NVME,
|
||||
.vendor_id = PCI_ANY_ID,
|
||||
.device_id = PCI_ANY_ID,
|
||||
.subsystem_vendor_id = PCI_ANY_ID,
|
||||
.subsystem_device_id = PCI_ANY_ID,
|
||||
},
|
||||
#else
|
||||
{RTE_PCI_DEVICE(0x8086, 0x0953)},
|
||||
#endif
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
||||
.id_table = nvme_pci_driver_id,
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
.probe = spdk_pci_device_init,
|
||||
.remove = spdk_pci_device_fini,
|
||||
#else
|
||||
.devinit = spdk_pci_device_init,
|
||||
.devuninit = spdk_pci_device_fini,
|
||||
.name = "spdk_nvme",
|
||||
#endif
|
||||
},
|
||||
|
||||
.cb_fn = NULL,
|
||||
.cb_arg = NULL,
|
||||
.mtx = PTHREAD_MUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 11, 0, 0)
|
||||
RTE_PMD_REGISTER_PCI(spdk_nvme, g_nvme_pci_drv.driver);
|
||||
#else
|
||||
static int
|
||||
spdk_nvme_drv_register(const char *name __rte_unused, const char *params __rte_unused)
|
||||
{
|
||||
rte_eal_pci_register(&g_nvme_pci_drv.driver);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rte_driver g_nvme_drv = {
|
||||
.type = PMD_PDEV,
|
||||
.init = spdk_nvme_drv_register,
|
||||
};
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
|
||||
PMD_REGISTER_DRIVER(g_nvme_drv, spdk_nvme);
|
||||
#else
|
||||
PMD_REGISTER_DRIVER(g_nvme_drv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int
|
||||
spdk_pci_nvme_device_attach(spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
||||
{
|
||||
return spdk_pci_device_attach(&g_nvme_pci_drv, enum_cb, enum_ctx, pci_address);
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
|
||||
{
|
||||
return spdk_pci_enumerate(&g_nvme_pci_drv, enum_cb, enum_ctx);
|
||||
}
|
@ -544,7 +544,7 @@ spdk_ioat_probe(void *cb_ctx, spdk_ioat_probe_cb probe_cb, spdk_ioat_attach_cb a
|
||||
enum_ctx.attach_cb = attach_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
|
||||
rc = spdk_pci_enumerate(SPDK_PCI_DEVICE_IOAT, ioat_enum_cb, &enum_ctx);
|
||||
rc = spdk_pci_ioat_enumerate(ioat_enum_cb, &enum_ctx);
|
||||
|
||||
pthread_mutex_unlock(&g_ioat_driver.lock);
|
||||
|
||||
|
@ -560,10 +560,10 @@ nvme_pcie_ctrlr_scan(enum spdk_nvme_transport transport,
|
||||
enum_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
if (!pci_address) {
|
||||
return spdk_pci_enumerate(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx);
|
||||
return spdk_pci_nvme_enumerate(pcie_nvme_enum_cb, &enum_ctx);
|
||||
} else {
|
||||
return spdk_pci_device_attach(SPDK_PCI_DEVICE_NVME, pcie_nvme_enum_cb, &enum_ctx,
|
||||
(struct spdk_pci_addr *)pci_address);
|
||||
return spdk_pci_nvme_device_attach(pcie_nvme_enum_cb, &enum_ctx,
|
||||
(struct spdk_pci_addr *)pci_address);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,7 @@ void spdk_delay_us(unsigned int us)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx)
|
||||
spdk_pci_ioat_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -40,9 +40,7 @@
|
||||
#include "lib/nvme/unit/test_env.c"
|
||||
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx)
|
||||
spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -55,9 +55,7 @@ int
|
||||
spdk_get_uevent(int fd, struct spdk_uevent *uevent);
|
||||
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx)
|
||||
spdk_pci_nvme_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user