From nobody Sat Nov 23 11:25:52 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 B16F819CC05; Wed, 20 Nov 2024 10:00:21 +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=1732096823; cv=none; b=Kt5RUQaBRg9ZkcgMRlRkK+P5J0XLKQpipg0/VKwlXvRvk/vapO2GtJaTKUpGtFcbRqcC9St43NYXZOq6Jpcftvl8KD6p72oj7ldquAIpvgQZkqF0qnCsNCxwcbG+GZGyoKvgJumlzeFsyOxXoLAx2ZGtIaRNsO+Ex/XJ2x+z7PY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096823; c=relaxed/simple; bh=HvMPg9eNH0Cq39DgYlaE54bKxU4kLupfTmtt+JKz4eA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ucAhJCRxJSRRr9XTJS1VjeET0B4yGtr5hz7UtxqkmJ9qjKO209iE1DH6VM02l0d41HXGZLojhvsRBUGGFHh1zY6SQSbKqB4eAj4lnirsp0TcAqx0M5zELzpCDrw/SVqZbR7bOwtdYibt+/RwxQRFFr/IqbpDTnCusLWSLF3idcA= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcKn1Z0xz6L764; Wed, 20 Nov 2024 17:59:57 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 6B66B140119; Wed, 20 Nov 2024 18:00:19 +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:18 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 01/13] rasdaemon: cxl: Fix logging of memory event type of DRAM trace event Date: Wed, 20 Nov 2024 09:59:11 +0000 Message-ID: <20241120095923.1891-2-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 rev 3.0 section 8.2.9.2.1.2 defines the DRAM Event Record. Fix logging of memory event type field of DRAM trace event. For e.g. if value is 0x1 it will be reported as an Invalid Address (General Media Event Record - Memory Event Type) instead of Scrub Media ECC Error (DRAM Event Record - Memory Event Type) and so on. Fixes: 9a2f6186db26 ("rasdaemon: Add support for the CXL dram events") Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index 67ce32e..8733b2b 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -898,6 +898,13 @@ int ras_cxl_general_media_event_handler(struct trace_s= eq *s, #define CXL_DER_VALID_COLUMN BIT(6) #define CXL_DER_VALID_CORRECTION_MASK BIT(7) =20 +static const char * const cxl_der_mem_event_type[] =3D { + "Media ECC Error", + "Scrub Media ECC Error", + "Invalid Address", + "Data Path Error", +}; + int ras_cxl_dram_event_handler(struct trace_seq *s, struct tep_record *record, struct tep_event *event, void *context) @@ -938,9 +945,9 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, if (tep_get_field_val(s, event, "type", record, &val, 1) < 0) return -1; ev.type =3D val; - if (trace_seq_printf(s, "type:%s ", - get_cxl_type_str(cxl_gmer_mem_event_type, - ARRAY_SIZE(cxl_gmer_mem_event_type), + if (trace_seq_printf(s, "memory_event_type:%s ", + get_cxl_type_str(cxl_der_mem_event_type, + ARRAY_SIZE(cxl_der_mem_event_type), ev.type)) <=3D 0) return -1; =20 --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 B6C5D1714BE; Wed, 20 Nov 2024 10:00:22 +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=1732096825; cv=none; b=JWDO4vrXERDDfcYy6ID7ktMI99nvWXhHoDt5l7lmRANzhpup/ilf8MBhS5lW5PFTsxLU/apxuISy+ES5bbBl4gQsyU5wBZNV9dsXXSroTAYQxj5fK4W9OS76tfW96jUTwL4Fclf6C4cBiybr1wpYRcxuunrRwbdRigJkb1iAs6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096825; c=relaxed/simple; bh=j+iCJZVSiM9lGRSBsJcmXMX/vFg8DZGDGte9IPZy7j4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=czD2favnkF/UvtWqtEWAzGSOb5z/kyiATyS5xb6VJe8hme3AgMj6N5IwD9dVFle0t/kYG4Fha9OT/QmaFBOH6G2dQ0mIos2H3plTvZj78dHJu45k30b8tVusUnHHfmQU2/Qkf1xCH2ay+yx5MUVi+ulL88VDTwcrJjnZRerSoBY= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcG95dP2z6J6YS; Wed, 20 Nov 2024 17:56:49 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 957DC140CF4; Wed, 20 Nov 2024 18:00:20 +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:19 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 02/13] rasdaemon: cxl: Fix mismatch in region field's name with kernel DRAM trace event Date: Wed, 20 Nov 2024 09:59:12 +0000 Message-ID: <20241120095923.1891-3-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 Fix mismatch in 'region' field's name with kernel DRAM trace event. Fixes: ea224ad58b37 ("rasdaemon: CXL: Extract, log and record region info f= rom cxl_general_media and cxl_dram events") Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index 8733b2b..7d4fc9f 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -966,7 +966,7 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, if (trace_seq_printf(s, "hpa:0x%llx ", (unsigned long long)ev.hpa) <=3D 0) return -1; =20 - ev.region =3D tep_get_field_raw(s, event, "region", record, &len, 1); + ev.region =3D 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) <=3D 0) --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 355B019D093; Wed, 20 Nov 2024 10:00:24 +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=1732096826; cv=none; b=V+gBQlGh7y9K/hdg29X4IK+22RuSJ1NXak2yO3BqZHxZDmWxD7H7ucpLNMhNA2b8iYChU4aqdxP3zCEkDYS4uc3/Kgi97frZ3LjVzlKP+cr1Idl73MBFDr0OtQcb4UlPhuHjNHDrDzRLrqRzg1C/7hzLvz13XgeXL6HxSHaor4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096826; c=relaxed/simple; bh=cancZSBNdg1EKba9CAg9GIjiqN5z5S/v/dGY3fvMpsA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e/KtG7RBKlbpeZG6salroVKsN8YvBmMaY1unO8C3325StGfuHQT8+A3gpEcz9C+TRcVajghodT1wKQhg/F+PNZcz2pymONO/MTbWcOJPfWrVs0DaLD2ReErMtcqUu7NX2SGya90yECs6q1VCWmRwHYLZvsl7SjMLsbtI91aGkic= 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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcKq3zc9z6L76Y; Wed, 20 Nov 2024 17:59:59 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id BE814140F39; Wed, 20 Nov 2024 18:00:21 +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:20 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 03/13] rasdaemon: cxl: Add automatic indexing for storing CXL fields in SQLite database Date: Wed, 20 Nov 2024 09:59:13 +0000 Message-ID: <20241120095923.1891-4-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 When the CXL specification adds new fields to the common header of CXL event records, manual updates to the indexing are required to store these CXL fields in the SQLite database. This update introduces automatic indexing to facilitate the storage of CXL fields in the SQLite database, eliminating the need for manual update to indexing. Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-record.c | 134 ++++++++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 60 deletions(-) diff --git a/ras-record.c b/ras-record.c index b4a1abd..9e68158 100644 --- a/ras-record.c +++ b/ras-record.c @@ -780,23 +780,25 @@ int ras_store_cxl_overflow_event(struct ras_events *r= as, struct ras_cxl_overflow =20 static int ras_store_cxl_common_hdr(sqlite3_stmt *stmt, struct ras_cxl_eve= nt_common_hdr *hdr) { + int idx =3D 1; + if (!stmt || !hdr) return 0; =20 - sqlite3_bind_text(stmt, 1, hdr->timestamp, -1, NULL); - sqlite3_bind_text(stmt, 2, hdr->memdev, -1, NULL); - sqlite3_bind_text(stmt, 3, hdr->host, -1, NULL); - sqlite3_bind_int64(stmt, 4, hdr->serial); - sqlite3_bind_text(stmt, 5, hdr->log_type, -1, NULL); - sqlite3_bind_text(stmt, 6, hdr->hdr_uuid, -1, NULL); - sqlite3_bind_int(stmt, 7, hdr->hdr_flags); - sqlite3_bind_int(stmt, 8, hdr->hdr_handle); - sqlite3_bind_int(stmt, 9, hdr->hdr_related_handle); - sqlite3_bind_text(stmt, 10, hdr->hdr_timestamp, -1, NULL); - sqlite3_bind_int(stmt, 11, hdr->hdr_length); - sqlite3_bind_int(stmt, 12, hdr->hdr_maint_op_class); - - return 0; + sqlite3_bind_text(stmt, idx++, hdr->timestamp, -1, NULL); + sqlite3_bind_text(stmt, idx++, hdr->memdev, -1, NULL); + sqlite3_bind_text(stmt, idx++, hdr->host, -1, NULL); + sqlite3_bind_int64(stmt, idx++, hdr->serial); + sqlite3_bind_text(stmt, idx++, hdr->log_type, -1, NULL); + sqlite3_bind_text(stmt, idx++, hdr->hdr_uuid, -1, NULL); + sqlite3_bind_int(stmt, idx++, hdr->hdr_flags); + sqlite3_bind_int(stmt, idx++, hdr->hdr_handle); + sqlite3_bind_int(stmt, idx++, hdr->hdr_related_handle); + sqlite3_bind_text(stmt, idx++, hdr->hdr_timestamp, -1, NULL); + sqlite3_bind_int(stmt, idx++, hdr->hdr_length); + sqlite3_bind_int(stmt, idx++, hdr->hdr_maint_op_class); + + return idx; } =20 /* @@ -827,15 +829,18 @@ static const struct db_table_descriptor cxl_generic_e= vent_tab =3D { =20 int ras_store_cxl_generic_event(struct ras_events *ras, struct ras_cxl_gen= eric_event *ev) { - int rc; + int rc, idx; struct sqlite3_priv *priv =3D ras->db_priv; =20 if (!priv || !priv->stmt_cxl_generic_event) return 0; log(TERM, LOG_INFO, "cxl_generic_event store: %p\n", priv->stmt_cxl_gener= ic_event); =20 - ras_store_cxl_common_hdr(priv->stmt_cxl_generic_event, &ev->hdr); - sqlite3_bind_blob(priv->stmt_cxl_generic_event, 13, ev->data, + idx =3D ras_store_cxl_common_hdr(priv->stmt_cxl_generic_event, &ev->hdr); + if (!idx) + return 0; + + sqlite3_bind_blob(priv->stmt_cxl_generic_event, idx++, ev->data, CXL_EVENT_RECORD_DATA_LENGTH, NULL); =20 rc =3D sqlite3_step(priv->stmt_cxl_generic_event); @@ -891,7 +896,7 @@ static const struct db_table_descriptor cxl_general_med= ia_event_tab =3D { int ras_store_cxl_general_media_event(struct ras_events *ras, struct ras_cxl_general_media_event *ev) { - int rc; + int rc, idx; struct sqlite3_priv *priv =3D ras->db_priv; =20 if (!priv || !priv->stmt_cxl_general_media_event) @@ -899,20 +904,23 @@ int ras_store_cxl_general_media_event(struct ras_even= ts *ras, log(TERM, LOG_INFO, "cxl_general_media_event store: %p\n", priv->stmt_cxl_general_media_event); =20 - ras_store_cxl_common_hdr(priv->stmt_cxl_general_media_event, &ev->hdr); - sqlite3_bind_int64(priv->stmt_cxl_general_media_event, 13, ev->dpa); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 14, ev->dpa_flags); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 15, ev->descriptor); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 16, ev->type); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 17, ev->transaction_= type); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 18, ev->channel); - sqlite3_bind_int(priv->stmt_cxl_general_media_event, 19, ev->rank); - 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, + idx =3D ras_store_cxl_common_hdr(priv->stmt_cxl_general_media_event, &ev-= >hdr); + if (!idx) + return 0; + + sqlite3_bind_int64(priv->stmt_cxl_general_media_event, idx++, ev->dpa); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->dpa_flags= ); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->descripto= r); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->type); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->transacti= on_type); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->channel); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->rank); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->device); + sqlite3_bind_blob(priv->stmt_cxl_general_media_event, idx++, 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); + sqlite3_bind_int64(priv->stmt_cxl_general_media_event, idx++, ev->hpa); + sqlite3_bind_text(priv->stmt_cxl_general_media_event, idx++, ev->region, = -1, NULL); + sqlite3_bind_text(priv->stmt_cxl_general_media_event, idx++, ev->region_u= uid, -1, NULL); =20 rc =3D sqlite3_step(priv->stmt_cxl_general_media_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) @@ -970,7 +978,7 @@ static const struct db_table_descriptor cxl_dram_event_= tab =3D { =20 int ras_store_cxl_dram_event(struct ras_events *ras, struct ras_cxl_dram_e= vent *ev) { - int rc; + int rc, idx; struct sqlite3_priv *priv =3D ras->db_priv; =20 if (!priv || !priv->stmt_cxl_dram_event) @@ -978,24 +986,27 @@ int ras_store_cxl_dram_event(struct ras_events *ras, = struct ras_cxl_dram_event * log(TERM, LOG_INFO, "cxl_dram_event store: %p\n", priv->stmt_cxl_dram_event); =20 - ras_store_cxl_common_hdr(priv->stmt_cxl_dram_event, &ev->hdr); - sqlite3_bind_int64(priv->stmt_cxl_dram_event, 13, ev->dpa); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 14, ev->dpa_flags); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 15, ev->descriptor); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 16, ev->type); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 17, ev->transaction_type); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 18, ev->channel); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 19, ev->rank); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 20, ev->nibble_mask); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 21, ev->bank_group); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 22, ev->bank); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 23, ev->row); - sqlite3_bind_int(priv->stmt_cxl_dram_event, 24, ev->column); - sqlite3_bind_blob(priv->stmt_cxl_dram_event, 25, ev->cor_mask, + idx =3D ras_store_cxl_common_hdr(priv->stmt_cxl_dram_event, &ev->hdr); + if (!idx) + return 0; + + sqlite3_bind_int64(priv->stmt_cxl_dram_event, idx++, ev->dpa); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->dpa_flags); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->descriptor); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->type); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->transaction_type); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->channel); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->rank); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->nibble_mask); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->bank_group); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->bank); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->row); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->column); + sqlite3_bind_blob(priv->stmt_cxl_dram_event, idx++, 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, NUL= L); + sqlite3_bind_int64(priv->stmt_cxl_dram_event, idx++, ev->hpa); + sqlite3_bind_text(priv->stmt_cxl_dram_event, idx++, ev->region, -1, NULL); + sqlite3_bind_text(priv->stmt_cxl_dram_event, idx++, ev->region_uuid, -1, = NULL); =20 rc =3D sqlite3_step(priv->stmt_cxl_dram_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) @@ -1047,7 +1058,7 @@ static const struct db_table_descriptor cxl_memory_mo= dule_event_tab =3D { int ras_store_cxl_memory_module_event(struct ras_events *ras, struct ras_cxl_memory_module_event *ev) { - int rc; + int rc, idx; struct sqlite3_priv *priv =3D ras->db_priv; =20 if (!priv || !priv->stmt_cxl_memory_module_event) @@ -1055,16 +1066,19 @@ int ras_store_cxl_memory_module_event(struct ras_ev= ents *ras, log(TERM, LOG_INFO, "cxl_memory_module_event store: %p\n", priv->stmt_cxl_memory_module_event); =20 - ras_store_cxl_common_hdr(priv->stmt_cxl_memory_module_event, &ev->hdr); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 13, ev->event_type); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 14, ev->health_statu= s); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 15, ev->media_status= ); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 16, ev->life_used); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 17, ev->dirty_shutdo= wn_cnt); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 18, ev->cor_vol_err_= cnt); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 19, ev->cor_per_err_= cnt); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 20, ev->device_temp); - sqlite3_bind_int(priv->stmt_cxl_memory_module_event, 21, ev->add_status); + idx =3D ras_store_cxl_common_hdr(priv->stmt_cxl_memory_module_event, &ev-= >hdr); + if (!idx) + return 0; + + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->event_typ= e); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->health_st= atus); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->media_sta= tus); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->life_used= ); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->dirty_shu= tdown_cnt); + sqlite3_bind_int(priv->stmt_cxl_memory_module_event, idx++, ev->cor_vol_e= rr_cnt); + 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); =20 rc =3D sqlite3_step(priv->stmt_cxl_memory_module_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 3666419EEBD; Wed, 20 Nov 2024 10:00:24 +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=1732096828; cv=none; b=KnR0JJGexBzq3jt8eFAH31XX8aua7Hh1sdGJhzHxnmxKgsR5Ex6D09z8eXEIPVj6TQl0KZyWhTuZiZwxpo+UYXrjR9/ZuUaoEu7P6Fwd8Uliw97sPbpa9TYSrnpzan91uhh+OaPeBXQ+TInRKISY/xjwvZscKYaL0rTmCJd/LrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096828; c=relaxed/simple; bh=NkWFOVxMosRl1G/2ptzkVO7oa4XwSHp5SLr4bZcOefU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uFPKt0n72oEpHLBK1wAYxVhnTSW9lm1UA+3mG6CgtRcuFWQ9kXPl+YAOF7PG7ZZ2Pv5Mm2Vz4oX9jmcNrJ3Tbt6QOtzXcCvuIpgoGuSb5rVTS8xFO+7upm6C9k60BG3wqT1jbcdzJHUh0Oeo0XUqLRBB32/uSZ7TA76c0Oi9dq8= 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 4XtcKr5Kywz6L7B4; Wed, 20 Nov 2024 18:00:00 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id ECC3F140B55; Wed, 20 Nov 2024 18:00:22 +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:22 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 04/13] rasdaemon: cxl: Update common event to CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:14 +0000 Message-ID: <20241120095923.1891-5-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 Table 8-42, Common Event Record format has updated with Maintenance Operation Subclass information. Add updates in rasdaemon CXL event handler for the above spec change and for the corresponding changes in kernel CXL common trace event implementation. Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 10 +++++++++- ras-record.c | 5 +++++ ras-record.h | 1 + ras-report.c | 6 ++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index 7d4fc9f..d16eaef 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -575,18 +575,20 @@ int ras_cxl_overflow_event_handler(struct trace_seq *= s, =20 /* * Common Event Record Format - * CXL 3.0 section 8.2.9.2.1; Table 8-42 + * CXL 3.1 section 8.2.9.2.1; Table 8-43 */ #define CXL_EVENT_RECORD_FLAG_PERMANENT BIT(2) #define CXL_EVENT_RECORD_FLAG_MAINT_NEEDED BIT(3) #define CXL_EVENT_RECORD_FLAG_PERF_DEGRADED BIT(4) #define CXL_EVENT_RECORD_FLAG_HW_REPLACE BIT(5) +#define CXL_EVENT_RECORD_FLAG_MAINT_OP_SUB_CLASS_VALID BIT(6) =20 static const struct cxl_event_flags cxl_hdr_flags[] =3D { { .bit =3D CXL_EVENT_RECORD_FLAG_PERMANENT, .flag =3D "PERMANENT_CONDITIO= N" }, { .bit =3D CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, .flag =3D "MAINTENANCE_NEE= DED" }, { .bit =3D CXL_EVENT_RECORD_FLAG_PERF_DEGRADED, .flag =3D "PERFORMANCE_DE= GRADED" }, { .bit =3D CXL_EVENT_RECORD_FLAG_HW_REPLACE, .flag =3D "HARDWARE_REPLACEM= ENT_NEEDED" }, + { .bit =3D CXL_EVENT_RECORD_FLAG_MAINT_OP_SUB_CLASS_VALID, .flag =3D "MAI= NT_OP_SUB_CLASS_VALID" }, }; =20 static int handle_ras_cxl_common_hdr(struct trace_seq *s, @@ -670,6 +672,12 @@ static int handle_ras_cxl_common_hdr(struct trace_seq = *s, if (trace_seq_printf(s, "hdr_maint_op_class:%u ", hdr->hdr_maint_op_class= ) <=3D 0) return -1; =20 + if (tep_get_field_val(s, event, "hdr_maint_op_sub_class", record, &val, = 1) < 0) + return -1; + hdr->hdr_maint_op_sub_class =3D val; + if (trace_seq_printf(s, "hdr_maint_op_sub_class:%u ", hdr->hdr_maint_op_s= ub_class) <=3D 0) + return -1; + return 0; } =20 diff --git a/ras-record.c b/ras-record.c index 9e68158..b52973f 100644 --- a/ras-record.c +++ b/ras-record.c @@ -797,6 +797,7 @@ static int ras_store_cxl_common_hdr(sqlite3_stmt *stmt,= struct ras_cxl_event_com sqlite3_bind_text(stmt, idx++, hdr->hdr_timestamp, -1, NULL); sqlite3_bind_int(stmt, idx++, hdr->hdr_length); sqlite3_bind_int(stmt, idx++, hdr->hdr_maint_op_class); + sqlite3_bind_int(stmt, idx++, hdr->hdr_maint_op_sub_class); =20 return idx; } @@ -818,6 +819,7 @@ static const struct db_fields cxl_generic_event_fields[= ] =3D { { .name =3D "hdr_ts", .type =3D "TEXT" }, { .name =3D "hdr_length", .type =3D "INTEGER" }, { .name =3D "hdr_maint_op_class", .type =3D "INTEGER" }, + { .name =3D "hdr_maint_op_sub_class", .type =3D "INTEGER" }, { .name =3D "data", .type =3D "BLOB" }, }; =20 @@ -873,6 +875,7 @@ static const struct db_fields cxl_general_media_event_f= ields[] =3D { { .name =3D "hdr_ts", .type =3D "TEXT" }, { .name =3D "hdr_length", .type =3D "INTEGER" }, { .name =3D "hdr_maint_op_class", .type =3D "INTEGER" }, + { .name =3D "hdr_maint_op_sub_class", .type =3D "INTEGER" }, { .name =3D "dpa", .type =3D "INTEGER" }, { .name =3D "dpa_flags", .type =3D "INTEGER" }, { .name =3D "descriptor", .type =3D "INTEGER" }, @@ -952,6 +955,7 @@ static const struct db_fields cxl_dram_event_fields[] = =3D { { .name =3D "hdr_ts", .type =3D "TEXT" }, { .name =3D "hdr_length", .type =3D "INTEGER" }, { .name =3D "hdr_maint_op_class", .type =3D "INTEGER" }, + { .name =3D "hdr_maint_op_sub_class", .type =3D "INTEGER" }, { .name =3D "dpa", .type =3D "INTEGER" }, { .name =3D "dpa_flags", .type =3D "INTEGER" }, { .name =3D "descriptor", .type =3D "INTEGER" }, @@ -1038,6 +1042,7 @@ static const struct db_fields cxl_memory_module_event= _fields[] =3D { { .name =3D "hdr_ts", .type =3D "TEXT" }, { .name =3D "hdr_length", .type =3D "INTEGER" }, { .name =3D "hdr_maint_op_class", .type =3D "INTEGER" }, + { .name =3D "hdr_maint_op_sub_class", .type =3D "INTEGER" }, { .name =3D "event_type", .type =3D "INTEGER" }, { .name =3D "health_status", .type =3D "INTEGER" }, { .name =3D "media_status", .type =3D "INTEGER" }, diff --git a/ras-record.h b/ras-record.h index cd549a1..2a0124a 100644 --- a/ras-record.h +++ b/ras-record.h @@ -179,6 +179,7 @@ struct ras_cxl_event_common_hdr { char hdr_timestamp[64]; uint8_t hdr_length; uint8_t hdr_maint_op_class; + uint8_t hdr_maint_op_sub_class; }; =20 struct ras_cxl_generic_event { diff --git a/ras-report.c b/ras-report.c index bc77d04..7e974b9 100644 --- a/ras-report.c +++ b/ras-report.c @@ -507,7 +507,8 @@ static int set_cxl_generic_event_backtrace(char *buf, s= truct ras_cxl_generic_eve "hdr_related_handle=3D0x%x\n" "hdr_timestamp=3D%s\n" "hdr_length=3D%u\n" - "hdr_maint_op_class=3D%u\n", + "hdr_maint_op_class=3D%u\n" + "hdr_maint_op_sub_class=3D%u\n", ev->hdr.timestamp, ev->hdr.memdev, ev->hdr.host, @@ -519,7 +520,8 @@ static int set_cxl_generic_event_backtrace(char *buf, s= truct ras_cxl_generic_eve ev->hdr.hdr_related_handle, ev->hdr.hdr_timestamp, ev->hdr.hdr_length, - ev->hdr.hdr_maint_op_class); + ev->hdr.hdr_maint_op_class, + ev->hdr.hdr_maint_op_sub_class); =20 return 0; } --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 80CA219F46D; Wed, 20 Nov 2024 10:00:26 +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=1732096828; cv=none; b=dAAr8Co6q0AWaLOHcvJKiT7T6cfoytMnn+0RS42ysHNBIyJSRKiz82onVvIFno1TEzd8IgPY3f3wdETGky5WCxS+hpL3gPTLVyXmYHEQ8ZHfB7i1WY/66cHlt3OVKcKmUrAEINEvlK4FnXMnltA5uo9ff/MuApazFkSi+Ey0tg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096828; c=relaxed/simple; bh=18A4qVqah5nZX5/kqkMBKLYmiZOBSZB4bPHEHDxopL8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pGXmObY9qfy7Qg3xF+j+k6UnXgK2qdpIlR4Wkze4TDn/fkXa1VUUxOmEz+BVs2fpMCi8Vf79l3xQar3syYRVrlGUiq5opo9hbu+p4u4T6LlLkzPEsWpw5PXHB6WNOTZi1OLFRKuL3GjAkC4LlalA3B7JR5juwYJARynmPFAcTRg= 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 4XtcHg40VFz6K94r; Wed, 20 Nov 2024 17:58:07 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 1F6431400DB; Wed, 20 Nov 2024 18:00:24 +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:23 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 05/13] rasdaemon: cxl: Add Component Identifier formatting for CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:15 +0000 Message-ID: <20241120095923.1891-6-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 Add Component Identifier formatting for CXL spec rev 3.1, Section 8.2.9.2.1, Table 8-44. Add helper function to print component ID, parse and log PLDM entity ID and resource ID. Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 41 +++++++++++++++++++++++++++++++++++++++++ ras-record.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index d16eaef..80afa9f 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -573,6 +573,47 @@ int ras_cxl_overflow_event_handler(struct trace_seq *s, return 0; } =20 +/* + * Component ID Format + * CXL 3.1 section 8.2.9.2.1; Table 8-44 + */ +#define CXL_PLDM_COMPONENT_ID_ENTITY_VALID BIT(0) +#define CXL_PLDM_COMPONENT_ID_RES_VALID BIT(1) +static const struct cxl_event_flags cxl_pldm_comp_id_flags[] =3D { + { .bit =3D CXL_PLDM_COMPONENT_ID_ENTITY_VALID, .flag =3D "PLDM Entity ID"= }, + { .bit =3D CXL_PLDM_COMPONENT_ID_RES_VALID, .flag =3D "Resource ID" }, +}; + +static int ras_cxl_print_component_id(struct trace_seq *s, uint8_t *comp_i= d, + uint8_t *entity_id, uint8_t *res_id) +{ + int i; + + if (comp_id[0] & CXL_PLDM_COMPONENT_ID_ENTITY_VALID) { + if (trace_seq_printf(s, "PLDM Entity ID:") <=3D 0) + return -1; + for (i =3D 1; i < 7; i++) { + if (trace_seq_printf(s, "%02x ", comp_id[i]) <=3D 0) + return -1; + } + if (entity_id) + memcpy(entity_id, &comp_id[1], CXL_PLDM_ENTITY_ID_LEN); + } + + if (comp_id[0] & CXL_PLDM_COMPONENT_ID_RES_VALID) { + if (trace_seq_printf(s, "Resource ID:") <=3D 0) + return -1; + for (i =3D 7; i < 11; i++) { + if (trace_seq_printf(s, "%02x ", comp_id[i]) <=3D 0) + return -1; + } + if (res_id) + memcpy(res_id, &comp_id[7], CXL_PLDM_RES_ID_LEN); + } + + return 0; +} + /* * Common Event Record Format * CXL 3.1 section 8.2.9.2.1; Table 8-43 diff --git a/ras-record.h b/ras-record.h index 2a0124a..a3a88eb 100644 --- a/ras-record.h +++ b/ras-record.h @@ -137,6 +137,9 @@ struct ras_cxl_poison_event { #define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10 #define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20 =20 +#define CXL_PLDM_ENTITY_ID_LEN 6 +#define CXL_PLDM_RES_ID_LEN 4 + struct ras_cxl_aer_ue_event { char timestamp[64]; const char *memdev; --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 83EFB1A0711; Wed, 20 Nov 2024 10:00:27 +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=1732096829; cv=none; b=q823LEKaQG67ciaX3UKKeislQbOea9yNGbq2MCMQji3HRs528iSppANjV6Dt8EMehsZsDTU40g3PEDq47+RYbikrQ07+NXnwSUVQuxtBw9yHb1/dBoa5eQRvH1gppegnNnzKI/vgn4fSDy+bc65ZXa81s37jv1ZwdI9ZDRE9uNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096829; c=relaxed/simple; bh=VpEIoevUndmR+SawF19/VvgHmd1CpKGjViQokrKuU6k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sDmoAE5KBcZUFt/p9APzOWlsCrPFMDgp7hJ4y2IxchSufxx4VV9uo2fHv9bDiGGV3OoTZU7s1kTkMphYRUXLMYRCkTcJy6qUh/axyP3isXKSJIEDNxRxL3WJFbV4RZiaAwWpL8kJt5r6DKloAy4c8uCsHGXEJdGrcZCg+j3GA6c= 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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcGG3N03z6J6X0; Wed, 20 Nov 2024 17:56:54 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 46E49140F39; Wed, 20 Nov 2024 18:00:25 +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:24 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 06/13] rasdaemon: cxl: Update CXL general media event to CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:16 +0000 Message-ID: <20241120095923.1891-7-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 rev 3.1 section 8.2.9.2.1.1 Table 8-45, General Media Event Record has updated with following new fields and new types for Memory Event Type and Transaction Type fields. 1. Advanced Programmable Corrected Memory Error Threshold Event Flags 2. Corrected Memory Error Count at Event 3. Memory Event Sub-Type The format of component identifier has changed (CXL spec 3.1 section 8.2.9.2.1 Table 8-44). Update the parsing, logging and recording of general media event for the above spec changes. Example rasdaemon log for CXL general media event, cxl_general_media 2024-11-20 00:00:49 +0000 memdev:mem1 host:0000:0f:00.0 \ serial:0x3 log type:Fatal hdr_uuid:fbcd0a77-c260-417f-85a9-088b1621eba6 \ hdr_handle:0x1 hdr_related_handle:0x0 hdr_timestamp:1970-01-01 00:00:49 +00= 00 \ hdr_length:128 hdr_maint_op_class:2 hdr_maint_op_sub_class:4 dpa:0x30d40 \ dpa_flags:descriptor:'UNCORRECTABLE EVENT' 'THRESHOLD EVENT' 'POISON LIST O= VERFLOW' \ memory_event_type:TE State Violation memory_event_sub_type:Media Link Comma= nd \ Training Error transaction_type:Host Inject Poison hpa:0xffffffffffffffff \ region: region_uuid:00000000-0000-0000-0000-000000000000 channel:3 rank:33 \ device:5 comp_id:03 74 c5 08 9a 1a 0b fc d2 7e 2f 31 9b 3c 81 4d \ comp_id_pldm_valid_flags:'PLDM Entity ID' 'Resource ID' \ PLDM Entity ID:74 c5 08 9a 1a 0b Resource ID:fc d2 7e 2f \ Advanced Programmable CME threshold Event Flags:'Corrected Memory Errors in= \ Multiple Media Components' 'Exceeded Programmable Threshold' \ Corrected Memory Error Count:0x78 Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 73 +++++++++++++++++++++++++++++++++++++++++++++-- ras-record.c | 13 +++++++++ ras-record.h | 5 ++++ ras-report.c | 10 +++++-- 4 files changed, 96 insertions(+), 5 deletions(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index 80afa9f..c64c540 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -772,9 +772,32 @@ static const struct cxl_event_flags cxl_dpa_flags[] = =3D { { .bit =3D CXL_DPA_NOT_REPAIRABLE, .flag =3D "NOT_REPAIRABLE" }, }; =20 +/* CXL rev 3.1 Section 8.2.9.2.1.1; Table 8-45 */ +static const char * const cxl_mem_event_sub_type[] =3D { + "Not Reported", + "Internal Datapath Error", + "Media Link Command Training Error", + "Media Link Control Training Error", + "Media Link Data Training Error", + "Media Link CRC Error", +}; + +#define CXL_CME_EV_FLAG_CME_MULTIPLE_MEDIA BIT(0) +#define CXL_CME_EV_FLAG_THRESHOLD_EXCEEDED BIT(1) +static const struct cxl_event_flags cxl_cme_threshold_ev_flags[] =3D { + { + .bit =3D CXL_CME_EV_FLAG_CME_MULTIPLE_MEDIA, + .flag =3D "Corrected Memory Errors in Multiple Media Components" + }, + { + .bit =3D CXL_CME_EV_FLAG_THRESHOLD_EXCEEDED, + .flag =3D "Exceeded Programmable Threshold" + }, +}; + /* * General Media Event Record - GMER - * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 + * CXL rev 3.1 Section 8.2.9.2.1.1; Table 8-45 */ #define CXL_GMER_EVT_DESC_UNCORRECTABLE_EVENT BIT(0) #define CXL_GMER_EVT_DESC_THRESHOLD_EVENT BIT(1) @@ -790,11 +813,16 @@ static const struct cxl_event_flags cxl_gmer_event_de= sc_flags[] =3D { #define CXL_GMER_VALID_RANK BIT(1) #define CXL_GMER_VALID_DEVICE BIT(2) #define CXL_GMER_VALID_COMPONENT BIT(3) +#define CXL_GMER_VALID_COMPONENT_ID_FORMAT BIT(4) =20 static const char * const cxl_gmer_mem_event_type[] =3D { "ECC Error", "Invalid Address", "Data Path Error", + "TE State Violation", + "Scrub Media ECC Error", + "Advanced Programmable CME Counter Expiration", + "CKID Violation", }; =20 static const char * const cxl_gmer_trans_type[] =3D { @@ -805,13 +833,15 @@ static const char * const cxl_gmer_trans_type[] =3D { "Host Inject Poison", "Internal Media Scrub", "Internal Media Management", + "Internal Media Error Check Scrub", + "Media Initialization", }; =20 int ras_cxl_general_media_event_handler(struct trace_seq *s, struct tep_record *record, struct tep_event *event, void *context) { - int len, i; + int len, i, rc; unsigned long long val; struct ras_events *ras =3D context; struct ras_cxl_general_media_event ev; @@ -846,11 +876,20 @@ int ras_cxl_general_media_event_handler(struct trace_= seq *s, if (tep_get_field_val(s, event, "type", record, &val, 1) < 0) return -1; ev.type =3D val; - if (trace_seq_printf(s, "type:%s ", + if (trace_seq_printf(s, "memory_event_type:%s ", get_cxl_type_str(cxl_gmer_mem_event_type, ARRAY_SIZE(cxl_gmer_mem_event_type), ev.type)) <=3D 0) return -1; =20 + if (tep_get_field_val(s, event, "sub_type", record, &val, 1) < 0) + return -1; + ev.sub_type =3D val; + if (trace_seq_printf(s, "memory_event_sub_type:%s ", + get_cxl_type_str(cxl_mem_event_sub_type, + ARRAY_SIZE(cxl_mem_event_sub_type), + ev.sub_type)) <=3D 0) + return -1; + if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0) return -1; ev.transaction_type =3D val; @@ -918,8 +957,36 @@ int ras_cxl_general_media_event_handler(struct trace_s= eq *s, if (trace_seq_printf(s, "%02x ", ev.comp_id[i]) <=3D 0) break; } + + if (ev.validity_flags & CXL_GMER_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; + } } =20 + if (tep_get_field_val(s, event, "cme_threshold_ev_flags", record, &val, = 1) < 0) + return -1; + ev.cme_threshold_ev_flags =3D val; + if (trace_seq_printf(s, "Advanced Programmable CME threshold Event Flags:= ") <=3D 0) + return -1; + if (decode_cxl_event_flags(s, ev.cme_threshold_ev_flags, + cxl_cme_threshold_ev_flags, + ARRAY_SIZE(cxl_cme_threshold_ev_flags)) < 0) + return -1; + + if (tep_get_field_val(s, event, "cme_count", record, &val, 1) < 0) + return -1; + ev.cme_count =3D val; + if (trace_seq_printf(s, "Corrected Memory Error Count:0x%x ", ev.cme_coun= t) <=3D 0) + return -1; + /* Insert data into the SGBD */ #ifdef HAVE_SQLITE3 ras_store_cxl_general_media_event(ras, &ev); diff --git a/ras-record.c b/ras-record.c index b52973f..e24562e 100644 --- a/ras-record.c +++ b/ras-record.c @@ -888,6 +888,11 @@ static const struct db_fields cxl_general_media_event_= fields[] =3D { { .name =3D "hpa", .type =3D "INTEGER" }, { .name =3D "region", .type =3D "TEXT" }, { .name =3D "region_uuid", .type =3D "TEXT" }, + { .name =3D "pldm_entity_id", .type =3D "BLOB" }, + { .name =3D "pldm_resource_id", .type =3D "BLOB" }, + { .name =3D "sub_type", .type =3D "INTEGER" }, + { .name =3D "cme_threshold_ev_flags", .type =3D "INTEGER" }, + { .name =3D "cme_count", .type =3D "INTEGER" }, }; =20 static const struct db_table_descriptor cxl_general_media_event_tab =3D { @@ -924,6 +929,14 @@ int ras_store_cxl_general_media_event(struct ras_event= s *ras, sqlite3_bind_int64(priv->stmt_cxl_general_media_event, idx++, ev->hpa); sqlite3_bind_text(priv->stmt_cxl_general_media_event, idx++, ev->region, = -1, NULL); sqlite3_bind_text(priv->stmt_cxl_general_media_event, idx++, ev->region_u= uid, -1, NULL); + sqlite3_bind_blob(priv->stmt_cxl_general_media_event, idx++, ev->entity_i= d, + CXL_PLDM_ENTITY_ID_LEN, NULL); + sqlite3_bind_blob(priv->stmt_cxl_general_media_event, idx++, ev->res_id, + CXL_PLDM_RES_ID_LEN, NULL); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->sub_type); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, + ev->cme_threshold_ev_flags); + sqlite3_bind_int(priv->stmt_cxl_general_media_event, idx++, ev->cme_count= ); =20 rc =3D sqlite3_step(priv->stmt_cxl_general_media_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) diff --git a/ras-record.h b/ras-record.h index a3a88eb..12e693b 100644 --- a/ras-record.h +++ b/ras-record.h @@ -196,15 +196,20 @@ struct ras_cxl_general_media_event { uint8_t dpa_flags; uint8_t descriptor; uint8_t type; + uint8_t sub_type; uint8_t transaction_type; uint8_t channel; uint8_t rank; uint32_t device; uint8_t *comp_id; + uint8_t entity_id[CXL_PLDM_ENTITY_ID_LEN]; + uint8_t res_id[CXL_PLDM_RES_ID_LEN]; uint16_t validity_flags; uint64_t hpa; const char *region; const char *region_uuid; + uint8_t cme_threshold_ev_flags; + uint32_t cme_count; }; =20 struct ras_cxl_dram_event { diff --git a/ras-report.c b/ras-report.c index 7e974b9..ed1f4b8 100644 --- a/ras-report.c +++ b/ras-report.c @@ -555,13 +555,16 @@ static int set_cxl_general_media_event_backtrace(char= *buf, struct ras_cxl_gener "dpa_flags=3D%u\n" "descriptor=3D%u\n" "type=3D%u\n" + "sub_type=3D0x%x\n" "transaction_type=3D%u\n" "hpa=3D0x%lx\n" "region=3D%s\n" "region_uuid=3D%s\n" "channel=3D%u\n" "rank=3D%u\n" - "device=3D0x%x\n", + "device=3D0x%x\n" + "cme_threshold_ev_flags=3D0x%x\n" + "cme_count=3D0x%x\n", ev->hdr.timestamp, ev->hdr.memdev, ev->hdr.host, @@ -578,13 +581,16 @@ static int set_cxl_general_media_event_backtrace(char= *buf, struct ras_cxl_gener ev->dpa_flags, ev->descriptor, ev->type, + ev->sub_type, ev->transaction_type, ev->hpa, ev->region, ev->region_uuid, ev->channel, ev->rank, - ev->device); + ev->device, + ev->cme_threshold_ev_flags, + ev->cme_count); =20 return 0; } --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 73A311A0734; Wed, 20 Nov 2024 10:00:28 +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=1732096830; cv=none; b=bWqo+NeZ3Oe65DSDQT9hxD2c6g8ENhJaofWa0EZEOm6EM3mQ7xe9hQKzvXlI5gO69obEgjEMnWjUghI51rmR3ZW1MoxTuekuzS61clEpr+LUJP+NEmp6yNAklZP04VOVsk+r+ryxMavIC7mWE6mddOi5PCWlzzO6B+JO0p/HG/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096830; c=relaxed/simple; bh=Jrqt4mVKGsicxRtMUqib57UOqRZD/I/8bhFcq1jVmNc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JTbZrQ+IaGxjLBRCSId+hIPFo+qA/E5D3JTeD2Hni0svSyzd9pqkIfzSxGLU/aEBrW5BCFKKEf3TZSucJU2pYJKso8SqyzUMX12Qu37h1qC8APSPu2AVDbYRGJdXl9O58j3mQHB6rw+HAdKdibx5sEFP9MeWL+0gw2lBJyL7KrA= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcGH4L97z6J6Zc; Wed, 20 Nov 2024 17:56:55 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 6917F140D1A; Wed, 20 Nov 2024 18:00:26 +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:25 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 07/13] rasdaemon: cxl: Update CXL DRAM event to CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:17 +0000 Message-ID: <20241120095923.1891-8-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.2 Table 8-46, DRAM Event Record has updated with following new fields and new types for Memory Event Type, Transaction Type and Validity Flags fields. 1. Component Identifier 2. Sub-channel 3. Advanced Programmable Corrected Memory Error Threshold Event Flags 4. Corrected Memory Error Count at Event 5. Memory Event Sub-Type Update the parsing, logging and recording of DRAM event for the above spec rev 3.1 changes. Example rasdaemon log for CXL DRAM event, cxl_dram 2024-11-20 00:18:53 +0000 memdev:mem0 host:0000:0f:00.0 serial:0x3= \ log type:Informational hdr_uuid:601dcbb3-9c06-4eab-b8af-4e9bfb5c9624 \ hdr_handle:0x1 hdr_related_handle:0x0 hdr_timestamp:1970-01-01 00:00:58 +00= 00 \ hdr_length:128 hdr_maint_op_class:1 hdr_maint_op_sub_class:3 dpa:0x18680 \ dpa_flags:descriptor:'UNCORRECTABLE EVENT' 'THRESHOLD EVENT' \ memory_event_type:Data Path Error memory_event_sub_type:Media Link CRC Erro= r \ transaction_type:Internal Media Scrub hpa:0xffffffffffffffff region: \ region_uuid:00000000-0000-0000-0000-000000000000 channel:3 rank:17 \ nibble_mask:3866802 bank_group:7 bank:11 row:2 column:77 correction_mask:21 00 00 00 00 00 00 00 2c 00 00 00 00 00 00 00 37 00 00 \ 00 00 00 00 00 42 00 00 00 00 00 00 00 comp_id:01 74 c5 08 9a 1a 0b fc d2 \ 7e 2f 31 9b 3c 81 4d comp_id_pldm_valid_flags:'PLDM Entity ID' \ PLDM Entity ID:74 c5 08 9a 1a 0b \ Advanced Programmable CME threshold Event Flags:'Corrected Memory Errors \ in Multiple Media Components' 'Exceeded Programmable Threshold' \ CVME Count:0x94 Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- ras-cxl-handler.c | 67 +++++++++++++++++++++++++++++++++++++++++++++-- ras-record.c | 18 +++++++++++++ ras-record.h | 7 +++++ ras-report.c | 12 +++++++-- 4 files changed, 100 insertions(+), 4 deletions(-) diff --git a/ras-cxl-handler.c b/ras-cxl-handler.c index c64c540..c028203 100644 --- a/ras-cxl-handler.c +++ b/ras-cxl-handler.c @@ -1003,7 +1003,7 @@ int ras_cxl_general_media_event_handler(struct trace_= seq *s, /* * DRAM Event Record - DER * - * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 + * CXL rev 3.1 section 8.2.9.2.1.2; Table 8-46 */ #define CXL_DER_VALID_CHANNEL BIT(0) #define CXL_DER_VALID_RANK BIT(1) @@ -1013,19 +1013,25 @@ int ras_cxl_general_media_event_handler(struct trac= e_seq *s, #define CXL_DER_VALID_ROW BIT(5) #define CXL_DER_VALID_COLUMN BIT(6) #define CXL_DER_VALID_CORRECTION_MASK BIT(7) +#define CXL_DER_VALID_COMPONENT_ID BIT(8) +#define CXL_DER_VALID_COMPONENT_ID_FORMAT BIT(9) +#define CXL_DER_VALID_SUB_CHANNEL BIT(10) =20 static const char * const cxl_der_mem_event_type[] =3D { "Media ECC Error", "Scrub Media ECC Error", "Invalid Address", "Data Path Error", + "TE State Violation", + "Advanced Programmable CME Counter Expiration", + "CKID Violation", }; =20 int ras_cxl_dram_event_handler(struct trace_seq *s, struct tep_record *record, struct tep_event *event, void *context) { - int len, i; + int len, i, rc; unsigned long long val; struct ras_events *ras =3D context; struct ras_cxl_dram_event ev; @@ -1067,6 +1073,15 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, ev.type)) <=3D 0) return -1; =20 + if (tep_get_field_val(s, event, "sub_type", record, &val, 1) < 0) + return -1; + ev.sub_type =3D val; + if (trace_seq_printf(s, "memory_event_sub_type:%s ", + get_cxl_type_str(cxl_mem_event_sub_type, + ARRAY_SIZE(cxl_mem_event_sub_type), + ev.sub_type)) <=3D 0) + return -1; + if (tep_get_field_val(s, event, "transaction_type", record, &val, 1) < 0) return -1; ev.transaction_type =3D val; @@ -1108,6 +1123,14 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, return -1; } =20 + if (ev.validity_flags & CXL_DER_VALID_SUB_CHANNEL) { + if (tep_get_field_val(s, event, "sub_channel", record, &val, 1) < 0) + return -1; + ev.sub_channel =3D val; + if (trace_seq_printf(s, "sub_channel:%u ", ev.sub_channel) <=3D 0) + return -1; + } + if (ev.validity_flags & CXL_DER_VALID_RANK) { if (tep_get_field_val(s, event, "rank", record, &val, 1) < 0) return -1; @@ -1168,6 +1191,46 @@ int ras_cxl_dram_event_handler(struct trace_seq *s, } } =20 + if (ev.validity_flags & CXL_DER_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_DER_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; + } + } + + if (tep_get_field_val(s, event, "cme_threshold_ev_flags", record, &val, = 1) < 0) + return -1; + ev.cme_threshold_ev_flags =3D val; + if (trace_seq_printf(s, "Advanced Programmable CME threshold Event Flags:= ") <=3D 0) + return -1; + if (decode_cxl_event_flags(s, ev.cme_threshold_ev_flags, + cxl_cme_threshold_ev_flags, + ARRAY_SIZE(cxl_cme_threshold_ev_flags)) < 0) + return -1; + + if (tep_get_field_val(s, event, "cvme_count", record, &val, 1) < 0) + return -1; + ev.cvme_count =3D val; + if (trace_seq_printf(s, "CVME Count:0x%x ", ev.cvme_count) <=3D 0) + return -1; + /* Insert data into the SGBD */ #ifdef HAVE_SQLITE3 ras_store_cxl_dram_event(ras, &ev); diff --git a/ras-record.c b/ras-record.c index e24562e..82939e7 100644 --- a/ras-record.c +++ b/ras-record.c @@ -985,6 +985,13 @@ static const struct db_fields cxl_dram_event_fields[] = =3D { { .name =3D "hpa", .type =3D "INTEGER" }, { .name =3D "region", .type =3D "TEXT" }, { .name =3D "region_uuid", .type =3D "TEXT" }, + { .name =3D "comp_id", .type =3D "BLOB" }, + { .name =3D "pldm_entity_id", .type =3D "BLOB" }, + { .name =3D "pldm_resource_id", .type =3D "BLOB" }, + { .name =3D "sub_type", .type =3D "INTEGER" }, + { .name =3D "sub_channel", .type =3D "INTEGER" }, + { .name =3D "cme_threshold_ev_flags", .type =3D "INTEGER" }, + { .name =3D "cvme_count", .type =3D "INTEGER" }, }; =20 static const struct db_table_descriptor cxl_dram_event_tab =3D { @@ -1024,6 +1031,17 @@ int ras_store_cxl_dram_event(struct ras_events *ras,= struct ras_cxl_dram_event * sqlite3_bind_int64(priv->stmt_cxl_dram_event, idx++, ev->hpa); sqlite3_bind_text(priv->stmt_cxl_dram_event, idx++, ev->region, -1, NULL); sqlite3_bind_text(priv->stmt_cxl_dram_event, idx++, ev->region_uuid, -1, = NULL); + sqlite3_bind_blob(priv->stmt_cxl_dram_event, idx++, ev->comp_id, + CXL_EVENT_GEN_MED_COMP_ID_SIZE, NULL); + sqlite3_bind_blob(priv->stmt_cxl_dram_event, idx++, ev->entity_id, + CXL_PLDM_ENTITY_ID_LEN, NULL); + sqlite3_bind_blob(priv->stmt_cxl_dram_event, idx++, ev->res_id, + CXL_PLDM_RES_ID_LEN, NULL); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->sub_type); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->sub_channel); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, + ev->cme_threshold_ev_flags); + sqlite3_bind_int(priv->stmt_cxl_dram_event, idx++, ev->cvme_count); =20 rc =3D sqlite3_step(priv->stmt_cxl_dram_event); if (rc !=3D SQLITE_OK && rc !=3D SQLITE_DONE) diff --git a/ras-record.h b/ras-record.h index 12e693b..3aec063 100644 --- a/ras-record.h +++ b/ras-record.h @@ -218,8 +218,10 @@ struct ras_cxl_dram_event { uint8_t dpa_flags; uint8_t descriptor; uint8_t type; + uint8_t sub_type; uint8_t transaction_type; uint8_t channel; + uint8_t sub_channel; uint8_t rank; uint32_t nibble_mask; uint8_t bank_group; @@ -231,6 +233,11 @@ struct ras_cxl_dram_event { uint64_t hpa; const char *region; const char *region_uuid; + uint8_t *comp_id; + uint8_t entity_id[CXL_PLDM_ENTITY_ID_LEN]; + uint8_t res_id[CXL_PLDM_RES_ID_LEN]; + uint8_t cme_threshold_ev_flags; + uint32_t cvme_count; }; =20 struct ras_cxl_memory_module_event { diff --git a/ras-report.c b/ras-report.c index ed1f4b8..8e343fc 100644 --- a/ras-report.c +++ b/ras-report.c @@ -624,17 +624,21 @@ static int set_cxl_dram_event_backtrace(char *buf, st= ruct ras_cxl_dram_event *ev "dpa_flags=3D%u\n" "descriptor=3D%u\n" "type=3D%u\n" + "sub_type=3D0x%x\n" "transaction_type=3D%u\n" "hpa=3D0x%lx\n" "region=3D%s\n" "region_uuid=3D%s\n" "channel=3D%u\n" + "sub_channel=3D%u\n" "rank=3D%u\n" "nibble_mask=3D%u\n" "bank_group=3D%u\n" "bank=3D%u\n" "row=3D%u\n" - "column=3D%u\n", + "column=3D%u\n" + "cme_threshold_ev_flags=3D0x%x\n" + "cvme_count=3D0x%x\n", ev->hdr.timestamp, ev->hdr.memdev, ev->hdr.host, @@ -651,17 +655,21 @@ static int set_cxl_dram_event_backtrace(char *buf, st= ruct ras_cxl_dram_event *ev ev->dpa_flags, ev->descriptor, ev->type, + ev->sub_type, ev->transaction_type, ev->hpa, ev->region, ev->region_uuid, ev->channel, + ev->sub_channel, ev->rank, ev->nibble_mask, ev->bank_group, ev->bank, ev->row, - ev->column); + ev->column, + ev->cme_threshold_ev_flags, + ev->cvme_count); =20 return 0; } --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 From nobody Sat Nov 23 11:25:52 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 636071A304A; Wed, 20 Nov 2024 10:00:31 +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=1732096833; cv=none; b=N2bfotV8kbQRtTXbOhXInu4NlRlCRqrvU9dCPCG6KYZCiauwao6pw6HMOBiSWMexS7PAmvUQwogTVyXlac5DHxQhNxmJfAL9v5iX6vY/lDYVJgU/cdg+FiuvlI3L0O0VQJtiNPz960QyQIuFdBcHILB/rE5Jmf45WqB9HWC07kE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096833; c=relaxed/simple; bh=odXjPx57klL4KaCZpHh0R8RKqBvJmgvJx5wio021wFQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WIJDLSuu4Y7tkPsUt+1Py/Bi9dt/tXX9Gs2YfnqeXd90yRmdCLPPXHvcntuEw9rCeZ3tiVtQU5htgm8Z0S7R0oEWeNAexMotnECmkUqiBcxX5s/d8oGMcrOpZ0MpYdg8k1JkvP31or9Vx7g1nQHAc+ikDfAA1MHc86IsNBVfZNs= 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 4XtcGL3QFtz6J6bg; Wed, 20 Nov 2024 17:56:58 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 43FAF140B55; Wed, 20 Nov 2024 18:00:29 +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:27 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 09/13] rasdaemon: ras-mc-ctl: Fix logging of memory event type in CXL DRAM error table Date: Wed, 20 Nov 2024 09:59:19 +0000 Message-ID: <20241120095923.1891-10-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 rev 3.0 section 8.2.9.2.1.2 defines the DRAM Event Record. Fix decoding of memory event type in the CXL DRAM error table in RAS SQLite database. For e.g. if value is 0x1 it will be logged as an Invalid Address (General Media Event Record - Memory Event Type) instead of Scrub Media ECC Error (DRAM Event Record - Memory Event Type) and so on. Fixes: c38c14afc5d7 ("rasdaemon: ras-mc-ctl: Add support for CXL DRAM trace= events") Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- util/ras-mc-ctl.in | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index c24941f..3f9bad0 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -1339,7 +1339,7 @@ sub get_cxl_descriptor_flags_text return join (", ", @out); } =20 -sub get_cxl_mem_event_type +sub get_cxl_gmer_mem_event_type { my @types; =20 @@ -1354,6 +1354,22 @@ sub get_cxl_mem_event_type return $types[$_[0]]; } =20 +sub get_cxl_der_mem_event_type +{ + my @types; + + if ($_[0] < 0 || $_[0] > 3) { + return "unknown-type"; + } + + @types =3D ("Media ECC Error", + "Scrub Media ECC Error", + "Invalid Address", + "Data Path Error"); + + return $types[$_[0]]; +} + sub get_cxl_transaction_type { my @types; @@ -1978,7 +1994,7 @@ sub errors $out .=3D sprintf "dpa=3D0x%llx, ", $dpa if (defined $dpa && length $= dpa); $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); - $out .=3D sprintf "memory event type: %s, ", get_cxl_mem_event_type($= mem_event_type) if (defined $mem_event_type && length $mem_event_type); + $out .=3D sprintf "memory event type: %s, ", get_cxl_gmer_mem_event_t= ype($mem_event_type) if (defined $mem_event_type && length $mem_event_type); $out .=3D sprintf "transaction_type: %s, ", get_cxl_transaction_type(= $transaction_type) if (defined $transaction_type && length $transaction_typ= e); $out .=3D sprintf "channel=3D%u, ", $channel if (defined $channel && = length $channel); $out .=3D sprintf "rank=3D%u, ", $rank if (defined $rank && length $r= ank); @@ -2024,7 +2040,7 @@ sub errors $out .=3D sprintf "dpa=3D0x%llx, ", $dpa if (defined $dpa && length $= dpa); $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); - $out .=3D sprintf "memory event type: %s, ", get_cxl_mem_event_type($= type) if (defined $type && length $type); + $out .=3D sprintf "memory event type: %s, ", get_cxl_der_mem_event_ty= pe($type) if (defined $type && length $type); $out .=3D sprintf "transaction_type: %s, ", get_cxl_transaction_type(= $transaction_type) if (defined $transaction_type && length $transaction_typ= e); $out .=3D sprintf "channel=3D%u, ", $channel if (defined $channel && = length $channel); $out .=3D sprintf "rank=3D%u, ", $rank if (defined $rank && length $r= ank); --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 D12C41A4F20; Wed, 20 Nov 2024 10:00:32 +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=1732096835; cv=none; b=Cf4/LC7q2/qsQDnqXzwtb5g0k2PbG6SB8ctkMifXoZolgz9XM0h5iovIQ3Et6xQtehe6zIYGACOYKsDIi8wc7Pv2cb/TNsh8Lvnmhsx89s88QM76i2wDjoikNNxEElxyI+Cl5MUsaNscJoUweI9On2SEdHUxUSDm8AYv4zm2X9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096835; c=relaxed/simple; bh=+7Nalnfa5ggI50m9KvlZLFKQ2L5CaiT2QyfvrLdm2YU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pu58gSj5DFaBVKPAEWE2ffNBIkLOhTjsP3DrTgbntC/SpI9P9Ph00pkPMHvWXNT8/FRFUzSCfmkscL4+8oPzg8vpNpmLCLMW/01HcAZnNrbtM1gSfyyty+pVefDnqkAdK0WuWqvwQJm5Arzbb9dZVq/jc2klwm/mtj2ftjJKlmo= 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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcL04VKcz6L764; Wed, 20 Nov 2024 18:00:08 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id D0177140F3F; Wed, 20 Nov 2024 18:00:30 +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:29 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 10/13] rasdaemon: ras-mc-ctl: Update logging of common event data to align with CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:20 +0000 Message-ID: <20241120095923.1891-11-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 The Common Event Record format in the CXL spec 3.1, section 8.2.9.2.1, Table 8-42, has been updated to include Maintenance Operation Subclass information. This update modifies ras-mc-ctl to log CXL common event data in the RAS SQLite database tables, reflecting the specification changes introduced in revision 3.1. Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- util/ras-mc-ctl.in | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index 3f9bad0..e075ad8 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -1755,7 +1755,7 @@ sub errors my ($memdev, $host, $serial, $error_status, $first_error, $header_log); my ($log_type, $first_ts, $last_ts); my ($trace_type, $region, $region_uuid, $hpa, $dpa, $dpa_length, $sour= ce, $flags, $overflow_ts); - my ($hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts, = $hdr_length, $hdr_maint_op_class, $data); + my ($hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts, = $hdr_length, $hdr_maint_op_class, $hdr_maint_op_sub_class, $data); my ($dpa_flags, $descriptor, $mem_event_type, $transaction_type, $chan= nel, $rank, $device, $comp_id); my ($nibble_mask, $bank_group, $row, $column, $cor_mask); my ($event_type, $health_status, $media_status, $life_used, $dirty_shu= tdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $device_temp, $add_status); @@ -1935,10 +1935,10 @@ sub errors =20 # CXL generic errors use constant CXL_EVENT_RECORD_DATA_LENGTH =3D> 0x50; - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, data from cxl_generic_event$conf{opt}{since} order by id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, data, hdr_maint_op_sub_class from cxl_generic_event$conf{opt}{si= nce} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $data)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $data, $hdr_maint_op_sub_class)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -1953,6 +1953,7 @@ sub errors $out .=3D "hdr_timestamp=3D$hdr_ts, " if (defined $hdr_ts && length $= hdr_ts); $out .=3D sprintf "hdr_length=3D%u, ", $hdr_length if (defined $hdr_l= ength && length $hdr_length); $out .=3D sprintf "hdr_maint_op_class=3D%u, ", $hdr_maint_op_class if= (defined $hdr_maint_op_class && length $hdr_maint_op_class); + $out .=3D sprintf "hdr_maint_op_sub_class=3D%u, ", $hdr_maint_op_sub_= class if (defined $hdr_maint_op_sub_class && length $hdr_maint_op_sub_class= ); if (defined $data && length $data) { $out .=3D sprintf "data:\n"; my @bytes =3D unpack "C*", $data; @@ -1973,10 +1974,10 @@ sub errors =20 # CXL general media errors use constant CXL_EVENT_GEN_MED_COMP_ID_SIZE =3D> 0x10; - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, device, comp_id, hpa, region, region_uuid from cxl_general_media_event$c= onf{opt}{since} order by id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, device, comp_id, hpa, region, region_uuid, hdr_maint_op_sub_class from c= xl_general_media_event$conf{opt}{since} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $mem_even= t_type, $transaction_type, $channel, $rank, $device, $comp_id, $hpa, $regio= n, $region_uuid)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $mem_even= t_type, $transaction_type, $channel, $rank, $device, $comp_id, $hpa, $regio= n, $region_uuid, $hdr_maint_op_sub_class)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -1991,6 +1992,7 @@ sub errors $out .=3D "hdr_timestamp=3D$hdr_ts, " if (defined $hdr_ts && length $= hdr_ts); $out .=3D sprintf "hdr_length=3D%u, ", $hdr_length if (defined $hdr_l= ength && length $hdr_length); $out .=3D sprintf "hdr_maint_op_class=3D%u, ", $hdr_maint_op_class if= (defined $hdr_maint_op_class && length $hdr_maint_op_class); + $out .=3D sprintf "hdr_maint_op_sub_class=3D%u, ", $hdr_maint_op_sub_= class if (defined $hdr_maint_op_sub_class && length $hdr_maint_op_sub_class= ); $out .=3D sprintf "dpa=3D0x%llx, ", $dpa if (defined $dpa && length $= dpa); $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); @@ -2019,10 +2021,10 @@ sub errors =20 # CXL DRAM errors use constant CXL_EVENT_DER_CORRECTION_MASK_SIZE =3D> 0x20; - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, nibble_mask, bank_group, bank, row, column, cor_mask, hpa, region, regio= n_uuid from cxl_dram_event$conf{opt}{since} order by id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, nibble_mask, bank_group, bank, row, column, cor_mask, hpa, region, regio= n_uuid, hdr_maint_op_sub_class from cxl_dram_event$conf{opt}{since} order b= y id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $type, $t= ransaction_type, $channel, $rank, $nibble_mask, $bank_group, $bank, $row, $= column, $cor_mask, $hpa, $region, $region_uuid)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $type, $t= ransaction_type, $channel, $rank, $nibble_mask, $bank_group, $bank, $row, $= column, $cor_mask, $hpa, $region, $region_uuid, $hdr_maint_op_sub_class)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -2037,6 +2039,7 @@ sub errors $out .=3D "hdr_timestamp=3D$hdr_ts, " if (defined $hdr_ts && length $= hdr_ts); $out .=3D sprintf "hdr_length=3D%u, ", $hdr_length if (defined $hdr_l= ength && length $hdr_length); $out .=3D sprintf "hdr_maint_op_class=3D%u, ", $hdr_maint_op_class if= (defined $hdr_maint_op_class && length $hdr_maint_op_class); + $out .=3D sprintf "hdr_maint_op_sub_class=3D%u, ", $hdr_maint_op_sub_= class if (defined $hdr_maint_op_sub_class && length $hdr_maint_op_sub_class= ); $out .=3D sprintf "dpa=3D0x%llx, ", $dpa if (defined $dpa && length $= dpa); $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); @@ -2068,10 +2071,10 @@ sub errors } =20 # CXL memory module errors - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, event_type, health_status, media_status, life_used, dirty_shutdo= wn_cnt, cor_vol_err_cnt, cor_per_err_cnt, device_temp, add_status from cxl_= memory_module_event$conf{opt}{since} order by id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, event_type, health_status, media_status, life_used, dirty_shutdo= wn_cnt, cor_vol_err_cnt, cor_per_err_cnt, device_temp, add_status, hdr_main= t_op_sub_class from cxl_memory_module_event$conf{opt}{since} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $event_type, $health_status, $media_stat= us, $life_used, $dirty_shutdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $d= evice_temp, $add_status)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $event_type, $health_status, $media_stat= us, $life_used, $dirty_shutdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $d= evice_temp, $add_status, $hdr_maint_op_sub_class)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -2086,6 +2089,7 @@ sub errors $out .=3D "hdr_timestamp=3D$hdr_ts, " if (defined $hdr_ts && length $= hdr_ts); $out .=3D sprintf "hdr_length=3D%u, ", $hdr_length if (defined $hdr_l= ength && length $hdr_length); $out .=3D sprintf "hdr_maint_op_class=3D%u, ", $hdr_maint_op_class if= (defined $hdr_maint_op_class && length $hdr_maint_op_class); + $out .=3D sprintf "hdr_maint_op_sub_class=3D%u, ", $hdr_maint_op_sub_= class if (defined $hdr_maint_op_sub_class && length $hdr_maint_op_sub_class= ); $out .=3D sprintf "event_type: %s, ", get_cxl_dev_event_type($event_t= ype) if (defined $event_type && length $event_type); $out .=3D sprintf "health_status: %s, ", get_cxl_health_status_text($= health_status) if (defined $health_status && length $health_status); $out .=3D sprintf "media_status: %s, ", get_cxl_media_status($media_s= tatus) if (defined $media_status && length $media_status); --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 306801A76C8; Wed, 20 Nov 2024 10:00:34 +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=1732096836; cv=none; b=IOEKbm73JRkftrz56YIa44reaXTftVFq95V6zo40i0mkXEWaiTOwmVwR1eyntjkj7pzdc5vwk0/l1irjm1JheUf3tRnO4hxNI0KqqP4FFm3wwXIV5Ivgo2fNQyiLMUz/pmiP/2keuCygMmU71uIgNmSa2i8gxHTrsDifZAquBLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096836; c=relaxed/simple; bh=MqbseApBiiaf4AQbjT0NrC1oXJ1AzC5mzlNW3Ad61EA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SFsRBNwpl+GwPzFNqso1rxAgNrR2ma4067WPA3Hxx4JsJwoi3YxzTbbhuPZhkLnvh6/6fHzBEdb6Vnok1+9Bofuu7/iRUOp/s4zMH3u3megKnjYYj0rhiBsbWM1lKy6LI4iDJ+ymAXqBszQdqxf9Mkiszs2xUk8sPiEmMhYhE1A= 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.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcL21S3jz6L769; Wed, 20 Nov 2024 18:00:10 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 6701D140FF5; Wed, 20 Nov 2024 18:00:32 +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:31 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 11/13] rasdaemon: ras-mc-ctl: Update logging of CXL general media event data to align with CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:21 +0000 Message-ID: <20241120095923.1891-12-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 rev 3.1 section 8.2.9.2.1.1 Table 8-45, General Media Event Record has updated with following new fields and new types for Memory Event Type and Transaction Type fields. 1. Advanced Programmable Corrected Memory Error Threshold Event Flags 2. Corrected Memory Error Count at Event 3. Memory Event Sub-Type The format of component identifier has changed (CXL spec 3.1 section 8.2.9.2.1 Table 8-44). This update modifies ras-mc-ctl to parse and log CXL general media event data stored in the RAS SQLite database table, reflecting the specification changes introduced in revision 3.1. Example output, ./util/ras-mc-ctl --errors ... CXL general media events: 1 2024-11-20 00:00:49 +0000 error: memdev=3Dmem1, host=3D0000:0f:00.0, \ serial=3D0x3, log=3DFatal, hdr_uuid=3D00000000-0000-0000-0000-000000000000,= \ hdr_flags=3D0x1 , hdr_handle=3D0x1, hdr_related_handle=3D0x0, \ hdr_timestamp=3D1970-01-01 00:00:49 +0000, hdr_length=3D128, \ hdr_maint_op_class=3D2, hdr_maint_op_sub_class=3D4, dpa=3D0x30d40, dpa_flag= s: , \ descriptor_flags: 'UNCORRECTABLE EVENT' , 'THRESHOLD EVENT' , \ 'POISON LIST OVERFLOW' , memory event type: TE State Violation, \ memory event sub type: Media Link Command Training Error, transaction_type:= \ Host Inject Poison, channel=3D3, rank=3D33, device=3D0x5, \ component_id:03 74 c5 08 9a 1a 0b fc d2 7e 2f 31 9b 3c 81 4d \ pldm_entity_id:74 c5 08 9a 1a 0b pldm_resource_id:fc d2 7e 2f \ hpa=3D0xffffffffffffffff, region_uuid=3D00000000-0000-0000-0000-00000000000= 0, \ cme_threshold_ev_flags: 'Corrected Memory Errors in Multiple Media Componen= ts' , \ 'Exceeded Programmable Threshold' , cme_count=3D0x78,=20 ... Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- util/ras-mc-ctl.in | 96 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 14 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index e075ad8..f8efa91 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -1339,21 +1339,65 @@ sub get_cxl_descriptor_flags_text return join (", ", @out); } =20 +#CXL rev 3.1 Section 8.2.9.2.1.1; Table 8-45 +#General Media Event Record - GMER sub get_cxl_gmer_mem_event_type { my @types; =20 - if ($_[0] < 0 || $_[0] > 2) { + if ($_[0] < 0 || $_[0] > 6) { return "unknown-type"; } =20 @types =3D ("ECC Error", "Invalid Address", - "Data Path Error"); + "Data Path Error", + "TE State Violation", + "Scrub Media ECC Error", + "Advanced Programmable CME Counter Expiration", + "CKID Violation"); + + return $types[$_[0]]; +} + +# CXL rev 3.1 Section 8.2.9.2.1.1; Table 8-45 +sub get_cxl_mem_event_sub_type +{ + my @types; + + if ($_[0] < 0 || $_[0] > 5) { + return "unknown-type"; + } + + @types =3D ("Not Reported", + "Internal Datapath Error", + "Media Link Command Training Error", + "Media Link Control Training Error", + "Media Link Data Training Error", + "Media Link CRC Error"); =20 return $types[$_[0]]; } =20 +use constant { + CXL_EVT_FLAG_CME_MULTIPLE_MEDIA =3D> 0x0001, + CXL_EVT_FLAG_THRESHOLD_EXCEEDED =3D> 0x0002, +}; +sub get_cxl_cme_threshold_ev_flags_text +{ + my $flags =3D $_[0]; + my @out; + + if ($flags & CXL_EVT_FLAG_CME_MULTIPLE_MEDIA) { + push @out, (sprintf "\'Corrected Memory Errors in Multiple Media Componen= ts\' "); + } + if ($flags & CXL_EVT_FLAG_THRESHOLD_EXCEEDED) { + push @out, (sprintf "\'Exceeded Programmable Threshold\' "); + } + + return join (", ", @out); +} + sub get_cxl_der_mem_event_type { my @types; @@ -1370,11 +1414,12 @@ sub get_cxl_der_mem_event_type return $types[$_[0]]; } =20 +# CXL rev 3.1 Section 8.2.9.2.1.1; Table 8-45 sub get_cxl_transaction_type { my @types; =20 - if ($_[0] < 0 || $_[0] > 6) { + if ($_[0] < 0 || $_[0] > 8) { return "unknown-type"; } =20 @@ -1384,7 +1429,9 @@ sub get_cxl_transaction_type "Host Scan Media", "Host Inject Poison", "Internal Media Scrub", - "Internal Media Management"); + "Internal Media Management", + "Internal Media Error Check Scrub", + "Media Initialization"); =20 return $types[$_[0]]; } @@ -1453,6 +1500,19 @@ sub get_cxl_media_status return $types[$_[0]]; } =20 +# arg0 - name of the id +# arg1 - id +# arg2 - size(bytes) of id +# arg3 - out log buffer +sub print_cxl_dev_id +{ + $_[3] .=3D sprintf "%s:", $_[0]; + my @bytes =3D unpack "C*", $_[1]; + for (my $i =3D 0; $i < $_[2]; $i++) { + $_[3] .=3D sprintf "%02x ", $bytes[$i]; + } +} + sub summary { require DBI; @@ -1756,9 +1816,10 @@ sub errors my ($log_type, $first_ts, $last_ts); my ($trace_type, $region, $region_uuid, $hpa, $dpa, $dpa_length, $sour= ce, $flags, $overflow_ts); my ($hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts, = $hdr_length, $hdr_maint_op_class, $hdr_maint_op_sub_class, $data); - my ($dpa_flags, $descriptor, $mem_event_type, $transaction_type, $chan= nel, $rank, $device, $comp_id); + my ($dpa_flags, $descriptor, $mem_event_type, $mem_event_sub_type, $tr= ansaction_type, $channel, $rank, $device, $comp_id, $pldm_entity_id, $pldm_= res_id); my ($nibble_mask, $bank_group, $row, $column, $cor_mask); my ($event_type, $health_status, $media_status, $life_used, $dirty_shu= tdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $device_temp, $add_status); + my ($cme_threshold_ev_flags, $cme_count); =20 my $dbh =3D DBI->connect("dbi:SQLite:dbname=3D$dbname", "", "", {}); =20 @@ -1974,10 +2035,12 @@ sub errors =20 # CXL general media errors use constant CXL_EVENT_GEN_MED_COMP_ID_SIZE =3D> 0x10; - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, device, comp_id, hpa, region, region_uuid, hdr_maint_op_sub_class from c= xl_general_media_event$conf{opt}{since} order by id"; + use constant CXL_EVENT_GEN_PLDM_ENTITY_ID_SIZE =3D> 0x6; + use constant CXL_EVENT_GEN_PLDM_RES_ID_SIZE =3D> 0x4; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, device, comp_id, hpa, region, region_uuid, hdr_maint_op_sub_class, pldm_= entity_id, pldm_resource_id, sub_type, cme_threshold_ev_flags, cme_count fr= om cxl_general_media_event$conf{opt}{since} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $mem_even= t_type, $transaction_type, $channel, $rank, $device, $comp_id, $hpa, $regio= n, $region_uuid, $hdr_maint_op_sub_class)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $mem_even= t_type, $transaction_type, $channel, $rank, $device, $comp_id, $hpa, $regio= n, $region_uuid, $hdr_maint_op_sub_class, $pldm_entity_id, $pldm_res_id, $m= em_event_sub_type, $cme_threshold_ev_flags, $cme_count)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -1997,20 +2060,25 @@ sub errors $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); $out .=3D sprintf "memory event type: %s, ", get_cxl_gmer_mem_event_t= ype($mem_event_type) if (defined $mem_event_type && length $mem_event_type); + $out .=3D sprintf "memory event sub type: %s, ", get_cxl_mem_e= vent_sub_type($mem_event_sub_type) if (defined $mem_event_sub_type && lengt= h $mem_event_sub_type); $out .=3D sprintf "transaction_type: %s, ", get_cxl_transaction_type(= $transaction_type) if (defined $transaction_type && length $transaction_typ= e); $out .=3D sprintf "channel=3D%u, ", $channel if (defined $channel && = length $channel); $out .=3D sprintf "rank=3D%u, ", $rank if (defined $rank && length $r= ank); $out .=3D sprintf "device=3D0x%x, ", $device if (defined $device && l= ength $device); - if (defined $comp_id && length $comp_id) { - $out .=3D sprintf "component_id:"; - my @bytes =3D unpack "C*", $comp_id; - for (my $i =3D 0; $i < CXL_EVENT_GEN_MED_COMP_ID_SIZE; $i++) { - $out .=3D sprintf "%02x ", $bytes[$i]; - } - } + if (defined $comp_id && length $comp_id) { + print_cxl_dev_id("component_id", $comp_id, CXL_EVENT_GEN_M= ED_COMP_ID_SIZE, $out); + } + if (defined $pldm_entity_id && length $pldm_entity_id) { + print_cxl_dev_id("pldm_entity_id", $pldm_entity_id, CXL_EV= ENT_GEN_PLDM_ENTITY_ID_SIZE, $out); + } + if (defined $pldm_res_id && length $pldm_res_id) { + print_cxl_dev_id("pldm_resource_id", $pldm_res_id, CXL_EVE= NT_GEN_PLDM_RES_ID_SIZE, $out); + } $out .=3D sprintf "hpa=3D0x%llx, ", $hpa if (defined $hpa && l= ength $hpa); $out .=3D "region=3D$region, " if (defined $region && length $= region); $out .=3D "region_uuid=3D$region_uuid, " if (defined $region_u= uid && length $region_uuid); + $out .=3D sprintf "cme_threshold_ev_flags: %s, ", get_cxl_cme_= threshold_ev_flags_text($cme_threshold_ev_flags) if (defined $cme_threshold= _ev_flags && length $cme_threshold_ev_flags); + $out .=3D sprintf "cme_count=3D0x%x, ", $cme_count if (defined= $cme_count && length $cme_count); $out .=3D "\n"; } if ($out ne "") { --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 7C2F51A9B54; Wed, 20 Nov 2024 10:00:35 +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=1732096837; cv=none; b=QZcNxIKBnIqFeCKG2Q897+D6/OdpVq2jv//QNW/8BBWPQz5K032eChR9NgSHrqwGTSxzZd0PM6jHmNBs7qH5CmO9jQcK54sH6MQ88DHoBxhdEo1w12/6OItzdzjSdEuqWR7qWtL8X9Exz2B4hT6h2NtOFKq8QXj415fUfna6PJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096837; c=relaxed/simple; bh=8tow5TpsCCDUPIdZt8gavZ1OoctIto5lKBkIKyiDrOA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ekZa4y/SPBI5sN/6qMlE4zzGlLJkSE45dDN3+w0+aL2Qkkb8W6ruGroNgPxA0vDEjC/Jx0qYWeQLUZuQY0qh7GMbv0c8sfGVbwoeq8rb8/X5NCK/qYd35/EWi4OnsDpnlBlGwYhHcMcXDDeyptWK5e47An0aNAfDBu3qwfHPelc= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcHr73f1z6K98N; Wed, 20 Nov 2024 17:58:16 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 88BA0140119; Wed, 20 Nov 2024 18:00:33 +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:32 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 12/13] rasdaemon: ras-mc-ctl: Update logging of CXL DRAM event data to align with CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:22 +0000 Message-ID: <20241120095923.1891-13-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.2 Table 8-46, DRAM Event Record has updated with following new fields and new types for Memory Event Type, Transaction Type and Validity Flags fields. 1. Component Identifier 2. Sub-channel 3. Advanced Programmable Corrected Memory Error Threshold Event Flags 4. Corrected Volatile Memory Error Count at Event 5. Memory Event Sub-Type This update modifies ras-mc-ctl to parse and log CXL DRAM event data stored in the RAS SQLite database table, reflecting the specification changes introduced in revision 3.1. Example output, ./util/ras-mc-ctl --errors ... CXL DRAM events: 1 2024-11-20 00:18:53 +0000 error: memdev=3Dmem0, host=3D0000:0f:00.0, seri= al=3D0x3, \ log=3DInformational, hdr_uuid=3D00000000-0000-0000-0000-000000000000, \ hdr_flags=3D0x1, , hdr_handle=3D0x1, hdr_related_handle=3D0x0, \ hdr_timestamp=3D1970-01-01 00:00:58 +0000, hdr_length=3D128, hdr_maint_op_c= lass=3D1, \ hdr_maint_op_sub_class=3D3, dpa=3D0x18680, dpa_flags: , \ descriptor_flags: 'UNCORRECTABLE EVENT' , 'THRESHOLD EVENT' , \ memory event type: Data Path Error, memory event sub type: Media Link CRC E= rror, \ transaction_type: Internal Media Scrub, channel=3D3, sub_channel=3D0, rank= =3D17, \ nibble_mask=3D3866802, bank_group=3D7, bank=3D11, row=3D2, column=3D77, \ correction_mask:21 00 00 00 00 00 00 00 2c 00 00 00 00 00 00 00 37 00 00 \ 00 00 00 00 00 42 00 00 00 00 00 00 00 hpa=3D0xffffffffffffffff, \ region_uuid=3D00000000-0000-0000-0000-000000000000, \ component_id:01 74 c5 08 9a 1a 0b fc d2 7e 2f 31 9b 3c 81 4d \ pldm_entity_id:74 c5 08 9a 1a 0b pldm_resource_id:00 00 00 00 \ cme_threshold_ev_flags: 'Corrected Memory Errors in Multiple Media Componen= ts' , \ 'Exceeded Programmable Threshold' , cvme_count=3D0x94,=20 ... Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- util/ras-mc-ctl.in | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index f8efa91..dbb1607 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -1402,14 +1402,17 @@ sub get_cxl_der_mem_event_type { my @types; =20 - if ($_[0] < 0 || $_[0] > 3) { + if ($_[0] < 0 || $_[0] > 6) { return "unknown-type"; } =20 @types =3D ("Media ECC Error", "Scrub Media ECC Error", "Invalid Address", - "Data Path Error"); + "Data Path Error", + "TE State Violation", + "Advanced Programmable CME Counter Expiration", + "CKID Violation"); =20 return $types[$_[0]]; } @@ -1819,7 +1822,7 @@ sub errors my ($dpa_flags, $descriptor, $mem_event_type, $mem_event_sub_type, $tr= ansaction_type, $channel, $rank, $device, $comp_id, $pldm_entity_id, $pldm_= res_id); my ($nibble_mask, $bank_group, $row, $column, $cor_mask); my ($event_type, $health_status, $media_status, $life_used, $dirty_shu= tdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $device_temp, $add_status); - my ($cme_threshold_ev_flags, $cme_count); + my ($sub_channel, $cme_threshold_ev_flags, $cme_count, $cvme_count); =20 my $dbh =3D DBI->connect("dbi:SQLite:dbname=3D$dbname", "", "", {}); =20 @@ -2089,10 +2092,10 @@ sub errors =20 # CXL DRAM errors use constant CXL_EVENT_DER_CORRECTION_MASK_SIZE =3D> 0x20; - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, nibble_mask, bank_group, bank, row, column, cor_mask, hpa, region, regio= n_uuid, hdr_maint_op_sub_class from cxl_dram_event$conf{opt}{since} order b= y id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, dpa, dpa_flags, descriptor, type, transaction_type, channel, ran= k, nibble_mask, bank_group, bank, row, column, cor_mask, hpa, region, regio= n_uuid, hdr_maint_op_sub_class, comp_id, pldm_entity_id, pldm_resource_id, = sub_type, sub_channel, cme_threshold_ev_flags, cvme_count from cxl_dram_eve= nt$conf{opt}{since} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $type, $t= ransaction_type, $channel, $rank, $nibble_mask, $bank_group, $bank, $row, $= column, $cor_mask, $hpa, $region, $region_uuid, $hdr_maint_op_sub_class)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $dpa, $dpa_flags, $descriptor, $type, $t= ransaction_type, $channel, $rank, $nibble_mask, $bank_group, $bank, $row, $= column, $cor_mask, $hpa, $region, $region_uuid, $hdr_maint_op_sub_class, $c= omp_id, $pldm_entity_id, $pldm_res_id, $mem_event_sub_type, $sub_channel, $= cme_threshold_ev_flags, $cvme_count)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -2112,8 +2115,10 @@ sub errors $out .=3D sprintf "dpa_flags: %s, ", get_cxl_dpa_flags_text($dpa_flag= s) if (defined $dpa_flags && length $dpa_flags); $out .=3D sprintf "descriptor_flags: %s, ", get_cxl_descriptor_flags_= text($descriptor) if (defined $descriptor && length $descriptor); $out .=3D sprintf "memory event type: %s, ", get_cxl_der_mem_event_ty= pe($type) if (defined $type && length $type); + $out .=3D sprintf "memory event sub type: %s, ", get_cxl_mem_event_su= b_type($mem_event_sub_type) if (defined $mem_event_sub_type && length $mem_= event_sub_type); $out .=3D sprintf "transaction_type: %s, ", get_cxl_transaction_type(= $transaction_type) if (defined $transaction_type && length $transaction_typ= e); $out .=3D sprintf "channel=3D%u, ", $channel if (defined $channel && = length $channel); + $out .=3D sprintf "sub_channel=3D%u, ", $sub_channel if (defined $sub= _channel && length $sub_channel); $out .=3D sprintf "rank=3D%u, ", $rank if (defined $rank && length $r= ank); $out .=3D sprintf "nibble_mask=3D%u, ", $nibble_mask if (defined $nib= ble_mask && length $nibble_mask); $out .=3D sprintf "bank_group=3D%u, ", $bank_group if (defined $bank_= group && length $bank_group); @@ -2130,6 +2135,17 @@ sub errors $out .=3D sprintf "hpa=3D0x%llx, ", $hpa if (defined $hpa && l= ength $hpa); $out .=3D "region=3D$region, " if (defined $region && length $= region); $out .=3D "region_uuid=3D$region_uuid, " if (defined $region_u= uid && length $region_uuid); + if (defined $comp_id && length $comp_id) { + print_cxl_dev_id("component_id", $comp_id, CXL_EVENT_GEN_M= ED_COMP_ID_SIZE, $out); + } + if (defined $pldm_entity_id && length $pldm_entity_id) { + print_cxl_dev_id("pldm_entity_id", $pldm_entity_id, CXL_EV= ENT_GEN_PLDM_ENTITY_ID_SIZE, $out); + } + if (defined $pldm_res_id && length $pldm_res_id) { + print_cxl_dev_id("pldm_resource_id", $pldm_res_id, CXL_EVE= NT_GEN_PLDM_RES_ID_SIZE, $out); + } + $out .=3D sprintf "cme_threshold_ev_flags: %s, ", get_cxl_cme_= threshold_ev_flags_text($cme_threshold_ev_flags) if (defined $cme_threshold= _ev_flags && length $cme_threshold_ev_flags); + $out .=3D sprintf "cvme_count=3D0x%x, ", $cvme_count if (defin= ed $cvme_count && length $cvme_count); $out .=3D "\n"; } if ($out ne "") { --=20 2.43.0 From nobody Sat Nov 23 11:25:52 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 7BFBA1AA1DE; Wed, 20 Nov 2024 10:00:36 +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=1732096838; cv=none; b=newU0nSR8UsuM/AeSdAl83OeFZELUcg4k4lOqbPPGcG4OuC9zNUgt93CyGhQIoJXDBVeMPW1jMbdXT4F/ekpYyOmxakOyr1iHKQCraUF0/YSdteoARRGq5crgCedoNUNjC7Po3OMwRqtSUI6XjXxTg/4JIr+nXyyTbOmLB8JYsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732096838; c=relaxed/simple; bh=aU8mrRh2PwcG4SYFEXTEPcfJJ57bkVCpuJvMDJZRP84=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jGE4wZHuuOr7KAUMW3j43fY2MYHNeM1C7i7SBWeIgghen1Up0B0hayHZJKyJJwDRnMxVOX2JFO/ILemHuMxQy2LyQGEM/N1+xU9YxTrLUOrH1jqs9a7Wcy///Rxvl61P89CX+enn9m1VjDHDC4fKVNT+4ZH3irgOPTG+oB3IaBU= 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.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XtcHt12zjz6K98Z; Wed, 20 Nov 2024 17:58:18 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id AECA7140CF4; Wed, 20 Nov 2024 18:00:34 +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:33 +0100 From: To: , , , , , , , , , , CC: , , , , Subject: [PATCH 13/13] rasdaemon: ras-mc-ctl: Update logging of CXL memory module data to align with CXL spec rev 3.1 Date: Wed, 20 Nov 2024 09:59:23 +0000 Message-ID: <20241120095923.1891-14-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 This update modifies ras-mc-ctl to parse and log CXL memory module event data stored in the RAS SQLite database table, reflecting the specification changes introduced in revision 3.1. Example output, ./util/ras-mc-ctl --errors ... CXL memory module events: 1 2024-11-20 00:22:33 +0000 error: memdev=3Dmem0, host=3D0000:0f:00.0, seri= al=3D0x3, \ log=3DFatal, hdr_uuid=3Dfe927475-dd59-4339-a586-79bab113b774, hdr_flags=3D0= x1, , \ hdr_handle=3D0x1, hdr_related_handle=3D0x0, hdr_timestamp=3D1970-01-01 00:0= 4:38 +0000, \ hdr_length=3D128, hdr_maint_op_class=3D0, hdr_maint_op_sub_class=3D1, \ 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, life_used=3D8, \ dirty_shutdown_cnt=3D33, cor_vol_err_cnt=3D25, cor_per_err_cnt=3D45, \ device_temp=3D3, add_status=3D3 \ component_id:02 74 c5 08 9a 1a 0b fc d2 7e 2f 31 9b 3c 81 4d \ pldm_entity_id:00 00 00 00 00 00 pldm_resource_id:fc d2 7e 2f=20 ... Signed-off-by: Shiju Jose Reviewed-by: Jonathan Cameron --- util/ras-mc-ctl.in | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in index dbb1607..0990da9 100755 --- a/util/ras-mc-ctl.in +++ b/util/ras-mc-ctl.in @@ -1439,11 +1439,12 @@ sub get_cxl_transaction_type return $types[$_[0]]; } =20 +# CXL rev 3.1 section 8.2.9.2.1.3; Table 8-47 sub get_cxl_dev_event_type { my @types; =20 - if ($_[0] < 0 || $_[0] > 5) { + if ($_[0] < 0 || $_[0] > 8) { return "unknown-type"; } =20 @@ -1452,15 +1453,37 @@ sub get_cxl_dev_event_type "Life Used Change", "Temperature Change", "Data Path Error", - "LSA Error"); + "LSA Error", + "Unrecoverable Internal Sideband Bus Error", + "Memory Media FRU Error", + "Power Management Fault"); =20 return $types[$_[0]]; } =20 +sub get_cxl_dev_event_sub_type +{ + my @types; + + if ($_[0] < 0 || $_[0] > 3) { + return "unknown-type"; + } + + @types =3D ("Not Reported", + "Invalid Config Data", + "Unsupported Config Data", + "Unsupported Memory Media FRU"); + + return $types[$_[0]]; +} + +#CXL rev 3.1 section 8.2.9.9.3.1; Table 8-133 use constant { CXL_DHI_HS_MAINTENANCE_NEEDED =3D> 0x0001, CXL_DHI_HS_PERFORMANCE_DEGRADED =3D> 0x0002, CXL_DHI_HS_HW_REPLACEMENT_NEEDED =3D> 0x0004, + CXL_DHI_HS_HW_REPLACEMENT_NEEDED =3D> 0x0004, + CXL_DHI_HS_MEM_CAPACITY_DEGRADED =3D> 0x0008, }; =20 sub get_cxl_health_status_text @@ -1477,6 +1500,9 @@ sub get_cxl_health_status_text if ($flags & CXL_DHI_HS_HW_REPLACEMENT_NEEDED) { push @out, (sprintf "\'REPLACEMENT_NEEDED\' "); } + if ($flags & CXL_DHI_HS_MEM_CAPACITY_DEGRADED) { + push @out, (sprintf "\'MEM_CAPACITY_DEGRADED\' "); + } =20 return join (", ", @out); } @@ -1821,7 +1847,7 @@ sub errors my ($hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts, = $hdr_length, $hdr_maint_op_class, $hdr_maint_op_sub_class, $data); my ($dpa_flags, $descriptor, $mem_event_type, $mem_event_sub_type, $tr= ansaction_type, $channel, $rank, $device, $comp_id, $pldm_entity_id, $pldm_= res_id); my ($nibble_mask, $bank_group, $row, $column, $cor_mask); - my ($event_type, $health_status, $media_status, $life_used, $dirty_shu= tdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $device_temp, $add_status); + my ($event_type, $event_sub_type, $health_status, $media_status, $life= _used, $dirty_shutdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $device_tem= p, $add_status); my ($sub_channel, $cme_threshold_ev_flags, $cme_count, $cvme_count); =20 my $dbh =3D DBI->connect("dbi:SQLite:dbname=3D$dbname", "", "", {}); @@ -2155,10 +2181,10 @@ sub errors } =20 # CXL memory module errors - $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, event_type, health_status, media_status, life_used, dirty_shutdo= wn_cnt, cor_vol_err_cnt, cor_per_err_cnt, device_temp, add_status, hdr_main= t_op_sub_class from cxl_memory_module_event$conf{opt}{since} order by id"; + $query =3D "select id, timestamp, memdev, host, serial, log_type, hdr_uui= d, hdr_flags, hdr_handle, hdr_related_handle, hdr_ts, hdr_length, hdr_maint= _op_class, event_type, health_status, media_status, life_used, dirty_shutdo= wn_cnt, cor_vol_err_cnt, cor_per_err_cnt, device_temp, add_status, hdr_main= t_op_sub_class, event_sub_type, comp_id, pldm_entity_id, pldm_resource_id f= rom cxl_memory_module_event$conf{opt}{since} order by id"; $query_handle =3D $dbh->prepare($query); $query_handle->execute(); - $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $event_type, $health_status, $media_stat= us, $life_used, $dirty_shutdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $d= evice_temp, $add_status, $hdr_maint_op_sub_class)); + $query_handle->bind_columns(\($id, $timestamp, $memdev, $host, $serial, $= log_type, $hdr_uuid, $hdr_flags, $hdr_handle, $hdr_related_handle, $hdr_ts,= $hdr_length, $hdr_maint_op_class, $event_type, $health_status, $media_stat= us, $life_used, $dirty_shutdown_cnt, $cor_vol_err_cnt, $cor_per_err_cnt, $d= evice_temp, $add_status, $hdr_maint_op_sub_class, $event_sub_type, $comp_id= , $pldm_entity_id, $pldm_res_id)); $out =3D ""; while($query_handle->fetch()) { $out .=3D "$id $timestamp error: "; @@ -2175,6 +2201,7 @@ sub errors $out .=3D sprintf "hdr_maint_op_class=3D%u, ", $hdr_maint_op_class if= (defined $hdr_maint_op_class && length $hdr_maint_op_class); $out .=3D sprintf "hdr_maint_op_sub_class=3D%u, ", $hdr_maint_op_sub_= class if (defined $hdr_maint_op_sub_class && length $hdr_maint_op_sub_class= ); $out .=3D sprintf "event_type: %s, ", get_cxl_dev_event_type($event_t= ype) if (defined $event_type && length $event_type); + $out .=3D sprintf "event_sub_type: %s, ", get_cxl_dev_event_su= b_type($event_sub_type) if (defined $event_sub_type && length $event_sub_t= ype); $out .=3D sprintf "health_status: %s, ", get_cxl_health_status_text($= health_status) if (defined $health_status && length $health_status); $out .=3D sprintf "media_status: %s, ", get_cxl_media_status($media_s= tatus) if (defined $media_status && length $media_status); $out .=3D sprintf "life_used=3D%u, ", $life_used if (defined $life_u= sed && length $life_used); @@ -2183,6 +2210,15 @@ sub errors $out .=3D sprintf "cor_per_err_cnt=3D%u, ", $cor_per_err_cnt if (def= ined $cor_per_err_cnt && length $cor_per_err_cnt); $out .=3D sprintf "device_temp=3D%u, ", $device_temp if (defined $de= vice_temp && length $device_temp); $out .=3D sprintf "add_status=3D%u ", $add_status if (defined $add_s= tatus && length $add_status); + if (defined $comp_id && length $comp_id) { + print_cxl_dev_id("component_id", $comp_id, CXL_EVENT_GEN_M= ED_COMP_ID_SIZE, $out); + } + if (defined $pldm_entity_id && length $pldm_entity_id) { + print_cxl_dev_id("pldm_entity_id", $pldm_entity_id, CXL_EV= ENT_GEN_PLDM_ENTITY_ID_SIZE, $out); + } + if (defined $pldm_res_id && length $pldm_res_id) { + print_cxl_dev_id("pldm_resource_id", $pldm_res_id, CXL_EVE= NT_GEN_PLDM_RES_ID_SIZE, $out); + } $out .=3D "\n"; } if ($out ne "") { --=20 2.43.0