By doing the registration immediately upon mapping the BAR instead of when the memory is inserted into the spdk_mem_map, we're able to register BARs that are not 2MB multiples in size and alignment. The SPDK API for registering a BAR already returns the physical/io address in the map call, and it can be used directly without a call to spdk_mem_register(). If the user does elect to later register the BAR using spdk_mem_register(), we attempt to insert the 2MB aligned segments we can into the spdk_mem_map. Users may still need to register memory for a few reasons, such as making spdk_vtophys() work, or for setting up the BAR as a target for RDMA. These cases still require 2MB aligned and sized segments. Change-Id: I395ae8803ec4bf22703f6f76db54200949e82532 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14017 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
79 lines
3.4 KiB
C
79 lines
3.4 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright (c) Intel Corporation.
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#ifndef SPDK_PCI_DPDK_H
|
|
#define SPDK_PCI_DPDK_H
|
|
|
|
#include "spdk/env.h"
|
|
|
|
struct spdk_pci_driver {
|
|
uint8_t driver_buf[256];
|
|
struct rte_pci_driver *driver;
|
|
|
|
const char *name;
|
|
const struct spdk_pci_id *id_table;
|
|
uint32_t drv_flags;
|
|
|
|
spdk_pci_enum_cb cb_fn;
|
|
void *cb_arg;
|
|
TAILQ_ENTRY(spdk_pci_driver) tailq;
|
|
};
|
|
|
|
struct rte_pci_device;
|
|
struct rte_pci_driver;
|
|
struct rte_device;
|
|
|
|
struct dpdk_fn_table {
|
|
uint64_t (*pci_device_vtophys)(struct rte_pci_device *dev, uint64_t vaddr, size_t len);
|
|
const char *(*pci_device_get_name)(struct rte_pci_device *);
|
|
struct rte_devargs *(*pci_device_get_devargs)(struct rte_pci_device *);
|
|
void (*pci_device_copy_identifiers)(struct rte_pci_device *_dev, struct spdk_pci_device *dev);
|
|
int (*pci_device_map_bar)(struct rte_pci_device *dev, uint32_t bar,
|
|
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
|
int (*pci_device_read_config)(struct rte_pci_device *dev, void *value, uint32_t len,
|
|
uint32_t offset);
|
|
int (*pci_device_write_config)(struct rte_pci_device *dev, void *value, uint32_t len,
|
|
uint32_t offset);
|
|
int (*pci_driver_register)(struct spdk_pci_driver *driver,
|
|
int (*probe_fn)(struct rte_pci_driver *driver, struct rte_pci_device *device),
|
|
int (*remove_fn)(struct rte_pci_device *device));
|
|
int (*pci_device_enable_interrupt)(struct rte_pci_device *rte_dev);
|
|
int (*pci_device_disable_interrupt)(struct rte_pci_device *rte_dev);
|
|
int (*pci_device_get_interrupt_efd)(struct rte_pci_device *rte_dev);
|
|
void (*bus_scan)(void);
|
|
int (*bus_probe)(void);
|
|
struct rte_devargs *(*device_get_devargs)(struct rte_device *dev);
|
|
void (*device_set_devargs)(struct rte_device *dev, struct rte_devargs *devargs);
|
|
const char *(*device_get_name)(struct rte_device *dev);
|
|
bool (*device_scan_allowed)(struct rte_device *dev);
|
|
};
|
|
|
|
int dpdk_pci_init(void);
|
|
|
|
uint64_t dpdk_pci_device_vtophys(struct rte_pci_device *dev, uint64_t vaddr, size_t len);
|
|
const char *dpdk_pci_device_get_name(struct rte_pci_device *);
|
|
struct rte_devargs *dpdk_pci_device_get_devargs(struct rte_pci_device *);
|
|
void dpdk_pci_device_copy_identifiers(struct rte_pci_device *_dev, struct spdk_pci_device *dev);
|
|
int dpdk_pci_device_map_bar(struct rte_pci_device *dev, uint32_t bar,
|
|
void **mapped_addr, uint64_t *phys_addr, uint64_t *size);
|
|
int dpdk_pci_device_read_config(struct rte_pci_device *dev, void *value, uint32_t len,
|
|
uint32_t offset);
|
|
int dpdk_pci_device_write_config(struct rte_pci_device *dev, void *value, uint32_t len,
|
|
uint32_t offset);
|
|
int dpdk_pci_driver_register(struct spdk_pci_driver *driver,
|
|
int (*probe_fn)(struct rte_pci_driver *driver, struct rte_pci_device *device),
|
|
int (*remove_fn)(struct rte_pci_device *device));
|
|
int dpdk_pci_device_enable_interrupt(struct rte_pci_device *rte_dev);
|
|
int dpdk_pci_device_disable_interrupt(struct rte_pci_device *rte_dev);
|
|
int dpdk_pci_device_get_interrupt_efd(struct rte_pci_device *rte_dev);
|
|
void dpdk_bus_scan(void);
|
|
int dpdk_bus_probe(void);
|
|
struct rte_devargs *dpdk_device_get_devargs(struct rte_device *dev);
|
|
void dpdk_device_set_devargs(struct rte_device *dev, struct rte_devargs *devargs);
|
|
const char *dpdk_device_get_name(struct rte_device *dev);
|
|
bool dpdk_device_scan_allowed(struct rte_device *dev);
|
|
|
|
#endif /* ifndef SPDK_PCI_DPDK_H */
|