#include "solidigm-garbage-collection.h"
#include "solidigm-util.h"
-typedef struct __attribute__((packed)) gc_item {
+struct __packed gc_item {
__le32 timer_type;
__le64 timestamp;
-} gc_item_t;
+};
#define VU_GC_MAX_ITEMS 100
-typedef struct garbage_control_collection_log {
+struct garbage_control_collection_log {
__le16 version_major;
__le16 version_minor;
- gc_item_t item[VU_GC_MAX_ITEMS];
+ struct __packed gc_item item[VU_GC_MAX_ITEMS];
__u8 reserved[2892];
-} garbage_control_collection_log_t;
+};
-static void vu_gc_log_show_json(garbage_control_collection_log_t *payload, const char *devname)
+static void vu_gc_log_show_json(struct garbage_control_collection_log *payload, const char *devname)
{
struct json_object *gc_entries = json_create_array();
for (int i = 0; i < VU_GC_MAX_ITEMS; i++) {
- gc_item_t item = payload->item[i];
+ struct __packed gc_item item = payload->item[i];
struct json_object *entry = json_create_object();
+
json_object_add_value_int(entry, "timestamp", le64_to_cpu(item.timestamp));
json_object_add_value_int(entry, "timer_type", le32_to_cpu(item.timer_type));
json_array_add_value_object(gc_entries, entry);
json_free_object(gc_entries);
}
-static void vu_gc_log_show(garbage_control_collection_log_t *payload, const char *devname,
+static void vu_gc_log_show(struct garbage_control_collection_log *payload, const char *devname,
__u8 uuid_index)
{
printf("Solidigm Garbage Collection Log for NVME device:%s UUID-idx:%d\n", devname,
printf("Timestamp Timer Type\n");
for (int i = 0; i < VU_GC_MAX_ITEMS; i++) {
- gc_item_t item = payload->item[i];
+ struct __packed gc_item item = payload->item[i];
+
printf("%-13" PRIu64 " %d\n", le64_to_cpu(item.timestamp), le32_to_cpu(item.timer_type));
}
}
return err;
enum nvme_print_flags flags = validate_output_format(cfg.output_format);
+
if (flags == -EINVAL) {
fprintf(stderr, "Invalid output format '%s'\n", cfg.output_format);
dev_close(dev);
- return EINVAL;
+ return -EINVAL;
}
uuid_index = solidigm_get_vu_uuid_index(dev);
- garbage_control_collection_log_t gc_log;
+ struct garbage_control_collection_log gc_log;
const int solidigm_vu_gc_log_id = 0xfd;
struct nvme_get_log_args args = {
.lpo = 0,
err = nvme_get_log(&args);
if (!err) {
- if (flags & BINARY) {
+ if (flags & BINARY)
d_raw((unsigned char *)&gc_log, sizeof(gc_log));
- } else if (flags & JSON) {
+ else if (flags & JSON)
vu_gc_log_show_json(&gc_log, dev->name);
- } else {
+ else
vu_gc_log_show(&gc_log, dev->name, uuid_index);
- }
- }
- else if (err > 0) {
+ } else if (err > 0) {
nvme_show_status(err);
}
.cdw13 = 0,
};
int output;
- int core_num,err;
+ int core_num, err;
err = read_header(&cmd, dev_fd(dev));
if (err)
bool all = false;
const char *desc = "Get Debug Firmware Logs and save them.";
- const char *type = "Log type: ALL, CONTROLLERINITTELEMETRY, HOSTINITTELEMETRY, "
- "HOSTINITTELEMETRYNOGEN, NLOG, ASSERT, EVENT. Defaults to ALL.";
+ const char *type =
+ "Log type: ALL, CONTROLLERINITTELEMETRY, HOSTINITTELEMETRY, HOSTINITTELEMETRYNOGEN, NLOG, ASSERT, EVENT. Defaults to ALL.";
const char *prefix = "Output file prefix; defaults to device serial number.";
const char *verbose = "To print out verbose info.";
const char *namespace_id = "Namespace to get logs from.";
__u32 bucket_data = le32_to_cpu(lt->stats.data[id]);
if (lt->print_flags == NORMAL) {
-
printf("%-*d", COL_WIDTH, id);
get_time_unit_label(buffer, lower_us, true);
__u32 bytes_per, __u32 us_step,
bool nonzero_print)
{
- for (int i = (start_offset / bytes_per) - 1;
- i < end_offset / bytes_per; i++) {
- if (nonzero_print && lt->stats.data[i] == 0)
+ for (int i = (start_offset / bytes_per) - 1; i < end_offset / bytes_per; i++) {
+ if (nonzero_print && !lt->stats.data[i])
continue;
- latency_tracker_bucket_parse(lt, i, us_step * i,
- us_step * (i + 1), true);
+ latency_tracker_bucket_parse(lt, i, us_step * i, us_step * (i + 1), true);
}
}
static int latency_tracker_bucket_pos2us(const struct latency_tracker *lt, int i)
{
__u32 base_val = 1 << lt->base_range_bits;
+
if (i < (base_val << 1))
return i;
* "values" : {
*/
static void latency_tracker_populate_json_root(const struct latency_tracker *lt,
- struct json_object *root)
+ struct json_object *root)
{
struct json_object *subroot = json_create_object();
json_object_add_value_object(root, "latstats", subroot);
json_object_add_value_string(subroot, "type", lt->cfg.write ? "write" : "read");
- if (lt->has_average_latency_field) {
- json_object_add_value_uint64(subroot, "average_latency", le64_to_cpu(lt->stats.average_latency));
- }
+ if (lt->has_average_latency_field)
+ json_object_add_value_uint64(subroot, "average_latency",
+ le64_to_cpu(lt->stats.average_latency));
json_object_add_value_object(subroot, "values", lt->bucket_list);
}
int lower_us = latency_tracker_bucket_pos2us(lt, i);
int upper_us = latency_tracker_bucket_pos2us(lt, i + 1);
- latency_tracker_bucket_parse(lt, i, lower_us,
- upper_us,
+ latency_tracker_bucket_parse(lt, i, lower_us, upper_us,
i < (lt->bucket_list_size - 1));
}
}
-static void print_dash_separator()
+static void print_dash_separator(void)
{
printf("--------------------------------------------------\n");
}
printf("UUID-idx: %d\n", lt->uuid_index);
printf("Major Revision: %u\nMinor Revision: %u\n",
le16_to_cpu(lt->stats.version_major), le16_to_cpu(lt->stats.version_minor));
- if (lt->has_average_latency_field) {
+ if (lt->has_average_latency_field)
printf("Average Latency: %" PRIu64 "\n", le64_to_cpu(lt->stats.average_latency));
- }
print_dash_separator();
printf("%-12s%-12s%-12s%-20s\n", "Bucket", "Start", "End", "Value");
print_dash_separator();
}
- if (lt->print_flags == JSON) {
+ if (lt->print_flags == JSON)
lt->bucket_list = json_object_new_array();
- }
}
static void latency_tracker_post_parse(struct latency_tracker *lt)
latency_tracker_parse_3_0(lt);
break;
case 4:
- if (version_minor >= 8){
+ if (version_minor >= 8)
lt->has_average_latency_field = true;
- }
latency_tracker_pre_parse(lt);
- if (version_minor == 0){
+ if (!version_minor) {
lt->base_range_bits = BASE_RANGE_BITS_4_0;
lt->bucket_list_size = BUCKET_LIST_SIZE_4_0;
}
#define LATENCY_TRACKING_FID 0xe2
#define LATENCY_TRACKING_FID_DATA_LEN 32
-static int latency_tracking_is_enable(struct latency_tracker *lt, __u32 * enabled)
+static int latency_tracking_is_enable(struct latency_tracker *lt, __u32 *enabled)
{
struct nvme_get_features_args args_get = {
.args_size = sizeof(args_get),
__u32 result;
int err;
- if (!(lt->cfg.enable || lt->cfg.disable)){
+ if (!(lt->cfg.enable || lt->cfg.disable))
return 0;
- }
- if (lt->cfg.enable && lt->cfg.disable){
- fprintf(stderr,"Cannot enable and disable simultaneously.\n");
- return EINVAL;
+ if (lt->cfg.enable && lt->cfg.disable) {
+ fprintf(stderr, "Cannot enable and disable simultaneously.\n");
+ return -EINVAL;
}
struct nvme_set_features_args args_set = {
{
int err;
- if (lt->cfg.read && lt->cfg.write){
- fprintf(stderr,"Cannot capture read and write logs simultaneously.\n");
- return EINVAL;
+ if (lt->cfg.read && lt->cfg.write) {
+ fprintf(stderr, "Cannot capture read and write logs simultaneously.\n");
+ return -EINVAL;
}
if (!(lt->cfg.read || lt->cfg.write))
if (lt.print_flags == -EINVAL) {
fprintf(stderr, "Invalid output format '%s'\n", lt.cfg.output_format);
dev_close(dev);
- return EINVAL;
+ return -EINVAL;
}
if (lt.cfg.type > 0xf) {
fprintf(stderr, "Invalid Log type value '%d'\n", lt.cfg.type);
dev_close(dev);
- return EINVAL;
+ return -EINVAL;
}
if (lt.cfg.type && !(lt.cfg.read || lt.cfg.write)) {
fprintf(stderr, "Log type option valid only when retrieving statistics\n");
dev_close(dev);
- return EINVAL;
+ return -EINVAL;
}
lt.uuid_index = solidigm_get_vu_uuid_index(dev);
err = latency_tracking_enable(<);
- if (err){
+ if (err) {
dev_close(dev);
return err;
}
err = latency_tracker_get_log(<);
- if (err){
+ if (err) {
dev_close(dev);
return err;
}
if (!err) {
if (lt.print_flags == JSON) {
struct json_object *root = json_create_object();
- json_object_add_value_int(root,"enabled", enabled);
+
+ json_object_add_value_int(root, "enabled", enabled);
json_print_object(root, NULL);
json_free_object(root);
printf("\n");
} else if (lt.print_flags == BINARY) {
putchar(enabled);
} else {
- printf(
- "Latency Statistics Tracking (UUID-idx:%d, FID:0x%X) is currently %i.\n",
- lt.uuid_index, LATENCY_TRACKING_FID, enabled);
+ printf("Latency Statistics Tracking (UUID-idx:%d, FID:0x%X) is currently %i.\n",
+ lt.uuid_index, LATENCY_TRACKING_FID, enabled);
}
} else {
fprintf(stderr, "Could not read feature id 0xE2.\n");
#define SOLIDIGM_MAX_UUID 2
struct lid_dir {
- struct __attribute__((packed)) {
+ struct __packed {
bool supported;
const char *str;
} lid[NVME_LOG_SUPPORTED_LOG_PAGES_MAX];
static bool is_invalid_uuid(const struct nvme_id_uuid_list_entry entry)
{
static const unsigned char ALL_ZERO_UUID[NVME_UUID_LEN] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
return memcmp(ALL_ZERO_UUID, entry.uuid, NVME_UUID_LEN) == 0;
static int get_supported_log_pages_log(struct nvme_dev *dev, int uuid_index,
struct nvme_supported_log_pages *supported)
{
- static const __u8 LID = 0x00;
+ static const __u8 LID;
memset(supported, 0, sizeof(*supported));
struct nvme_get_log_args args = {
return nvme_get_log(&args);
}
-static struct lid_dir* get_standard_lids(struct nvme_supported_log_pages *supported)
+static struct lid_dir *get_standard_lids(struct nvme_supported_log_pages *supported)
{
static struct lid_dir standard_dir = { 0 };
}
static void update_vendor_lid_supported(struct nvme_supported_log_pages *supported,
- struct lid_dir* lid_dir)
+ struct lid_dir *lid_dir)
{
for (int lid = 0; lid < NVME_LOG_SUPPORTED_LOG_PAGES_MAX; lid++) {
- if (!supported->lid_support[lid]|| lid < MIN_VENDOR_LID)
+ if (!supported->lid_support[lid] || lid < MIN_VENDOR_LID)
continue;
lid_dir->lid[lid].supported = true;
}
}
-static struct lid_dir* get_solidigm_lids(struct nvme_supported_log_pages *supported)
+static struct lid_dir *get_solidigm_lids(struct nvme_supported_log_pages *supported)
{
static struct lid_dir solidigm_dir = { 0 };
return &solidigm_dir;
}
-static struct lid_dir* get_ocp_lids(struct nvme_supported_log_pages *supported)
+static struct lid_dir *get_ocp_lids(struct nvme_supported_log_pages *supported)
{
static struct lid_dir ocp_dir = { 0 };
struct lid_dir *lid_dirs[SOLIDIGM_MAX_UUID + 1] = { 0 };
struct nvme_id_uuid_list uuid_list = { 0 };
struct nvme_supported_log_pages supported = { 0 };
-
+
err = get_supported_log_pages_log(dev, NO_UUID_INDEX, &supported);
if (!err) {
if (solidigm_lid_dir->lid[lid].supported)
lid_dirs[NO_UUID_INDEX]->lid[lid] = solidigm_lid_dir->lid[lid];
}
- }
- else {
+ } else {
for (int uuid_index = 1; uuid_index <= SOLIDIGM_MAX_UUID; uuid_index++) {
if (is_invalid_uuid(uuid_list.entry[uuid_index - 1]))
break;
else if (get_supported_log_pages_log(dev, uuid_index, &supported))
continue;
-
+
if (is_solidigm_uuid(uuid_list.entry[uuid_index - 1]))
lid_dirs[uuid_index] = get_solidigm_lids(&supported);
else if (is_ocp_uuid(uuid_list.entry[uuid_index - 1]))
lid_dirs[uuid_index] = get_ocp_lids(&supported);
}
}
- }
- else
+ } else {
nvme_show_status(err);
+ }
if (!err) {
const enum nvme_print_flags print_flag = validate_output_format(format);
- if (print_flag == NORMAL)
+ if (print_flag == NORMAL) {
supported_log_pages_normal(lid_dirs);
- else if (print_flag == JSON) {
+ } else if (print_flag == JSON) {
supported_log_pages_json(lid_dirs);
} else {
fprintf(stderr, "Error: Invalid output format specified: %s.\n", format);
#include "solidigm-smart.h"
#include "solidigm-util.h"
-struct __attribute__((packed)) nvme_additional_smart_log_item {
+struct __packed nvme_additional_smart_log_item {
__u8 id;
__u8 _kp[2];
__u8 normalized;
__u8 _np;
- union __attribute__((packed)) {
+ union __packed {
__u8 raw[6];
- struct __attribute__((packed)) wear_level {
+ struct __packed wear_level {
__le16 min;
__le16 max;
__le16 avg;
} wear_level;
- struct __attribute__((packed)) thermal_throttle {
+ struct __packed thermal_throttle {
__u8 pct;
__u32 count;
} thermal_throttle;
- } ;
+ };
__u8 _rp;
-} ;
-typedef struct nvme_additional_smart_log_item smart_log_item_t;
+};
#define VU_SMART_PAGE_SIZE 512
-#define VU_SMART_MAX_ITEMS VU_SMART_PAGE_SIZE / sizeof(smart_log_item_t)
-typedef struct vu_smart_log {
- smart_log_item_t item[VU_SMART_MAX_ITEMS];
-} vu_smart_log_t;
+#define VU_SMART_MAX_ITEMS (VU_SMART_PAGE_SIZE / sizeof(struct nvme_additional_smart_log_item))
+struct vu_smart_log {
+ struct nvme_additional_smart_log_item item[VU_SMART_MAX_ITEMS];
+};
static char *id_to_name(__u8 id)
{
}
}
-static void smart_log_item_print(smart_log_item_t *item)
+static void smart_log_item_print(struct nvme_additional_smart_log_item *item)
{
- if (!item->id) {
+ if (!item->id)
return;
- }
printf("%#x %-45s %3d ",
item->id, id_to_name(item->id), item->normalized);
}
}
-static void smart_log_item_add_json(smart_log_item_t *item, struct json_object *dev_stats)
+static void smart_log_item_add_json(struct nvme_additional_smart_log_item *item, struct json_object *dev_stats)
{
struct json_object *entry_stats = json_create_object();
- if (!item->id) {
+ if (!item->id)
return;
- }
json_object_add_value_int(entry_stats, "normalized", item->normalized);
json_object_add_value_object(dev_stats, id_to_name(item->id), entry_stats);
}
-static void vu_smart_log_show_json(vu_smart_log_t *payload, unsigned int nsid, const char *devname)
+static void vu_smart_log_show_json(struct vu_smart_log *payload, unsigned int nsid, const char *devname)
{
struct json_object *dev_stats = json_create_object();
- smart_log_item_t *item = payload->item;
+ struct nvme_additional_smart_log_item *item = payload->item;
struct json_object *root;
- for (int i = 0; i < VU_SMART_MAX_ITEMS; i++) {
+ for (int i = 0; i < VU_SMART_MAX_ITEMS; i++)
smart_log_item_add_json(&item[i], dev_stats);
- }
root = json_create_object();
json_object_add_value_string(root, "Solidigm SMART log", devname);
json_free_object(root);
}
-static void vu_smart_log_show(vu_smart_log_t *payload, unsigned int nsid, const char *devname,
+static void vu_smart_log_show(struct vu_smart_log *payload, unsigned int nsid, const char *devname,
__u8 uuid_index)
{
- smart_log_item_t *item = payload->item;
+ struct nvme_additional_smart_log_item *item = payload->item;
printf("Additional Smart Log for NVMe device:%s namespace-id:%x UUID-idx:%d\n",
devname, nsid, uuid_index);
printf("ID KEY Normalized Raw\n");
- for (int i = 0; i < VU_SMART_MAX_ITEMS; i++) {
+ for (int i = 0; i < VU_SMART_MAX_ITEMS; i++)
smart_log_item_print(&item[i]);
- }
}
int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
- const char *desc = "Get Solidigm vendor specific smart log (optionally, "\
- "for the specified namespace), and show it.";
+ const char *desc =
+ "Get Solidigm vendor specific smart log (optionally, for the specified namespace), and show it.";
const int solidigm_vu_smart_log_id = 0xCA;
- vu_smart_log_t smart_log_payload;
+ struct vu_smart_log smart_log_payload;
enum nvme_print_flags flags;
struct nvme_dev *dev;
int err;
err = nvme_get_log(&args);
if (!err) {
- if (flags & JSON) {
+ if (flags & JSON)
vu_smart_log_show_json(&smart_log_payload,
cfg.namespace_id, dev->name);
- } else if (flags & BINARY) {
+ else if (flags & BINARY)
d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload));
- } else {
+ else
vu_smart_log_show(&smart_log_payload, cfg.namespace_id,
dev->name, uuid_index);
- }
} else if (err > 0) {
nvme_show_status(err);
}
cfg.cfg_file, strerror(err));
goto close_fd;
}
- struct json_tokener * jstok = json_tokener_new();
+ struct json_tokener *jstok = json_tokener_new();
tl.configuration = json_tokener_parse_ex(jstok, conf_str, length);
free(conf_str);
static const char *getOemDataMapDescription(uint32_t id)
{
- if (id < (sizeof(oemDataMapDesc) / sizeof(oemDataMapDesc[0]))) {
+ if (id < ARRAY_SIZE(oemDataMapDesc))
return oemDataMapDesc[id];
- }
return "unknown";
}
#define OEMSIGNATURE 0x504D4443
#pragma pack(push, cod, 1)
-struct cod_header
-{
+struct cod_header {
uint32_t versionMajor;
uint32_t versionMinor;
uint32_t Signature; //!Fixed signature value (0x504D4443) for identification and validation
uint8_t Reserved[12];
};
-struct cod_item
-{
+struct cod_item {
uint32_t DataFieldMapUid; //!The data field unique identifier value
uint32_t reserved1 : 8;
uint32_t dataFieldType : 8;
uint8_t Reserved2[8];
};
-struct cod_map
-{
+struct cod_map {
struct cod_header header;
struct cod_item items[];
};
void solidigm_telemetry_log_cod_parse(struct telemetry_log *tl)
{
- enum cod_field_type
- {
+ enum cod_field_type {
INTEGER,
FLOAT,
STRING,
uint64_t offset = json_object_get_int(COD_offset);
- if (offset == 0) {
+ if (!offset)
return;
- }
if ((offset + sizeof(struct cod_header)) > tl->log_size) {
SOLIDIGM_LOG_WARNING("Warning: COD map header out of bounds.");
const struct cod_map *data = (struct cod_map *) (((uint8_t *)tl->log) + offset);
uint32_t signature = be32_to_cpu(data->header.Signature);
- if ( signature != OEMSIGNATURE){
+
+ if (signature != OEMSIGNATURE) {
SOLIDIGM_LOG_WARNING("Warning: Unsupported COD data signature %x!", signature);
return;
}
- if ((offset + data->header.MapSizeInBytes) > tl->log_size){
+ if ((offset + data->header.MapSizeInBytes) > tl->log_size) {
SOLIDIGM_LOG_WARNING("Warning: COD map data out of bounds.");
return;
}
struct json_object *cod = json_create_object();
+
json_object_object_add(tl->root, "cod", cod);
for (uint64_t i = 0; i < data->header.EntryCount; i++) {
if ((offset + sizeof(struct cod_header) + (i + 1) * sizeof(struct cod_item)) >
- tl->log_size){
+ tl->log_size) {
SOLIDIGM_LOG_WARNING("Warning: COD data out of bounds at item %"PRIu64"!",
i);
return;
}
struct cod_item item = data->items[i];
- if (item.DataFieldOffset + item.DataFieldOffset > tl->log_size) {
+
+ if (item.DataFieldOffset + item.DataFieldOffset > tl->log_size)
continue;
- }
- if (item.dataInvalid) {
+ if (item.dataInvalid)
continue;
- }
- uint8_t *val = ((uint8_t *)tl->log )+ item.DataFieldOffset;
+ uint8_t *val = ((uint8_t *)tl->log) + item.DataFieldOffset;
const char *key = getOemDataMapDescription(item.DataFieldMapUid);
- switch(item.dataFieldType){
- case(INTEGER):
- if (item.issigned) {
- json_object_object_add(cod, key,
- json_object_new_int64(le64_to_cpu(*(uint64_t *)val)));
- } else {
- json_object_add_value_uint64(cod, key, le64_to_cpu(*(uint64_t *)val));
- }
- break;
- case(FLOAT):
- json_object_add_value_float(cod, key, *(float *) val);
- break;
- case(STRING):
- json_object_object_add(cod, key,
- json_object_new_string_len((const char *)val, item.DataFieldSizeInBytes));
- break;
- case(TWO_BYTE_ASCII):
- json_object_object_add(cod, key,
- json_object_new_string_len((const char *)val,2));
- break;
- case(FOUR_BYTE_ASCII):
+
+ switch (item.dataFieldType) {
+ case INTEGER:
+ if (item.issigned)
json_object_object_add(cod, key,
- json_object_new_string_len((const char *)val, 4));
- break;
- default:
- SOLIDIGM_LOG_WARNING("Warning: Unknown COD field type (%d)", item.DataFieldMapUid);
-
+ json_object_new_int64(le64_to_cpu(*(uint64_t *)val)));
+ else
+ json_object_add_value_uint64(cod, key, le64_to_cpu(*(uint64_t *)val));
+ break;
+ case FLOAT:
+ json_object_add_value_float(cod, key, *(float *)val);
+ break;
+ case STRING:
+ json_object_object_add(cod, key,
+ json_object_new_string_len((const char *)val, item.DataFieldSizeInBytes));
+ break;
+ case TWO_BYTE_ASCII:
+ json_object_object_add(cod, key,
+ json_object_new_string_len((const char *)val, 2));
+ break;
+ case FOUR_BYTE_ASCII:
+ json_object_object_add(cod, key,
+ json_object_new_string_len((const char *)val, 4));
+ break;
+ default:
+ SOLIDIGM_LOG_WARNING("Warning: Unknown COD field type (%d)", item.DataFieldMapUid);
+ break;
}
}
}
uint32_t offset_byte;
uint64_t val;
- if (size_bit == 0) {
+ if (!size_bit) {
char err_msg[MAX_WARNING_SIZE];
snprintf(err_msg, MAX_WARNING_SIZE,
char err_msg[MAX_WARNING_SIZE];
snprintf(err_msg, MAX_WARNING_SIZE,
- "Value crossing 64 bit, byte aligned bounday, "
- "not supported. size_bit=%u, offset_bit_from_byte=%u.",
- size_bit, offset_bit_from_byte);
+ "Value crossing 64 bit, byte aligned bounday, not supported. size_bit=%u, offset_bit_from_byte=%u.",
+ size_bit, offset_bit_from_byte);
*val_obj = json_object_new_string(err_msg);
return false;
type = json_object_get_string(obj);
if (!json_object_object_get_ex(struct_def, "offsetBit", &obj)) {
- SOLIDIGM_LOG_WARNING("Warning: Structure definition missing "
- "property 'offsetBit': %s",
- json_object_to_json_string(struct_def));
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Structure definition missing property 'offsetBit': %s",
+ json_object_to_json_string(struct_def));
return -1;
}
offset_bit = json_object_get_uint64(obj);
if (!json_object_object_get_ex(struct_def, "sizeBit", &obj)) {
- SOLIDIGM_LOG_WARNING("Warning: Structure definition missing "
- "property 'sizeBit': %s",
- json_object_to_json_string(struct_def));
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Structure definition missing property 'sizeBit': %s",
+ json_object_to_json_string(struct_def));
return -1;
}
if (!json_object_object_get_ex(struct_def, "arraySize",
&obj_arraySizeArray)) {
- SOLIDIGM_LOG_WARNING("Warning: Structure definition missing "
- "property 'arraySize': %s",
- json_object_to_json_string(struct_def));
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Structure definition missing property 'arraySize': %s",
+ json_object_to_json_string(struct_def));
return -1;
}
array_rank = json_object_array_length(obj_arraySizeArray);
- if (array_rank == 0) {
- SOLIDIGM_LOG_WARNING("Warning: Structure property 'arraySize' "
- "don't support flexible array: %s",
- json_object_to_json_string(struct_def));
+ if (!array_rank) {
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Structure property 'arraySize' don't support flexible array: %s",
+ json_object_to_json_string(struct_def));
return -1;
}
if (array_rank > MAX_ARRAY_RANK) {
- SOLIDIGM_LOG_WARNING("Warning: Structure property 'arraySize' "
- "don't support more than %d dimensions: %s", MAX_ARRAY_RANK,
- json_object_to_json_string(struct_def));
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Structure property 'arraySize' don't support more than %d dimensions: %s",
+ MAX_ARRAY_RANK, json_object_to_json_string(struct_def));
return -1;
}
else
json_object_object_add(sub_output, name, val_obj);
} else {
- SOLIDIGM_LOG_WARNING("Warning: %s From property '%s', "
- "array index %u, structure definition: %s",
- json_object_get_string(val_obj),
- name, j, json_object_to_json_string(struct_def));
+ SOLIDIGM_LOG_WARNING(
+ "Warning: %s From property '%s', array index %u, structure definition: %s",
+ json_object_get_string(val_obj), name, j,
+ json_object_to_json_string(struct_def));
json_free_object(val_obj);
}
} else {
const char *nlog_name = NULL;
uint32_t header_offset = sizeof(const struct telemetry_object_header);
- if ((char *)&toc->items[i] > (((char *)toc) + da_size - sizeof(const struct toc_item))) {
- SOLIDIGM_LOG_WARNING("Warning: Data Area %d, "
- "Table of Contents item %d "
- "crossed Data Area size.", da, i);
+ if ((char *)&toc->items[i] >
+ (((char *)toc) + da_size - sizeof(const struct toc_item))) {
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Data Area %d, Table of Contents item %d crossed Data Area size.",
+ da, i);
return;
}
obj_offset = toc->items[i].OffsetBytes;
if ((obj_offset + sizeof(const struct telemetry_object_header)) > da_size) {
- SOLIDIGM_LOG_WARNING("Warning: Data Area %d, item %d "
- "data, crossed Data Area size.", da, i);
+ SOLIDIGM_LOG_WARNING(
+ "Warning: Data Area %d, item %d data, crossed Data Area size.", da, i);
continue;
}
json_object_add_value_uint(toc_item, "mediaBankId", header->CoreId);
has_struct = solidigm_config_get_struct_by_token_version(tl->configuration,
- header->Token,
- header->versionMajor,
- header->versionMinor,
- &structure_definition);
+ header->Token,
+ header->versionMajor,
+ header->versionMinor,
+ &structure_definition);
if (!has_struct) {
if (!nlog_formats)
continue;
#include "header.h"
#pragma pack(push, reason_indentifier, 1)
-struct reason_indentifier_1_0
-{
+struct reason_indentifier_1_0 {
uint16_t versionMajor;
uint16_t versionMinor;
uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue.
MEMBER_SIZE(struct nvme_telemetry_log, rsnident),
"Size mismatch for reason_indentifier_1_0");
-struct reason_indentifier_1_1
-{
+struct reason_indentifier_1_1 {
uint16_t versionMajor;
uint16_t versionMinor;
uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue.
MEMBER_SIZE(struct nvme_telemetry_log, rsnident),
"Size mismatch for reason_indentifier_1_1");
-struct reason_indentifier_1_2
-{
+struct reason_indentifier_1_2 {
uint16_t versionMajor;
uint16_t versionMinor;
uint32_t reasonCode; //! 0 denotes no issue. All other values denote a potential issue.
reserved = json_create_array();
json_object_add_value_array(reason_id, "reserved", reserved);
- for ( int i=0; i < sizeof(ri->Reserved); i++) {
+ for (int i = 0; i < sizeof(ri->Reserved); i++) {
struct json_object *val = json_object_new_int(ri->Reserved[i]);
+
json_object_array_add(reserved, val);
}
}
json_object_add_value_array(reason_id, "reserved", reserved);
for (int i = 0; i < sizeof(ri->Reserved); i++) {
struct json_object *val = json_object_new_int(ri->Reserved[i]);
+
json_object_array_add(reserved, val);
}
}
json_object_add_value_array(reason_id, "reserved2", reserved);
for (int i = 0; i < sizeof(ri->Reserved2); i++) {
struct json_object *val = json_object_new_int(ri->Reserved2[i]);
+
json_object_array_add(reserved, val);
}
json_object_add_value_array(reason_id, "dualPortReserved", dp_reserved);
for (int i = 0; i < sizeof(ri->DualPortReserved); i++) {
struct json_object *val = json_object_new_int(ri->DualPortReserved[i]);
+
json_object_array_add(dp_reserved, val);
}
}
sizeof(ri1_0->DriveStatus)));
if (version_major == 1) {
switch (version_minor) {
- case 0:
- telemetry_log_reason_id_parse1_0_ext(tl, reason_id);
- break;
- case 1:
- telemetry_log_reason_id_parse1_1_ext(tl, reason_id);
- break;
- default:
- telemetry_log_reason_id_parse1_2_ext(tl, reason_id);
+ case 0:
+ telemetry_log_reason_id_parse1_0_ext(tl, reason_id);
+ break;
+ case 1:
+ telemetry_log_reason_id_parse1_1_ext(tl, reason_id);
+ break;
+ default:
+ telemetry_log_reason_id_parse1_2_ext(tl, reason_id);
+ break;
}
}
}