From patchwork Fri Nov 11 03:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 13039531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBC61C4332F for ; Fri, 11 Nov 2022 03:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbiKKDNG (ORCPT ); Thu, 10 Nov 2022 22:13:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232667AbiKKDND (ORCPT ); Thu, 10 Nov 2022 22:13:03 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC2F5CD29; Thu, 10 Nov 2022 19:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668136380; x=1699672380; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y00FqPXd0tXMVfbMPOYOFfjRtaD0786m2Qc/OlOfGUE=; b=IUdDeEcWfeS9KM33cf7hVpD8Az0gL3y3vfxU+Fdsb/MJyFviz3FLIoc4 cWZKLYlVg8Y0FM88FSzBw9vZAVE1vsPIGhFu5Lr8Ce0mc4VA/dARTEOjX WYefm52/CWHIPPhsaAsDFZ9l7kwJRJMOXfGXMe39WhE2bMzeajtRigpWQ dQBhP8LU2lxYyhh6e0CCegh+SAXh/mP+c4cJZDZqpErXu6m39qnd+j44k FHg5ubgQA7PTMhD0ADaP+pb8upN0lgv3SsyTK9iqyTV5UZcZyj4rSOnoc ycT1a7EUUmvJ5Uy/MHebiwf4Wj78WVpPIW/W7rGrpBna/tEIa26F9MlzU g==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="310224419" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="310224419" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 19:13:00 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="812296108" X-IronPort-AV: E=Sophos;i="5.96,155,1665471600"; d="scan'208";a="812296108" Received: from aschofie-mobl2.amr.corp.intel.com (HELO localhost) ([10.209.161.45]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 19:12:59 -0800 From: alison.schofield@intel.com To: Dan Williams , Ira Weiny , Vishal Verma , Dave Jiang , Ben Widawsky , Steven Rostedt , Ingo Molnar Cc: Alison Schofield , 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 Message-Id: <7accc4b25613bd04ded1c48fa317dcf08803575f.1668115235.git.alison.schofield@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Alison Schofield 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 Reviewed-by: Jonathan Cameron --- 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; }