Commit b0a80710 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvmf: don't generate cntlids in reserved range



The NVMe-oF 1.0 spec says:

"The NVM subsystem shall not allocate a Controller ID in the range FFF0h
to FFFFh as a valid Controller ID"

Change-Id: If0b7dc4948e40b3bdf370a1da97199a25d362e71
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376247


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarZiye Yang <optimistyzy@gmail.com>
parent 65cac5fb
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -171,18 +171,16 @@ spdk_nvmf_tgt_gen_cntlid(struct spdk_nvmf_tgt *tgt)
	struct spdk_nvmf_ctrlr *ctrlr;
	uint16_t count;

	count = UINT16_MAX - 1;
	do {
		/* cntlid is an unsigned 16-bit integer, so let it overflow
		 * back to 0 if necessary.
		 */
		tgt->next_cntlid++;
		if (tgt->next_cntlid == 0) {
			/* 0 is not a valid cntlid because it is the reserved value in the RDMA
			 * private data for cntlid. This is the value sent by pre-NVMe-oF 1.1
			 * initiators.
	/*
	 * In the worst case, we might have to try all CNTLID values between 1 and 0xFFF0 - 1
	 * before we find one that is unused (or find that all values are in use).
	 */
	count = 0xFFF0 - 1;
	do {
		tgt->next_cntlid++;
		if (tgt->next_cntlid >= 0xFFF0) {
			/* The spec reserves cntlid values in the range FFF0h to FFFFh. */
			tgt->next_cntlid = 1;
		}

		/* Check if a subsystem with this cntlid currently exists. This could