Linux CXL
 help / color / mirror / Atom feed
From: alison.schofield@intel.com
To: Dan Williams <dan.j.williams@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ben Widawsky <bwidawsk@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>
Cc: Alison Schofield <alison.schofield@intel.com>,
	linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 6/6] tools/testing/cxl: Mock the Get Poison List mbox command
Date: Thu, 10 Nov 2022 19:12:44 -0800	[thread overview]
Message-ID: <7accc4b25613bd04ded1c48fa317dcf08803575f.1668115235.git.alison.schofield@intel.com> (raw)
In-Reply-To: <cover.1668115235.git.alison.schofield@intel.com>

From: Alison Schofield <alison.schofield@intel.com>

Return fake poison error records when the get poison list mbox
command is issued. This supports testing the kernel tracing
and cxl list capabilities for media errors.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 tools/testing/cxl/test/mem.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
index f0704d090073..f729e055605d 100644
--- a/tools/testing/cxl/test/mem.c
+++ b/tools/testing/cxl/test/mem.c
@@ -38,6 +38,10 @@ static struct cxl_cel_entry mock_cel[] = {
 		.opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO),
 		.effect = cpu_to_le16(0),
 	},
+	{
+		.opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON),
+		.effect = cpu_to_le16(0),
+	},
 };
 
 /* See CXL 2.0 Table 181 Get Health Info Output Payload */
@@ -207,6 +211,30 @@ static int mock_health_info(struct cxl_dev_state *cxlds,
 	return 0;
 }
 
+static int mock_get_poison(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
+{
+	struct {
+		struct cxl_mbox_poison_payload_out poison_out;
+		struct cxl_poison_record record;
+	} mock_poison_list = {
+		.poison_out = {
+			.count = cpu_to_le16(1),
+		},
+		.record = {
+			/* .address encodes DPA and poison source bits */
+			.address = cpu_to_le64(CXL_POISON_SOURCE_INTERNAL),
+			.length = cpu_to_le32(1),
+		},
+	};
+
+	if (cmd->size_out < sizeof(mock_poison_list))
+		return -EINVAL;
+
+	memcpy(cmd->payload_out, &mock_poison_list, sizeof(mock_poison_list));
+	cmd->size_out = sizeof(mock_poison_list);
+	return 0;
+}
+
 static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd)
 {
 	struct device *dev = cxlds->dev;
@@ -234,6 +262,9 @@ static int cxl_mock_mbox_send(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *
 	case CXL_MBOX_OP_GET_HEALTH_INFO:
 		rc = mock_health_info(cxlds, cmd);
 		break;
+	case CXL_MBOX_OP_GET_POISON:
+		rc = mock_get_poison(cxlds, cmd);
+		break;
 	default:
 		break;
 	}
-- 
2.37.3


  parent reply	other threads:[~2022-11-11  3:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  3:12 [PATCH v3 0/6] CXL Poison List Retrieval & Tracing alison.schofield
2022-11-11  3:12 ` [PATCH v3 1/6] trace, cxl: Introduce a TRACE_EVENT for CXL poison records alison.schofield
2022-11-16 12:19   ` Jonathan Cameron
2022-12-04 22:42   ` Dan Williams
2022-11-11  3:12 ` [PATCH v3 2/6] cxl/mbox: Add GET_POISON_LIST mailbox command alison.schofield
2022-11-16 12:41   ` Jonathan Cameron
2022-11-17 23:55     ` Alison Schofield
2022-12-07  2:41   ` Dan Williams
2022-12-07 16:10     ` Alison Schofield
2022-12-07 21:39       ` Dan Williams
2022-12-08  3:47         ` Alison Schofield
2022-11-11  3:12 ` [PATCH v3 3/6] cxl/memdev: Add trigger_poison_list sysfs attribute alison.schofield
2022-11-16 12:48   ` Jonathan Cameron
2022-11-18  0:15     ` Alison Schofield
2022-11-11  3:12 ` [PATCH v3 4/6] cxl/region: " alison.schofield
2022-11-16 12:50   ` Jonathan Cameron
2022-11-18  0:24     ` Alison Schofield
2022-11-11  3:12 ` [PATCH v3 5/6] tools/testing/cxl: Mock the max err records field of Identify cmd alison.schofield
2022-11-16 12:51   ` Jonathan Cameron
2022-11-18  0:25     ` Alison Schofield
2022-11-11  3:12 ` alison.schofield [this message]
2022-11-16 12:52   ` [PATCH v3 6/6] tools/testing/cxl: Mock the Get Poison List mbox command Jonathan Cameron

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=7accc4b25613bd04ded1c48fa317dcf08803575f.1668115235.git.alison.schofield@intel.com \
    --to=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox