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: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/376247
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
This commit is contained in:
Daniel Verkamp 2017-08-29 13:02:50 -07:00
parent 65cac5fbe0
commit b0a80710ec

View File

@ -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;
/*
* 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 {
/* 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.
*/
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