Linux-EDAC Archive on lore.kernel.org
 help / color / Atom feed
From: Xiaofei Tan <tanxiaofei@huawei.com>
To: <mchehab@kernel.org>, <linux-edac@vger.kernel.org>
Cc: Xiaofei Tan <tanxiaofei@huawei.com>, <linuxarm@huawei.com>,
	<shiju.jose@huawei.com>, <jonathan.cameron@huawei.com>
Subject: [PATCH 4/5] rasdaemon: add timestamp for hip08 OEM error records in sqlite3 DB
Date: Tue, 8 Oct 2019 20:38:57 +0800
Message-ID: <1570538338-230884-5-git-send-email-tanxiaofei@huawei.com> (raw)
In-Reply-To: <1570538338-230884-1-git-send-email-tanxiaofei@huawei.com>

This patch does two things:
1.Add timestamp for hip08 OEM error records in sqlite3 DB.
2.Add suffix "_v2" for hip08 OEM event names to keep compatibility
with old sqlite3 DB.

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
 non-standard-hisi_hip07.c  |  9 ++++++---
 non-standard-hisi_hip08.c  | 41 ++++++++++++++++++++++++++++++++---------
 ras-non-standard-handler.c |  3 +--
 ras-non-standard-handler.h |  2 +-
 4 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/non-standard-hisi_hip07.c b/non-standard-hisi_hip07.c
