nvmf: Rename spdk_nvmf_ctrlr_gent_cntlid to spdk_nvmf_tgt_gen_cntlid
Also, move it to the appropriate compilation unit. Further, remove use of g_nvmf_tgt. Shift the function to a new compilation unit as well. Change-Id: I1a43ff366532b450f00aed54a290fb9eed9bf453 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/375455 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
81c3400a1e
commit
ff4f68a55f
@ -57,8 +57,6 @@
|
|||||||
*/
|
*/
|
||||||
#define FW_VERSION SPDK_VERSION_MAJOR_STRING SPDK_VERSION_MINOR_STRING SPDK_VERSION_PATCH_STRING
|
#define FW_VERSION SPDK_VERSION_MAJOR_STRING SPDK_VERSION_MINOR_STRING SPDK_VERSION_PATCH_STRING
|
||||||
|
|
||||||
static uint16_t spdk_nvmf_ctrlr_gen_cntlid(void);
|
|
||||||
|
|
||||||
static struct spdk_nvmf_ctrlr *
|
static struct spdk_nvmf_ctrlr *
|
||||||
spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
||||||
struct spdk_nvmf_qpair *admin_qpair,
|
struct spdk_nvmf_qpair *admin_qpair,
|
||||||
@ -83,7 +81,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrlr->cntlid = spdk_nvmf_ctrlr_gen_cntlid();
|
ctrlr->cntlid = spdk_nvmf_tgt_gen_cntlid(tgt);
|
||||||
if (ctrlr->cntlid == 0) {
|
if (ctrlr->cntlid == 0) {
|
||||||
/* Unable to get a cntlid */
|
/* Unable to get a cntlid */
|
||||||
SPDK_ERRLOG("Reached max simultaneous ctrlrs\n");
|
SPDK_ERRLOG("Reached max simultaneous ctrlrs\n");
|
||||||
@ -167,44 +165,6 @@ invalid_connect_response(struct spdk_nvmf_fabric_connect_rsp *rsp, uint8_t iattr
|
|||||||
rsp->status_code_specific.invalid.ipo = ipo;
|
rsp->status_code_specific.invalid.ipo = ipo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t
|
|
||||||
spdk_nvmf_ctrlr_gen_cntlid(void)
|
|
||||||
{
|
|
||||||
static uint16_t cntlid = 0; /* cntlid is static, so its value is preserved */
|
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
|
||||||
uint16_t count;
|
|
||||||
|
|
||||||
count = UINT16_MAX - 1;
|
|
||||||
do {
|
|
||||||
/* cntlid is an unsigned 16-bit integer, so let it overflow
|
|
||||||
* back to 0 if necessary.
|
|
||||||
*/
|
|
||||||
cntlid++;
|
|
||||||
if (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.
|
|
||||||
*/
|
|
||||||
cntlid++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if a subsystem with this cntlid currently exists. This could
|
|
||||||
* happen for a very long-lived ctrlr on a target with many short-lived
|
|
||||||
* ctrlrs, where cntlid wraps around.
|
|
||||||
*/
|
|
||||||
subsystem = spdk_nvmf_find_subsystem_with_cntlid(cntlid);
|
|
||||||
|
|
||||||
count--;
|
|
||||||
|
|
||||||
} while (subsystem != NULL && count > 0);
|
|
||||||
|
|
||||||
if (count == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cntlid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
spdk_nvmf_ctrlr_connect(struct spdk_nvmf_qpair *qpair,
|
||||||
struct spdk_nvmf_fabric_connect_cmd *cmd,
|
struct spdk_nvmf_fabric_connect_cmd *cmd,
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
|
#include "ctrlr.h"
|
||||||
#include "subsystem.h"
|
#include "subsystem.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
||||||
@ -173,6 +174,50 @@ spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
spdk_nvmf_tgt_gen_cntlid(struct spdk_nvmf_tgt *tgt)
|
||||||
|
{
|
||||||
|
struct spdk_nvmf_subsystem *subsystem;
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
tgt->next_cntlid++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if a subsystem with this cntlid currently exists. This could
|
||||||
|
* happen for a very long-lived ctrlr on a target with many short-lived
|
||||||
|
* ctrlrs, where cntlid wraps around.
|
||||||
|
*/
|
||||||
|
TAILQ_FOREACH(subsystem, &tgt->subsystems, entries) {
|
||||||
|
TAILQ_FOREACH(ctrlr, &subsystem->ctrlrs, link) {
|
||||||
|
if (ctrlr->cntlid == tgt->next_cntlid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
count--;
|
||||||
|
|
||||||
|
} while (subsystem != NULL && count > 0);
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tgt->next_cntlid;
|
||||||
|
}
|
||||||
|
|
||||||
struct spdk_nvmf_transport *
|
struct spdk_nvmf_transport *
|
||||||
spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, enum spdk_nvme_transport_type type)
|
spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt, enum spdk_nvme_transport_type type)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
struct spdk_nvmf_tgt {
|
struct spdk_nvmf_tgt {
|
||||||
struct spdk_nvmf_tgt_opts opts;
|
struct spdk_nvmf_tgt_opts opts;
|
||||||
|
|
||||||
|
uint16_t next_cntlid;
|
||||||
uint64_t discovery_genctr;
|
uint64_t discovery_genctr;
|
||||||
TAILQ_HEAD(, spdk_nvmf_subsystem) subsystems;
|
TAILQ_HEAD(, spdk_nvmf_subsystem) subsystems;
|
||||||
struct spdk_nvmf_discovery_log_page *discovery_log_page;
|
struct spdk_nvmf_discovery_log_page *discovery_log_page;
|
||||||
@ -113,6 +114,8 @@ extern struct spdk_nvmf_tgt g_nvmf_tgt;
|
|||||||
struct spdk_nvmf_listen_addr *spdk_nvmf_listen_addr_create(struct spdk_nvme_transport_id *trid);
|
struct spdk_nvmf_listen_addr *spdk_nvmf_listen_addr_create(struct spdk_nvme_transport_id *trid);
|
||||||
void spdk_nvmf_listen_addr_destroy(struct spdk_nvmf_listen_addr *addr);
|
void spdk_nvmf_listen_addr_destroy(struct spdk_nvmf_listen_addr *addr);
|
||||||
|
|
||||||
|
uint16_t spdk_nvmf_tgt_gen_cntlid(struct spdk_nvmf_tgt *tgt);
|
||||||
|
|
||||||
struct spdk_nvmf_transport *spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt,
|
struct spdk_nvmf_transport *spdk_nvmf_tgt_get_transport(struct spdk_nvmf_tgt *tgt,
|
||||||
enum spdk_nvme_transport_type);
|
enum spdk_nvme_transport_type);
|
||||||
|
|
||||||
|
@ -46,23 +46,6 @@
|
|||||||
#include "spdk_internal/bdev.h"
|
#include "spdk_internal/bdev.h"
|
||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
struct spdk_nvmf_subsystem *
|
|
||||||
spdk_nvmf_find_subsystem_with_cntlid(uint16_t cntlid)
|
|
||||||
{
|
|
||||||
struct spdk_nvmf_subsystem *subsystem;
|
|
||||||
struct spdk_nvmf_ctrlr *ctrlr;
|
|
||||||
|
|
||||||
TAILQ_FOREACH(subsystem, &g_nvmf_tgt.subsystems, entries) {
|
|
||||||
TAILQ_FOREACH(ctrlr, &subsystem->ctrlrs, link) {
|
|
||||||
if (ctrlr->cntlid == cntlid) {
|
|
||||||
return subsystem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem)
|
spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem)
|
||||||
{
|
{
|
||||||
|
@ -39,8 +39,6 @@
|
|||||||
#include "spdk/nvme.h"
|
#include "spdk/nvme.h"
|
||||||
#include "spdk/nvmf.h"
|
#include "spdk/nvmf.h"
|
||||||
|
|
||||||
struct spdk_nvmf_subsystem *spdk_nvmf_find_subsystem_with_cntlid(uint16_t cntlid);
|
|
||||||
|
|
||||||
void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt,
|
void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt,
|
||||||
void *buffer, uint64_t offset,
|
void *buffer, uint64_t offset,
|
||||||
uint32_t length);
|
uint32_t length);
|
||||||
|
@ -42,15 +42,15 @@ SPDK_LOG_REGISTER_TRACE_FLAG("nvmf", SPDK_TRACE_NVMF)
|
|||||||
struct spdk_nvmf_tgt g_nvmf_tgt;
|
struct spdk_nvmf_tgt g_nvmf_tgt;
|
||||||
|
|
||||||
struct spdk_nvmf_subsystem *
|
struct spdk_nvmf_subsystem *
|
||||||
spdk_nvmf_find_subsystem_with_cntlid(uint16_t cntlid)
|
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_nvmf_subsystem *
|
uint16_t
|
||||||
spdk_nvmf_tgt_find_subsystem(struct spdk_nvmf_tgt *tgt, const char *subnqn)
|
spdk_nvmf_tgt_gen_cntlid(struct spdk_nvmf_tgt *tgt)
|
||||||
{
|
{
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct spdk_nvme_ctrlr_data *
|
const struct spdk_nvme_ctrlr_data *
|
||||||
|
Loading…
Reference in New Issue
Block a user