env: Move pci.c from util to env
This allows users to swap their PCI library from libpciaccess/dpdk to another mechanism using the standard method for swapping out the env library. Change-Id: Ib2248f8b43754a540de2ec01897e571f0302b667 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
b9fbdd189a
commit
0dd80395f3
@ -39,7 +39,7 @@
|
||||
#include "nvmf/transport.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/nvme.h"
|
||||
|
||||
static void
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include <rte_mempool.h>
|
||||
|
||||
#include "spdk/ioat.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
struct user_config {
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include <rte_mempool.h>
|
||||
|
||||
#include "spdk/ioat.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
#define SRC_BUFFER_SIZE (512*1024)
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "rte_eal.h"
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
#include "config-host.h"
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <rte_malloc.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
struct ctrlr_entry {
|
||||
struct spdk_nvme_ctrlr *ctrlr;
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
#include "spdk/pci_ids.h"
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#define MAX_DEVS 64
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#include "spdk/fd.h"
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#define MAX_DEVS 64
|
||||
|
||||
|
@ -45,6 +45,8 @@ extern "C" {
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct spdk_pci_device;
|
||||
|
||||
/**
|
||||
* Allocate a pinned, physically contiguous memory buffer with the
|
||||
* given size and alignment. The buffer will be zeroed.
|
||||
@ -63,6 +65,41 @@ spdk_free(void *buf);
|
||||
|
||||
uint64_t spdk_vtophys(void *buf);
|
||||
|
||||
enum spdk_pci_device_type {
|
||||
SPDK_PCI_DEVICE_NVME,
|
||||
SPDK_PCI_DEVICE_IOAT,
|
||||
};
|
||||
|
||||
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_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
||||
int spdk_pci_device_unmap_bar(struct spdk_pci_device *dev, uint32_t bar, void *addr);
|
||||
|
||||
uint16_t spdk_pci_device_get_domain(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_bus(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_dev(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_func(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_vendor_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_device_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_subvendor_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_subdevice_id(struct spdk_pci_device *dev);
|
||||
uint32_t spdk_pci_device_get_class(struct spdk_pci_device *dev);
|
||||
const char *spdk_pci_device_get_device_name(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(struct spdk_pci_device *dev);
|
||||
|
||||
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);
|
||||
int spdk_pci_device_cfg_read16(struct spdk_pci_device *dev, uint16_t *value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_write16(struct spdk_pci_device *dev, uint16_t value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_read32(struct spdk_pci_device *dev, uint32_t *value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_write32(struct spdk_pci_device *dev, uint32_t value, uint32_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -45,7 +45,7 @@ extern "C" {
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
/**
|
||||
* Opaque handle for a single I/OAT channel returned by \ref spdk_ioat_probe().
|
||||
|
@ -45,7 +45,8 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "spdk/pci.h"
|
||||
|
||||
#include "spdk/env.h"
|
||||
#include "nvme_spec.h"
|
||||
|
||||
#define SPDK_NVME_DEFAULT_RETRY_COUNT (4)
|
||||
|
@ -1,89 +0,0 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* PCI driver abstraction layer
|
||||
*/
|
||||
|
||||
#ifndef SPDK_PCI_H
|
||||
#define SPDK_PCI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
|
||||
enum spdk_pci_device_type {
|
||||
SPDK_PCI_DEVICE_NVME,
|
||||
SPDK_PCI_DEVICE_IOAT,
|
||||
};
|
||||
|
||||
struct spdk_pci_device;
|
||||
|
||||
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_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
|
||||
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
||||
int spdk_pci_device_unmap_bar(struct spdk_pci_device *dev, uint32_t bar, void *addr);
|
||||
|
||||
uint16_t spdk_pci_device_get_domain(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_bus(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_dev(struct spdk_pci_device *dev);
|
||||
uint8_t spdk_pci_device_get_func(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_vendor_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_device_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_subvendor_id(struct spdk_pci_device *dev);
|
||||
uint16_t spdk_pci_device_get_subdevice_id(struct spdk_pci_device *dev);
|
||||
uint32_t spdk_pci_device_get_class(struct spdk_pci_device *dev);
|
||||
const char *spdk_pci_device_get_device_name(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(struct spdk_pci_device *dev);
|
||||
|
||||
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);
|
||||
int spdk_pci_device_cfg_read16(struct spdk_pci_device *dev, uint16_t *value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_write16(struct spdk_pci_device *dev, uint16_t value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_read32(struct spdk_pci_device *dev, uint32_t *value, uint32_t offset);
|
||||
int spdk_pci_device_cfg_write32(struct spdk_pci_device *dev, uint32_t value, uint32_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -48,7 +48,7 @@
|
||||
|
||||
#include "spdk/conf.h"
|
||||
#include "spdk/endian.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/bdev.h"
|
||||
#include "spdk/nvme.h"
|
||||
|
@ -45,9 +45,7 @@
|
||||
#include "spdk/conf.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/event.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/io_channel.h"
|
||||
|
||||
#include "spdk/ioat.h"
|
||||
|
||||
#define IOAT_MAX_CHANNELS 64
|
||||
|
2
lib/env/Makefile
vendored
2
lib/env/Makefile
vendored
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(DPDK_INC)
|
||||
C_SRCS = env.c vtophys.c
|
||||
C_SRCS = env.c pci.c vtophys.c
|
||||
LIBNAME = env
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
2
lib/util/pci.c → lib/env/pci.c
vendored
2
lib/util/pci.c → lib/env/pci.c
vendored
@ -53,7 +53,7 @@
|
||||
#include <sys/pciio.h>
|
||||
#endif
|
||||
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/pci_ids.h"
|
||||
|
||||
#define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
|
@ -32,9 +32,9 @@
|
||||
*/
|
||||
|
||||
#include "ioat_internal.h"
|
||||
#include "spdk/pci.h"
|
||||
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <rte_cycles.h>
|
||||
|
||||
#include "spdk/assert.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include <rte_pci.h>
|
||||
|
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#include "nvme_internal.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
static int nvme_ctrlr_construct_and_submit_aer(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct nvme_async_event_request *aer);
|
||||
|
@ -46,8 +46,9 @@
|
||||
#define __NVME_IMPL_H__
|
||||
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/nvme_spec.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS)
|
||||
C_SRCS = bit_array.c fd.c io_channel.c string.c pci.c
|
||||
C_SRCS = bit_array.c fd.c io_channel.c string.c
|
||||
LIBNAME = util
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#define MAX_DEVS 64
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
static uint32_t swap32(uint32_t value)
|
||||
{
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
#include "spdk/fd.h"
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/nvme_intel.h"
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
struct ctrlr_entry {
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <rte_lcore.h>
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#define MAX_DEVS 64
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "spdk_cunit.h"
|
||||
|
||||
#include "spdk/pci.h"
|
||||
#include "spdk/env.h"
|
||||
|
||||
#include "nvme/nvme.c"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user