Commit 1c9d2c75 authored by Kaiqi Chen's avatar Kaiqi Chen Committed by Jim Harris
Browse files

nvmf: add options to set kas and min_kato



This patch adds `kas` field in `spdk_nvmf_transport_opts` struct to
set keep alive support. This field indicates the granularity of the
KATO (Keep Alive Timeout) field in 100 millisecond units. And this
field can not set to 0h to disable Keep Alive Timer feature.

This patch also adds `min_kato` field in `spdk_nvmf_transport_opts`
struct to set the minimum KATO value in milliseconds. The TCP and
RDMA Transport do not actually impose any limitations on the minimum
and maximum KATO, adding just the min_kato field is sufficient in
this patch. The reason is that the SPDK NVMe-oF target previously set
the default KATO to 10 seconds. To preserve this default value for
backward compatibility, introducing a configurable min_kato field in
the transport options to configure the KATO is the cleanest solution.

Change-Id: Ie25a9b46a2332a1c59814ac4350d38b2b0e679fb
Signed-off-by: default avatarKaiqi Chen <kaiqi.chen@smartx.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25649


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@nutanix.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent 4390e4ee
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -54,6 +54,13 @@ queue pair creation.
Added public API `spdk_nvmf_send_discovery_log_notice` to send discovery log page
change notice to client.

Added `kas` in `spdk_nvmf_transport_opts` struct. This field indicates the granularity of the
KATO (Keep Alive Timeout) in 100 millisecond units, and this field cannot be set to 0 to disable
the Keep Alive Timer feature.

Added `min_kato` in `spdk_nvmf_transport_opts` struct to set the minimum keep alive timeout value
in milliseconds.

### reduce

Add `spdk_reduce_vol_get_info()` to get the information for the compressed volume.
+2 −0
Original line number Diff line number Diff line
@@ -8324,6 +8324,8 @@ zcopy | Optional | boolean | Use zero-copy operations if t
ack_timeout                 | Optional | number  | ACK timeout in milliseconds
data_wr_pool_size           | Optional | number  | RDMA data WR pool size (RDMA only)
disable_command_passthru    | Optional | boolean | Disallow command passthru.
kas                         | Optional | number  | The granularity of the KATO (Keep Alive Timeout) in 100 millisecond units
min_kato                    | Optional | number  | The minimum Keep Alive Timeout value in milliseconds

#### Example

+5 −1
Original line number Diff line number Diff line
@@ -110,8 +110,12 @@ struct spdk_nvmf_transport_opts {
	uint32_t ack_timeout;
	/* Size of RDMA data WR pool */
	uint32_t data_wr_pool_size;
	/* The minimum Keep Alive Timeout value in milliseconds */
	uint32_t min_kato;
	/* kas indicates the granularity of the Keep Alive Timer in 100ms units. */
	uint16_t kas;
} __attribute__((packed));
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_transport_opts) == 72, "Incorrect size");
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvmf_transport_opts) == 78, "Incorrect size");

