linux-edac.vger.kernel.org archive mirror
 help / color / mirror / 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 3/5] rasdaemon: change submodule ID of sqlite3 DB field to text for hip08
Date: Tue, 8 Oct 2019 20:38:56 +0800	[thread overview]
Message-ID: <1570538338-230884-4-git-send-email-tanxiaofei@huawei.com> (raw)
In-Reply-To: <1570538338-230884-1-git-send-email-tanxiaofei@huawei.com>

Change submodule ID of sqlite3 DB field from integer to text for hip08
to make it easier to understand by user.

For example, from:
INSERT INTO hip08_oem_type2_event VALUES(1,1,1,0,0,'SMMU',2,
'corrected','');

change to:
INSERT INTO hip08_oem_type2_event VALUES(1,1,1,0,0,'SMMU','MGMT_SMMU',
'corrected','');

Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
 non-standard-hisi_hip08.c | 113 +++++++++++++++++++++++++++-------------------
 1 file changed, 67 insertions(+), 46 deletions(-)

diff --git a/non-standard-hisi_hip08.c b/non-standard-hisi_hip08.c
index 9de7be8..002f4bf 100644
--- a/non-standard-hisi_hip08.c
+++ b/non-standard-hisi_hip08.c
@@ -46,8 +46,8 @@
 /* HISI OEM format2 error definitions */
 #define HISI_OEM_MODULE_ID_SMMU	0
 #define HISI_OEM_MODULE_ID_HHA	1
-#define HISI_OEM_MODULE_ID_HLLC	2
-#define HISI_OEM_MODULE_ID_PA	3
+#define HISI_OEM_MODULE_ID_PA	2
+#define HISI_OEM_MODULE_ID_HLLC	3
 #define HISI_OEM_MODULE_ID_DDRC	4
 
 #define HISI_OEM_TYPE2_VALID_ERR_FR	BIT(6)
@@ -217,48 +217,61 @@ static char *oem_type2_module_name(uint8_t module_id)
 	return "unknown module";
 }
 
-static char *oem_type2_sub_module_id(char *p, uint8_t module_id,
-				     uint8_t sub_module_id)
+static const char *smmu_submodule_name[] = {
+	"HAC_SMMU",
+	"PCIE_SMMU",
+	"MGMT_SMMU",
+	"NIC_SMMU",
+};
+
+static const char *hllc_submodule_name[] = {
+	"HLLC0",
+	"HLLC1",
+	"HLLC2",
+};
+
+static const char *hha_submodule_name[] = {
+	"TA_HHA0",
+	"TA_HHA1",
+	"TB_HHA0",
+	"TB_HHA1"
+};
+
+static const char *ddrc_submodule_name[] = {
+	"TA_DDRC0",
+	"TA_DDRC1",
+	"TA_DDRC2",
+	"TA_DDRC3",
+	"TB_DDRC0",
+	"TB_DDRC1",
+	"TB_DDRC2",
+	"TB_DDRC3",
+};
+
+static const char *oem_type2_sub_module_name(uint8_t module_id, uint8_t sub_module_id)
 {
 	switch (module_id) {
 	case HISI_OEM_MODULE_ID_SMMU:
+		if (sub_module_id < sizeof(smmu_submodule_name)/sizeof(char *))
+			return smmu_submodule_name[sub_module_id];
+		break;
 	case HISI_OEM_MODULE_ID_HLLC:
-	case HISI_OEM_MODULE_ID_PA:
-		p += sprintf(p, "%d ", sub_module_id);
+		if (sub_module_id < sizeof(hllc_submodule_name)/sizeof(char *))
+			return hllc_submodule_name[sub_module_id];
 		break;
-
+	case HISI_OEM_MODULE_ID_PA:
+		return "PA";
 	case HISI_OEM_MODULE_ID_HHA:
-		if (sub_module_id == 0)
-			p += sprintf(p, "TA HHA0 ");
-		else if (sub_module_id == 1)
-			p += sprintf(p, "TA HHA1 ");
-		else if (sub_module_id == 2)
-			p += sprintf(p, "TB HHA0 ");
-		else if (sub_module_id == 3)
-			p += sprintf(p, "TB HHA1 ");
+		if (sub_module_id < sizeof(hha_submodule_name)/sizeof(char *))
+			return hha_submodule_name[sub_module_id];
 		break;
-
 	case HISI_OEM_MODULE_ID_DDRC:
-		if (sub_module_id == 0)
-			p += sprintf(p, "TA DDRC0 ");
-		else if (sub_module_id == 1)
-			p += sprintf(p, "TA DDRC1 ");
-		else if (sub_module_id == 2)
-			p += sprintf(p, "TA DDRC2 ");
-		else if (sub_module_id == 3)
-			p += sprintf(p, "TA DDRC3 ");
-		else if (sub_module_id == 4)
-			p += sprintf(p, "TB DDRC0 ");
-		else if (sub_module_id == 5)
-			p += sprintf(p, "TB DDRC1 ");
-		else if (sub_module_id == 6)
-			p += sprintf(p, "TB DDRC2 ");
-		else if (sub_module_id == 7)
-			p += sprintf(p, "TB DDRC3 ");
+		if (sub_module_id < sizeof(ddrc_submodule_name)/sizeof(char *))
+			return ddrc_submodule_name[sub_module_id];
 		break;
 	}
 
-	return p;
+	return "unknown";
 }
 
 static char *pcie_local_sub_module_name(uint8_t id)
