nvme: Remove pci_addr from probe_info
This can be obtained by parsing the traddr. Change-Id: Idaf35066cbf900c87e771a44934de99fb5420001 Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
9511b2a20b
commit
3da43e64e4
@ -338,13 +338,18 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
struct spdk_nvmf_probe_ctx *ctx = cb_ctx;
|
struct spdk_nvmf_probe_ctx *ctx = cb_ctx;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
|
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx->any && !ctx->found) {
|
if (ctx->any && !ctx->found) {
|
||||||
ctx->found = true;
|
ctx->found = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spdk_pci_addr_compare(&probe_info->pci_addr, &ctx->pci_addr) == 0) {
|
if (spdk_pci_addr_compare(&pci_addr, &ctx->pci_addr) == 0) {
|
||||||
ctx->found = true;
|
ctx->found = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -360,20 +365,17 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
int rc;
|
int rc;
|
||||||
char path[MAX_STRING_LEN];
|
char path[MAX_STRING_LEN];
|
||||||
int numa_node = -1;
|
int numa_node = -1;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
SPDK_NOTICELOG("Attaching NVMe device %p at %x:%x:%x.%x to subsystem %s\n",
|
spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr);
|
||||||
|
|
||||||
|
SPDK_NOTICELOG("Attaching NVMe device %p at %s to subsystem %s\n",
|
||||||
ctrlr,
|
ctrlr,
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr,
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func,
|
|
||||||
spdk_nvmf_subsystem_get_nqn(ctx->app_subsystem->subsystem));
|
spdk_nvmf_subsystem_get_nqn(ctx->app_subsystem->subsystem));
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%04x:%02x:%02x.%1u/numa_node",
|
snprintf(path, sizeof(path), "/sys/bus/pci/devices/%s/numa_node",
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
numa_node = spdk_get_numa_node_value(path);
|
numa_node = spdk_get_numa_node_value(path);
|
||||||
if (numa_node >= 0) {
|
if (numa_node >= 0) {
|
||||||
@ -390,7 +392,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = nvmf_subsystem_add_ctrlr(ctx->app_subsystem->subsystem, ctrlr, &probe_info->pci_addr);
|
rc = nvmf_subsystem_add_ctrlr(ctx->app_subsystem->subsystem, ctrlr, &pci_addr);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
SPDK_ERRLOG("Failed to add controller to subsystem\n");
|
SPDK_ERRLOG("Failed to add controller to subsystem\n");
|
||||||
}
|
}
|
||||||
|
@ -859,11 +859,7 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
/* Update with user specified arbitration configuration */
|
/* Update with user specified arbitration configuration */
|
||||||
opts->arb_mechanism = g_arbitration.arbitration_mechanism;
|
opts->arb_mechanism = g_arbitration.arbitration_mechanism;
|
||||||
|
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -872,11 +868,7 @@ static void
|
|||||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
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_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attached to %04x:%02x:%02x.%02x\n",
|
printf("Attached to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
/* Update with actual arbitration configuration in use */
|
/* Update with actual arbitration configuration in use */
|
||||||
g_arbitration.arbitration_mechanism = opts->arb_mechanism;
|
g_arbitration.arbitration_mechanism = opts->arb_mechanism;
|
||||||
|
@ -94,6 +94,11 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct thread_data *td = cb_ctx;
|
struct thread_data *td = cb_ctx;
|
||||||
int rc;
|
int rc;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
|
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we want to claim this device */
|
/* Check if we want to claim this device */
|
||||||
for_each_file(td, f, i) {
|
for_each_file(td, f, i) {
|
||||||
@ -103,9 +108,9 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
fprintf(stderr, "Invalid filename: %s\n", f->file_name);
|
fprintf(stderr, "Invalid filename: %s\n", f->file_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (bus == probe_info->pci_addr.bus &&
|
if (bus == pci_addr.bus &&
|
||||||
slot == probe_info->pci_addr.dev &&
|
slot == pci_addr.dev &&
|
||||||
func == probe_info->pci_addr.func) {
|
func == pci_addr.func) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +128,9 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
struct spdk_fio_ns *fio_ns;
|
struct spdk_fio_ns *fio_ns;
|
||||||
struct fio_file *f;
|
struct fio_file *f;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
|
spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr);
|
||||||
|
|
||||||
/* Create an fio_ctrlr and add it to the list */
|
/* Create an fio_ctrlr and add it to the list */
|
||||||
fio_ctrlr = calloc(1, sizeof(*fio_ctrlr));
|
fio_ctrlr = calloc(1, sizeof(*fio_ctrlr));
|
||||||
@ -137,9 +145,9 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
int domain, bus, slot, func, nsid, rc;
|
int domain, bus, slot, func, nsid, rc;
|
||||||
rc = sscanf(f->file_name, "%x.%x.%x.%x/%x", &domain, &bus, &slot, &func, &nsid);
|
rc = sscanf(f->file_name, "%x.%x.%x.%x/%x", &domain, &bus, &slot, &func, &nsid);
|
||||||
if (rc == 5 &&
|
if (rc == 5 &&
|
||||||
bus == probe_info->pci_addr.bus &&
|
bus == pci_addr.bus &&
|
||||||
slot == probe_info->pci_addr.dev &&
|
slot == pci_addr.dev &&
|
||||||
func == probe_info->pci_addr.func) {
|
func == pci_addr.func) {
|
||||||
fio_ns = calloc(1, sizeof(*fio_ns));
|
fio_ns = calloc(1, sizeof(*fio_ns));
|
||||||
if (fio_ns == NULL) {
|
if (fio_ns == NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -241,11 +241,7 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -264,11 +260,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Attached to %04x:%02x:%02x.%02x\n",
|
printf("Attached to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
|
snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
|
||||||
|
|
||||||
|
@ -265,11 +265,7 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -278,11 +274,7 @@ static void
|
|||||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
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_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attached to %04x:%02x:%02x.%02x\n",
|
printf("Attached to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
register_dev(ctrlr);
|
register_dev(ctrlr);
|
||||||
}
|
}
|
||||||
|
@ -396,6 +396,7 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_probe_inf
|
|||||||
uint8_t str[512];
|
uint8_t str[512];
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
struct spdk_nvme_error_information_entry *error_entry;
|
struct spdk_nvme_error_information_entry *error_entry;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
cap = spdk_nvme_ctrlr_get_regs_cap(ctrlr);
|
cap = spdk_nvme_ctrlr_get_regs_cap(ctrlr);
|
||||||
vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr);
|
vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr);
|
||||||
@ -406,13 +407,17 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_probe_inf
|
|||||||
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
||||||
|
|
||||||
printf("=====================================================\n");
|
printf("=====================================================\n");
|
||||||
if (probe_info->trid.subnqn[0]) {
|
if (probe_info->trid.trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
printf("NVMe over Fabrics controller at %s:%s: %s\n",
|
printf("NVMe over Fabrics controller at %s:%s: %s\n",
|
||||||
probe_info->trid.traddr, probe_info->trid.trsvcid, probe_info->trid.subnqn);
|
probe_info->trid.traddr, probe_info->trid.trsvcid, probe_info->trid.subnqn);
|
||||||
} else {
|
} else {
|
||||||
|
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
printf("NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
printf("NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
||||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
pci_addr.domain, pci_addr.bus,
|
||||||
probe_info->pci_addr.dev, probe_info->pci_addr.func,
|
pci_addr.dev, pci_addr.func,
|
||||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||||
}
|
}
|
||||||
printf("=====================================================\n");
|
printf("=====================================================\n");
|
||||||
|
@ -107,7 +107,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
/* add to dev list */
|
/* add to dev list */
|
||||||
dev = &devs[num_devs++];
|
dev = &devs[num_devs++];
|
||||||
dev->pci_addr = probe_info->pci_addr;
|
spdk_pci_addr_parse(&dev->pci_addr, probe_info->trid.traddr);
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
|
|
||||||
/* Retrieve controller data */
|
/* Retrieve controller data */
|
||||||
|
@ -976,14 +976,13 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
if (probe_info->trid.subnqn[0]) {
|
if (probe_info->trid.trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
printf("Attaching to NVMe over Fabrics controller at %s:%s: %s\n",
|
printf("Attaching to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||||
probe_info->trid.subnqn);
|
probe_info->trid.subnqn);
|
||||||
} else {
|
} else {
|
||||||
printf("Attaching to NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
printf("Attaching to NVMe Controller at %s [%04x:%04x]\n",
|
||||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
probe_info->trid.traddr,
|
||||||
probe_info->pci_addr.dev, probe_info->pci_addr.func,
|
|
||||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,14 +993,13 @@ static void
|
|||||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
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_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
if (probe_info->trid.subnqn[0]) {
|
if (probe_info->trid.trtype != SPDK_NVME_TRANSPORT_PCIE) {
|
||||||
printf("Attached to NVMe over Fabrics controller at %s:%s: %s\n",
|
printf("Attached to NVMe over Fabrics controller at %s:%s: %s\n",
|
||||||
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
probe_info->trid.traddr, probe_info->trid.trsvcid,
|
||||||
probe_info->trid.subnqn);
|
probe_info->trid.subnqn);
|
||||||
} else {
|
} else {
|
||||||
printf("Attached to NVMe Controller at %04x:%02x:%02x.%x [%04x:%04x]\n",
|
printf("Attached to NVMe Controller at %s [%04x:%04x]\n",
|
||||||
probe_info->pci_addr.domain, probe_info->pci_addr.bus,
|
probe_info->trid.traddr,
|
||||||
probe_info->pci_addr.dev, probe_info->pci_addr.func,
|
|
||||||
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
probe_info->pci_id.vendor_id, probe_info->pci_id.device_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
/* add to dev list */
|
/* add to dev list */
|
||||||
dev = &devs[num_devs++];
|
dev = &devs[num_devs++];
|
||||||
dev->pci_addr = probe_info->pci_addr;
|
spdk_pci_addr_parse(&dev->pci_addr, probe_info->trid.traddr);
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +166,6 @@ struct spdk_nvme_transport_id {
|
|||||||
* NVMe controller information provided during spdk_nvme_probe().
|
* NVMe controller information provided during spdk_nvme_probe().
|
||||||
*/
|
*/
|
||||||
struct spdk_nvme_probe_info {
|
struct spdk_nvme_probe_info {
|
||||||
/**
|
|
||||||
* PCI address.
|
|
||||||
*
|
|
||||||
* If not available, each field will be filled with all 0xFs.
|
|
||||||
*/
|
|
||||||
struct spdk_pci_addr pci_addr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCI device ID.
|
* PCI device ID.
|
||||||
*
|
*
|
||||||
|
@ -413,12 +413,14 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
struct nvme_probe_ctx *ctx = cb_ctx;
|
struct nvme_probe_ctx *ctx = cb_ctx;
|
||||||
int i;
|
int i;
|
||||||
bool claim_device = false;
|
bool claim_device = false;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
SPDK_NOTICELOG("Probing device %x:%x:%x.%x\n",
|
if (spdk_pci_addr_parse(&pci_addr, probe_info->trid.traddr)) {
|
||||||
probe_info->pci_addr.domain,
|
return false;
|
||||||
probe_info->pci_addr.bus,
|
}
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
SPDK_NOTICELOG("Probing device %s\n",
|
||||||
|
probe_info->trid.traddr);
|
||||||
|
|
||||||
if (ctx->controllers_remaining == 0) {
|
if (ctx->controllers_remaining == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -428,7 +430,7 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
claim_device = true;
|
claim_device = true;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < NVME_MAX_CONTROLLERS; i++) {
|
for (i = 0; i < NVME_MAX_CONTROLLERS; i++) {
|
||||||
if (spdk_pci_addr_compare(&probe_info->pci_addr, &ctx->whitelist[i]) == 0) {
|
if (spdk_pci_addr_compare(&pci_addr, &ctx->whitelist[i]) == 0) {
|
||||||
claim_device = true;
|
claim_device = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -440,7 +442,7 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Claim the device in case conflict with other process */
|
/* Claim the device in case conflict with other process */
|
||||||
if (spdk_pci_device_claim(&probe_info->pci_addr) != 0) {
|
if (spdk_pci_device_claim(&pci_addr) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +477,7 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
dev->pci_addr = probe_info->pci_addr;
|
spdk_pci_addr_parse(&dev->pci_addr, probe_info->trid.traddr);
|
||||||
dev->id = nvme_controller_index++;
|
dev->id = nvme_controller_index++;
|
||||||
|
|
||||||
nvme_ctrlr_initialize_blockdevs(dev, nvme_luns_per_ns, dev->id);
|
nvme_ctrlr_initialize_blockdevs(dev, nvme_luns_per_ns, dev->id);
|
||||||
|
@ -476,20 +476,23 @@ nvme_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
|
|||||||
{
|
{
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
struct spdk_uevent event;
|
struct spdk_uevent event;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
while (spdk_get_uevent(hotplug_fd, &event) > 0) {
|
while (spdk_get_uevent(hotplug_fd, &event) > 0) {
|
||||||
if (event.subsystem == SPDK_NVME_UEVENT_SUBSYSTEM_UIO) {
|
if (event.subsystem == SPDK_NVME_UEVENT_SUBSYSTEM_UIO) {
|
||||||
if (event.action == SPDK_NVME_UEVENT_ADD) {
|
if (event.action == SPDK_NVME_UEVENT_ADD) {
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVME, "add nvme address: %04x:%02x:%02x.%u\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVME, "add nvme address: %s\n",
|
||||||
event.pci_addr.domain, event.pci_addr.bus, event.pci_addr.dev, event.pci_addr.func);
|
event.traddr);
|
||||||
if (spdk_process_is_primary()) {
|
if (spdk_process_is_primary()) {
|
||||||
nvme_transport_ctrlr_attach(SPDK_NVME_TRANSPORT_PCIE, probe_cb, cb_ctx, &event.pci_addr);
|
if (spdk_pci_addr_parse(&pci_addr, event.traddr)) {
|
||||||
|
nvme_transport_ctrlr_attach(SPDK_NVME_TRANSPORT_PCIE, probe_cb, cb_ctx, &pci_addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (event.action == SPDK_NVME_UEVENT_REMOVE) {
|
} else if (event.action == SPDK_NVME_UEVENT_REMOVE) {
|
||||||
bool in_list = false;
|
bool in_list = false;
|
||||||
|
|
||||||
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||||
if (spdk_pci_addr_compare(&event.pci_addr, &ctrlr->probe_info.pci_addr) == 0) {
|
if (strcmp(event.traddr, ctrlr->probe_info.trid.traddr) == 0) {
|
||||||
in_list = true;
|
in_list = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -497,8 +500,8 @@ nvme_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
|
|||||||
if (in_list == false) {
|
if (in_list == false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVME, "remove nvme address: %04x:%02x:%02x.%u\n",
|
SPDK_TRACELOG(SPDK_TRACE_NVME, "remove nvme address: %s\n",
|
||||||
event.pci_addr.domain, event.pci_addr.bus, event.pci_addr.dev, event.pci_addr.func);
|
event.traddr);
|
||||||
|
|
||||||
nvme_ctrlr_fail(ctrlr, true);
|
nvme_ctrlr_fail(ctrlr, true);
|
||||||
|
|
||||||
|
@ -528,9 +528,12 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
struct nvme_pcie_enum_ctx *enum_ctx = ctx;
|
struct nvme_pcie_enum_ctx *enum_ctx = ctx;
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
struct spdk_pci_addr pci_addr;
|
||||||
|
|
||||||
|
pci_addr = spdk_pci_device_get_addr(pci_dev);
|
||||||
|
|
||||||
probe_info.trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
probe_info.trid.trtype = SPDK_NVME_TRANSPORT_PCIE;
|
||||||
probe_info.pci_addr = spdk_pci_device_get_addr(pci_dev);
|
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);
|
probe_info.pci_id = spdk_pci_device_get_id(pci_dev);
|
||||||
|
|
||||||
/* Verify that this controller is not already attached */
|
/* Verify that this controller is not already attached */
|
||||||
@ -539,7 +542,7 @@ pcie_nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
* different per each process, we compare by BDF to determine whether it is the
|
* different per each process, we compare by BDF to determine whether it is the
|
||||||
* same controller.
|
* same controller.
|
||||||
*/
|
*/
|
||||||
if (spdk_pci_addr_compare(&probe_info.pci_addr, &ctrlr->probe_info.pci_addr) == 0) {
|
if (strcmp(probe_info.trid.traddr, ctrlr->probe_info.trid.traddr) == 0) {
|
||||||
if (!spdk_process_is_primary()) {
|
if (!spdk_process_is_primary()) {
|
||||||
rc = nvme_ctrlr_add_process(ctrlr, pci_dev);
|
rc = nvme_ctrlr_add_process(ctrlr, pci_dev);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -48,6 +50,7 @@
|
|||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
|
|
||||||
#define SPDK_UEVENT_MSG_LEN 4096
|
#define SPDK_UEVENT_MSG_LEN 4096
|
||||||
|
#define TRADDR_FMT "%.4" PRIx16 ":%.2" PRIx8 ":%.2" PRIx8 ".%" PRIx8
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_uevent_connect(void)
|
spdk_uevent_connect(void)
|
||||||
@ -138,10 +141,7 @@ parse_event(const char *buf, struct spdk_uevent *event)
|
|||||||
if (ret != 4) {
|
if (ret != 4) {
|
||||||
SPDK_ERRLOG("Invalid format for NVMe BDF: %s\n", pci_address);
|
SPDK_ERRLOG("Invalid format for NVMe BDF: %s\n", pci_address);
|
||||||
}
|
}
|
||||||
event->pci_addr.domain = domain;
|
snprintf(event->traddr, sizeof(event->traddr), TRADDR_FMT, domain, bus, dev, func);
|
||||||
event->pci_addr.bus = bus;
|
|
||||||
event->pci_addr.dev = dev;
|
|
||||||
event->pci_addr.func = func;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
|
#include "spdk/nvmf_spec.h"
|
||||||
|
|
||||||
#ifndef SPDK_UEVENT_H_
|
#ifndef SPDK_UEVENT_H_
|
||||||
#define SPDK_UEVENT_H_
|
#define SPDK_UEVENT_H_
|
||||||
@ -50,7 +51,7 @@ enum spdk_nvme_uevent_action {
|
|||||||
struct spdk_uevent {
|
struct spdk_uevent {
|
||||||
enum spdk_nvme_uevent_action action;
|
enum spdk_nvme_uevent_action action;
|
||||||
int subsystem;
|
int subsystem;
|
||||||
struct spdk_pci_addr pci_addr;
|
char traddr[SPDK_NVMF_TRADDR_MAX_LEN + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
int spdk_uevent_connect(void);
|
int spdk_uevent_connect(void);
|
||||||
|
@ -188,11 +188,7 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -208,11 +204,8 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
|
|
||||||
snprintf(dev->name, sizeof(dev->name), "%04x:%02x:%02x.%02x",
|
snprintf(dev->name, sizeof(dev->name), "%s",
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
printf("Attached to %s\n", dev->name);
|
printf("Attached to %s\n", dev->name);
|
||||||
|
|
||||||
|
@ -609,11 +609,7 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -629,11 +625,8 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
|
|
||||||
snprintf(dev->name, sizeof(dev->name), "%04X:%02X:%02X.%02X",
|
snprintf(dev->name, sizeof(dev->name), "%s",
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
printf("Attached to %s\n", dev->name);
|
printf("Attached to %s\n", dev->name);
|
||||||
}
|
}
|
||||||
|
@ -537,20 +537,13 @@ probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
if (ctrlr_found == 1) {
|
if (ctrlr_found == 1) {
|
||||||
fprintf(stderr, "only attching to one controller, so skipping\n");
|
fprintf(stderr, "only attching to one controller, so skipping\n");
|
||||||
fprintf(stderr, " controller at PCI address %04x:%02x:%02x.%02x\n",
|
fprintf(stderr, " controller at PCI address %s\n",
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ctrlr_found = 1;
|
ctrlr_found = 1;
|
||||||
|
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -559,11 +552,7 @@ static void
|
|||||||
attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
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_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attached to %04x:%02x:%02x.%02x\n",
|
printf("Attached to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
register_ctrlr(ctrlr);
|
register_ctrlr(ctrlr);
|
||||||
}
|
}
|
||||||
|
@ -383,11 +383,7 @@ static bool
|
|||||||
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
probe_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
||||||
struct spdk_nvme_ctrlr_opts *opts)
|
struct spdk_nvme_ctrlr_opts *opts)
|
||||||
{
|
{
|
||||||
printf("Attaching to %04x:%02x:%02x.%02x\n",
|
printf("Attaching to %s\n", probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.domain,
|
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -403,11 +399,8 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_probe_info *probe_info,
|
|||||||
|
|
||||||
dev->ctrlr = ctrlr;
|
dev->ctrlr = ctrlr;
|
||||||
|
|
||||||
snprintf(dev->name, sizeof(dev->name), "%04X:%02X:%02X.%02X",
|
snprintf(dev->name, sizeof(dev->name), "%s",
|
||||||
probe_info->pci_addr.domain,
|
probe_info->trid.traddr);
|
||||||
probe_info->pci_addr.bus,
|
|
||||||
probe_info->pci_addr.dev,
|
|
||||||
probe_info->pci_addr.func);
|
|
||||||
|
|
||||||
printf("Attached to %s\n", dev->name);
|
printf("Attached to %s\n", dev->name);
|
||||||
}
|
}
|
||||||
|
@ -145,3 +145,53 @@ uint64_t spdk_get_ticks_hz(void)
|
|||||||
{
|
{
|
||||||
return 1000000;
|
return 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_pci_addr_parse(struct spdk_pci_addr *addr, const char *bdf)
|
||||||
|
{
|
||||||
|
unsigned domain, bus, dev, func;
|
||||||
|
|
||||||
|
if (addr == NULL || bdf == NULL) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sscanf(bdf, "%x:%x:%x.%x", &domain, &bus, &dev, &func) == 4) {
|
||||||
|
/* Matched a full address - all variables are initialized */
|
||||||
|
} else if (sscanf(bdf, "%x:%x:%x", &domain, &bus, &dev) == 3) {
|
||||||
|
func = 0;
|
||||||
|
} else if (sscanf(bdf, "%x:%x.%x", &bus, &dev, &func) == 3) {
|
||||||
|
domain = 0;
|
||||||
|
} else if (sscanf(bdf, "%x:%x", &bus, &dev) == 2) {
|
||||||
|
domain = 0;
|
||||||
|
func = 0;
|
||||||
|
} else {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (domain > 0xFFFF || bus > 0xFF || dev > 0x1F || func > 7) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr->domain = domain;
|
||||||
|
addr->bus = bus;
|
||||||
|
addr->dev = dev;
|
||||||
|
addr->func = func;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
spdk_pci_addr_fmt(char *bdf, size_t sz, const struct spdk_pci_addr *addr)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = snprintf(bdf, sz, "%04x:%02x:%02x.%x",
|
||||||
|
addr->domain, addr->bus,
|
||||||
|
addr->dev, addr->func);
|
||||||
|
|
||||||
|
if (rc > 0 && (size_t)rc < sz) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user