Skip to content

Commit

Permalink
rasdaemon: CXL: Extract, log and record region info from cxl_general_…
Browse files Browse the repository at this point in the history
…media and cxl_dram events

Add extract, log and record region info to cxl_general_media and
cxl_dram events.

The corresponding kernel changes:
https://lore.kernel.org/all/[email protected]/T/#m6fd773b5477fc44b875848e053708a1c8996c4e4

Signed-off-by: Shiju Jose <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
shijujose4 authored and mchehab committed Nov 18, 2024
1 parent e9337d0 commit ea224ad
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ras-cxl-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,26 @@ int ras_cxl_general_media_event_handler(struct trace_seq *s,
ev.transaction_type)) <= 0)
return -1;

if (tep_get_field_val(s, event, "hpa", record, &val, 1) < 0)
return -1;
ev.hpa = val;
if (trace_seq_printf(s, "hpa:0x%llx ", (unsigned long long)ev.hpa) <= 0)
return -1;

ev.region = tep_get_field_raw(s, event, "region_name", record, &len, 1);
if (!ev.region)
return -1;
if (trace_seq_printf(s, "region:%s ", ev.region) <= 0)
return -1;

ev.region_uuid = tep_get_field_raw(s, event, "region_uuid",
record, &len, 1);
if (!ev.region_uuid)
return -1;
ev.region_uuid = uuid_be(ev.region_uuid);
if (trace_seq_printf(s, "region_uuid:%s ", ev.region_uuid) <= 0)
return -1;

if (tep_get_field_val(s, event, "validity_flags", record, &val, 1) < 0)
return -1;
ev.validity_flags = val;
Expand Down Expand Up @@ -933,6 +953,26 @@ int ras_cxl_dram_event_handler(struct trace_seq *s,
ev.transaction_type)) <= 0)
return -1;

if (tep_get_field_val(s, event, "hpa", record, &val, 1) < 0)
return -1;
ev.hpa = val;
if (trace_seq_printf(s, "hpa:0x%llx ", (unsigned long long)ev.hpa) <= 0)
return -1;

ev.region = tep_get_field_raw(s, event, "region", record, &len, 1);
if (!ev.region)
return -1;
if (trace_seq_printf(s, "region:%s ", ev.region) <= 0)
return -1;

ev.region_uuid = tep_get_field_raw(s, event, "region_uuid",
record, &len, 1);
if (!ev.region_uuid)
return -1;
ev.region_uuid = uuid_be(ev.region_uuid);
if (trace_seq_printf(s, "region_uuid:%s ", ev.region_uuid) <= 0)
return -1;

if (tep_get_field_val(s, event, "validity_flags", record, &val, 1) < 0)
return -1;
ev.validity_flags = val;
Expand Down
12 changes: 12 additions & 0 deletions ras-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ static const struct db_fields cxl_general_media_event_fields[] = {
{ .name = "rank", .type = "INTEGER" },
{ .name = "device", .type = "INTEGER" },
{ .name = "comp_id", .type = "BLOB" },
{ .name = "hpa", .type = "INTEGER" },
{ .name = "region", .type = "TEXT" },
{ .name = "region_uuid", .type = "TEXT" },
};

static const struct db_table_descriptor cxl_general_media_event_tab = {
Expand Down Expand Up @@ -907,6 +910,9 @@ int ras_store_cxl_general_media_event(struct ras_events *ras,
sqlite3_bind_int(priv->stmt_cxl_general_media_event, 20, ev->device);
sqlite3_bind_blob(priv->stmt_cxl_general_media_event, 21, ev->comp_id,
CXL_EVENT_GEN_MED_COMP_ID_SIZE, NULL);
sqlite3_bind_int64(priv->stmt_cxl_general_media_event, 22, ev->hpa);
sqlite3_bind_text(priv->stmt_cxl_general_media_event, 23, ev->region, -1, NULL);
sqlite3_bind_text(priv->stmt_cxl_general_media_event, 24, ev->region_uuid, -1, NULL);

rc = sqlite3_step(priv->stmt_cxl_general_media_event);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
Expand Down Expand Up @@ -951,6 +957,9 @@ static const struct db_fields cxl_dram_event_fields[] = {
{ .name = "row", .type = "INTEGER" },
{ .name = "column", .type = "INTEGER" },
{ .name = "cor_mask", .type = "BLOB" },
{ .name = "hpa", .type = "INTEGER" },
{ .name = "region", .type = "TEXT" },
{ .name = "region_uuid", .type = "TEXT" },
};

static const struct db_table_descriptor cxl_dram_event_tab = {
Expand Down Expand Up @@ -984,6 +993,9 @@ int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_event *
sqlite3_bind_int(priv->stmt_cxl_dram_event, 24, ev->column);
sqlite3_bind_blob(priv->stmt_cxl_dram_event, 25, ev->cor_mask,
CXL_EVENT_DER_CORRECTION_MASK_SIZE, NULL);
sqlite3_bind_int64(priv->stmt_cxl_dram_event, 26, ev->hpa);
sqlite3_bind_text(priv->stmt_cxl_dram_event, 27, ev->region, -1, NULL);
sqlite3_bind_text(priv->stmt_cxl_dram_event, 28, ev->region_uuid, -1, NULL);

rc = sqlite3_step(priv->stmt_cxl_dram_event);
if (rc != SQLITE_OK && rc != SQLITE_DONE)
Expand Down
6 changes: 6 additions & 0 deletions ras-record.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ struct ras_cxl_general_media_event {
uint32_t device;
uint8_t *comp_id;
uint16_t validity_flags;
uint64_t hpa;
const char *region;
const char *region_uuid;
};

struct ras_cxl_dram_event {
Expand All @@ -216,6 +219,9 @@ struct ras_cxl_dram_event {
uint16_t column;
uint8_t *cor_mask;
uint16_t validity_flags;
uint64_t hpa;
const char *region;
const char *region_uuid;
};

struct ras_cxl_memory_module_event {
Expand Down
12 changes: 12 additions & 0 deletions ras-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ static int set_cxl_general_media_event_backtrace(char *buf, struct ras_cxl_gener
"descriptor=%u\n"
"type=%u\n"
"transaction_type=%u\n"
"hpa=0x%lx\n"
"region=%s\n"
"region_uuid=%s\n"
"channel=%u\n"
"rank=%u\n"
"device=0x%x\n",
Expand All @@ -574,6 +577,9 @@ static int set_cxl_general_media_event_backtrace(char *buf, struct ras_cxl_gener
ev->descriptor,
ev->type,
ev->transaction_type,
ev->hpa,
ev->region,
ev->region_uuid,
ev->channel,
ev->rank,
ev->device);
Expand Down Expand Up @@ -611,6 +617,9 @@ static int set_cxl_dram_event_backtrace(char *buf, struct ras_cxl_dram_event *ev
"descriptor=%u\n"
"type=%u\n"
"transaction_type=%u\n"
"hpa=0x%lx\n"
"region=%s\n"
"region_uuid=%s\n"
"channel=%u\n"
"rank=%u\n"
"nibble_mask=%u\n"
Expand All @@ -635,6 +644,9 @@ static int set_cxl_dram_event_backtrace(char *buf, struct ras_cxl_dram_event *ev
ev->descriptor,
ev->type,
ev->transaction_type,
ev->hpa,
ev->region,
ev->region_uuid,
ev->channel,
ev->rank,
ev->nibble_mask,
Expand Down

0 comments on commit ea224ad

Please sign in to comment.