Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1191788rdb; Wed, 1 Nov 2023 14:12:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWmZA9Y9a71HmgtJ5uNy8vCyPVlJegm16whjuymEYD3brhODGERtVw9AlbnVZPP1HhgfVt X-Received: by 2002:a05:6871:514:b0:1e9:c1e0:5a97 with SMTP id s20-20020a056871051400b001e9c1e05a97mr18110336oal.13.1698873127427; Wed, 01 Nov 2023 14:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698873127; cv=none; d=google.com; s=arc-20160816; b=qlE31AEQTmqjUwhk91tZU6IJlW+p2ePMHvr5mRSXRMKtKk9VMzUWm66JwpcBeUpicb 6SkwYiSeMK5tqoDcYXQFLlxgNv0JrkPFidUfVqy70bpZd6oFXIUw549Sr0guhtsOigJ4 KoBKtLtff7jqh7SPEkQtrL1y2t0IY9jDlEOsKAb/1Mb9EIDfhKFdQN5IzCJvLzo1j73S ywTO6D9DzK9E9gt9hrfXcVPDYWmfvqWYWvttU15ugQzDsutTY/0LFtfwDvhaJYdSTImw bsg29XPOX04G1tGLMSzkLndN5zb6/TE2F9Ewoh6uI1dfixGDN2oa4fL3Z50fxNInrGAg cZAg== 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=AbKdBKKdk4sviRPagx0NBVH0VBRFHwWqD4j+SV2GnMI=; fh=4WvFpXupgJy9TZSzZnyqw1IvnufN/ktGDtOBUEq5CPM=; b=DSpvEwM6lc85NUEzDCqopMzFUL+d4az5+iVFnu6Zkq7DOCpj8XmjqCA8NrvlYs9nRS dCHwHao0lGbMlQuGevwV+UTjSOp8L+waCoGcJfVwYyJnIH29t2SyTwCNqjedIrEYB5TI KzY9oikfanmG+TA0PB+dcaNlAbQQQMRiXMlXRSJniKIiYYUmkmbWH9b6S9ZgyV5P7x1q cBEyg74PqK0PlbH4rkjz+za286b5AMKHj89QPYLWUpbFtHVNA7f5w6R9muCuGg3JaYU5 KaV5/VKNLhgcmrExtBJNqrTbYA5HUZAb3yLQlxzBQvN5siFtTHwcBexHK55ucqCO0znx x+PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cfp27LPK; 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 o21-20020a656a55000000b005b90b310e26si784727pgu.403.2023.11.01.14.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 14:12:07 -0700 (PDT) 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=cfp27LPK; 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 343B380AB1DB; Wed, 1 Nov 2023 14:12:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344864AbjKAVL6 (ORCPT + 99 others); Wed, 1 Nov 2023 17:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344340AbjKAVLx (ORCPT ); Wed, 1 Nov 2023 17:11:53 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 709B8111; Wed, 1 Nov 2023 14:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698873106; x=1730409106; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=ZEFbbYepN1TDRPwicNxKX/v/WvX1obzlRNocbU9ta3g=; b=cfp27LPKGyVG3GOKvf28z/Tf+qBCeCGUwiCswwYFOtsdh8llshR3VT2n EA2n5gdVa2DMjsys6Hl/tYmTBA3js/qO9f8UMJKYKBgx1Ckgr59wR7dcG Ue7ow252J1CYi69b9nU0d/GLG9RTSyFkC4l2sYNML7q8nbAHR10KRNQ31 3fvitYNBortuqR5tra6FRtAZnHyx/xiWuTOVPEk9cnYZL6dp/yrsl4iR3 DZi8Dx7TUqwIjhV0UVn1p5lPzXgWO5lBzpg9Ylfbl1qeQ7uwa7yx9QW+K M0eq/IKH/LXIm6FpedMM01n2fUM6dtdL6XbPLFGIeVwOwLil19SAP00ca g==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="10120107" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="10120107" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 14:11:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="1092482756" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="1092482756" Received: from iweiny-desk3.amr.corp.intel.com (HELO localhost) ([10.212.80.64]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 14:11:45 -0700 From: Ira Weiny Date: Wed, 01 Nov 2023 14:11:21 -0700 Subject: [PATCH RFC v3 4/6] cxl/events: Create a CXL event union MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230601-cxl-cper-v3-4-0189d61f7956@intel.com> References: <20230601-cxl-cper-v3-0-0189d61f7956@intel.com> In-Reply-To: <20230601-cxl-cper-v3-0-0189d61f7956@intel.com> To: Dan Williams , Jonathan Cameron , Smita Koralahalli 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-0f7f0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698873100; l=6616; i=ira.weiny@intel.com; s=20221222; h=from:subject:message-id; bh=ZEFbbYepN1TDRPwicNxKX/v/WvX1obzlRNocbU9ta3g=; b=l7HilFkq2da9GEE1Ny3HbqiGuBnV/ljDeVq5+Y1c1VEl6LYFjoL0DikJMalQQy9LIA9gZ1AKC fkTX7qGmpsFDdVN14xGtHdpJF7E2O1bDphHJJk1a8HAOHsNqL1RrhGn X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=brwqReAJklzu/xZ9FpSsMPSQ/qkSalbg6scP3w809Ec= X-Spam-Status: No, score=-2.5 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,URIBL_BLOCKED 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]); Wed, 01 Nov 2023 14:12:06 -0700 (PDT) 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 after the record type is determined. Signed-off-by: Ira Weiny --- Changes from RFC v2: [iweiny: new patch] --- drivers/cxl/core/mbox.c | 23 +++++++++-------------- drivers/cxl/core/trace.h | 10 +++++----- include/linux/cxl-event.h | 23 +++++++++++++++++------ tools/testing/cxl/test/mem.c | 31 ++++++++++++++++++------------- 4 files changed, 49 insertions(+), 38 deletions(-) diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c index f27c409f9034..bb40b844e3bd 100644 --- a/drivers/cxl/core/mbox.c +++ b/drivers/cxl/core/mbox.c @@ -864,25 +864,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, rec); + trace_cxl_general_media(cxlmd, type, &evt->gen_media); } else if (uuid_equal(id, &dram_event_uuid)) { - struct cxl_event_dram *rec = (struct cxl_event_dram *)record; - - trace_cxl_dram(cxlmd, type, rec); + trace_cxl_dram(cxlmd, type, &evt->dram); } 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, rec); + trace_cxl_memory_module(cxlmd, type, &evt->mem_module); } else { - /* For unknown record types print just the header */ - trace_cxl_generic_event(cxlmd, type, record); + trace_cxl_generic_event(cxlmd, type, id, &evt->generic); } } @@ -926,7 +918,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 72c620597708..be0bda68f80f 100644 --- a/drivers/cxl/core/trace.h +++ b/drivers/cxl/core/trace.h @@ -223,9 +223,9 @@ TRACE_EVENT(cxl_overflow, TRACE_EVENT(cxl_generic_event, TP_PROTO(const struct cxl_memdev *cxlmd, enum cxl_event_log_type log, - struct cxl_event_record_raw *rec), + uuid_t *uuid, struct cxl_event_generic *gen_rec), - TP_ARGS(cxlmd, log, rec), + TP_ARGS(cxlmd, log, uuid, gen_rec), TP_STRUCT__entry( CXL_EVT_TP_entry @@ -234,9 +234,9 @@ TRACE_EVENT(cxl_generic_event, ), TP_fast_assign( - CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); - memcpy(&__entry->hdr_uuid, &rec->id, sizeof(uuid_t)); - memcpy(__entry->data, &rec->data, CXL_EVENT_RECORD_DATA_LENGTH); + CXL_EVT_TP_fast_assign(cxlmd, log, gen_rec->hdr); + memcpy(&__entry->hdr_uuid, uuid, sizeof(uuid_t)); + memcpy(__entry->data, gen_rec->data, CXL_EVENT_RECORD_DATA_LENGTH); ), CXL_EVT_TP_printk("uuid=%pUb %s", &__entry->hdr_uuid, diff --git a/include/linux/cxl-event.h b/include/linux/cxl-event.h index ebb00ead1496..6b689e1efc78 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; +}; + +/* + * 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 85862be00c48..2535eb182ece 100644 --- a/tools/testing/cxl/test/mem.c +++ b/tools/testing/cxl/test/mem.c @@ -244,7 +244,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++; } @@ -332,25 +333,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.41.0