Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1145767rwb; Thu, 10 Nov 2022 11:48:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM7Xdl8prr1V3Rq6lE8qCXG6tT0T2lVOChwjMfe1Nb2AQE7zWc1bRLog4yWmtss/KLARpYSa X-Received: by 2002:a17:906:d295:b0:7ab:2de1:2e45 with SMTP id ay21-20020a170906d29500b007ab2de12e45mr3740616ejb.422.1668109721964; Thu, 10 Nov 2022 11:48:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668109721; cv=none; d=google.com; s=arc-20160816; b=ruRpPypq4w3/otkUUy0Tr3awhWTRlMOPWCN6yfPSjWe96MfpSWwpDlzsC2ei3S3JKR t2VVyKbSaTt82kpzuBOkDw0v7wyd43OFKbgVPzzzCo6DzZWnle1csYnlqGSFD+UB43zQ L3YGiLEUlrwJ3A4j7lT2kwEEln8ruBThpZ2CntRMlaEN7NhLjIfoh66DbegJzs3PeSwE DXGGEVlm8hN9+aORjqWnV2xrjYP8AXgxtw+0hoOmkDzZMzpdnhNdJSWfjqK2Eazd9L9D QARSpB+RFd7rTRzG1f7moyPPt5FUP02bNJ9U3I+Jn2UokQyCYXA9WveqtTGdGEKpkSct st9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2JGiASQncqjDyZbyOP/Xwg4vl/UdTKRGLGtEwNnnAtY=; b=x+MQJkxScvVFk6Z3R1viZNItA2AMjGu3lvHdFjhp9q+E82NSfON1VtkD5sNTNkRlBD QgbDCEEwiK8I3Q2BFjJScrbnKgYvEm8Saf4/xXtntw63tB1ttXgVBNLmIKsYkJcWFvrM s3BQbNRQxT8pa7vebb0NVqp8vsNpWF8d16FZ+AosbPnVNGJr4gQbq+8RQEj6PBTKGenc kqavOqZAi9oDVclPR1BJrGnQwZt5tU6OX1cDZsY6Fu4A7IeEckj6lqOk4tZ7DxvSUBTU Qv0rSjbxkud4b+FC+L820312+7zoD3tzzVy0VvKWoH5IBFBCHp+qqNCy9aFFhTUH3XCM 5uLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H1fb9gCw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa30-20020a170907869e00b00741a16e8562si105078ejc.826.2022.11.10.11.48.19; Thu, 10 Nov 2022 11:48:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H1fb9gCw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbiKJTGn (ORCPT + 92 others); Thu, 10 Nov 2022 14:06:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbiKJTFp (ORCPT ); Thu, 10 Nov 2022 14:05:45 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200E754B18; Thu, 10 Nov 2022 11:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668107129; x=1699643129; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tGLSIWnfH0DX3OQVfNiE0JPNGcqNJkXbIRqhBGzlC2A=; b=H1fb9gCwAejUnLOr8+PLS7V92QZNyCF0aQ0mAlEahoEs+5eLNXrRDEZ0 oGptIDEsLe3MgMfB1WVg/pM0syS5LpTO9lxaBytPJIJyBryf4sne5O3RN mn2CbK2aKpewDG0EbPgzLCV4XZ0Z4+Z7k7h9Jjf0AB0DNWLFlgptPDkJz WsvrUqblwonVZD8J3kGC6SgwzQcvMeGO7LzRVRVMMmJ19l3b3EnZJRt3G QVTixePUvNHkiLDzzIXIjmvK8WOdLOoKbq3b6GGBQYL+PdFuJEQLNnQ9z +8gdGC8F1puYM8tirQKvjmXrGDIcGiuQ+yWleYz5TxppoQMFHOkV3bbg6 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="375662165" X-IronPort-AV: E=Sophos;i="5.96,154,1665471600"; d="scan'208";a="375662165" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 10:58:11 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="882473467" X-IronPort-AV: E=Sophos;i="5.96,154,1665471600"; d="scan'208";a="882473467" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.212.6.223]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 10:58:11 -0800 From: ira.weiny@intel.com To: Dan Williams Cc: Ira Weiny , Alison Schofield , Vishal Verma , Ben Widawsky , Steven Rostedt , Jonathan Cameron , Davidlohr Bueso , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org Subject: [PATCH 11/11] cxl/test: Simulate event log overflow Date: Thu, 10 Nov 2022 10:57:58 -0800 Message-Id: <20221110185758.879472-12-ira.weiny@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221110185758.879472-1-ira.weiny@intel.com> References: <20221110185758.879472-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 From: Ira Weiny Log overflow is marked by a separate trace message. Simulate a log with lots of messages and flag overflow until it is drained a bit. Signed-off-by: Ira Weiny --- Changes from RFC Adjust for new struct changes --- tools/testing/cxl/test/events.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tools/testing/cxl/test/events.c b/tools/testing/cxl/test/events.c index 8693f3fb9cbb..5ce257114f4e 100644 --- a/tools/testing/cxl/test/events.c +++ b/tools/testing/cxl/test/events.c @@ -69,11 +69,21 @@ static void event_store_add_event(struct mock_event_store *mes, log->nr_events++; } +static u16 log_overflow(struct mock_event_log *log) +{ + int cnt = log_rec_left(log) - 5; + + if (cnt < 0) + return 0; + return cnt; +} + int mock_get_event(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) { struct cxl_get_event_payload *pl; struct mock_event_log *log; u8 log_type; + u16 nr_overflow; /* Valid request? */ if (cmd->size_in != sizeof(log_type)) @@ -95,6 +105,20 @@ int mock_get_event(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) if (log_rec_left(log) > 1) pl->flags |= CXL_GET_EVENT_FLAG_MORE_RECORDS; + nr_overflow = log_overflow(log); + if (nr_overflow) { + u64 ns; + + pl->flags |= CXL_GET_EVENT_FLAG_OVERFLOW; + pl->overflow_err_count = cpu_to_le16(nr_overflow); + ns = ktime_get_real_ns(); + ns -= 5000000000; /* 5s ago */ + pl->first_overflow_timestamp = cpu_to_le64(ns); + ns = ktime_get_real_ns(); + ns -= 1000000000; /* 1s ago */ + pl->last_overflow_timestamp = cpu_to_le64(ns); + } + memcpy(&pl->record[0], get_cur_event(log), sizeof(pl->record[0])); pl->record[0].hdr.handle = get_cur_event_handle(log); return 0; @@ -274,6 +298,19 @@ u32 cxl_mock_add_event_logs(struct cxl_dev_state *cxlds) (struct cxl_event_record_raw *)&mem_module); mes->ev_status |= CXLDEV_EVENT_STATUS_INFO; + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &maint_needed); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &hardware_replace); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, + (struct cxl_event_record_raw *)&dram); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, + (struct cxl_event_record_raw *)&gen_media); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, + (struct cxl_event_record_raw *)&mem_module); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &hardware_replace); + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, + (struct cxl_event_record_raw *)&dram); + mes->ev_status |= CXLDEV_EVENT_STATUS_FAIL; + event_store_add_event(mes, CXL_EVENT_TYPE_FATAL, &hardware_replace); event_store_add_event(mes, CXL_EVENT_TYPE_FATAL, (struct cxl_event_record_raw *)&dram); -- 2.37.2