env: pass PCI address when claiming devices
The PCI device claim function does not need the whole spdk_pci_device structure, just the address. Change-Id: If59df512043ee062cf9f759bdc104fc522625ba8 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
c01291b215
commit
e912a90f77
@ -193,7 +193,7 @@ struct spdk_pci_id spdk_pci_device_get_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_claim(const struct spdk_pci_addr *pci_addr);
|
||||
|
||||
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);
|
||||
|
@ -342,15 +342,12 @@ static bool
|
||||
probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
struct nvme_probe_ctx *ctx = cb_ctx;
|
||||
uint16_t found_domain = spdk_pci_device_get_domain(pci_dev);
|
||||
uint8_t found_bus = spdk_pci_device_get_bus(pci_dev);
|
||||
uint8_t found_dev = spdk_pci_device_get_dev(pci_dev);
|
||||
uint8_t found_func = spdk_pci_device_get_func(pci_dev);
|
||||
struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr(pci_dev);
|
||||
int i;
|
||||
bool claim_device = false;
|
||||
|
||||
SPDK_NOTICELOG("Probing device %x:%x:%x.%x\n",
|
||||
found_domain, found_bus, found_dev, found_func);
|
||||
pci_addr.domain, pci_addr.bus, pci_addr.dev, pci_addr.func);
|
||||
|
||||
if (ctx->controllers_remaining == 0) {
|
||||
return false;
|
||||
@ -360,10 +357,7 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr_o
|
||||
claim_device = true;
|
||||
} else {
|
||||
for (i = 0; i < NVME_MAX_CONTROLLERS; i++) {
|
||||
if (found_domain == ctx->whitelist[i].domain &&
|
||||
found_bus == ctx->whitelist[i].bus &&
|
||||
found_dev == ctx->whitelist[i].dev &&
|
||||
found_func == ctx->whitelist[i].func) {
|
||||
if (spdk_pci_addr_compare(&pci_addr, &ctx->whitelist[i]) == 0) {
|
||||
claim_device = true;
|
||||
break;
|
||||
}
|
||||
@ -375,7 +369,7 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr_o
|
||||
}
|
||||
|
||||
/* Claim the device in case conflict with other process */
|
||||
if (spdk_pci_device_claim(pci_dev) != 0) {
|
||||
if (spdk_pci_device_claim(&pci_addr) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -241,11 +241,12 @@ static bool
|
||||
probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev)
|
||||
{
|
||||
struct ioat_probe_ctx *ctx = cb_ctx;
|
||||
struct spdk_pci_addr pci_addr = spdk_pci_device_get_addr(pci_dev);
|
||||
|
||||
SPDK_NOTICELOG(" Found matching device at %d:%d:%d vendor:0x%04x device:0x%04x\n name:%s\n",
|
||||
spdk_pci_device_get_bus(pci_dev),
|
||||
spdk_pci_device_get_dev(pci_dev),
|
||||
spdk_pci_device_get_func(pci_dev),
|
||||
pci_addr.bus,
|
||||
pci_addr.dev,
|
||||
pci_addr.func,
|
||||
spdk_pci_device_get_vendor_id(pci_dev),
|
||||
spdk_pci_device_get_device_id(pci_dev),
|
||||
spdk_pci_device_get_device_name(pci_dev));
|
||||
@ -256,7 +257,7 @@ probe_cb(void *cb_ctx, struct spdk_pci_device *pci_dev)
|
||||
}
|
||||
|
||||
/* Claim the device in case conflict with other process */
|
||||
if (spdk_pci_device_claim(pci_dev) != 0) {
|
||||
if (spdk_pci_device_claim(&pci_addr) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
8
lib/env/pci.c
vendored
8
lib/env/pci.c
vendored
@ -446,7 +446,7 @@ spdk_pci_addr_compare(const struct spdk_pci_addr *a1, const struct spdk_pci_addr
|
||||
|
||||
#ifdef __linux__
|
||||
int
|
||||
spdk_pci_device_claim(struct spdk_pci_device *dev)
|
||||
spdk_pci_device_claim(const struct spdk_pci_addr *pci_addr)
|
||||
{
|
||||
int dev_fd;
|
||||
char shm_name[64];
|
||||
@ -459,9 +459,7 @@ spdk_pci_device_claim(struct spdk_pci_device *dev)
|
||||
.l_len = 0,
|
||||
};
|
||||
|
||||
sprintf(shm_name, PCI_PRI_FMT, spdk_pci_device_get_domain(dev),
|
||||
spdk_pci_device_get_bus(dev), spdk_pci_device_get_dev(dev),
|
||||
spdk_pci_device_get_func(dev));
|
||||
sprintf(shm_name, PCI_PRI_FMT, pci_addr->domain, pci_addr->bus, pci_addr->dev, pci_addr->func);
|
||||
|
||||
dev_fd = shm_open(shm_name, O_RDWR | O_CREAT, 0600);
|
||||
if (dev_fd == -1) {
|
||||
@ -501,7 +499,7 @@ spdk_pci_device_claim(struct spdk_pci_device *dev)
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
int
|
||||
spdk_pci_device_claim(struct spdk_pci_device *dev)
|
||||
spdk_pci_device_claim(const struct spdk_pci_addr *pci_addr)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user