nvme: Remove pci_id from probe_info
This can be obtained by parsing traddr into a pci_addr, then getting a handle to the pci_dev and asking for all of the pci information. Change-Id: I1948cbd3ec65611293192ef5558ace19dd444d4c Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
3da43e64e4
commit
6c2e170dc7
@ -396,7 +396,9 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_probe_inf
|
||||
uint8_t str[512];
|
||||
uint32_t i;
|
||||
struct spdk_nvme_error_information_entry *error_entry;
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_device *pci_dev;
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
cap = spdk_nvme_ctrlr_get_regs_cap(ctrlr);
|
||||
vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr);
|
||||
@ -415,10 +417,17 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_probe_inf
|
||||
return;
|
||||
}
|
||||
|
||||
pci_dev = spdk_pci_get_device(&pci_addr);
|
||||
if (!pci_dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
printf("NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
||||
pci_addr.domain, pci_addr.bus,
|
||||
pci_addr.dev, pci_addr.func,
|
||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||
pci_id.vendor_id, pci_id.device_id);
|
||||
}
|
||||
printf("=====================================================\n");
|
||||
|
||||
|
@ -976,14 +976,29 @@ static bool
|
||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||
struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_device *pci_dev;
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
if (probe_info->trid.trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||
printf("Attaching to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||
probe_info->trid.subnqn);
|
||||
} else {
|
||||
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pci_dev = spdk_pci_get_device(&pci_addr);
|
||||
if (!pci_dev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
printf("Attaching to NVMe Controller at %s [%04x:%04x]\n",
|
||||
probe_info->trid.traddr,
|
||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||
pci_id.vendor_id, pci_id.device_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -993,14 +1008,29 @@ static void
|
||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||
struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||
{
|
||||
struct spdk_pci_addr pci_addr;
|
||||
struct spdk_pci_device *pci_dev;
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
if (probe_info->trid.trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||
printf("Attached to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||
probe_info->trid.subnqn);
|
||||
} else {
|
||||
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
pci_dev = spdk_pci_get_device(&pci_addr);
|
||||
if (!pci_dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
printf("Attached to NVMe Controller at %s [%04x:%04x]\n",
|
||||
probe_info->trid.traddr,
|
||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||
pci_id.vendor_id, pci_id.device_id);
|
||||
}
|
||||
|
||||
register_ctrlr(ctrlr);
|
||||
|
@ -166,13 +166,6 @@ struct spdk_nvme_transport_id {
|
||||
* NVMe controller information provided during spdk_nvme_probe().
|
||||
*/
|
||||
struct spdk_nvme_probe_info {
|
||||
/**
|
||||
* PCI device ID.
|
||||
*
|
||||
* If not available, each field will be filled with all 0xFs.
|
||||
*/
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
/* The transport identifier */
|
||||
struct spdk_nvme_transport_id trid;
|
||||
};
|
||||
|
@ -242,10 +242,12 @@ nvme_pcie_qpair(struct spdk_nvme_qpair *qpair)
|
||||
int
|
||||
nvme_pcie_ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id)
|
||||
{
|
||||
struct nvme_pcie_ctrlr *pctrlr = nvme_pcie_ctrlr(ctrlr);
|
||||
|
||||
assert(ctrlr != NULL);
|
||||
assert(pci_id != NULL);
|
||||
|
||||
*pci_id = ctrlr->probe_info.pci_id;
|
||||
*pci_id = spdk_pci_device_get_id(pctrlr->devhandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -534,7 +536,6 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||
|
||||
probe_info.trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||
spdk_pci_addr_fmt(probe_info.trid.traddr, sizeof(probe_info.trid.traddr), &pci_addr);
|
||||
probe_info.pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
|
||||
/* Verify that this controller is not already attached */
|
||||
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||
@ -591,6 +592,7 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport_type
|
||||
union spdk_nvme_cap_register cap;
|
||||
uint32_t cmd_reg;
|
||||
int rc;
|
||||
struct spdk_pci_id pci_id;
|
||||
|
||||
pctrlr = spdk_zmalloc(sizeof(struct nvme_pcie_ctrlr), 64, NULL);
|
||||
if (pctrlr == NULL) {
|
||||
@ -634,7 +636,8 @@ struct spdk_nvme_ctrlr *nvme_pcie_ctrlr_construct(enum spdk_nvme_transport_type
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pctrlr->ctrlr.quirks = nvme_get_quirks(&probe_info->pci_id);
|
||||
pci_id = spdk_pci_device_get_id(pci_dev);
|
||||
pctrlr->ctrlr.quirks = nvme_get_quirks(&pci_id);
|
||||
|
||||
rc = nvme_pcie_ctrlr_construct_admin_qpair(&pctrlr->ctrlr);
|
||||
if (rc != 0) {
|
||||
|
@ -1221,12 +1221,7 @@ nvme_rdma_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
|
||||
int
|
||||
nvme_rdma_ctrlr_get_pci_id(struct spdk_nvme_ctrlr *ctrlr, struct spdk_pci_id *pci_id)
|
||||
{
|
||||
assert(ctrlr != NULL);
|
||||
assert(pci_id != NULL);
|
||||
|
||||
*pci_id = ctrlr->probe_info.pci_id;
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user