mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-15 15:06:42 +00:00
Add nvme_controller_data argument to all print functions.
It's desirable to access controler data to inform printing log pages (such as limiting the printing to valid ranges). Sponsored by: Netflix
This commit is contained in:
parent
24e470ef9c
commit
8ce85adf7d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324977
@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
#define DEFAULT_SIZE (4096)
|
||||
#define MAX_FW_SLOTS (7)
|
||||
|
||||
typedef void (*print_fn_t)(void *buf, uint32_t size);
|
||||
typedef void (*print_fn_t)(const struct nvme_controller_data *cdata, void *buf, uint32_t size);
|
||||
|
||||
struct kv_name
|
||||
{
|
||||
@ -75,8 +75,16 @@ kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key)
|
||||
}
|
||||
|
||||
static void
|
||||
print_bin(void *data, uint32_t length)
|
||||
print_log_hex(const struct nvme_controller_data *cdata __unused, void *data, uint32_t length)
|
||||
{
|
||||
|
||||
print_hex(data, length);
|
||||
}
|
||||
|
||||
static void
|
||||
print_bin(const struct nvme_controller_data *cdata __unused, void *data, uint32_t length)
|
||||
{
|
||||
|
||||
write(STDOUT_FILENO, data, length);
|
||||
}
|
||||
|
||||
@ -115,7 +123,7 @@ read_logpage(int fd, uint8_t log_page, int nsid, void *payload,
|
||||
}
|
||||
|
||||
static void
|
||||
print_log_error(void *buf, uint32_t size)
|
||||
print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
|
||||
{
|
||||
int i, nentries;
|
||||
struct nvme_error_information_entry *entry = buf;
|
||||
@ -162,7 +170,7 @@ print_temp(uint16_t t)
|
||||
|
||||
|
||||
static void
|
||||
print_log_health(void *buf, uint32_t size __unused)
|
||||
print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
struct nvme_health_information_page *health = buf;
|
||||
char cbuf[UINT128_DIG + 1];
|
||||
@ -224,7 +232,7 @@ print_log_health(void *buf, uint32_t size __unused)
|
||||
}
|
||||
|
||||
static void
|
||||
print_log_firmware(void *buf, uint32_t size __unused)
|
||||
print_log_firmware(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
int i;
|
||||
const char *status;
|
||||
@ -260,7 +268,7 @@ print_log_firmware(void *buf, uint32_t size __unused)
|
||||
* offset 147: it is only 1 byte, not 6.
|
||||
*/
|
||||
static void
|
||||
print_intel_temp_stats(void *buf, uint32_t size __unused)
|
||||
print_intel_temp_stats(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
struct intel_log_temp_stats *temp = buf;
|
||||
|
||||
@ -287,7 +295,7 @@ print_intel_temp_stats(void *buf, uint32_t size __unused)
|
||||
* Read and write stats pages have identical encoding.
|
||||
*/
|
||||
static void
|
||||
print_intel_read_write_lat_log(void *buf, uint32_t size __unused)
|
||||
print_intel_read_write_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
const char *walker = buf;
|
||||
int i;
|
||||
@ -303,28 +311,28 @@ print_intel_read_write_lat_log(void *buf, uint32_t size __unused)
|
||||
}
|
||||
|
||||
static void
|
||||
print_intel_read_lat_log(void *buf, uint32_t size)
|
||||
print_intel_read_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
|
||||
{
|
||||
|
||||
printf("Intel Read Latency Log\n");
|
||||
printf("======================\n");
|
||||
print_intel_read_write_lat_log(buf, size);
|
||||
print_intel_read_write_lat_log(cdata, buf, size);
|
||||
}
|
||||
|
||||
static void
|
||||
print_intel_write_lat_log(void *buf, uint32_t size)
|
||||
print_intel_write_lat_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size)
|
||||
{
|
||||
|
||||
printf("Intel Write Latency Log\n");
|
||||
printf("=======================\n");
|
||||
print_intel_read_write_lat_log(buf, size);
|
||||
print_intel_read_write_lat_log(cdata, buf, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Table 19. 5.4 SMART Attributes. Samsung also implements this and some extra data not documented.
|
||||
*/
|
||||
static void
|
||||
print_intel_add_smart(void *buf, uint32_t size __unused)
|
||||
print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
uint8_t *walker = buf;
|
||||
uint8_t *end = walker + 150;
|
||||
@ -753,7 +761,7 @@ kv_indirect(void *buf, uint32_t subtype, uint8_t res, uint32_t size, struct subp
|
||||
}
|
||||
|
||||
static void
|
||||
print_hgst_info_log(void *buf, uint32_t size __unused)
|
||||
print_hgst_info_log(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
|
||||
{
|
||||
uint8_t *walker, *end, *subpage;
|
||||
int pages;
|
||||
@ -928,7 +936,7 @@ logpage(int argc, char *argv[])
|
||||
"smart/health information");
|
||||
}
|
||||
|
||||
print_fn = print_hex;
|
||||
print_fn = print_log_hex;
|
||||
size = DEFAULT_SIZE;
|
||||
if (binflag)
|
||||
print_fn = print_bin;
|
||||
@ -960,7 +968,7 @@ logpage(int argc, char *argv[])
|
||||
/* Read the log page */
|
||||
buf = get_log_buffer(size);
|
||||
read_logpage(fd, log_page, nsid, buf, size);
|
||||
print_fn(buf, size);
|
||||
print_fn(&cdata, buf, size);
|
||||
|
||||
close(fd);
|
||||
exit(0);
|
||||
|
Loading…
Reference in New Issue
Block a user