index 7f58fb3..09ddcb2 100644
--- a/non-standard-hisi_hip07.c
+++ b/non-standard-hisi_hip07.c
@@ -89,11 +89,13 @@ static char *sas_axi_err_type(int etype)
 
 static int decode_hip07_sas_error(struct ras_events *ras,
 				  struct ras_ns_dec_tab *dec_tab,
-				  struct trace_seq *s, const void *error)
+				  struct trace_seq *s,
+				  struct ras_non_standard_event *event)
 {
 	char buf[1024];
 	char *p = buf;
-	const struct hisi_sas_err_sec *err = error;
+	const struct hisi_sas_err_sec *err =
+			(struct hisi_sas_err_sec *)event->error;
 
 	if (err->val_bits == 0) {
 		trace_seq_printf(s, "%s: no valid error data\n",
@@ -124,7 +126,8 @@ static int decode_hip07_sas_error(struct ras_events *ras,
 
 static int decode_hip07_hns_error(struct ras_events *ras,
 				  struct ras_ns_dec_tab *dec_tab,
-				  struct trace_seq *s, const void *error)
+				  struct trace_seq *s,
+				  struct ras_non_standard_event *event)
 {
 	return 0;
 }
diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c
index 002f4bf..61e19b7 100644
--- a/non-standard-hisi_hip08.c
+++ b/non-standard-hisi_hip08.c
@@ -140,6 +140,7 @@ enum hisi_oem_data_type {
 
 enum {
 	hip08_oem_type1_field_id,
+	hip08_oem_type1_field_timestamp,
 	hip08_oem_type1_field_version,
 	hip08_oem_type1_field_soc_id,
 	hip08_oem_type1_field_socket_id,
@@ -152,6 +153,7 @@ enum {
 
 enum {
 	hip08_oem_type2_field_id,
+	hip08_oem_type2_field_timestamp,
 	hip08_oem_type2_field_version,
 	hip08_oem_type2_field_soc_id,
 	hip08_oem_type2_field_socket_id,
@@ -164,6 +166,7 @@ enum {
 
 enum {
 	hip08_pcie_local_field_id,
+	hip08_pcie_local_field_timestamp,
 	hip08_pcie_local_field_version,
 	hip08_pcie_local_field_soc_id,
 	hip08_pcie_local_field_socket_id,
@@ -289,6 +292,7 @@ static char *pcie_local_sub_module_name(uint8_t id)
 #ifdef HAVE_SQLITE3
 static const struct db_fields hip08_oem_type1_event_fields[] = {
 	{ .name = "id",			.type = "INTEGER PRIMARY KEY" },
+	{ .name = "timestamp",          .type = "TEXT" },
 	{ .name = "version",		.type = "INTEGER" },
 	{ .name = "soc_id",		.type = "INTEGER" },
 	{ .name = "socket_id",		.type = "INTEGER" },
@@ -300,13 +304,14 @@ static const struct db_fields hip08_oem_type1_event_fields[] = {
 };
 
 static const struct db_table_descriptor hip08_oem_type1_event_tab = {
-	.name = "hip08_oem_type1_event",
+	.name = "hip08_oem_type1_event_v2",
 	.fields = hip08_oem_type1_event_fields,
 	.num_fields = ARRAY_SIZE(hip08_oem_type1_event_fields),
 };
 
 static const struct db_fields hip08_oem_type2_event_fields[] = {
 	{ .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+	{ .name = "timestamp",          .type = "TEXT" },
 	{ .name = "version",            .type = "INTEGER" },
 	{ .name = "soc_id",             .type = "INTEGER" },
 	{ .name = "socket_id",          .type = "INTEGER" },
@@ -318,13 +323,14 @@ static const struct db_fields hip08_oem_type2_event_fields[] = {
 };
 
 static const struct db_table_descriptor hip08_oem_type2_event_tab = {
-	.name = "hip08_oem_type2_event",
+	.name = "hip08_oem_type2_event_v2",
 	.fields = hip08_oem_type2_event_fields,
 	.num_fields = ARRAY_SIZE(hip08_oem_type2_event_fields),
 };
 
 static const struct db_fields hip08_pcie_local_event_fields[] = {
 	{ .name = "id",                 .type = "INTEGER PRIMARY KEY" },
+	{ .name = "timestamp",          .type = "TEXT" },
 	{ .name = "version",            .type = "INTEGER" },
 	{ .name = "soc_id",             .type = "INTEGER" },
 	{ .name = "socket_id",          .type = "INTEGER" },
@@ -338,7 +344,7 @@ static const struct db_fields hip08_pcie_local_event_fields[] = {
 };
 
 static const struct db_table_descriptor hip08_pcie_local_event_tab = {
-	.name = "hip08_pcie_local_event",
+	.name = "hip08_pcie_local_event_v2",
 	.fields = hip08_pcie_local_event_fields,
 	.num_fields = ARRAY_SIZE(hip08_pcie_local_event_fields),
 };
@@ -399,9 +405,11 @@ static int step_vendor_data_tab(struct ras_ns_dec_tab *dec_tab, char *name)
 /* error data decoding functions */
 static int decode_hip08_oem_type1_error(struct ras_events *ras,
 					struct ras_ns_dec_tab *dec_tab,
-					struct trace_seq *s, const void *error)
+					struct trace_seq *s,
+					struct ras_non_standard_event *event)
 {
-	const struct hisi_oem_type1_err_sec *err = error;
+	const struct hisi_oem_type1_err_sec *err =
+			(struct hisi_oem_type1_err_sec*)event->error;
 	char buf[1024];
 	char *p = buf;
 
@@ -422,6 +430,9 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
 		}
 	}
 #endif
+	record_vendor_data(dec_tab, hisi_oem_data_type_text,
+			   hip08_oem_type1_field_timestamp,
+			   0, event->timestamp);
 
 	p += sprintf(p, "[ ");
 	p += sprintf(p, "table_version=%d ", err->version);
@@ -524,9 +535,11 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
 
 static int decode_hip08_oem_type2_error(struct ras_events *ras,
 					struct ras_ns_dec_tab *dec_tab,
-					struct trace_seq *s, const void *error)
+					struct trace_seq *s,
+					struct ras_non_standard_event *event)
 {
-	const struct hisi_oem_type2_err_sec *err = error;
+	const struct hisi_oem_type2_err_sec *err =
+			(struct hisi_oem_type2_err_sec *)event->error;
 	char buf[1024];
 	char *p = buf;
 
@@ -546,6 +559,10 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
 		}
 	}
 #endif
+	record_vendor_data(dec_tab, hisi_oem_data_type_text,
+			   hip08_oem_type2_field_timestamp,
+			   0, event->timestamp);
+
 	p += sprintf(p, "[ ");
 	p += sprintf(p, "table_version=%d ", err->version);
 	record_vendor_data(dec_tab, hisi_oem_data_type_int,
@@ -657,9 +674,11 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
 
 static int decode_hip08_pcie_local_error(struct ras_events *ras,
 					 struct ras_ns_dec_tab *dec_tab,
-					 struct trace_seq *s, const void *error)
+					 struct trace_seq *s,
+					 struct ras_non_standard_event *event)
 {
-	const struct hisi_pcie_local_err_sec *err = error;
+	const struct hisi_pcie_local_err_sec *err =
+			(struct hisi_pcie_local_err_sec *)event->error;
 	char buf[1024];
 	char *p = buf;
 	uint32_t i;
@@ -680,6 +699,10 @@ static int decode_hip08_pcie_local_error(struct ras_events *ras,
 		}
 	}
 #endif
+	record_vendor_data(dec_tab, hisi_oem_data_type_text,
+			   hip08_pcie_local_field_timestamp,
+			   0, event->timestamp);
+
 	p += sprintf(p, "[ ");
 	p += sprintf(p, "table_version=%d ", err->version);
 	record_vendor_data(dec_tab, hisi_oem_data_type_int,
diff --git a/ras-non-standard-handler.c b/ras-non-standard-handler.c
index 4eda80b..1b5d67a 100644
--- a/ras-non-standard-handler.c
+++ b/ras-non-standard-handler.c
@@ -166,8 +166,7 @@ int ras_non_standard_event_handler(struct trace_seq *s,
 		for (i = 0; dec_tab[i].decode; i++) {
 			if (uuid_le_cmp(ev.sec_type,
 					dec_tab[i].sec_type) == 0) {
-				dec_tab[i].decode(ras, &dec_tab[i],
-						  s, ev.error);
+				dec_tab[i].decode(ras, &dec_tab[i], s, &ev);
 				dec_done = true;
 				break;
 			}
diff --git a/ras-non-standard-handler.h b/ras-non-standard-handler.h
index a7e48a3..fd9dd92 100644
--- a/ras-non-standard-handler.h
+++ b/ras-non-standard-handler.h
@@ -23,7 +23,7 @@
 typedef struct ras_ns_dec_tab {
 	const char *sec_type;
 	int (*decode)(struct ras_events *ras, struct ras_ns_dec_tab *dec_tab,
-		      struct trace_seq *s, const void *err);
+		      struct trace_seq *s, struct ras_non_standard_event *event);
 #ifdef HAVE_SQLITE3
 #include <sqlite3.h>
 	sqlite3_stmt *stmt_dec_record;
-- 
2.8.1


  parent reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 12:38 [PATCH 0/5] some optimizations of hip08 oem error records Xiaofei Tan
2019-10-08 12:38 ` [PATCH 1/5] rasdaemon: optimize sqlite3 DB record of register fields for hip08 Xiaofei Tan
2019-10-10 17:34   ` Mauro Carvalho Chehab
2019-10-08 12:38 ` [PATCH 2/5] rasdaemon: add underscore(_) for some logging item names " Xiaofei Tan
2019-10-08 12:38 ` [PATCH 3/5] rasdaemon: change submodule ID of sqlite3 DB field to text " Xiaofei Tan
2019-10-08 12:38 ` Xiaofei Tan [this message]
2019-10-08 12:38 ` [PATCH 5/5] rasdaemon: support three more modules for OEM type1 error " Xiaofei Tan

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1570538338-230884-5-git-send-email-tanxiaofei@huawei.com \
    --to=tanxiaofei@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=shiju.jose@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-EDAC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-edac/0 linux-edac/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-edac linux-edac/ https://lore.kernel.org/linux-edac \
		linux-edac@vger.kernel.org
	public-inbox-index linux-edac

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-edac


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git