nvme/pcie: Add the support to probe nvme by pci_addr
Currently we use the pci functions provided by DPDK, it identifies the device by class id related info but not by pci bdf info, so we can add the filering by pci_addr in pcie_nvme_enum_cb function. Change-Id: I5942e98853f00fc10fa6aae5c113517653d1b357 Signed-off-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
parent
997582bf2c
commit
0a573526b6
@ -912,8 +912,6 @@ parse_args(int argc, char **argv)
|
||||
#endif
|
||||
break;
|
||||
case 'a':
|
||||
g_trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||
g_trid.adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
||||
snprintf(g_trid.traddr, sizeof(g_trid.traddr), "%s", optarg);
|
||||
break;
|
||||
case 's':
|
||||
@ -934,6 +932,9 @@ parse_args(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_trid.trtype = SPDK_NVME_TRANSPORT_RDMA;
|
||||
g_trid.adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
||||
|
||||
optind = 1;
|
||||
|
||||
return 0;
|
||||
@ -965,6 +966,7 @@ static const char *ealargs[] = {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
struct spdk_nvme_transport_id *tr_id = NULL;
|
||||
|
||||
rc = parse_args(argc, argv);
|
||||
if (rc != 0) {
|
||||
@ -986,7 +988,11 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
if ((g_trid.trtype == SPDK_NVME_TRANSPORT_PCIE) && (strlen(g_trid.traddr) != 0)) {
|
||||
tr_id = &g_trid;
|
||||
}
|
||||
|
||||
if (spdk_nvme_probe(tr_id, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||
rc = 1;
|
||||
}
|
||||
|
@ -77,6 +77,8 @@
|
||||
struct nvme_pcie_enum_ctx {
|
||||
spdk_nvme_probe_cb probe_cb;
|
||||
void *cb_ctx;
|
||||
struct spdk_pci_addr pci_addr;
|
||||
bool has_pci_addr;
|
||||
};
|
||||
|
||||
/* PCIe transport extensions for spdk_nvme_ctrlr */
|
||||
@ -616,6 +618,12 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
}
|
||||
}
|
||||
|
||||
/* check whether user passes the pci_addr */
|
||||
if (enum_ctx->has_pci_addr &&
|
||||
(spdk_pci_addr_compare(&pci_addr, &enum_ctx->pci_addr) != 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nvme_ctrlr_probe(&trid, pci_dev,
|
||||
enum_ctx->probe_cb, enum_ctx->cb_ctx);
|
||||
}
|
||||
@ -626,11 +634,18 @@ nvme_pcie_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
||||
spdk_nvme_probe_cb probe_cb,
|
||||
spdk_nvme_remove_cb remove_cb)
|
||||
{
|
||||
struct nvme_pcie_enum_ctx enum_ctx;
|
||||
struct nvme_pcie_enum_ctx enum_ctx = {};
|
||||
|
||||
enum_ctx.probe_cb = probe_cb;
|
||||
enum_ctx.cb_ctx = cb_ctx;
|
||||
|
||||
if (strlen(trid->traddr) != 0) {
|
||||
if (spdk_pci_addr_parse(&enum_ctx.pci_addr, trid->traddr)) {
|
||||
return -1;
|
||||
}
|
||||
enum_ctx.has_pci_addr = true;
|
||||
}
|
||||
|
||||
if (hotplug_fd < 0) {
|
||||
hotplug_fd = spdk_uevent_connect();
|
||||
if (hotplug_fd < 0) {
|
||||
|
@ -29,6 +29,9 @@ fi
|
||||
|
||||
timing_enter identify
|
||||
$rootdir/examples/nvme/identify/identify
|
||||
for bdf in $(linux_iter_pci 0108); do
|
||||
$rootdir/examples/nvme/identify/identify -a ${bdf}
|
||||
done
|
||||
timing_exit identify
|
||||
|
||||
timing_enter perf
|
||||
|
@ -135,6 +135,12 @@ spdk_pci_device_get_addr(struct spdk_pci_device *dev)
|
||||
abort();
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_addr_compare(const struct spdk_pci_addr *a1, const struct spdk_pci_addr *a2)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_cfg_read32(struct spdk_pci_device *dev, uint32_t *value, uint32_t offset)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user