Commit e6659485 authored by Jacek Kalwas's avatar Jacek Kalwas Committed by Tomasz Zawadzki
Browse files

nvme/auth: use bitfields for auth flags



It is more readable and is better matches the SPDK code style.

Change-Id: I83be3caf6e53991c18a1516d4d9fc8cee75fab38
Signed-off-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26804


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Community-CI: Mellanox Build Bot
parent 49ea3cb0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1230,7 +1230,7 @@ nvme_fabric_qpair_authenticate_async(struct spdk_nvme_qpair *qpair)
		return -ENOKEY;
	}

	if (qpair->auth.flags & NVME_QPAIR_AUTH_FLAG_ASCR) {
	if (qpair->auth.flags.ascr) {
		AUTH_ERRLOG(qpair, "secure channel concatenation is not supported\n");
		return -EINVAL;
	}
+5 −7
Original line number Diff line number Diff line
@@ -568,7 +568,7 @@ nvme_fabric_qpair_connect_async(struct spdk_nvme_qpair *qpair, uint32_t num_entr
				      spdk_get_ticks_hz() / SPDK_SEC_TO_USEC;
	}

	qpair->auth.flags = 0;
	qpair->auth.flags.raw = 0;
	qpair->fabric_poll_status = status;
	return 0;
}
@@ -614,10 +614,10 @@ nvme_fabric_qpair_connect_poll(struct spdk_nvme_qpair *qpair)
		NVME_CTRLR_DEBUGLOG(ctrlr, "cntlid set\n");
	}
	if (rsp->status_code_specific.success.authreq.atr) {
		qpair->auth.flags |= NVME_QPAIR_AUTH_FLAG_ATR;
		qpair->auth.flags.atr = true;
	}
	if (rsp->status_code_specific.success.authreq.ascr) {
		qpair->auth.flags |= NVME_QPAIR_AUTH_FLAG_ASCR;
		qpair->auth.flags.ascr = true;
	}
finish:
	qpair->fabric_poll_status = NULL;
@@ -632,10 +632,8 @@ finish:
bool
nvme_fabric_qpair_auth_required(struct spdk_nvme_qpair *qpair)
{
	struct spdk_nvme_ctrlr *ctrlr = qpair->ctrlr;

	return qpair->auth.flags & (NVME_QPAIR_AUTH_FLAG_ATR | NVME_QPAIR_AUTH_FLAG_ASCR) ||
	       ctrlr->opts.dhchap_ctrlr_key != NULL || qpair->auth.cb_fn != NULL;
	return qpair->auth.flags.atr || qpair->auth.flags.ascr ||
	       qpair->ctrlr->opts.dhchap_ctrlr_key != NULL || qpair->auth.cb_fn != NULL;
}

int
+10 −7
Original line number Diff line number Diff line
@@ -430,11 +430,6 @@ enum nvme_qpair_auth_state {
	NVME_QPAIR_AUTH_STATE_DONE,
};

/* Authentication transaction required (authreq.atr) */
#define NVME_QPAIR_AUTH_FLAG_ATR	(1 << 0)
/* Authentication and secure channel required (authreq.ascr) */
#define NVME_QPAIR_AUTH_FLAG_ASCR	(1 << 1)

/* Maximum size of a digest */
#define NVME_AUTH_DIGEST_MAX_SIZE	64

@@ -445,8 +440,16 @@ struct nvme_auth {
	int				status;
	/* Transaction ID */
	uint16_t			tid;
	/* Flags */
	uint32_t			flags;
	union {
		struct {
			/* Authentication transaction required (authreq.atr) */
			uint32_t        atr : 1;
			/* Authentication and secure channel required (authreq.ascr) */
			uint32_t        ascr : 1;
			uint32_t        reserved : 30;
		};
		uint32_t                raw;
	} flags;
	/* Selected hash function */
	uint8_t				hash;
	/* Buffer used for controller challenge */