struct spdk_nvmf_listen_opts {
	/**
+15 −13
Original line number Diff line number Diff line
@@ -23,11 +23,6 @@
#include "spdk/log.h"
#include "spdk_internal/usdt.h"

#define MIN_KEEP_ALIVE_TIMEOUT_IN_MS 10000
#define NVMF_DISC_KATO_IN_MS 120000
#define KAS_TIME_UNIT_IN_MS 100
#define KAS_DEFAULT_VALUE (MIN_KEEP_ALIVE_TIMEOUT_IN_MS / KAS_TIME_UNIT_IN_MS)

#define NVMF_CC_RESET_SHN_TIMEOUT_IN_MS	10000

#define NVMF_CTRLR_RESET_SHN_TIMEOUT_IN_MS	(NVMF_CC_RESET_SHN_TIMEOUT_IN_MS + 5000)
@@ -374,7 +369,7 @@ nvmf_ctrlr_cdata_init(struct spdk_nvmf_transport *transport, struct spdk_nvmf_su
		      struct spdk_nvmf_ctrlr_data *cdata)
{
	cdata->aerl = SPDK_NVMF_MAX_ASYNC_EVENTS - 1;
	cdata->kas = KAS_DEFAULT_VALUE;
	cdata->kas = transport->opts.kas;
	cdata->vid = SPDK_PCI_VID_INTEL;
	cdata->ssvid = SPDK_PCI_VID_INTEL;
	/* INTEL OUI */
@@ -476,9 +471,15 @@ nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
	 * If this field is cleared to 0h, then Keep Alive is not supported.
	 */
	if (ctrlr->cdata.kas) {
		if (connect_cmd->kato == 0) {
			ctrlr->feat.keep_alive_timer.bits.kato = 0;
		} else if (connect_cmd->kato <= transport->opts.min_kato) {
			ctrlr->feat.keep_alive_timer.bits.kato = transport->opts.min_kato;
		} else {
			ctrlr->feat.keep_alive_timer.bits.kato = spdk_divide_round_up(connect_cmd->kato,
				KAS_DEFAULT_VALUE * KAS_TIME_UNIT_IN_MS) *
				KAS_DEFAULT_VALUE * KAS_TIME_UNIT_IN_MS;
					ctrlr->cdata.kas * NVMF_KAS_TIME_UNIT_IN_MS) *
					ctrlr->cdata.kas * NVMF_KAS_TIME_UNIT_IN_MS;
		}
	}

	ctrlr->feat.async_event_configuration.bits.ns_attr_notice = 1;
@@ -2011,6 +2012,7 @@ static int
nvmf_ctrlr_set_features_keep_alive_timer(struct spdk_nvmf_request *req)
{
	struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
	struct spdk_nvmf_transport *transport = req->qpair->transport;
	struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
	struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;

@@ -2022,14 +2024,14 @@ nvmf_ctrlr_set_features_keep_alive_timer(struct spdk_nvmf_request *req)
	 */
	if (cmd->cdw11_bits.feat_keep_alive_timer.bits.kato == 0) {
		rsp->status.sc = SPDK_NVME_SC_KEEP_ALIVE_INVALID;
	} else if (cmd->cdw11_bits.feat_keep_alive_timer.bits.kato < MIN_KEEP_ALIVE_TIMEOUT_IN_MS) {
		ctrlr->feat.keep_alive_timer.bits.kato = MIN_KEEP_ALIVE_TIMEOUT_IN_MS;
	} else if (cmd->cdw11_bits.feat_keep_alive_timer.bits.kato <= transport->opts.min_kato) {
		ctrlr->feat.keep_alive_timer.bits.kato = transport->opts.min_kato;
	} else {
		/* round up to milliseconds */
		ctrlr->feat.keep_alive_timer.bits.kato = spdk_divide_round_up(
					cmd->cdw11_bits.feat_keep_alive_timer.bits.kato,
					KAS_DEFAULT_VALUE * KAS_TIME_UNIT_IN_MS) *
				KAS_DEFAULT_VALUE * KAS_TIME_UNIT_IN_MS;
					transport->opts.kas * NVMF_KAS_TIME_UNIT_IN_MS) *
				transport->opts.kas * NVMF_KAS_TIME_UNIT_IN_MS;
	}

	/*
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
#define NVMF_MIN_CNTLID 1
#define NVMF_MAX_CNTLID 0xFFEF

#define NVMF_DISC_KATO_IN_MS 120000
#define NVMF_KAS_TIME_UNIT_IN_MS 100
#define NVMF_DEFAULT_KAS 100
#define NVMF_DEFAULT_MIN_KATO 10000

enum spdk_nvmf_tgt_state {
	NVMF_TGT_IDLE = 0,
	NVMF_TGT_RUNNING,
Loading