Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4289564rdb; Mon, 11 Dec 2023 14:58:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzi+a3s0LKghmekJ0xHLSO1Yc7ss7OkWy2bIpXV3oekfB6zp6EUbtgUP7sGaihnpQTgpZk X-Received: by 2002:a17:90a:5904:b0:286:bd98:398f with SMTP id k4-20020a17090a590400b00286bd98398fmr4162032pji.1.1702335494438; Mon, 11 Dec 2023 14:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702335494; cv=none; d=google.com; s=arc-20160816; b=oNmf7lNwlaohJS6OJS4c9colofdUk3mH62lCfQpH4sg7ZfrnPQ2YrAfxGuXfO7CPip zcWJrCRTEbJEU7blmYWK8bhAa4u7TTjn1Va73IZh214NuMob0KP/AD2GIqWA9uD+3RjM ht/qvvaaFtWvnqpTc3S/7m8INoIdfD7QZ5SRWwWWujcZwi4MkoQ4Wn9dFsqHcEGxoqiG N0epL3j3gkjoVquIgt4I/PRhMPCezMPHDOwkDiYVo3nyGB42nptiS5oKZkefGs33TN+G I2NR7uE/WnUv3t2KgGfMB2HYdibyD9ifeho8Enrg2T5BS90smSU3/XCIQt7bzWZxgcQf QGKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=GzFrTtcLdqdS8/3MUjGKSWwD83/E2LyMpBN8mBkGhGc=; fh=ooyHxRI2wofYX0BZXsqrgCR3CEVFl26oPigvpILVPuw=; b=T1917G68v35IA0maTOYV4LhG7Q3V8FhV8tRtLr1OoonNx5c/VZ9ojMa64F8ESh3PCM 8SFCyBzHge9vFchX/rWSDK945s/uFr6u1R3g6uOzx46vgutHDUN4u1Q3wAt8Nf2pZ9zX 7cnjSM6sLNqtt8DUlohmkXK1iLwG+kxWYAG2xll/GDyn2w0N1RF2e2UcmHnkoyrZSjF4 539qtvG+10ewFPiFN+Jn/08aqd6NITjiNOb2z+cRFTMxAinAbXMoGbXtkPV0ig5EHxKe 9Klw77pfbGJMmCxyCpGHE2XUO20qW6NajHMqJ/jCkEDvfE1wOCjtdJow7aSVUMLumbm9 /t5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QRYNUr79; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id mu3-20020a17090b388300b002869b900b5esi6997046pjb.17.2023.12.11.14.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 14:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QRYNUr79; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DD16F804E8AA; Mon, 11 Dec 2023 14:58:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345351AbjLKW55 (ORCPT + 99 others); Mon, 11 Dec 2023 17:57:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345178AbjLKW5r (ORCPT ); Mon, 11 Dec 2023 17:57:47 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2950DE4; Mon, 11 Dec 2023 14:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702335470; x=1733871470; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=Wh6w+U6hISsmCWTf+hNF1aRXAEAgHGQkwXc7Og8WW4g=; b=QRYNUr79B1IuuPawSPEg44ZLiVGrFVYEho/kjyHTE51nlrp9T7qAYByL jFw0WVosYRqVIDmWZwdB+HxWE48PqacD+ph4tvBj8akLO8x4sYerGAadW yKmxzen51bT4Rgis91Y8BnD55XCyEc837/Y8Yht5w5CSwtPOrZGhBQm3U 0JxHGZPt0zQyMvoi0ESvImS89MSyIIN4Xe9G1z02O/Yila8QGgGyPjB2y JR93m/ozix3PCF0f/hUphwr4gkgB+RbqeU8OH7Iu/LGyWJCc0MYN7qAYb caJNzPt/Rc7buaaa2W4TlkK3rxt7LaD8xAg/WDcnVA+zfIup7NTEIKXkI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="8084372" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="8084372" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 14:57:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="946513485" X-IronPort-AV: E=Sophos;i="6.04,268,1695711600"; d="scan'208";a="946513485" Received: from iweiny-desk3.amr.corp.intel.com (HELO localhost) ([10.213.189.178]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Dec 2023 14:57:48 -0800 From: Ira Weiny Date: Mon, 11 Dec 2023 14:57:45 -0800 Subject: [PATCH v2 5/7] cxl/events: Create a CXL event union MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231211-cxl-cper-v2-5-c116900ba658@intel.com> References: <20231211-cxl-cper-v2-0-c116900ba658@intel.com> In-Reply-To: <20231211-cxl-cper-v2-0-c116900ba658@intel.com> To: Dan Williams , Jonathan Cameron , Smita Koralahalli , Shiju Jose Cc: Yazen Ghannam , Davidlohr Bueso , Dave Jiang , Alison Schofield , Vishal Verma , Ard Biesheuvel , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, Ira Weiny X-Mailer: b4 0.13-dev-2539e X-Developer-Signature: v=1; a=ed25519-sha256; t=1702335463; l=6756; i=ira.weiny@intel.com; s=20221222; h=from:subject:message-id; bh=Wh6w+U6hISsmCWTf+hNF1aRXAEAgHGQkwXc7Og8WW4g=; b=+zi64UWodIRtLcj1EnrLRvLy7cHQEJ/kYwNlTmmdhswnIp22zWfWChsl8Jcj9Sc9nJ/j9NXiJ kBINR8yOHppDpVOCtp4ecWsz/sF4dSlNNbqX8joCYNwuAzGeMYmox33 X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=brwqReAJklzu/xZ9FpSsMPSQ/qkSalbg6scP3w809Ec= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 14:58:13 -0800 (PST) The CXL CPER and event log records share everything but a UUID/GUID in their structures. Define a cxl_event union without the UUID/GUID to be shared between the CPER and event log record formats. Adjust the code to use this union. Signed-off-by: Ira Weiny --- Changes from RFC: [iweiny: ensure event union is packed] --- drivers/cxl/core/mbox.c | 32 +++++++++++++------------------- drivers/cxl/core/trace.h | 8 ++++---- include/linux/cxl-event.h | 23 +++++++++++++++++------ tools/testing/cxl/test/mem.c | 31 ++++++++++++++++++------------- 4 files changed, 52 insertions(+), 42 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index f4d82e29435d..a67161f8764a 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -858,26 +858,17 @@ static void cxl_event_trace_record(const struct cxl_memdev *cxlmd, enum cxl_event_log_type type, struct cxl_event_record_raw *record) { + union cxl_event *evt = &record->event; uuid_t *id = &record->id; - if (uuid_equal(id, &gen_media_event_uuid)) { - struct cxl_event_gen_media *rec = - (struct cxl_event_gen_media *)record; - - trace_cxl_general_media(cxlmd, type, id, rec); - } else if (uuid_equal(id, &dram_event_uuid)) { - struct cxl_event_dram *rec = (struct cxl_event_dram *)record; - - trace_cxl_dram(cxlmd, type, id, rec); - } else if (uuid_equal(id, &mem_mod_event_uuid)) { - struct cxl_event_mem_module *rec = - (struct cxl_event_mem_module *)record; - - trace_cxl_memory_module(cxlmd, type, id, rec); - } else { - /* For unknown record types print just the header */ - trace_cxl_generic_event(cxlmd, type, id, record); - } + if (uuid_equal(id, &gen_media_event_uuid)) + trace_cxl_general_media(cxlmd, type, id, &evt->gen_media); + else if (uuid_equal(id, &dram_event_uuid)) + trace_cxl_dram(cxlmd, type, id, &evt->dram); + else if (uuid_equal(id, &mem_mod_event_uuid)) + trace_cxl_memory_module(cxlmd, type, id, &evt->mem_module); + else + trace_cxl_generic_event(cxlmd, type, id, &evt->generic); } static int cxl_clear_event_record(struct cxl_memdev_state *mds, @@ -920,7 +911,10 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds, */ i = 0; for (cnt = 0; cnt < total; cnt++) { - payload->handles[i++] = get_pl->records[cnt].hdr.handle; + struct cxl_event_record_raw *raw = &get_pl->records[cnt]; + struct cxl_event_generic *gen = &raw->event.generic; + + payload->handles[i++] = gen->hdr.handle; dev_dbg(mds->cxlds.dev, "Event log '%d': Clearing %u\n", log, le16_to_cpu(payload->handles[i])); diff --git a/drivers/cxl/core/trace.h b/drivers/cxl/core/trace.h index 68973a101a75..3e09f2f2d7df 100644 --- a/drivers/cxl/core/trace.h +++ b/drivers/cxl/core/trace.h @@ -225,9 +225,9 @@ TRACE_EVENT(cxl_overflow, TRACE_EVENT(cxl_generic_event, TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, - const uuid_t *uuid, struct cxl_event_record_raw *rec), + const uuid_t *uuid, struct cxl_event_generic *gen_rec), - TP_ARGS(cxlmd, log, uuid, rec), + TP_ARGS(cxlmd, log, uuid, gen_rec), TP_STRUCT__entry( CXL_EVT_TP_entry @@ -235,8 +235,8 @@ TRACE_EVENT(cxl_generic_event, ), TP_fast_assign( - CXL_EVT_TP_fast_assign(cxlmd, log, uuid, rec->hdr); - memcpy(__entry->data, &rec->data, CXL_EVENT_RECORD_DATA_LENGTH); + CXL_EVT_TP_fast_assign(cxlmd, log, uuid, gen_rec->hdr); + memcpy(__entry->data, gen_rec->data, CXL_EVENT_RECORD_DATA_LENGTH); ), CXL_EVT_TP_printk("%s", diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h index ebb00ead1496..18dab4d90dc8 100644 --- a/include/linux/cxl-event.h +++ b/include/linux/cxl-event.h @@ -18,13 +18,8 @@ struct cxl_event_record_hdr { u8 reserved[15]; } __packed; -/* - * Common Event Record Format - * CXL rev 3.0 section 8.2.9.2.1; Table 8-42 - */ #define CXL_EVENT_RECORD_DATA_LENGTH 0x50 -struct cxl_event_record_raw { - uuid_t id; +struct cxl_event_generic { struct cxl_event_record_hdr hdr; u8 data[CXL_EVENT_RECORD_DATA_LENGTH]; } __packed; @@ -97,4 +92,20 @@ struct cxl_event_mem_module { u8 reserved[0x3d]; } __packed; +union cxl_event { + struct cxl_event_generic generic; + struct cxl_event_gen_media gen_media; + struct cxl_event_dram dram; + struct cxl_event_mem_module mem_module; +} __packed; + +/* + * Common Event Record Format; in event logs + * CXL rev 3.0 section 8.2.9.2.1; Table 8-42 + */ +struct cxl_event_record_raw { + uuid_t id; + union cxl_event event; +} __packed; + #endif /* _LINUX_CXL_EVENT_H */ diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c index 9cc2b8ce1efd..35ee41e435ab 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -251,7 +251,8 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd) for (i = 0; i < CXL_TEST_EVENT_CNT && !event_log_empty(log); i++) { memcpy(&pl->records[i], event_get_current(log), sizeof(pl->records[i])); - pl->records[i].hdr.handle = event_get_cur_event_handle(log); + pl->records[i].event.generic.hdr.handle = + event_get_cur_event_handle(log); log->cur_idx++; } @@ -339,25 +340,29 @@ static void cxl_mock_event_trigger(struct device *dev) struct cxl_event_record_raw maint_needed = { .id = UUID_INIT(0xBA5EBA11, 0xABCD, 0xEFEB, 0xa5, 0x5a, 0xa5, 0x5a, 0xa5, 0xa5, 0x5a, 0xa5), - .hdr = { - .length = sizeof(struct cxl_event_record_raw), - .flags[0] = CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, - /* .handle = Set dynamically */ - .related_handle = cpu_to_le16(0xa5b6), + .event.generic = { + .hdr = { + .length = sizeof(struct cxl_event_record_raw), + .flags[0] = CXL_EVENT_RECORD_FLAG_MAINT_NEEDED, + /* .handle = Set dynamically */ + .related_handle = cpu_to_le16(0xa5b6), + }, + .data = { 0xDE, 0xAD, 0xBE, 0xEF }, }, - .data = { 0xDE, 0xAD, 0xBE, 0xEF }, }; struct cxl_event_record_raw hardware_replace = { .id = UUID_INIT(0xABCDEFEB, 0xBA11, 0xBA5E, 0xa5, 0x5a, 0xa5, 0x5a, 0xa5, 0xa5, 0x5a, 0xa5), - .hdr = { - .length = sizeof(struct cxl_event_record_raw), - .flags[0] = CXL_EVENT_RECORD_FLAG_HW_REPLACE, - /* .handle = Set dynamically */ - .related_handle = cpu_to_le16(0xb6a5), + .event.generic = { + .hdr = { + .length = sizeof(struct cxl_event_record_raw), + .flags[0] = CXL_EVENT_RECORD_FLAG_HW_REPLACE, + /* .handle = Set dynamically */ + .related_handle = cpu_to_le16(0xb6a5), + }, + .data = { 0xDE, 0xAD, 0xBE, 0xEF }, }, - .data = { 0xDE, 0xAD, 0xBE, 0xEF }, }; struct cxl_test_gen_media { -- 2.43.0