@@ -281,7 +294,7 @@ static const struct db_fields hip08_oem_type1_event_fields[] = {
 	{ .name = "socket_id",		.type = "INTEGER" },
 	{ .name = "nimbus_id",		.type = "INTEGER" },
 	{ .name = "module_id",		.type = "TEXT" },
-	{ .name = "sub_module_id",	.type = "INTEGER" },
+	{ .name = "sub_module_id",	.type = "TEXT" },
 	{ .name = "err_severity",	.type = "TEXT" },
 	{ .name = "regs_dump",		.type = "TEXT" },
 };
@@ -299,7 +312,7 @@ static const struct db_fields hip08_oem_type2_event_fields[] = {
 	{ .name = "socket_id",          .type = "INTEGER" },
 	{ .name = "nimbus_id",          .type = "INTEGER" },
 	{ .name = "module_id",          .type = "TEXT" },
-	{ .name = "sub_module_id",      .type = "INTEGER" },
+	{ .name = "sub_module_id",      .type = "TEXT" },
 	{ .name = "err_severity",       .type = "TEXT" },
 	{ .name = "regs_dump",		.type = "TEXT" },
 };
@@ -437,17 +450,23 @@ static int decode_hip08_oem_type1_error(struct ras_events *ras,
 	}
 
 	if (err->val_bits & HISI_OEM_VALID_MODULE_ID) {
-		p += sprintf(p, "module=%s-",
+		p += sprintf(p, "module=%s ",
 			     oem_type1_module_name(err->module_id));
 		record_vendor_data(dec_tab, hisi_oem_data_type_text,
 				   hip08_oem_type1_field_module_id,
 				   0, oem_type1_module_name(err->module_id));
-		if (err->val_bits & HISI_OEM_VALID_SUB_MODULE_ID) {
-			p += sprintf(p, "%d ", err->sub_module_id);
-			record_vendor_data(dec_tab, hisi_oem_data_type_int,
-					   hip08_oem_type1_field_sub_module_id,
-					   err->sub_module_id, NULL);
-		}
+	}
+
+	if (err->val_bits & HISI_OEM_VALID_SUB_MODULE_ID) {
+		char submodule_name[64];
+
+		sprintf(submodule_name, "%s%d",
+			oem_type1_module_name(err->module_id),
+			err->sub_module_id);
+		p += sprintf(p, "submodule=%s ", submodule_name);
+		record_vendor_data(dec_tab, hisi_oem_data_type_text,
+				   hip08_oem_type1_field_sub_module_id,
+				   0, submodule_name);
 	}
 
 	if (err->val_bits & HISI_OEM_VALID_ERR_SEVERITY) {
@@ -562,11 +581,13 @@ static int decode_hip08_oem_type2_error(struct ras_events *ras,
 	}
 
 	if (err->val_bits & HISI_OEM_VALID_SUB_MODULE_ID) {
-		p =  oem_type2_sub_module_id(p, err->module_id,
-					     err->sub_module_id);
-		record_vendor_data(dec_tab, hisi_oem_data_type_int,
+		const char *str = oem_type2_sub_module_name(err->module_id,
+							    err->sub_module_id);
+
+		p += sprintf(p, "submodule=%s ", str);
+		record_vendor_data(dec_tab, hisi_oem_data_type_text,
 				   hip08_oem_type2_field_sub_module_id,
-				   err->sub_module_id, NULL);
+				   0, str);
 	}
 
 	if (err->val_bits & HISI_OEM_VALID_ERR_SEVERITY) {
-- 
2.8.1


  parent reply	other threads:[~2019-10-08 12:42 UTC|newest]

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 ` Xiaofei Tan [this message]
2019-10-08 12:38 ` [PATCH 4/5] rasdaemon: add timestamp for hip08 OEM error records in sqlite3 DB Xiaofei Tan
2019-10-08 12:38 ` [PATCH 5/5] rasdaemon: support three more modules for OEM type1 error for hip08 Xiaofei Tan

Reply instructions:

You may reply publicly 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-4-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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).