summaryrefslogtreecommitdiffstats
path: root/plugins/solidigm/solidigm-telemetry/config.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-30 22:38:48 +0000
commit01c4d3d32c5044d3d17055c2d94d40fee9d130e1 (patch)
tree2c213cd5436bff644fa7023b94674a9c12d2e1af /plugins/solidigm/solidigm-telemetry/config.c
parentAdding upstream version 2.4+really2.4. (diff)
downloadnvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.tar.xz
nvme-cli-01c4d3d32c5044d3d17055c2d94d40fee9d130e1.zip
Adding upstream version 2.5.upstream/2.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/solidigm/solidigm-telemetry/config.c')
-rw-r--r--plugins/solidigm/solidigm-telemetry/config.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/plugins/solidigm/solidigm-telemetry/config.c b/plugins/solidigm/solidigm-telemetry/config.c
index 5111703..cc2a8bb 100644
--- a/plugins/solidigm/solidigm-telemetry/config.c
+++ b/plugins/solidigm/solidigm-telemetry/config.c
@@ -4,13 +4,17 @@
*
* Author: leonardo.da.cunha@solidigm.com
*/
-#include <stdbool.h>
-#include "util/json.h"
+
#include <stdio.h>
+#include <string.h>
+#include "config.h"
// max 16 bit unsigned integer nummber 65535
#define MAX_16BIT_NUM_AS_STRING_SIZE 6
+#define OBJ_NAME_PREFIX "UID_"
+#define NLOG_OBJ_PREFIX OBJ_NAME_PREFIX "NLOG_"
+
static bool config_get_by_version(const struct json_object *obj, int version_major,
int version_minor, struct json_object **value)
{
@@ -28,17 +32,45 @@ static bool config_get_by_version(const struct json_object *obj, int version_maj
return value != NULL;
}
-bool solidigm_config_get_by_token_version(const struct json_object *obj, int token_id,
+bool solidigm_config_get_struct_by_token_version(const struct json_object *config, int token_id,
int version_major, int version_minor,
struct json_object **value)
{
- struct json_object *token_obj = NULL;
+ struct json_object *token = NULL;
char str_key[MAX_16BIT_NUM_AS_STRING_SIZE];
snprintf(str_key, sizeof(str_key), "%d", token_id);
- if (!json_object_object_get_ex(obj, str_key, &token_obj))
+ if (!json_object_object_get_ex(config, str_key, &token))
return false;
- if (!config_get_by_version(token_obj, version_major, version_minor, value))
+ if (!config_get_by_version(token, version_major, version_minor, value))
return false;
return value != NULL;
}
+
+const char *solidigm_config_get_nlog_obj_name(const struct json_object *config, uint32_t token)
+{
+ struct json_object *nlog_names = NULL;
+ struct json_object *obj_name;
+ char hex_header[STR_HEX32_SIZE];
+ const char *name;
+
+ if (!json_object_object_get_ex(config, "TELEMETRY_OBJECT_UIDS", &nlog_names))
+ return NULL;
+ snprintf(hex_header, STR_HEX32_SIZE, "0x%08X", token);
+
+ if (!json_object_object_get_ex(nlog_names, hex_header, &obj_name))
+ return NULL;
+ name = json_object_get_string(obj_name);
+ if (strncmp(NLOG_OBJ_PREFIX, name, strlen(NLOG_OBJ_PREFIX)))
+ return NULL;
+
+ return &name[strlen(OBJ_NAME_PREFIX)];
+}
+
+struct json_object *solidigm_config_get_nlog_formats(const struct json_object *config)
+{
+ struct json_object *nlog_formats = NULL;
+
+ json_object_object_get_ex(config, "NLOG_FORMATS", &nlog_formats);
+ return nlog_formats;
+}