nvme: Add parse and output strings of prchk flags
The next patch will use the string "prchk:reftag|apptag" as per-controller prchk options for .INI config file. Hence add helper functions for them beforehand. Change-Id: I58c225cc36cc84bf594f108e611028996b5eedb9 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/443834 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
260f9a77c3
commit
9562a5c7c1
@ -418,6 +418,27 @@ int spdk_nvme_transport_id_parse_adrfam(enum spdk_nvmf_adrfam *adrfam, const cha
|
||||
int spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
|
||||
const struct spdk_nvme_transport_id *trid2);
|
||||
|
||||
/**
|
||||
* Parse the string representation of PI check settings (prchk:guard|reftag)
|
||||
*
|
||||
* \param prchk_flags Output PI check flags.
|
||||
* \param str Input string representation of PI check settings.
|
||||
*
|
||||
* \return 0 if parsing was successful and prchk_flags is set, or negated errno
|
||||
* values on failure.
|
||||
*/
|
||||
int spdk_nvme_prchk_flags_parse(uint32_t *prchk_flags, const char *str);
|
||||
|
||||
/**
|
||||
* Look up the string representation of PI check settings (prchk:guard|reftag)
|
||||
*
|
||||
* \param prchk_flags PI check flags to convert.
|
||||
*
|
||||
* \return static string constant describing PI check settings. If prchk_flags is 0,
|
||||
* NULL is returned.
|
||||
*/
|
||||
const char *spdk_nvme_prchk_flags_str(uint32_t prchk_flags);
|
||||
|
||||
/**
|
||||
* Determine whether the NVMe library can handle a specific NVMe over Fabrics
|
||||
* transport type.
|
||||
|
@ -965,4 +965,57 @@ spdk_nvme_transport_id_compare(const struct spdk_nvme_transport_id *trid1,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_prchk_flags_parse(uint32_t *prchk_flags, const char *str)
|
||||
{
|
||||
size_t val_len;
|
||||
char key[32];
|
||||
char val[1024];
|
||||
|
||||
if (prchk_flags == NULL || str == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while (*str != '\0') {
|
||||
val_len = parse_next_key(&str, key, val, sizeof(key), sizeof(val));
|
||||
|
||||
if (val_len == 0) {
|
||||
SPDK_ERRLOG("Failed to parse prchk\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (strcasecmp(key, "prchk") == 0) {
|
||||
if (strcasestr(val, "reftag") != NULL) {
|
||||
*prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
|
||||
}
|
||||
if (strcasestr(val, "guard") != NULL) {
|
||||
*prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
|
||||
}
|
||||
} else {
|
||||
SPDK_ERRLOG("Unknown key '%s'\n", key);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
spdk_nvme_prchk_flags_str(uint32_t prchk_flags)
|
||||
{
|
||||
if (prchk_flags & SPDK_NVME_IO_FLAGS_PRCHK_REFTAG) {
|
||||
if (prchk_flags & SPDK_NVME_IO_FLAGS_PRCHK_GUARD) {
|
||||
return "prchk:reftag|guard";
|
||||
} else {
|
||||
return "prchk:reftag";
|
||||
}
|
||||
} else {
|
||||
if (prchk_flags & SPDK_NVME_IO_FLAGS_PRCHK_GUARD) {
|
||||
return "prchk:guard";
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
||||
|
Loading…
Reference in New Issue
Block a user