From nobody Sat Nov 23 14:15:50 2024 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7266C1A0AF2; Wed, 20 Nov 2024 10:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096831; cv=none; b=aZnuYNoXT/ClSfLcIUfR0ymmDnrvIG44uPrc6JnmHdnVQyk4GyJD52b12rsLLoUK0/LURKhdWX6+IrvdXXenEa+OMgPgPS6WhZ2rkkqjo+pl7gv1FCLN/mckHd0sVr/KEzx/DfyDTA7DF6aQftWgO+saC9xx3Z3IrDWhiRvEcDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096831; c=relaxed/simple; bh=cxCs72tUf6ocg2a5GN5Q5n3MVyWCMd4VNgbnaNcjdr8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NLoKT0AFjG6OIk7yjS6V/nkKOMvL+XmyeaW198KGIj5fKJpcEAYDbsB7k+gtUZqAR/MJ4B9O456YS6Jh0RFc0CPWi4Bw9A2HRa02b9Df7JFFcHly+5DcDii1hQwP4wXoWsliOQNEeQAv9cODXyVEZHFkGlp4KumofLO21uSIdqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcHl144Yz6K94Z; Wed, 20 Nov 2024 17:58:11 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id AE7DE140AB8; Wed, 20 Nov 2024 18:00:27 +0800 (CST) Received: from P_UKIT01-A7bmah.china.huawei.com (10.195.247.212) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 20 Nov 2024 11:00:26 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 08/13] rasdaemon: cxl: Update memory module event to CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:18 +0000 Message-ID: <20241120095923.1891-9-shiju.jose@huawei.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20241120095923.1891-1-shiju.jose@huawei.com> References: <20241120095923.1891-1-shiju.jose@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To frapeml500007.china.huawei.com (7.182.85.172) Content-Type: text/plain; charset="utf-8" From: Shiju Jose CXL spec 3.1 section 8.2.9.2.1.3 Table 8-47, Memory Module Event Record has updated with following new fields and new info for Device Event Type and Device Health Information fields. 1. Validity Flags 2. Component Identifier 3. Device Event Sub-Type Update the parsing, logging and recording of memory module event for the above spec rev 3.1 changes. Example rasdaemon log for CXL memory module event, cxl_memory_module 2024-11-20 00:22:33 +0000 memdev:mem0 host:0000:0f:00.0 \ serial:0x3 log type:Fatal hdr_uuid:fe927475-dd59-4339-a586-79bab113b774 \ hdr_handle:0x1 hdr_related_handle:0x0 hdr_timestamp:1970-01-01 00:04:38 \ +0000 hdr_length:128 hdr_maint_op_class:0 hdr_maint_op_sub_class:1 \ event_type:Temperature Change event_sub_type:Unsupported Config Data \ health_status:'MAINTENANCE_NEEDED' 'REPLACEMENT_NEEDED' media_status:All \ Data Loss in Event of Power Loss as_life_used:Unknown as_dev_temp:Normal \ as_cor_vol_err_cnt:Normal as_cor_per_err_cnt:Normal life_used:8 \ device_temp:3 dirty_shutdown_cnt:33 cor_vol_err_cnt:25 cor_per_err_cnt:45 \ comp_id:02 74 c5 08 9a 1a 0b fc d2 7e 2f 31 9b 3c 81 4d \ comp_id_pldm_valid_flags:'Resource ID' Resource ID:fc d2 7e 2f Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-- ras-record.c | 11 ++++++++++ ras-record.h | 5 +++++ ras-report.c | 2 ++ 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index c028203..a16a095 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -1247,7 +1247,7 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, /* * Memory Module Event Record - MMER * - * CXL res 3.0 section 8.2.9.2.1.3; Table 8-45 + * CXL res 3.1 section 8.2.9.2.1.3; Table 8-47 */ static const char * const cxl_dev_evt_type[] =3D { "Health Status Change", @@ -1256,21 +1256,33 @@ static const char * const cxl_dev_evt_type[] =3D { "Temperature Change", "Data Path Error", "LSA Error", + "Unrecoverable Internal Sideband Bus Error", + "Memory Media FRU Error", + "Power Management Fault", +}; + +static const char * const cxl_dev_evt_sub_type[] =3D { + "Not Reported", + "Invalid Config Data", + "Unsupported Config Data", + "Unsupported Memory Media FRU", }; =20 /* * Device Health Information - DHI * - * CXL res 3.0 section 8.2.9.8.3.1; Table 8-100 + * CXL res 3.1 section 8.2.9.9.3.1; Table 8-133 */ #define CXL_DHI_HS_MAINTENANCE_NEEDED BIT(0) #define CXL_DHI_HS_PERFORMANCE_DEGRADED BIT(1) #define CXL_DHI_HS_HW_REPLACEMENT_NEEDED BIT(2) +#define CXL_DHI_HS_MEM_CAPACITY_DEGRADED BIT(3) =20 static const struct cxl_event_flags cxl_health_status[] =3D { { .bit =3D CXL_DHI_HS_MAINTENANCE_NEEDED, .flag =3D "MAINTENANCE_NEEDED" = }, { .bit =3D CXL_DHI_HS_PERFORMANCE_DEGRADED, .flag =3D "PERFORMANCE_DEGRAD= ED" }, { .bit =3D CXL_DHI_HS_HW_REPLACEMENT_NEEDED, .flag =3D "REPLACEMENT_NEEDE= D" }, + { .bit =3D CXL_DHI_HS_MEM_CAPACITY_DEGRADED, .flag =3D "MEM_CAPACITY_DEGR= ADED" }, }; =20 static const char * const cxl_media_status[] =3D { @@ -1302,10 +1314,14 @@ static const char * const cxl_one_bit_status[] =3D { #define CXL_DHI_AS_COR_VOL_ERR_CNT(as) (((as) & 0x10) >> 4) #define CXL_DHI_AS_COR_PER_ERR_CNT(as) (((as) & 0x20) >> 5) =20 +#define CXL_MMER_VALID_COMPONENT_ID BIT(0) +#define CXL_MMER_VALID_COMPONENT_ID_FORMAT BIT(1) + int ras_cxl_memory_module_event_handler(struct trace_seq *s, struct tep_record *record, struct tep_event *event, void *context) { + int len, i, rc; unsigned long long val; struct ras_events *ras =3D context; struct ras_cxl_memory_module_event ev; @@ -1323,6 +1339,15 @@ int ras_cxl_memory_module_event_handler(struct trace= _seq *s, ev.event_type)) <=3D 0) return -1; =20 + if (tep_get_field_val(s, event, "event_sub_type", record, &val, 1) < 0) + return -1; + ev.event_sub_type =3D val; + if (trace_seq_printf(s, "event_sub_type:%s ", + get_cxl_type_str(cxl_dev_evt_sub_type, + ARRAY_SIZE(cxl_dev_evt_sub_type), + ev.event_sub_type)) <=3D 0) + return -1; + if (tep_get_field_val(s, event, "health_status", record, &val, 1) < 0) return -1; ev.health_status =3D val; @@ -1395,6 +1420,33 @@ int ras_cxl_memory_module_event_handler(struct trace= _seq *s, if (trace_seq_printf(s, "cor_per_err_cnt:%u ", ev.cor_per_err_cnt) <=3D 0) return -1; =20 + if (tep_get_field_val(s, event, "validity_flags", record, &val, 1) < 0) + return -1; + ev.validity_flags =3D val; + + if (ev.validity_flags & CXL_MMER_VALID_COMPONENT_ID) { + ev.comp_id =3D tep_get_field_raw(s, event, "comp_id", record, &len, 1); + if (!ev.comp_id) + return -1; + if (trace_seq_printf(s, "comp_id:") <=3D 0) + return -1; + for (i =3D 0; i < CXL_EVENT_GEN_MED_COMP_ID_SIZE; i++) { + if (trace_seq_printf(s, "%02x ", ev.comp_id[i]) <=3D 0) + break; + } + + if (ev.validity_flags & CXL_MMER_VALID_COMPONENT_ID_FORMAT) { + if (trace_seq_printf(s, "comp_id_pldm_valid_flags:") <=3D 0) + return -1; + if (decode_cxl_event_flags(s, ev.comp_id[0], cxl_pldm_comp_id_flags, + ARRAY_SIZE(cxl_pldm_comp_id_flags)) < 0) + return -1; + + rc =3D ras_cxl_print_component_id(s, ev.comp_id, ev.entity_id, ev.res_i= d); + if (rc) + return rc; + } + } /* Insert data into the SGBD */ #ifdef HAVE_SQLITE3 ras_store_cxl_memory_module_event(ras, &ev); diff --git a/ras-record.c b/ras-record.c index 82939e7..d87a70f 100644 --- a/ras-record.c +++ b/ras-record.c @@ -1083,6 +1083,10 @@ static const struct db_fields cxl_memory_module_even= t_fields[] =3D { { .name =3D "cor_per_err_cnt", .type =3D "INTEGER" }, { .name =3D "device_temp", .type =3D "INTEGER" }, { .name =3D "add_status", .type =3D "INTEGER" }, + { .name =3D "event_sub_type", .type =3D "INTEGER" }, + { .name =3D "comp_id", .type =3D "BLOB" }, + { .name =3D "pldm_entity_id", .type =3D "BLOB" }, + { .name =3D "pldm_resource_id", .type =3D "BLOB" }, }; =20 static const struct db_table_descriptor cxl_memory_module_event_tab =3D { @@ -1115,6 +1119,13 @@ int ras_store_cxl_memory_module_event(struct ras_eve= nts *ras, sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->cor_per_e= rr_cnt); sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->device_te= mp); sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->add_statu= s); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->event_sub= _type); + sqlite3_bind_blob(priv->stmt_cxl_memory_module_event, idx++, ev->comp_id, + CXL_EVENT_GEN_MED_COMP_ID_SIZE, NULL); + sqlite3_bind_blob(priv->stmt_cxl_memory_module_event, idx++, ev->entity_i= d, + CXL_PLDM_ENTITY_ID_LEN, NULL); + sqlite3_bind_blob(priv->stmt_cxl_memory_module_event, idx++, ev->res_id, + CXL_PLDM_RES_ID_LEN, NULL); =20 rc =3D sqlite3_step(priv->stmt_cxl_memory_module_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) diff --git a/ras-record.h b/ras-record.h index 3aec063..5eab62c 100644 --- a/ras-record.h +++ b/ras-record.h @@ -243,6 +243,7 @@ struct ras_cxl_dram_event { struct ras_cxl_memory_module_event { struct ras_cxl_event_common_hdr hdr; uint8_t event_type; + uint8_t event_sub_type; uint8_t health_status; uint8_t media_status; uint8_t life_used; @@ -251,6 +252,10 @@ struct ras_cxl_memory_module_event { uint32_t cor_per_err_cnt; int16_t device_temp; uint8_t add_status; + uint16_t validity_flags; + uint8_t *comp_id; + uint8_t entity_id[CXL_PLDM_ENTITY_ID_LEN]; + uint8_t res_id[CXL_PLDM_RES_ID_LEN]; }; =20 struct ras_mc_event; diff --git a/ras-report.c b/ras-report.c index 8e343fc..4535421 100644 --- a/ras-report.c +++ b/ras-report.c @@ -700,6 +700,7 @@ static int set_cxl_memory_module_event_backtrace(char *= buf, struct ras_cxl_memor "hdr_length=3D%u\n" "hdr_maint_op_class=3D%u\n" "event_type=3D%u\n" + "event_sub_type=3D0x%x\n" "health_status=3D%u\n" "media_status=3D%u\n" "life_used=3D%u\n" @@ -721,6 +722,7 @@ static int set_cxl_memory_module_event_backtrace(char *= buf, struct ras_cxl_memor ev->hdr.hdr_length, ev->hdr.hdr_maint_op_class, ev->event_type, + ev->event_sub_type, ev->health_status, ev->media_status, ev->life_used, --=20 2.43.0