Adding upstream version 2.2.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
28d4a2895d
commit
8dc527e3df
446 changed files with 8369 additions and 4059 deletions
|
@ -13,12 +13,14 @@
|
|||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "nvme.h"
|
||||
#include "libnvme.h"
|
||||
#include "plugin.h"
|
||||
#include "linux/types.h"
|
||||
#include "util/types.h"
|
||||
#include "nvme-print.h"
|
||||
|
||||
#define CREATE_CMD
|
||||
|
@ -122,18 +124,6 @@ struct __attribute__((__packed__)) ssd_latency_monitor_log {
|
|||
__u8 log_page_guid[0x10]; /* 0x1F0 */
|
||||
};
|
||||
|
||||
static long double int128_to_double(__u8 *data)
|
||||
{
|
||||
int i;
|
||||
long double result = 0;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
result *= 256;
|
||||
result += data[15 - i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int convert_ts(time_t time, char *ts_buf)
|
||||
{
|
||||
struct tm gmTimeInfo;
|
||||
|
@ -208,10 +198,10 @@ static void ocp_print_C0_log_normal(void *data)
|
|||
(uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN]));
|
||||
printf(" NUSE - Namespace utilization %"PRIu64"\n",
|
||||
(uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE]));
|
||||
printf(" PLP start count %.0Lf\n",
|
||||
int128_to_double(&log_data[SCAO_PSC]));
|
||||
printf(" Endurance estimate %.0Lf\n",
|
||||
int128_to_double(&log_data[SCAO_EEST]));
|
||||
printf(" PLP start count %s\n",
|
||||
uint128_t_to_string(le128_to_cpu(&log_data[SCAO_PSC])));
|
||||
printf(" Endurance estimate %s\n",
|
||||
uint128_t_to_string(le128_to_cpu(&log_data[SCAO_EEST])));
|
||||
smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]);
|
||||
printf(" Log page version %"PRIu16"\n",smart_log_ver);
|
||||
printf(" Log page GUID 0x");
|
||||
|
@ -300,10 +290,10 @@ static void ocp_print_C0_log_json(void *data)
|
|||
(uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_SVN]));
|
||||
json_object_add_value_uint64(root, "NUSE - Namespace utilization",
|
||||
(uint64_t)le64_to_cpu(*(uint64_t *)&log_data[SCAO_NUSE]));
|
||||
json_object_add_value_uint(root, "PLP start count",
|
||||
int128_to_double(&log_data[SCAO_PSC]));
|
||||
json_object_add_value_uint64(root, "Endurance estimate",
|
||||
int128_to_double(&log_data[SCAO_EEST]));
|
||||
json_object_add_value_uint128(root, "PLP start count",
|
||||
le128_to_cpu(&log_data[SCAO_PSC]));
|
||||
json_object_add_value_uint128(root, "Endurance estimate",
|
||||
le128_to_cpu(&log_data[SCAO_EEST]));
|
||||
smart_log_ver = (uint16_t)le16_to_cpu(*(uint16_t *)&log_data[SCAO_LPV]);
|
||||
json_object_add_value_uint(root, "Log page version", smart_log_ver);
|
||||
char guid[40];
|
||||
|
@ -401,7 +391,7 @@ static int ocp_smart_add_log(int argc, char **argv, struct command *cmd,
|
|||
struct plugin *plugin)
|
||||
{
|
||||
const char *desc = "Retrieve latency monitor log data.";
|
||||
int fd;
|
||||
struct nvme_dev *dev;
|
||||
int ret = 0;
|
||||
|
||||
struct config {
|
||||
|
@ -417,22 +407,23 @@ static int ocp_smart_add_log(int argc, char **argv, struct command *cmd,
|
|||
OPT_END()
|
||||
};
|
||||
|
||||
fd = parse_and_open(argc, argv, desc, opts);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
ret = parse_and_open(&dev, argc, argv, desc, opts);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = get_c0_log_page(fd, cfg.output_format);
|
||||
ret = get_c0_log_page(dev_fd(dev), cfg.output_format);
|
||||
if (ret)
|
||||
fprintf(stderr, "ERROR : OCP : Failure reading the C0 Log Page, ret = %d\n",
|
||||
ret);
|
||||
close(fd);
|
||||
dev_close(dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ocp_print_C3_log_normal(struct ssd_latency_monitor_log *log_data)
|
||||
static int ocp_print_C3_log_normal(struct nvme_dev *dev,
|
||||
struct ssd_latency_monitor_log *log_data)
|
||||
{
|
||||
printf("-Latency Monitor/C3 Log Page Data- \n");
|
||||
printf(" Controller : %s\n", devicename);
|
||||
printf(" Controller : %s\n", dev->name);
|
||||
int i, j;
|
||||
int pos = 0;
|
||||
char ts_buf[128];
|
||||
|
@ -662,7 +653,7 @@ static void ocp_print_C3_log_json(struct ssd_latency_monitor_log *log_data)
|
|||
json_free_object(root);
|
||||
}
|
||||
|
||||
static int get_c3_log_page(int fd, char *format)
|
||||
static int get_c3_log_page(struct nvme_dev *dev, char *format)
|
||||
{
|
||||
int ret = 0;
|
||||
int fmt = -1;
|
||||
|
@ -682,8 +673,8 @@ static int get_c3_log_page(int fd, char *format)
|
|||
}
|
||||
memset(data, 0, sizeof (__u8) * C3_LATENCY_MON_LOG_BUF_LEN);
|
||||
|
||||
ret = nvme_get_log_simple(fd, C3_LATENCY_MON_OPCODE,
|
||||
C3_LATENCY_MON_LOG_BUF_LEN, data);
|
||||
ret = nvme_get_log_simple(dev_fd(dev), C3_LATENCY_MON_OPCODE,
|
||||
C3_LATENCY_MON_LOG_BUF_LEN, data);
|
||||
|
||||
if (strcmp(format, "json"))
|
||||
fprintf(stderr,
|
||||
|
@ -725,7 +716,7 @@ static int get_c3_log_page(int fd, char *format)
|
|||
|
||||
switch (fmt) {
|
||||
case NORMAL:
|
||||
ocp_print_C3_log_normal(log_data);
|
||||
ocp_print_C3_log_normal(dev, log_data);
|
||||
break;
|
||||
case JSON:
|
||||
ocp_print_C3_log_json(log_data);
|
||||
|
@ -745,7 +736,7 @@ static int ocp_latency_monitor_log(int argc, char **argv, struct command *comman
|
|||
struct plugin *plugin)
|
||||
{
|
||||
const char *desc = "Retrieve latency monitor log data.";
|
||||
int fd;
|
||||
struct nvme_dev *dev;
|
||||
int ret = 0;
|
||||
|
||||
struct config {
|
||||
|
@ -762,15 +753,15 @@ static int ocp_latency_monitor_log(int argc, char **argv, struct command *comman
|
|||
OPT_END()
|
||||
};
|
||||
|
||||
fd = parse_and_open(argc, argv, desc, opts);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
ret = parse_and_open(&dev, argc, argv, desc, opts);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = get_c3_log_page(fd, cfg.output_format);
|
||||
ret = get_c3_log_page(dev, cfg.output_format);
|
||||
if (ret)
|
||||
fprintf(stderr,
|
||||
"ERROR : OCP : Failure reading the C3 Log Page, ret = %d\n",
|
||||
ret);
|
||||
close(fd);
|
||||
dev_close(dev);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue