Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/solidigm/solidigm-nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "cmd.h"

#define SOLIDIGM_PLUGIN_VERSION "1.20"
#define SOLIDIGM_PLUGIN_VERSION "1.21"

PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_VERSION),
COMMAND_LIST(
Expand Down
2 changes: 0 additions & 2 deletions plugins/solidigm/solidigm-telemetry/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <stdio.h>
#include <string.h>

#include <json.h>

#include "config.h"
#include "telemetry-log.h"

Expand Down
66 changes: 11 additions & 55 deletions plugins/solidigm/solidigm-telemetry/data-area.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* Author: [email protected]
*/

#include <ctype.h>

#include "cod.h"
#include "common.h"
#include "config.h"
Expand All @@ -23,36 +21,6 @@
#define MAX_ARRAY_RANK 16
#define NLOG_HEADER_ID 101

static bool uint8_array_try_string(const struct telemetry_log *tl,
uint64_t offset_bit, uint32_t size_bit,
uint32_t array_size,
struct json_object **str_obj)
{
uint32_t offset_byte = (uint32_t)offset_bit / NUM_BITS_IN_BYTE;

if (size_bit != 8) {
*str_obj = json_object_new_string(
"Error: Only UINT8 arrays can be converted to strings");
return false;
}

if (offset_byte > (tl->log_size - array_size)) {
char err_msg[MAX_WARNING_SIZE];

snprintf(err_msg, MAX_WARNING_SIZE,
"String offset greater than binary size (%u > %zu).",
offset_byte, tl->log_size);
*str_obj = json_object_new_string(err_msg);
return false;
}

// Get direct pointer to the UINT8 array in the telemetry log
const uint8_t *data_ptr = (const uint8_t *)tl->log + offset_byte;

// Use the generic converter function
return sldm_uint8_array_to_string(data_ptr, array_size, str_obj);
}

static void reverse_string(char *buff, size_t len)
{
char *start = buff;
Expand Down Expand Up @@ -240,12 +208,17 @@ int sldm_telemetry_structure_parse(const struct telemetry_log *tl,

if (array_rank > 1) {
uint32_t linear_pos_per_index = 1;
uint32_t outer_size = array_size_dimension[array_rank - 1];
uint32_t prev_index_offset_bit = 0;
struct json_object *dimension_output;
struct json_object *inner_dim_array;

/* Stride = product of all inner dimensions (1..rank-1) */
for (unsigned int i = 1; i < array_rank; i++)
/*
* arraySize convention: the last element is the outermost
* (major) dimension. Stride = product of all inner dims
* [0..rank-2].
*/
for (unsigned int i = 0; i < array_rank - 1; i++)
linear_pos_per_index *= array_size_dimension[i];

/*
Expand All @@ -260,11 +233,11 @@ int sldm_telemetry_structure_parse(const struct telemetry_log *tl,
}

/*
* Build a copy of arraySize without the first dimension
* so recursive calls see only the inner dimensions.
* Build a copy of arraySize without the last (outermost)
* dimension so recursive calls see only the inner dimensions.
*/
inner_dim_array = json_create_array();
for (size_t i = 1; i < array_rank; i++) {
for (size_t i = 0; i < array_rank - 1; i++) {
struct json_object *dim =
json_object_array_get_idx(
obj_arraySizeArray, i);
Expand All @@ -276,7 +249,7 @@ int sldm_telemetry_structure_parse(const struct telemetry_log *tl,
json_object_object_add(struct_def, "arraySize",
inner_dim_array);

for (unsigned int i = 0 ; i < array_size_dimension[0]; i++) {
for (unsigned int i = 0 ; i < outer_size; i++) {
struct json_object *sub_array = json_create_array();
uint64_t offset;

Expand All @@ -298,23 +271,6 @@ int sldm_telemetry_structure_parse(const struct telemetry_log *tl,
sub_output = output;

if (array_size_dimension[0] > 1 || force_array) {
// Check if this is a UINT8 array that should be treated as a string
if (json_object_is_type(output, json_type_object) &&
(strcmp(type, "UINT8") == 0 || strcmp(type, "uint8_t") == 0) && !force_array) {
// Handle UINT8 arrays as strings
struct json_object *str_obj = NULL;
uint64_t offset = parent_offset_bit + offset_bit;

if (uint8_array_try_string(tl, offset, size_bit,
array_size_dimension[0], &str_obj)) {
json_object_object_add(output, name, str_obj);
return 0;
}

// If string conversion failed, fall back to normal array processing
json_object_put(str_obj);
}

/*
* When output is already an array (from an outer
* multi-dim call), fill it directly to avoid extra wrap.
Expand Down
3 changes: 0 additions & 3 deletions plugins/solidigm/solidigm-telemetry/telemetry-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#include <assert.h>
#include <stdbool.h>

#include <libnvme.h>

#include "util/json.h"

#if !defined __cplusplus
Expand Down
Loading