Commit 470e8518 authored by Slawomir Ptak's avatar Slawomir Ptak Committed by Tomasz Zawadzki
Browse files

lib/nvmf: NVMeoF referrals in NVMeoF target



NVMeoF Discovery Service referrals implementation
in the NVMeoF target. Added three new RPC methods for
referral management: nvmf_discovery_add_referral,
nvmf_discovery_remove_referral, nvmf_discovery_get_referrals.

Change-Id: I0f4810c6ac8d401bc619d21a26376b7e3c3373bd
Signed-off-by: default avatarSlawomir Ptak <slawomir.ptak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19500


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9468fe64
Loading
Loading
Loading
Loading
+126 −0
Original line number Diff line number Diff line
@@ -7992,6 +7992,9 @@ secure_channel | Optional | bool | Whether all connections immed

#### listen_address {#rpc_nvmf_listen_address}

The listen_address is used for adding the listeners to the NVMe-oF target
and for referring to discovery services on other targets.

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
trtype                  | Required | string      | Transport type ("RDMA")
@@ -8505,6 +8508,129 @@ Example response:
}
~~~

### nvmf_discovery_add_referral  method {#rpc_nvmf_discovery_add_referral}

Add a discovery service referral to an NVMe-oF target. If a referral with the given
parameters already exists, no action will be taken.

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
tgt_name                | Optional | string      | Parent NVMe-oF target name.
address                 | Required | object      | @ref rpc_nvmf_listen_address object
secure_channel          | Optional | bool        | The connection to that discovery subsystem requires a secure channel

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "nvmf_discovery_add_referral",
  "params": {
    "address": {
      "trtype": "RDMA",
      "adrfam": "IPv4",
      "traddr": "192.168.0.123",
      "trsvcid": "4420"
    }
  }
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

### nvmf_discovery_remove_referral  method {#rpc_nvmf_discovery_remove_referral}

Remove a discovery service referral from an NVMe-oF target.

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
tgt_name                | Optional | string      | Parent NVMe-oF target name.
address                 | Required | object      | @ref rpc_nvmf_listen_address object

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "nvmf_discovery_remove_referral",
  "params": {
    "address": {
      "trtype": "RDMA",
      "adrfam": "IPv4",
      "traddr": "192.168.0.123",
      "trsvcid": "4420"
    }
  }
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

### nvmf_discovery_get_referrals {#rpc_nvmf_discovery_get_referrals}

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
tgt_name                | Optional | string      | Parent NVMe-oF target name.

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "nvmf_discovery_get_referrals"
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "address": {
        "trtype": "RDMA",
        "adrfam": "IPv4",
        "traddr": "192.168.0.123",
        "trsvcid": "4420"
      }
    }
  ]
}
~~~

### nvmf_set_config {#rpc_nvmf_set_config}

Set global configuration of NVMe-oF target.  This RPC may only be called before SPDK subsystems
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ print_discovery_log(struct spdk_nvmf_discovery_log_page *log_page)
		       entry->adrfam, spdk_nvme_transport_id_adrfam_str(entry->adrfam));
		printf("Subsystem Type:                        %u (%s)\n",
		       entry->subtype,
		       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY ? "Referral to a Discovery Service" :
		       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY ? "Referral to a discovery service" :
		       entry->subtype == SPDK_NVMF_SUBTYPE_NVME ? "NVM Subsystem" :
		       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY_CURRENT ? "Current Discovery Subsystem" :
		       "Unknown");
+1 −1
Original line number Diff line number Diff line
@@ -2532,7 +2532,7 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
			       entry->adrfam, spdk_nvme_transport_id_adrfam_str(entry->adrfam));
			printf("Subsystem Type:                        %u (%s)\n",
			       entry->subtype,
			       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY ? "Referral to a Discovery Service" :
			       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY ? "Referral to a discovery service" :
			       entry->subtype == SPDK_NVMF_SUBTYPE_NVME ? "NVM Subsystem" :
			       entry->subtype == SPDK_NVMF_SUBTYPE_DISCOVERY_CURRENT ? "Current Discovery Subsystem" :
			       "Unknown");
+26 −0
Original line number Diff line number Diff line
@@ -151,6 +151,32 @@ struct spdk_nvmf_poll_group_stat {
 */
typedef void (*spdk_nvmf_tgt_subsystem_listen_done_fn)(void *ctx, int status);

/**
 * Add a discovery service referral to an NVMe-oF target
 *
 * \param tgt The target to which the referral will be added
 * \param trid Transport ID of the referral
 * \param secure_channel The referral describes a discovery service which
 * requires a secure channel
 *
 * \return 0 on success or a negated errno on failure
 */
int spdk_nvmf_tgt_add_referral(struct spdk_nvmf_tgt *tgt,
			       struct spdk_nvme_transport_id *trid,
			       bool secure_channel);

/**
 * Remove a discovery service referral from an NVMeoF target
 *
 * \param tgt The target from which the referral will be removed
 * \param trid Transport ID of the referral to remove
 *
 * \return 0 on success or a negated errno on failure.
 */
int spdk_nvmf_tgt_remove_referral(struct spdk_nvmf_tgt *tgt,
				  struct spdk_nvme_transport_id *trid);


/**
 * Construct an NVMe-oF target.
 *
+1 −1
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ enum spdk_nvmf_adrfam {
 * NVM subsystem types
 */
enum spdk_nvmf_subtype {
	/** Referral to a Discovery Service */
	/** Referral to a discovery service */
	SPDK_NVMF_SUBTYPE_DISCOVERY		= 0x1,

	/** NVM Subsystem */
Loading