Commit a1a770d0 authored by Michael Haeuptle's avatar Michael Haeuptle Committed by Konrad Sztyber
Browse files

nvmf/vfio-user: Support dynamic controller



Support dynamic controllers for the vfio-user transport.

It was hard-coded to 1 which can clash when a subsystem
is also exposed over RDMA or TCP. The vfio-user transport now
generates a unique controller id.

Change-Id: I4ad3a232371df1156cbfa50bc382889e23a30078
Signed-off-by: default avatarMichael Haeuptle <michael.haeuptle@hpe.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24378


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
parent 0306fa3a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -597,4 +597,14 @@ nvmf_get_transport_poll_group(struct spdk_nvmf_poll_group *group,

	return NULL;
}

/**
 * Generates a new NVMF controller id
 *
 * \param subsystem The subsystem
 *
 * \return unique controller id or 0xFFFF when all controller ids are in use
 */
uint16_t nvmf_subsystem_gen_cntlid(struct spdk_nvmf_subsystem *subsystem);

#endif /* __NVMF_INTERNAL_H__ */
+1 −1
Original line number Diff line number Diff line
@@ -2401,7 +2401,7 @@ spdk_nvmf_subsystem_set_cntlid_range(struct spdk_nvmf_subsystem *subsystem,
	return 0;
}

static uint16_t
uint16_t
nvmf_subsystem_gen_cntlid(struct spdk_nvmf_subsystem *subsystem)
{
	int count;
+5 −2
Original line number Diff line number Diff line
@@ -4368,8 +4368,11 @@ nvmf_vfio_user_create_ctrlr(struct nvmf_vfio_user_transport *transport,
		err = -ENOMEM;
		goto out;
	}
	/* We can only support one connection for now */
	ctrlr->cntlid = 0x1;
	/*
	 * We can only support one connection for now, but generate a unique cntlid in case vfio-user
	 * transport is used together with RDMA or TCP transports in the same target
	 */
	ctrlr->cntlid = nvmf_subsystem_gen_cntlid(endpoint->subsystem);
	ctrlr->intr_fd = -1;
	ctrlr->transport = transport;
	ctrlr->endpoint = endpoint;
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ DEFINE_STUB(spdk_nvmf_ctrlr_save_migr_data, int, (struct spdk_nvmf_ctrlr *ctrlr,
DEFINE_STUB(spdk_nvmf_ctrlr_restore_migr_data, int, (struct spdk_nvmf_ctrlr *ctrlr,
		const struct spdk_nvmf_ctrlr_migr_data *data), 0);
DEFINE_STUB(spdk_mempool_lookup, struct spdk_mempool *, (const char *name), NULL);
DEFINE_STUB(nvmf_subsystem_gen_cntlid, uint16_t, (struct spdk_nvmf_subsystem *subsystem), 1)

static void *
gpa_to_vva(void *prv, uint64_t addr, uint64_t len, uint32_t flags)