lkml.org 
[lkml]   [2022]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 6/6] tools/testing/cxl: Mock the Get Poison List mbox command
On Thu, 10 Nov 2022 19:12:44 -0800
alison.schofield@intel.com wrote:

> 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>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.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;
> }

\
 
 \ /
  Last update: 2022-11-16 13:53    [W:0.133 / U:1.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site