From be7bea38bf5d3c04f940e7f9e800d0239e089f78 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Mon, 6 Mar 2023 16:20:23 +0000 Subject: [PATCH 01/11] Fix Power protocol DOMAIN_NAME_GET enum naming Fix Power protocol DOMAIN_NAME_GET enum naming Signed-off-by: Cristian Marussi --- val/include/val_interface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/val/include/val_interface.h b/val/include/val_interface.h index 07a0a28..d3de942 100644 --- a/val/include/val_interface.h +++ b/val/include/val_interface.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -195,7 +195,7 @@ typedef enum { POWER_STATE_GET, POWER_STATE_NOTIFY, POWER_STATE_CHANGE_REQUESTED_NOTIFY, - POWER_STATE_DOMAIN_NAME_GET, + POWER_DOMAIN_NAME_GET, POWER_PROTOCOL_INVALID_COMMAND } POWER_DOMAIN_COMMANDS; -- GitLab From 3a98d50e36682baa5ddd7feb47f57879ebc3c6e5 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Mon, 11 Jul 2022 19:31:06 +0100 Subject: [PATCH 02/11] Add support for using Kernel SCMI Raw mode access Add support to use SCMI Kernel Raw message access support using the optional TRANS=raw compile switch and also a command-line option for the Linux app to select a different debugfs path to be used as the root of SCMI Raw interface. Signed-off-by: Cristian Marussi --- Makefile | 4 +- docs/guide_linux_testing.md | 51 ++- docs/user_guide.md | 20 +- linux_app/app.c | 16 +- platform/linux/common/Makefile | 24 +- platform/linux/common/transport_mailbox.c | 10 +- platform/linux/common/transport_raw.c | 407 +++++++++++++++++++ platform/linux/sgm776/include/pal_platform.h | 4 +- platform/linux/sgm776/pal_platform.c | 4 +- platform/linux/tc/include/pal_platform.h | 4 +- platform/linux/tc/pal_platform.c | 4 +- val/val_interface.c | 5 +- 12 files changed, 530 insertions(+), 23 deletions(-) create mode 100644 platform/linux/common/transport_raw.c diff --git a/Makefile b/Makefile index e1b494c..4c8ee67 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ #/** @file -# * Copyright (c) 2019-2021 Arm Limited or its affiliates. All rights reserved. +# * Copyright (c) 2019-2023 Arm Limited or its affiliates. All rights reserved. # * SPDX-License-Identifier : Apache-2.0 # * # * Licensed under the Apache License, Version 2.0 (the "License"); @@ -71,6 +71,8 @@ DIRS+=$(PLAT_DIR)/$(PLAT) endif BUILD_ALL=$(DIRS) +export TRANS=mailbox + # Name for directory within each subdir that contains its header files export HEADER_DIR=include diff --git a/docs/guide_linux_testing.md b/docs/guide_linux_testing.md index 53946f7..7e0c867 100644 --- a/docs/guide_linux_testing.md +++ b/docs/guide_linux_testing.md @@ -9,11 +9,12 @@ Table of Contents: * [Mailbox test driver](#mailbox-test-driver) * [Doorbell support patches for mailbox](#doorbell-support-patches-for-mailbox) * [Additional changes to enable mailbox test driver](#additional-changes-to-enable-mailbox-test-driver) + * [SCMI Raw mode support](#scmi-raw-driver) - [Kernel build](#kernel-build) Introduction ------- -This document lists the instructions that must be followed to run SCMI ACS as Linux application using the mailbox test driver interface on SGM/TC target. +This document lists the instructions that must be followed to run SCMI ACS as Linux application using one of the available test interfaces on any of the available targets. For an introduction to the System Guidance for Mobile (SGM) platforms, please refer to the [Arm Developer documentation]. Software Stack @@ -22,7 +23,13 @@ Arm provides a [super-project] with guides for building and running a full softw Linux kernel ------- -The following changes must be made in the Linux kernel source code after downloading the software stack for SGM/TC. +There are two main ways in which the SCMI ACS, running as a Linux application, can inject and snoop SCMI traffic back and forth from the SCMI backend server that is intended to be tested. + +A test interface based on the Mailbox test driver was provided at first: this setup assumes that the SCMI backend server under test is placed in a setup where the communication channel is based on mailboxes and you'll need a properly configured Mailbox test driver as detailed below. + +Alternatively, on more recent kernels, the standard SCMI stack can be configured to expose on debugfs a few entries can be used to inject and snoop bare SCMI raw messages; this way the traffic going back and forth will use whatever underlying transport is currently configured on the system: as a consequence it is possible to verify the compliance of the SCMI server under test no matter where it is placed and which transport medium eploys. + +The following alternative changes must be made in the Linux kernel source code after downloading the software stack for SGM/TC. ### Mailbox test driver To use SCMI test agent on SGM/TC target, the Linux kernel must be rebuilt to include the mailbox test driver with mailbox doorbell support and additional changes. Doorbell support patches for mailbox, and additional changes to enable mailbox test driver are tested against Linux kernel version 4.13. @@ -58,6 +65,44 @@ waitq_err: ``` The current change in mailbox test driver is not an ideal solution. A better solution is to use sysfs entry for configurability. This enhancement will be upstreamed in the future, thereby making this change redundant. +### SCMI Raw mode support +Alternatively, on supported Kernels, it is possible to configure the SCMI test agent on any target to use the Kernel SCMI Raw access mode; in such a case the Kernel must be rebuild enabling CONFIG_ARM_SCMI_RAW_MODE_SUPPORT=y and the SCMI ACS suite itself must be rebuild specifying TRANS=raw on the make command line, like in: + +> `make PLAT=linux TRANS=raw TARGET=sgm776 PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,voltage,reset VERBOSE=1` + +If TRANS= is not specified the usual Mailbox driver backend is instead compiled into the SCMI ACS suite. + +No device tree change is needed in this case. + +The SCMI ACS then starts injecting/snooping SCMI messages via the following debugfs API entries, as exposed by the Kernel OSPM Agent running in Raw mode: + +``` + /sys/kernel/debug/scmi/ + `-- 0 + |-- atomic_threshold_us + |-- instance_name + |-- raw + | |-- channels + | | |-- 0x10 + | | | |-- message + | | | `-- message_async + | | `-- 0x13 + | | |-- message + | | `-- message_async + | |-- errors + | |-- message + | |-- message_async + | |-- notification + | `-- reset + `-- transport + |-- is_atomic + |-- max_msg_size + |-- max_rx_timeout_ms + |-- rx_max_msg + |-- tx_max_msg + `-- type +``` + ## Kernel build Build the kernel and device tree after making the changes and use the run-scripts for running the SGM/TC @@ -65,7 +110,7 @@ For instructions to build the test suite for Linux platform and running it, see - - - - - - - - - - - - - - - - -_Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved._ +_Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved._ [ARM Developer documentation]: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms [Mailbox doorbell support patches]: https://lkml.org/lkml/2017/5/24/339 diff --git a/docs/user_guide.md b/docs/user_guide.md index 159c07b..6ec6ccd 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -104,8 +104,12 @@ The output will be libscmi_test.a and scmi_test_agent for the Linux platform in The scmi_test_agent app supports the command-line option '-r' to optionally enable relaxed protocol versioning checks: when enabled the relevant testcases are run even if the SCMI Server under test advertised to implement a greater protocol version (i.e. newer) than the one officially supported by the current test-suite for that test-case and, in such a case, the protocol version mismatch is logged. This behaviour could possibly lead to false positives if the newer protocol version specification introduced some non-backward compatible change: for this reason the relaxed checks are off by default andhave to be explicitly enabled using the '-r' switch. +Instead of using the mailbox test driver, alternatively, the SCMI test suite can be build to make use of the Kernel SCMI Raw access interface by specifying TRANS=raw on the make commandline: + +>`make PLAT=linux TRANS=raw TARGET=sgm776 PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,reset VERBOSE=1` + **NOTE**: -* You must rebuild the Linux kernel and device trees for LINUX by following the [Guide to test SCMI on LINUX]. +* In both cases you must rebuild the Linux kernel (and the device tree in the mailbox test driver case) for LINUX by following the [Guide to test SCMI on LINUX]. #### 2.3 Baremetal @@ -138,6 +142,18 @@ To run the test suite on the Linux platform, execute the following command in th The test logs are captured in a report file arm\_scmi\_test\_log.txt in the same directory as the executable. +#### OSPM test agent command-line options + +A few command-line option can be provided when running the test suite in the Linux platform. + +>`Usage: ./scmi_test_agent [-r][-p ]` + +where: +``` + -r: relax protocol version checking. Tests will be run even if the supported SCMI protocol version, + as advertised by the platform, is newer than the version supported by the testcase. + -p : provide a different SCMI debugfs root path. Default is: /sys/kernel/debug/scmi/0/ +``` ### Running in Baremetal environment To run the test suite on the baremetal environment, invoke to `arm_scmi_agent_execute()` from test framework. For more details, refer to [Validation Methodology Document]. @@ -220,7 +236,7 @@ Each individual check delivers a PASS, FAIL, or SKIPPED. - - - - - - - - - - - - - - - - - -_Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved._ +_Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved._ [Linaro Release]: https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/ [Validation Methodology Document]: ./Arm_SCMI_Validation_Methodology.pdf "SCMI Test Suite Design" diff --git a/linux_app/app.c b/linux_app/app.c index 0d1b9db..b367850 100644 --- a/linux_app/app.c +++ b/linux_app/app.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,26 +34,32 @@ int main(int argc, char *argv[]) uint32_t num_pass; uint32_t num_fail; uint32_t num_skip; + char *scmi_raw_root_path = NULL; - while ((opt = getopt(argc, argv, "r")) != -1) { + while ((opt = getopt(argc, argv, "rp:")) != -1) { switch (opt) { case 'r': relaxed_version_checks = true; break; + case 'p': + scmi_raw_root_path = optarg; + break; default: /* '?' */ - fprintf(stderr, "Usage: %s [-r]\n", + fprintf(stderr, "Usage: %s [-r][-p ]\n", argv[0]); exit(EXIT_FAILURE); } } val_print(VAL_PRINT_ERR, "\n\n **** SCMI Compliance Suite **** "); - - if (val_initialize_system((void *) NULL)) { + if (val_initialize_system(scmi_raw_root_path)) { val_print(VAL_PRINT_ERR, "\n **** INIT FAILED ***"); return 0; } + val_print(VAL_PRINT_INFO, "\n Using *%s* SCMI protocol version checking", + relaxed_version_checks ? "relaxed" : "strict"); + val_print(VAL_PRINT_ERR, "\n\n *** Starting BASE tests ***"); val_base_execute_tests(); diff --git a/platform/linux/common/Makefile b/platform/linux/common/Makefile index b436bda..531b6cf 100644 --- a/platform/linux/common/Makefile +++ b/platform/linux/common/Makefile @@ -1,5 +1,5 @@ #/** @file -# * Copyright (c) 2021 Arm Limited or its affiliates. All rights reserved. +# * Copyright (c) 2021-2023 Arm Limited or its affiliates. All rights reserved. # * SPDX-License-Identifier : Apache-2.0 # * # * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,4 +15,24 @@ # * limitations under the License. #**/ -include ${TOP}/platform/build_platform.mk +H_FILES := $(wildcard $(HEADER_DIR)/*.h) +OBJS := $(PLATFORM_OBJ_DIR)/transport_${TRANS}.o $(PLATFORM_OBJ_DIR)/common.o + +all: all_platform + +all_platform: $(OBJS) + @echo "### Finished building with makefile at `pwd` ###" + +$(PLATFORM_OBJ_DIR)/transport_${TRANS}.o: transport_${TRANS}.c $(H_FILES) + @echo "$(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -c $< -o $@" + $(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -g -c $< -o $@ + +$(PLATFORM_OBJ_DIR)/common.o: common.c $(H_FILES) + @echo "$(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -c $< -o $@" + $(CC) $(D_NAMES) $(CFLAGS) $(I_DIRS) -g -c $< -o $@ + +clean: clean_platform + +clean_platform: + +.PHONY: clean diff --git a/platform/linux/common/transport_mailbox.c b/platform/linux/common/transport_mailbox.c index 80d18ae..dd5885c 100644 --- a/platform/linux/common/transport_mailbox.c +++ b/platform/linux/common/transport_mailbox.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2021 Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023 Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -64,6 +64,14 @@ enum { MB_LENGTH_MESSAGE_HEADER = 0x4 } mailbox_byte_length; +/*! + * @brief Interface function that performs any needed Linux initialization. + */ +uint32_t linux_initialize_system(void *info) +{ + return NO_ERROR; +} + /*! * @brief Interface function that sends a * command to mailbox driver interfaces and receives a platform diff --git a/platform/linux/common/transport_raw.c b/platform/linux/common/transport_raw.c new file mode 100644 index 0000000..0e2b970 --- /dev/null +++ b/platform/linux/common/transport_raw.c @@ -0,0 +1,407 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "val_interface.h" + +#define NO_ERROR 0 +#define ERROR 5 + +#define TRANS_DEFAULT_BASE_PATH "/sys/kernel/debug/scmi/0" + +#define TRANS_MAX_MSG_SZ_FILE "transport/max_msg_size" +#define TRANS_RX_TMO_MS "transport/max_rx_timeout_ms" + +#define TRANS_RAW_RESET_FILE "raw/reset" +#define TRANS_MESSAGE_FILE "raw/message" +#define TRANS_NOTIF_FILE "raw/notification" +#define TRANS_ERROR_FILE "raw/errors" + +#define MAX_BUF 32 +#define MESSAGE_PAYLOAD_START 4 + +struct linux_scmi_raw_config { + int fd_base; + int fd_reset; + unsigned long max_msg_size; + unsigned long rx_timeout_ms; + void *buffer; +}; + +static struct linux_scmi_raw_config *rawc; + +static int linux_read_integer_from_file(int fd_base, char *filepath, + unsigned long *val) +{ + int fd, count; + unsigned long value; + unsigned char buffer[MAX_BUF]; + + *val = 0; + fd = openat(fd_base, filepath, O_RDONLY | O_NONBLOCK); + if (fd < 0) + return ERROR; + + bzero(buffer, MAX_BUF); + /* read returned message into the buffer */ + count = read(fd, buffer, MAX_BUF); + if (count < 0) { + close(fd); + return ERROR; + } + + value = strtoul((const char *)buffer, NULL, 10); + if (value == ULONG_MAX) { + close(fd); + return ERROR; + } + + *val = value; + close(fd); + + return 0; +} + +static void scmi_raw_mode_cleanup(void) +{ + if (!rawc) + return; + + close(rawc->fd_reset); + close(rawc->fd_base); + + free(rawc->buffer); + free(rawc); +} + +static void term_handler(int sig) +{ + scmi_raw_mode_cleanup(); + + raise(sig); +} + +/*! + * @brief Interface function that performs any needed Linux initialization. + */ +uint32_t linux_initialize_system(void *info) +{ + int ret; + const char *base_path = TRANS_DEFAULT_BASE_PATH; + struct linux_scmi_raw_config *conf; + struct sigaction action; + + conf = malloc(sizeof(*conf)); + if (!conf) + return ERROR; + + memset(conf, 0, sizeof(*conf)); + + if (info) + base_path = (const char *)info; + val_print(VAL_PRINT_INFO, "\n Using SCMI kernel Raw transport rooted at:%s/raw", base_path); + + conf->fd_base = open(base_path, O_RDONLY | O_NONBLOCK); + if (conf->fd_base < 0) { + val_print(VAL_PRINT_ERR, "\n Failed to open:%s", base_path); + goto err_conf; + } + + ret = linux_read_integer_from_file(conf->fd_base, TRANS_RX_TMO_MS, + &conf->rx_timeout_ms); + if (ret) + goto err_fd_base; + + ret = linux_read_integer_from_file(conf->fd_base, TRANS_MAX_MSG_SZ_FILE, + &conf->max_msg_size); + if (ret) + goto err_fd_base; + + /* Add space for the SCMI message header */ + conf->max_msg_size += sizeof(uint32_t); + conf->buffer = malloc(conf->max_msg_size); + if (!conf->buffer) + goto err_fd_base; + + conf->fd_reset = openat(conf->fd_base, + TRANS_RAW_RESET_FILE, O_RDWR | O_SYNC); + if (conf->fd_reset < 0) + goto err_buffer; + + bzero(&action, sizeof(struct sigaction)); + action.sa_handler = term_handler; + action.sa_flags = SA_RESETHAND; + ret = sigaction(SIGINT, &action, 0); + if (ret) + goto err_fd_reset; + + /* Flush any pending SCMI messages on start...just in case */ + val_print(VAL_PRINT_INFO, "\n Resetting SCMI kernel Raw queues."); + write(conf->fd_reset, "Y\n", 3); + + rawc = conf; + atexit(scmi_raw_mode_cleanup); + + return NO_ERROR; + +err_fd_reset: + close(conf->fd_reset); +err_buffer: + free(conf->buffer); +err_fd_base: + close(conf->fd_base); +err_conf: + free(conf); + + return ERROR; +} + +/*! + * @brief Interface function that sends a + * command to SCMI raw message interfaces and receives a platform + * message. + */ +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + int fd_message; + uint32_t ret = 0; + struct pollfd pfd; + ssize_t count; + uint32_t counter; + uint8_t *buffer; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + for (counter = 0; counter < 4; ++counter) + buffer[counter] = (message_header_send >> (counter * 8)) & 0xFF; + + for (counter = 0; counter < (parameter_count * 4); counter += 4) { + uint32_t byte_shift; + + for (byte_shift = 0; byte_shift < 4; ++byte_shift) { + buffer[MESSAGE_PAYLOAD_START+counter+byte_shift] = + (parameters[counter/4] >> (byte_shift * 8)) & 0xFF; + } + } + + fd_message = openat(rawc->fd_base, TRANS_MESSAGE_FILE, O_RDWR | O_SYNC); + if (fd_message < 0) + return ERROR; + + write(fd_message, buffer, + sizeof(uint32_t) + parameter_count * sizeof(uint32_t)); + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, rawc->rx_timeout_ms + 1000); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR;\ + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else if (counter == 1) { + // extract status + *status = *((uint32_t *)buffer + counter); + } + else { + // extract payload + // return_values starts from 0, hence subtract 2 here + return_values[(counter - 2)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that waits for + * delayed response. + */ +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout) +{ + int fd_message; + uint32_t ret = 0; + uint8_t *buffer; + uint32_t counter; + struct pollfd pfd; + ssize_t count; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + fd_message = openat(rawc->fd_base, TRANS_MESSAGE_FILE, O_RDONLY | O_SYNC); + if (fd_message < 0) + return ERROR; + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, rawc->rx_timeout_ms + 1000); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR; + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else if (counter == 1) { + // extract status + *status = *((uint32_t *)buffer + counter); + } + else { + // extract payload + // return_values starts from 0, hence subtract 2 here + return_values[(counter - 2)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that waits for + * notification. + */ +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout) +{ + int fd_message; + uint32_t ret = 0; + uint8_t *buffer; + uint32_t counter; + struct pollfd pfd; + ssize_t count; + + buffer = rawc->buffer; + memset(buffer, 0x0, rawc->max_msg_size); + + fd_message = openat(rawc->fd_base, TRANS_NOTIF_FILE, O_RDONLY | O_SYNC); + if (fd_message < 0) + return ERROR; + + /* polling */ + pfd.fd = fd_message; + pfd.events = POLLIN; + ret = poll(&pfd, 1, timeout * 30); + if (ret <= 0) { + close(fd_message); + return ERROR; + } + + /* read returned message into the buffer */ + count = read(fd_message, buffer, rawc->max_msg_size); + if (count < 0) { + close(fd_message); + return ERROR; + } + + /* read the payload part */ + for (counter = 0; counter < count / 4; ++counter) { + if (counter == 0) { + // extract header + // plus 1 to skip the Length + *message_header_rcv = *((uint32_t *)buffer + counter); + } + else { + // extract payload + return_values[(counter - 1)] = *((uint32_t *)buffer + counter); + (*return_values_count)++; + } + } + + close(fd_message); + + return NO_ERROR; +} + +/*! + * @brief Interface function that gets accessible device for given agent + */ +uint32_t linux_agent_get_accessible_device(uint32_t agent_id) +{ + return NO_ERROR; +} + +/*! + * @brief Interface function that gets inaccessible device for given agent + */ +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id) +{ + return NO_ERROR; +} + +/*! + * @brief Interface function that gets protocol which can access given device + */ +uint32_t linux_device_get_accessible_protocol(uint32_t device_id) +{ + return NO_ERROR; +} + + diff --git a/platform/linux/sgm776/include/pal_platform.h b/platform/linux/sgm776/include/pal_platform.h index 6e93a36..3c5e030 100644 --- a/platform/linux/sgm776/include/pal_platform.h +++ b/platform/linux/sgm776/include/pal_platform.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,6 +46,8 @@ int linux_map_phys_to_virt(unsigned long paddr, size_t length, int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); +uint32_t linux_initialize_system(void *info); + int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); diff --git a/platform/linux/sgm776/pal_platform.c b/platform/linux/sgm776/pal_platform.c index 20d1adc..ef803a6 100644 --- a/platform/linux/sgm776/pal_platform.c +++ b/platform/linux/sgm776/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -69,7 +69,7 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, **/ uint32_t pal_initialize_system(void *info) { - return 0; /* No initialization needed for SGM to run test */ + return linux_initialize_system(info); } /** diff --git a/platform/linux/tc/include/pal_platform.h b/platform/linux/tc/include/pal_platform.h index 4f5e079..cd2d4ca 100644 --- a/platform/linux/tc/include/pal_platform.h +++ b/platform/linux/tc/include/pal_platform.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,6 +44,8 @@ int linux_map_phys_to_virt(unsigned long paddr, size_t length, int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); +uint32_t linux_initialize_system(void *info); + int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); diff --git a/platform/linux/tc/pal_platform.c b/platform/linux/tc/pal_platform.c index 3cb196c..ccba5e5 100644 --- a/platform/linux/tc/pal_platform.c +++ b/platform/linux/tc/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -69,7 +69,7 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, **/ uint32_t pal_initialize_system(void *info) { - return 0; /* No initialization needed for TC to run test */ + return linux_initialize_system(info); } /** diff --git a/val/val_interface.c b/val/val_interface.c index 136878f..65121ad 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2019-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,8 +45,7 @@ uint32_t val_msg_hdr_create(uint32_t protocol_id, uint32_t msg_id, uint32_t msg_ } /** - @brief This function forms the command message header - 1. Caller - ACK. + @brief This function initialize system if required @param none @return none **/ -- GitLab From e22d1907b315d2eef4eccc808b627be4c42bc12a Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Fri, 9 Sep 2022 16:02:11 +0100 Subject: [PATCH 03/11] Add asynchronous command support to SCMI Raw transport Add support to use Kernel SCMI Raw access entries to send asynchronous commands from the test suite. Signed-off-by: Cristian Marussi --- platform/baremetal/pal_platform.c | 22 +++++++++- platform/linux/common/transport_mailbox.c | 16 +++++++ platform/linux/common/transport_raw.c | 40 +++++++++++++---- platform/linux/sgm776/include/pal_platform.h | 4 ++ platform/linux/sgm776/pal_platform.c | 20 +++++++++ platform/linux/tc/include/pal_platform.h | 4 ++ platform/linux/tc/pal_platform.c | 20 +++++++++ platform/mocker/pal_platform.c | 11 ++++- val/include/pal_interface.h | 5 ++- val/include/val_interface.h | 2 + val/val_interface.c | 45 ++++++++++++++++---- 11 files changed, 169 insertions(+), 20 deletions(-) diff --git a/platform/baremetal/pal_platform.c b/platform/baremetal/pal_platform.c index 9ec4b56..e28f103 100644 --- a/platform/baremetal/pal_platform.c +++ b/platform/baremetal/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -87,6 +87,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, message_header_rcv, status, return_values_count, return_values); } +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + arm_scmi_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, return_values); +} + + /** @brief This API is used to receive delayed response @param message header received diff --git a/platform/linux/common/transport_mailbox.c b/platform/linux/common/transport_mailbox.c index dd5885c..ba83bd7 100644 --- a/platform/linux/common/transport_mailbox.c +++ b/platform/linux/common/transport_mailbox.c @@ -193,6 +193,22 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, return NO_ERROR; } +/*! + * @brief Interface function that sends an asynchronous + * command to mailbox driver interfaces and receives the platform + * immediate reply message. Delayed response is collected with a dedicated function. + * + * Same behaviour as synchronous command for mailbox transport really. + */ + int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /*! * @brief Interface function that waits for * delayed response. diff --git a/platform/linux/common/transport_raw.c b/platform/linux/common/transport_raw.c index 0e2b970..24f4ea6 100644 --- a/platform/linux/common/transport_raw.c +++ b/platform/linux/common/transport_raw.c @@ -43,6 +43,7 @@ #define TRANS_RAW_RESET_FILE "raw/reset" #define TRANS_MESSAGE_FILE "raw/message" +#define TRANS_MESSAGE_ASYNC_FILE "raw/message_async" #define TRANS_NOTIF_FILE "raw/notification" #define TRANS_ERROR_FILE "raw/errors" @@ -185,14 +186,9 @@ err_conf: return ERROR; } -/*! - * @brief Interface function that sends a - * command to SCMI raw message interfaces and receives a platform - * message. - */ -int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, +static int32_t __linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, - size_t *return_values_count, uint32_t *return_values) + size_t *return_values_count, uint32_t *return_values, const char *filepath) { int fd_message; uint32_t ret = 0; @@ -216,7 +212,7 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, } } - fd_message = openat(rawc->fd_base, TRANS_MESSAGE_FILE, O_RDWR | O_SYNC); + fd_message = openat(rawc->fd_base, filepath, O_RDWR | O_SYNC); if (fd_message < 0) return ERROR; @@ -262,6 +258,34 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, return NO_ERROR; } +/*! + * @brief Interface function that sends a + * command to SCMI raw message interfaces and receives a platform + * message. + */ +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return __linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values, TRANS_MESSAGE_FILE); +} + +/*! + * @brief Interface function that sends an asynchronous + * command to SCMI raw message interfaces and receives the platform + * immediate reply message. Delayed response is collected with a dedicated function. + */ +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + return __linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values, TRANS_MESSAGE_ASYNC_FILE); +} + /*! * @brief Interface function that waits for * delayed response. diff --git a/platform/linux/sgm776/include/pal_platform.h b/platform/linux/sgm776/include/pal_platform.h index 3c5e030..002a71b 100644 --- a/platform/linux/sgm776/include/pal_platform.h +++ b/platform/linux/sgm776/include/pal_platform.h @@ -52,6 +52,10 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + int linux_wait_for_notification(uint32_t *message_header_rcv, size_t *return_values_count, uint32_t *return_values, uint32_t timeout); diff --git a/platform/linux/sgm776/pal_platform.c b/platform/linux/sgm776/pal_platform.c index ef803a6..4ad0a21 100644 --- a/platform/linux/sgm776/pal_platform.c +++ b/platform/linux/sgm776/pal_platform.c @@ -62,6 +62,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, return_values); } +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /** @brief This API is used to initialize platform to run tests if needed @param platform info diff --git a/platform/linux/tc/include/pal_platform.h b/platform/linux/tc/include/pal_platform.h index cd2d4ca..777c1e6 100644 --- a/platform/linux/tc/include/pal_platform.h +++ b/platform/linux/tc/include/pal_platform.h @@ -50,6 +50,10 @@ int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + int linux_wait_for_notification(uint32_t *message_header_rcv, size_t *return_values_count, uint32_t *return_values, uint32_t timeout); diff --git a/platform/linux/tc/pal_platform.c b/platform/linux/tc/pal_platform.c index ccba5e5..2c50181 100644 --- a/platform/linux/tc/pal_platform.c +++ b/platform/linux/tc/pal_platform.c @@ -62,6 +62,26 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, return_values); } +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + /** @brief This API is used to initialize platform to run tests if needed @param platform info diff --git a/platform/mocker/pal_platform.c b/platform/mocker/pal_platform.c index c75b6c5..5c6f9e5 100644 --- a/platform/mocker/pal_platform.c +++ b/platform/mocker/pal_platform.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -99,6 +99,15 @@ void pal_send_message(uint32_t message_header_send, size_t parameter_count, } } +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + pal_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values) { diff --git a/val/include/pal_interface.h b/val/include/pal_interface.h index c2b5cd7..9c2dac6 100644 --- a/val/include/pal_interface.h +++ b/val/include/pal_interface.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2021, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2021-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,6 +54,9 @@ int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t leng void pal_send_message(uint32_t message_header_send, size_t parameter_count, const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); void pal_print(uint32_t level, const char *string, va_list args); void *pal_memcpy(void *dest, const void *src, size_t size); diff --git a/val/include/val_interface.h b/val/include/val_interface.h index d3de942..fa176c5 100644 --- a/val/include/val_interface.h +++ b/val/include/val_interface.h @@ -124,6 +124,8 @@ int val_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vadd int val_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length); void val_send_message(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer); +void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, + uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer); void val_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); void val_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, diff --git a/val/val_interface.c b/val/val_interface.c index 65121ad..35f7b7f 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -388,6 +388,19 @@ uint32_t val_compare_return_count(uint32_t received, uint32_t expected) return VAL_STATUS_PASS; } +static void val_message_dump(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer) +{ + uint32_t i; + + val_print(VAL_PRINT_DEBUG, "\n MSG HDR : 0x%08x", msg_hdr); + val_print(VAL_PRINT_DEBUG, "\n NUM PARAM : %d", num_parameter); + + for (i = 0; i < num_parameter; i++) + { + val_print(VAL_PRINT_DEBUG, "\n PARAMETER[%02d] : 0x%08x", i, parameter_buffer[i]); + } +} + /** @brief This function is used to map a physical address in the virtual memory space of the process @@ -438,20 +451,34 @@ void val_send_message(uint32_t msg_hdr, size_t num_parameter, uint32_t *paramete uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, uint32_t *rcvd_buffer) { - uint32_t i; - - val_print(VAL_PRINT_DEBUG, "\n MSG HDR : 0x%08x", msg_hdr); - val_print(VAL_PRINT_DEBUG, "\n NUM PARAM : %d", num_parameter); - - for (i = 0; i < num_parameter; i++) - { - val_print(VAL_PRINT_DEBUG, "\n PARAMETER[%02d] : 0x%08x", i, parameter_buffer[i]); - } + val_message_dump(msg_hdr, num_parameter, parameter_buffer); pal_send_message(msg_hdr, num_parameter, parameter_buffer, rcvd_msg_hdr, status, rcvd_buffer_size, rcvd_buffer); } +/** + @brief This function is used to send async command data to platform and receive response + 1. Caller - Test Suite. + @param msg_hdr Command message + @param num_parameter Number of parameter sent to platform + @param parameter_buffer Buffer of sent parameters + @param rcvd_msg_hdr message header received from platform + @param status Status of command processed + @param rcvd_buffer_size Size of return buffer + @param rcvd_buffer return values buffer + @return none +**/ +void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *parameter_buffer, + uint32_t *rcvd_msg_hdr, int32_t *status, size_t *rcvd_buffer_size, + uint32_t *rcvd_buffer) +{ + val_message_dump(msg_hdr, num_parameter, parameter_buffer); + + pal_send_message_async(msg_hdr, num_parameter, parameter_buffer, rcvd_msg_hdr, status, + rcvd_buffer_size, rcvd_buffer); +} + /** @brief This API is used to receive notifications from platform 1. Caller - Test Suite. -- GitLab From 675ad1d3d7bb10584bb00840d7959b6925a7d366 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Fri, 9 Sep 2022 16:02:38 +0100 Subject: [PATCH 04/11] Fix Clock test 010 to use async commands Use new val_send_message_async() API to send Clock async command requests, so that it can work seamlessly also with SCMI Raw transport. Signed-off-by: Cristian Marussi --- test_pool/clock/test_c010.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_pool/clock/test_c010.c b/test_pool/clock/test_c010.c index a9aa545..6332931 100644 --- a/test_pool/clock/test_c010.c +++ b/test_pool/clock/test_c010.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -107,7 +107,7 @@ uint32_t clock_rate_set_async_check(void) parameters[param_count++] = new_rate_low; parameters[param_count++] = new_rate_high; cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_CLOCK, CLOCK_RATE_SET, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + val_send_message_async(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) -- GitLab From e855f6fcabb71892f1a3a7e0985534d1ba90c79c Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Fri, 5 Aug 2022 17:14:51 +0100 Subject: [PATCH 05/11] Fix Sensor test 014 to use async commands Use new val_send_message_async() API to send Sensor async command requests, so that it can work seamlessly also with SCMI Raw transport. Signed-off-by: Cristian Marussi --- test_pool/sensor/test_m014.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test_pool/sensor/test_m014.c b/test_pool/sensor/test_m014.c index 8393184..a99eec9 100644 --- a/test_pool/sensor/test_m014.c +++ b/test_pool/sensor/test_m014.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,8 +62,8 @@ uint32_t sensor_reading_get_async_mode(void) parameters[param_count++] = sensor_id; parameters[param_count++] = SENSOR_READ_ASYNC_MODE; cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_SENSOR, SENSOR_READING_GET, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, - &return_value_count, return_values); + val_send_message_async(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + &return_value_count, return_values); if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; @@ -77,7 +77,7 @@ uint32_t sensor_reading_get_async_mode(void) val_print(VAL_PRINT_TEST, "\n [Check 2] Wait for delayed response"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); + val_receive_delayed_response(&rsp_msg_hdr, &status, &return_value_count, return_values); val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : 0x%08x", rsp_msg_hdr); if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_SENSOR)) -- GitLab From c38886dd77865baab41f41bdcc1cd4893f1bc722 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Sat, 13 Aug 2022 18:28:40 +0100 Subject: [PATCH 06/11] Use monotonically increasing sequence numbers Even though it is not strictly required, since the ACS does NOT run testcases in parallel, using monotonically increasing sequence numbers inside generated SCMI messages exposes the SCMI server under test to a wider variety of possible incoming messages to handle. Using monotonically increasing sequence numbers is also more future proof in case the ACS suite will ever start running testcases in parallel on supported transports. Signed-off-by: Cristian Marussi --- val/val_interface.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/val/val_interface.c b/val/val_interface.c index 35f7b7f..977f0cf 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -25,6 +25,8 @@ static uint64_t g_test_skip; static uint32_t g_protocol_list; +static uint32_t monotonic_token; + /** @brief This function forms the command message header 1. Caller - ACK. @@ -37,6 +39,7 @@ uint32_t val_msg_hdr_create(uint32_t protocol_id, uint32_t msg_id, uint32_t msg_ { uint32_t msg_hdr = 0; + msg_hdr = msg_hdr | ((monotonic_token++ & 0x3FF) << 18); msg_hdr = msg_hdr | (protocol_id << 10); msg_hdr = msg_hdr | (msg_type << 8); msg_hdr = msg_hdr | msg_id; -- GitLab From dc24ad91a65dde04a75b1519f45e2505d3a67cb7 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Mon, 29 Aug 2022 18:13:58 +0100 Subject: [PATCH 07/11] Make Clock SET tests pass also with SCMI_DENIED Some clocks are NOT meant to be changed directly in term of rates or status: the request will be denied if the Server properly checks for permissions and as such an SCMI_DENIED outcome must be accepted as a PASS. Signed-off-by: Cristian Marussi --- test_pool/clock/test_c009.c | 9 ++++++--- test_pool/clock/test_c010.c | 7 +++++-- test_pool/clock/test_c011.c | 9 ++++++--- test_pool/clock/test_c015.c | 12 +++++++++++- test_pool/clock/test_c017.c | 10 +++++++--- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/test_pool/clock/test_c009.c b/test_pool/clock/test_c009.c index d341c90..d6c1138 100644 --- a/test_pool/clock/test_c009.c +++ b/test_pool/clock/test_c009.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -102,10 +102,13 @@ uint32_t clock_rate_set_sync_check(void) val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print_return_values(return_value_count, return_values); diff --git a/test_pool/clock/test_c010.c b/test_pool/clock/test_c010.c index 6332931..ef1f1f2 100644 --- a/test_pool/clock/test_c010.c +++ b/test_pool/clock/test_c010.c @@ -75,10 +75,13 @@ uint32_t clock_rate_set_async_check(void) val_send_message(cmd_msg_hdr, param_count, &clock_id, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print_return_values(return_value_count, return_values); diff --git a/test_pool/clock/test_c011.c b/test_pool/clock/test_c011.c index 91cfb11..df29150 100644 --- a/test_pool/clock/test_c011.c +++ b/test_pool/clock/test_c011.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,10 +66,13 @@ uint32_t clock_rate_set_invalid_param_check(void) val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, &return_value_count, return_values); - if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + if (val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + + if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; val_print(VAL_PRINT_TEST, "\n [Check 2] Query with invalid flag"); diff --git a/test_pool/clock/test_c015.c b/test_pool/clock/test_c015.c index affd155..6c2eaa4 100644 --- a/test_pool/clock/test_c015.c +++ b/test_pool/clock/test_c015.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +45,13 @@ uint32_t clock_config_set_invalid_attr_check(void) for (clock_id = 0; clock_id < num_clocks; clock_id++) { + bool could_be_denied = false; + val_print(VAL_PRINT_TEST, "\n CLOCK ID: %d", clock_id); + + if (val_check_clock_config_change_support(clock_id) == 1) + could_be_denied = true; + val_print(VAL_PRINT_TEST, "\n [Check 1] Query with invalid attribute"); /* Clock config set with invalid attributes should fail with INVALID_PARAMETERS */ @@ -60,6 +66,10 @@ uint32_t clock_config_set_invalid_attr_check(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; + if (could_be_denied && + val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + if (val_compare_status(status, SCMI_INVALID_PARAMETERS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; } diff --git a/test_pool/clock/test_c017.c b/test_pool/clock/test_c017.c index 85aba92..d2621fa 100644 --- a/test_pool/clock/test_c017.c +++ b/test_pool/clock/test_c017.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,12 +53,12 @@ uint32_t clock_config_set_check(void) for (clock_id = 0; clock_id < num_clocks; clock_id++) { + bool could_be_denied = false; val_print(VAL_PRINT_TEST, "\n CLOCK ID: %d", clock_id); - /* Skip if always on clock*/ if (val_check_clock_config_change_support(clock_id) == 1) - continue; + could_be_denied = true; run_flag = 1; /* Find new attribute from previously stored value */ @@ -81,6 +81,10 @@ uint32_t clock_config_set_check(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; + if (could_be_denied && + val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) + return VAL_STATUS_PASS; + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; -- GitLab From 17f76729f3b435f54d8dd6f593ab320a551896c6 Mon Sep 17 00:00:00 2001 From: Vincent Guittot Date: Wed, 8 Feb 2023 17:10:14 +0100 Subject: [PATCH 08/11] Fix failure-path logic for test_c017 test_d026 test_d027 When notification related testcases (test_d026/test_d027) fail halfway, issue a proper cleanup taking care to disable any notification that had been previously enabled. When clock configure related testcase (test_c017) fails on some resource carry-on trying remaining resources instead of gving up. Fixed also a few typos and indentation issues. Signed-off-by: Vincent Guittot [ Rebased on SCMI Raw series and added a full commit message ] Signed-off-by: Cristian Marussi --- test_pool/clock/test_c017.c | 3 ++ test_pool/performance/test_d026.c | 54 ++++++++++++++++--------------- test_pool/performance/test_d027.c | 19 +++++++---- test_pool/sensor/test_m006.c | 4 +-- 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/test_pool/clock/test_c017.c b/test_pool/clock/test_c017.c index d2621fa..440d54d 100644 --- a/test_pool/clock/test_c017.c +++ b/test_pool/clock/test_c017.c @@ -85,6 +85,9 @@ uint32_t clock_config_set_check(void) val_compare_status(status, SCMI_DENIED) == VAL_STATUS_PASS) return VAL_STATUS_PASS; + if (val_compare_status(status, SCMI_NOT_SUPPORTED) == VAL_STATUS_PASS) + continue; + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; diff --git a/test_pool/performance/test_d026.c b/test_pool/performance/test_d026.c index b1ab7fe..e7b1659 100644 --- a/test_pool/performance/test_d026.c +++ b/test_pool/performance/test_d026.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ uint32_t performance_limit_set_async(void) { int32_t status; + uint32_t ret = VAL_STATUS_PASS; uint32_t rsp_msg_hdr; uint32_t cmd_msg_hdr; size_t param_count; @@ -160,36 +161,37 @@ uint32_t performance_limit_set_async(void) val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - return VAL_STATUS_FAIL; - if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - return VAL_STATUS_FAIL; - if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LIMITS_CHANGED)) - return VAL_STATUS_FAIL; - - val_print_return_values(return_value_count, return_values); - if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) - return VAL_STATUS_FAIL; - if (val_compare("RANGE MAX ", return_values[NOTIFICATION_RANGE_MAX_OFFSET], tmp_max)) - return VAL_STATUS_FAIL; - if (val_compare("RANGE MIN ", return_values[NOTIFICATION_RANGE_MIN_OFFSET], range_min)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; + else if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) + ret = VAL_STATUS_FAIL; + else if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LIMITS_CHANGED)) + ret = VAL_STATUS_FAIL; + else { + val_print_return_values(return_value_count, return_values); + if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) + ret = VAL_STATUS_FAIL; + else if (val_compare("RANGE MAX ", return_values[NOTIFICATION_RANGE_MAX_OFFSET], tmp_max)) + ret = VAL_STATUS_FAIL; + else if (val_compare("RANGE MIN ", return_values[NOTIFICATION_RANGE_MIN_OFFSET], range_min)) + ret = VAL_STATUS_FAIL; + } /* Disable limit change notification for the domain */ - val_print(VAL_PRINT_TEST, "\n [Check 6] Disable limit change notify for domain_id: %d", + val_print(VAL_PRINT_TEST, "\n [Check 6] Disable limit change notify for domain_id: %d", domain_id); - VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - parameters[param_count++] = domain_id; - parameters[param_count++] = NOTIFY_DISABLE; - cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_PERFORMANCE, PERFORMANCE_NOTIFY_LIMITS, COMMAND_MSG); - val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, - &return_value_count, return_values); + VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); + parameters[param_count++] = domain_id; + parameters[param_count++] = NOTIFY_DISABLE; + cmd_msg_hdr = val_msg_hdr_create(PROTOCOL_PERFORMANCE, PERFORMANCE_NOTIFY_LIMITS, COMMAND_MSG); + val_send_message(cmd_msg_hdr, param_count, parameters, &rsp_msg_hdr, &status, + &return_value_count, return_values); - if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) - return VAL_STATUS_FAIL; + if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) + return VAL_STATUS_FAIL; - if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) - return VAL_STATUS_FAIL; + if (val_compare_status(status, SCMI_SUCCESS) != VAL_STATUS_PASS) + return VAL_STATUS_FAIL; val_print(VAL_PRINT_TEST, "\n [Check 7] Restore perf limits for domain_id: %d", domain_id); @@ -208,6 +210,6 @@ uint32_t performance_limit_set_async(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - return VAL_STATUS_PASS; + return ret; } diff --git a/test_pool/performance/test_d027.c b/test_pool/performance/test_d027.c index bdbbfd6..ac4c8bf 100644 --- a/test_pool/performance/test_d027.c +++ b/test_pool/performance/test_d027.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ uint32_t performance_level_set_async(void) { int32_t status; + uint32_t ret = VAL_STATUS_PASS; uint32_t rsp_msg_hdr; uint32_t cmd_msg_hdr; size_t param_count; @@ -158,19 +159,23 @@ uint32_t performance_level_set_async(void) VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); + if (return_value_count == 0) + ret = VAL_STATUS_FAIL; + else { val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LEVEL_CHANGED)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; val_print_return_values(return_value_count, return_values); if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; if (val_compare("PERF LEVEL ", return_values[NOTIFICATION_LEVEL_OFFSET], cur_level)) - return VAL_STATUS_FAIL; + ret = VAL_STATUS_FAIL; + } /* Disable level change notification for the domain */ @@ -207,6 +212,6 @@ uint32_t performance_level_set_async(void) if (val_compare_msg_hdr(cmd_msg_hdr, rsp_msg_hdr) != VAL_STATUS_PASS) return VAL_STATUS_FAIL; - return VAL_STATUS_PASS; + return ret; } diff --git a/test_pool/sensor/test_m006.c b/test_pool/sensor/test_m006.c index 0271dc0..4d13d1f 100644 --- a/test_pool/sensor/test_m006.c +++ b/test_pool/sensor/test_m006.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2020, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2020-2023, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,7 @@ #include "val_sensor.h" #define TEST_NUM (SCMI_SENSOR_TEST_NUM_BASE + 6) -#define TEST_DESC "Sensor trip pnt notify invalid event_ctrl chk" +#define TEST_DESC "Sensor trip point notify invalid event_ctrl chk" #define MAX_PARAMETER_SIZE 2 -- GitLab From 41c9687d7ae77ea8706807a8a20efd042cd072b4 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Mon, 29 Aug 2022 19:37:10 +0100 Subject: [PATCH 09/11] Properly handle unexpected notifications Testcases that expect to receive a notification must account for the fact that the platform of the system under test could emit a number of unrelated and unexpected notifications due to activities originating from some other agents on the system. Introduce a common mechanism to receive a specific notification which keeps on looping searching for the expected notification until is received or a time out is hit. Fix accordingly also test_d026 and test_d027 to use this new API to receive notifications. Signed-off-by: Cristian Marussi --- test_pool/performance/test_d026.c | 13 ++++------- test_pool/performance/test_d027.c | 24 +++++++------------- val/include/val_interface.h | 2 +- val/val_interface.c | 37 ++++++++++++++++++++++++++++--- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/test_pool/performance/test_d026.c b/test_pool/performance/test_d026.c index e7b1659..cc6e29d 100644 --- a/test_pool/performance/test_d026.c +++ b/test_pool/performance/test_d026.c @@ -157,17 +157,12 @@ uint32_t performance_limit_set_async(void) val_print(VAL_PRINT_TEST, "\n [Check 5] Wait for limit change notify"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); - - val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); - if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - ret = VAL_STATUS_FAIL; - else if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - ret = VAL_STATUS_FAIL; - else if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LIMITS_CHANGED)) + val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values, + PROTOCOL_PERFORMANCE, PERFORMANCE_LIMITS_CHANGED); + val_print_return_values(return_value_count, return_values); + if (return_value_count < 3) ret = VAL_STATUS_FAIL; else { - val_print_return_values(return_value_count, return_values); if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) ret = VAL_STATUS_FAIL; else if (val_compare("RANGE MAX ", return_values[NOTIFICATION_RANGE_MAX_OFFSET], tmp_max)) diff --git a/test_pool/performance/test_d027.c b/test_pool/performance/test_d027.c index ac4c8bf..c61eb70 100644 --- a/test_pool/performance/test_d027.c +++ b/test_pool/performance/test_d027.c @@ -157,24 +157,16 @@ uint32_t performance_level_set_async(void) val_print(VAL_PRINT_TEST, "\n [Check 5] Wait for level change notify"); VAL_INIT_TEST_PARAM(param_count, rsp_msg_hdr, return_value_count, status); - val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values); - - if (return_value_count == 0) - ret = VAL_STATUS_FAIL; - else { - val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", rsp_msg_hdr); - if (val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(rsp_msg_hdr, 10, 17), PROTOCOL_PERFORMANCE)) - ret = VAL_STATUS_FAIL; - if (val_compare("MSG TYPE ", VAL_EXTRACT_BITS(rsp_msg_hdr, 8, 9), NOTIFICATION_MSG)) - ret = VAL_STATUS_FAIL; - if (val_compare("MSG ID ", VAL_EXTRACT_BITS(rsp_msg_hdr, 0, 7), PERFORMANCE_LEVEL_CHANGED)) - ret = VAL_STATUS_FAIL; - + val_receive_notification(&rsp_msg_hdr, &return_value_count, return_values, + PROTOCOL_PERFORMANCE, PERFORMANCE_LEVEL_CHANGED); val_print_return_values(return_value_count, return_values); - if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) - ret = VAL_STATUS_FAIL; - if (val_compare("PERF LEVEL ", return_values[NOTIFICATION_LEVEL_OFFSET], cur_level)) + if (return_value_count < 2) ret = VAL_STATUS_FAIL; + else { + if (val_compare("DOMAIN ID ", return_values[NOTIFICATION_DOMAIN_ID_OFFSET], domain_id)) + ret = VAL_STATUS_FAIL; + if (val_compare("PERF LEVEL ", return_values[NOTIFICATION_LEVEL_OFFSET], cur_level)) + ret = VAL_STATUS_FAIL; } /* Disable level change notification for the domain */ diff --git a/val/include/val_interface.h b/val/include/val_interface.h index fa176c5..39876ff 100644 --- a/val/include/val_interface.h +++ b/val/include/val_interface.h @@ -129,7 +129,7 @@ void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *pa void val_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, size_t *return_values_count, uint32_t *return_values); void val_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, - uint32_t *return_values); + uint32_t *return_values, uint32_t exp_proto_id, uint32_t exp_msg_id); uint32_t val_initialize_system(void *info); uint32_t val_test_initialize(uint32_t test_num, char *test_desc); void val_print_return_values(uint32_t count, uint32_t *values); diff --git a/val/val_interface.c b/val/val_interface.c index 977f0cf..2afa63a 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -488,11 +488,42 @@ void val_send_message_async(uint32_t msg_hdr, size_t num_parameter, uint32_t *pa @param message header received @param return values count @param return values list + @param exp_proto_id + @param exp_msg_id **/ void val_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, - uint32_t *return_values) -{ - pal_receive_notification(message_header_rcv, return_values_count, return_values); + uint32_t *return_values, uint32_t exp_proto_id, + uint32_t exp_msg_id) +{ + int retries = 10; + bool found = false, timeout = false; + + /* + * Receiving notifications can be tricky since other activity on the system, + * other than the one triggered by the test suite itself, can generate any + * kind of unrelated notification. + * + * In order to handle this, keep on consuming any received notification + * until we found the expected one or we timeout. + * + * Bail out after max_retries anyway to avoid endless loop in case of a + * constant flow of unrelated notifications. + */ + do { + /* Reset before next attempt */ + *return_values_count = 0; + pal_receive_notification(message_header_rcv, return_values_count, return_values); + if (*return_values_count != 0) { + val_print(VAL_PRINT_TEST, "\n NOTIFY MSG HDR : %08x", *message_header_rcv); + if (!val_compare("PROTOCOL ID", VAL_EXTRACT_BITS(*message_header_rcv, 10, 17), exp_proto_id) && + !val_compare("MSG TYPE ", VAL_EXTRACT_BITS(*message_header_rcv, 8, 9), NOTIFICATION_MSG) && + !val_compare("MSG ID ", VAL_EXTRACT_BITS(*message_header_rcv, 0, 7), exp_msg_id)) + found = true; + } else { + val_print(VAL_PRINT_ERR, "\n TIMEOUT WAITING FOR NOTIFICATION - Proto: %02x Msg:%02x", exp_proto_id, exp_msg_id); + timeout = true; + } + } while (!timeout && !found && --retries); } /** -- GitLab From 8867431b83316de71effb63fd041dbc39d837b59 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Fri, 16 Sep 2022 14:58:29 +0100 Subject: [PATCH 10/11] Add TARGET juno for linux platform Add expectations for running Linux app under a JUNO target. Signed-off-by: Cristian Marussi --- Makefile | 5 +- platform/linux/common/transport_mailbox.c | 8 +- platform/linux/juno/Makefile | 18 +++ .../linux/juno/include/pal_base_expected.h | 43 ++++++ .../linux/juno/include/pal_clock_expected.h | 40 +++++ .../juno/include/pal_performance_expected.h | 41 +++++ platform/linux/juno/include/pal_platform.h | 69 +++++++++ .../juno/include/pal_power_domain_expected.h | 29 ++++ .../linux/juno/include/pal_reset_expected.h | 30 ++++ .../linux/juno/include/pal_sensor_expected.h | 29 ++++ .../linux/juno/include/pal_voltage_expected.h | 30 ++++ platform/linux/juno/pal_base.c | 109 ++++++++++++++ platform/linux/juno/pal_clock.c | 62 ++++++++ platform/linux/juno/pal_performance.c | 82 ++++++++++ platform/linux/juno/pal_platform.c | 141 ++++++++++++++++++ platform/linux/juno/pal_power_domain.c | 62 ++++++++ platform/linux/juno/pal_reset.c | 43 ++++++ platform/linux/juno/pal_sensor.c | 62 ++++++++ platform/linux/juno/pal_voltage.c | 43 ++++++ 19 files changed, 941 insertions(+), 5 deletions(-) create mode 100644 platform/linux/juno/Makefile create mode 100644 platform/linux/juno/include/pal_base_expected.h create mode 100644 platform/linux/juno/include/pal_clock_expected.h create mode 100644 platform/linux/juno/include/pal_performance_expected.h create mode 100644 platform/linux/juno/include/pal_platform.h create mode 100644 platform/linux/juno/include/pal_power_domain_expected.h create mode 100644 platform/linux/juno/include/pal_reset_expected.h create mode 100644 platform/linux/juno/include/pal_sensor_expected.h create mode 100755 platform/linux/juno/include/pal_voltage_expected.h create mode 100644 platform/linux/juno/pal_base.c create mode 100644 platform/linux/juno/pal_clock.c create mode 100644 platform/linux/juno/pal_performance.c create mode 100644 platform/linux/juno/pal_platform.c create mode 100644 platform/linux/juno/pal_power_domain.c create mode 100644 platform/linux/juno/pal_reset.c create mode 100644 platform/linux/juno/pal_sensor.c create mode 100755 platform/linux/juno/pal_voltage.c diff --git a/Makefile b/Makefile index 4c8ee67..9a0a464 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ MOCKER=mocker LINUX=linux SGM776=sgm776 TC=tc +JUNO=juno COMMON=common #Set PLATFORM @@ -48,8 +49,10 @@ ifeq ($(PLAT),$(LINUX)) PLAT_DIR=$(DIR)/$(SGM776) $(DIR)/$(COMMON) else ifeq ($(TARGET),$(TC)) PLAT_DIR=$(DIR)/$(TC) $(DIR)/$(COMMON) + else ifeq ($(TARGET),$(JUNO)) + PLAT_DIR=$(DIR)/$(JUNO) $(DIR)/$(COMMON) else - $(error TARGET $(TARGET) is invalid. Provide valid TARGET value (sgm776 or tc) as TARGET=tc or TARGET=sgm776) + $(error TARGET $(TARGET) is invalid. Provide valid TARGET value) endif TARGET_UPPER=$(shell echo $(TARGET) | tr '[:lower:]' '[:upper:]') endif diff --git a/platform/linux/common/transport_mailbox.c b/platform/linux/common/transport_mailbox.c index ba83bd7..8ade155 100644 --- a/platform/linux/common/transport_mailbox.c +++ b/platform/linux/common/transport_mailbox.c @@ -34,14 +34,14 @@ #define NO_ERROR 0 #define ERROR 5 -#ifdef TARGET_TC +#if defined TARGET_TC #define MB_SIGNAL_FILE "/sys/kernel/debug/6000000.mailbox-test/signal" #define MB_MESSAGE_FILE "/sys/kernel/debug/6000000.mailbox-test/message" -#endif - -#ifdef TARGET_SGM776 +#elif defined TARGET_SGM776 #define MB_SIGNAL_FILE "/sys/kernel/debug/mailbox/signal" #define MB_MESSAGE_FILE "/sys/kernel/debug/mailbox/message" +#else + #error "TARGET unsupported with mailbox transport !" #endif /* mailbox memory byte offset mapping */ diff --git a/platform/linux/juno/Makefile b/platform/linux/juno/Makefile new file mode 100644 index 0000000..e1f163b --- /dev/null +++ b/platform/linux/juno/Makefile @@ -0,0 +1,18 @@ +#/** @file +# * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# * SPDX-License-Identifier : Apache-2.0 +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +#**/ + +include ${TOP}/platform/build_platform.mk diff --git a/platform/linux/juno/include/pal_base_expected.h b/platform/linux/juno/include/pal_base_expected.h new file mode 100644 index 0000000..a7ec82a --- /dev/null +++ b/platform/linux/juno/include/pal_base_expected.h @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_BASE_EXPECTED_H__ +#define __PAL_BASE_EXPECTED_H__ + +#include + +#define UNTRUSTED 0 + +static uint32_t supported_protocols[] = { + PWR_DOMAIN_PROTOCOL_ID, + SYSTEM_POWER_PROTOCOL_ID, + PERFORMANCE_PROTOCOL_ID, + CLOCK_PROTOCOL_ID, + SENSOR_PROTOCOL_ID, +}; + +static char *agents[] = { + "OSPM", "PSCI" +}; + +/* Expected BASE parameters */ + +static char *vendor_name = "arm"; +static char *subvendor_name = "arm"; +static uint32_t implementation_version = VERSION_ENCODE32(2, 10, 0); + +#endif /* __PAL_BASE_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_clock_expected.h b/platform/linux/juno/include/pal_clock_expected.h new file mode 100644 index 0000000..23be62c --- /dev/null +++ b/platform/linux/juno/include/pal_clock_expected.h @@ -0,0 +1,40 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_CLOCK_EXPECTED_H__ +#define __PAL_CLOCK_EXPECTED_H__ + +/* Expected CLOCK parameters */ +#ifdef CLOCK_PROTOCOL + +#define UNSUPPORTED 1 + +static uint32_t num_clocks = 0x06; +static uint32_t num_of_clock_rates[] = { + 0x5, /* BIG_CLK */ + 0x5, /* LITTLE_CLK */ + 0x5, /* GPU_CLK */ + 0x1, /* HDLCD_0 */ + 0x1, /* HDLCD_1 */ + 0x7 /* I2SCLK */ +}; + +uint32_t max_num_pending_async_rate_chg_supported = 0; + +#endif + +#endif /* __PAL_CLOCK_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_performance_expected.h b/platform/linux/juno/include/pal_performance_expected.h new file mode 100644 index 0000000..3de8438 --- /dev/null +++ b/platform/linux/juno/include/pal_performance_expected.h @@ -0,0 +1,41 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_PERFORMANCE_EXPECTED_H__ +#define __PAL_PERFORMANCE_EXPECTED_H__ + +/* Expected PERFORMANCE parameters */ +#ifdef PERFORMANCE_PROTOCOL +static uint32_t num_perf_domains = 0x03; + +static uint32_t perf_num_performance_levels[] = { + 5, /* BIG_CPU */ + 5, /* LITTLE_CPU */ + 5 /* GPU */ +}; + +static char *performance_domain_names[] = { + "BIG_CPU", + "LITTLE_CPU", + "GPU" +}; + +uint32_t statistics_address_low_perf = 0; +uint32_t statistics_address_len_perf = 0; +#endif + +#endif /* __PAL_PERFORMANCE_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_platform.h b/platform/linux/juno/include/pal_platform.h new file mode 100644 index 0000000..7241e8d --- /dev/null +++ b/platform/linux/juno/include/pal_platform.h @@ -0,0 +1,69 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_PLATFORM_H__ +#define __PAL_PLATFORM_H__ + +#include +#include +#include + +#define LOG_FILE "arm_scmi_test_log.txt" + +#define VERSION_ENCODE32(MAJOR, MINOR, PATCH) (((MAJOR & 0xff) << 24) | \ + ((MINOR & 0xff) << 16)| \ + (PATCH & 0xffff)) +#define BASE_PROTOCOL_ID 0x10 +#define PWR_DOMAIN_PROTOCOL_ID 0x11 +#define SYSTEM_POWER_PROTOCOL_ID 0x12 +#define PERFORMANCE_PROTOCOL_ID 0x13 +#define CLOCK_PROTOCOL_ID 0x14 +#define SENSOR_PROTOCOL_ID 0x15 +#define RESET_PROTOCOL_ID 0x16 +#define APCORE_PROTOCOL_ID 0x09 + +#define TIMEOUT 100 + +int linux_map_phys_to_virt(unsigned long paddr, size_t length, + unsigned long *vaddr); + +int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, + size_t length); + +uint32_t linux_initialize_system(void *info); + +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout); + +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout); + +uint32_t linux_agent_get_accessible_device(uint32_t agent_id); +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id); +uint32_t linux_device_get_accessible_protocol(uint32_t device_id); + +#endif diff --git a/platform/linux/juno/include/pal_power_domain_expected.h b/platform/linux/juno/include/pal_power_domain_expected.h new file mode 100644 index 0000000..1c9837a --- /dev/null +++ b/platform/linux/juno/include/pal_power_domain_expected.h @@ -0,0 +1,29 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_POWER_DOMAIN_EXPECTED_H__ +#define __PAL_POWER_DOMAIN_EXPECTED_H__ + +/* Expected POWER DOMAIN parameters */ +#ifdef POWER_DOMAIN_PROTOCOL +static uint32_t num_power_domains = 0x0a; +uint32_t statistics_address_low_pow = 0; +uint32_t statistics_address_len_pow = 0; + +#endif + +#endif /* __PAL_POWER_DOMAIN_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_reset_expected.h b/platform/linux/juno/include/pal_reset_expected.h new file mode 100644 index 0000000..af9ef66 --- /dev/null +++ b/platform/linux/juno/include/pal_reset_expected.h @@ -0,0 +1,30 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_RESET_EXPECTED_H__ +#define __PAL_RESET_EXPECTED_H__ + +#ifdef RESET_PROTOCOL + +uint32_t num_reset_domains = 0x0; + +static char *reset_domain_names[] = { + NULL, +}; +#endif + +#endif /* __PAL_RESET_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_sensor_expected.h b/platform/linux/juno/include/pal_sensor_expected.h new file mode 100644 index 0000000..785a508 --- /dev/null +++ b/platform/linux/juno/include/pal_sensor_expected.h @@ -0,0 +1,29 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_SENSOR_EXPECTED_H__ +#define __PAL_SENSOR_EXPECTED_H__ + +#ifdef SENSOR_PROTOCOL + +static uint32_t num_sensors = 0x09; +uint32_t statistics_address_low_snsr = 0; +uint32_t statistics_address_len_snsr = 0; + +#endif + +#endif /* __PAL_SENSOR_EXPECTED_H__ */ diff --git a/platform/linux/juno/include/pal_voltage_expected.h b/platform/linux/juno/include/pal_voltage_expected.h new file mode 100755 index 0000000..87ff6fb --- /dev/null +++ b/platform/linux/juno/include/pal_voltage_expected.h @@ -0,0 +1,30 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_VOLTAGE_EXPECTED_H__ +#define __PAL_VOLTAGE_EXPECTED_H__ + +#ifdef VOLTAGE_PROTOCOL + +uint32_t num_voltage_domains = 0x00; + +static char *voltage_domain_names[] = { + NULL, +}; +#endif + +#endif /* __PAL_VOLTAGE_EXPECTED_H__ */ diff --git a/platform/linux/juno/pal_base.c b/platform/linux/juno/pal_base.c new file mode 100644 index 0000000..87507f3 --- /dev/null +++ b/platform/linux/juno/pal_base.c @@ -0,0 +1,109 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_interface.h" +#include "pal_base_expected.h" + +/** + @brief This API is used to check vendor name + @param none + @return vendor name +**/ +char *pal_base_get_expected_vendor_name(void) +{ + return vendor_name; +} + +/** + @brief This API is used for checking subvendor name + @param none + @return subvendor name +**/ +char *pal_base_get_expected_subvendor_name(void) +{ + return subvendor_name; +} + +/** + @brief This API is used for checking implementation version + @param none + @return implementation version +**/ +uint32_t pal_base_get_expected_implementation_version(void) +{ + return implementation_version; +} + +/** + @brief This API is used for checking num of agents + @param none + @return num of agents +**/ +uint32_t pal_base_get_expected_num_agents(void) +{ + return NUM_ELEMS(agents); +} + +/** + @brief This API is used for checking num of protocols agent have access + @param none + @return num of protocols +**/ +uint32_t pal_base_get_expected_num_protocols(void) +{ + return NUM_ELEMS(supported_protocols); +} + +/** + @brief This API is used for checking if agent is trusted + @param agent id + @return true/false +**/ +uint32_t pal_check_trusted_agent(uint32_t agent_id) +{ + return UNTRUSTED; +} + +/** + @brief This API is used to get device which agent can access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_accessible_device(uint32_t agent_id) +{ + return linux_agent_get_accessible_device(agent_id); +} + +/** + @brief This API is used to get device which agent cannot access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_inaccessible_device(uint32_t agent_id) +{ + return linux_agent_get_inaccessible_device(agent_id); +} + +/** + @brief This API is used to get protocol by which given device can be access + @param device id + @return protocol id +**/ +uint32_t pal_device_get_accessible_protocol(uint32_t device_id) +{ + return linux_device_get_accessible_protocol(device_id); +} diff --git a/platform/linux/juno/pal_clock.c b/platform/linux/juno/pal_clock.c new file mode 100644 index 0000000..68b039f --- /dev/null +++ b/platform/linux/juno/pal_clock.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef CLOCK_PROTOCOL + +#include "pal_interface.h" +#include "pal_clock_expected.h" + +/** + @brief This API is used for checking num of clocks + @param none + @return num of clocks +**/ +uint32_t pal_clock_get_expected_num_clocks(void) +{ + return num_clocks; +} + +/** + @brief This API is used for checking max num of pending async cmd support for clock + @param none + @return max num of pending async cmd +**/ +uint32_t pal_clock_get_expected_max_async_cmd(void) +{ + return max_num_pending_async_rate_chg_supported; +} + +/** + @brief This API is used for checking num of rates a clock supports + @param clock id + @return num of rates a clock supports +**/ +uint32_t pal_clock_get_expected_number_of_rates(uint32_t clock_id) +{ + return num_of_clock_rates[clock_id]; +} + +/** + @brief This API checks if clock supports config change + @param clock id + @return supported / unsupported +**/ +uint32_t pal_check_clock_config_change_support(uint32_t clock_id) +{ + return UNSUPPORTED; +} + +#endif diff --git a/platform/linux/juno/pal_performance.c b/platform/linux/juno/pal_performance.c new file mode 100644 index 0000000..f63bff5 --- /dev/null +++ b/platform/linux/juno/pal_performance.c @@ -0,0 +1,82 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef PERFORMANCE_PROTOCOL + +#include "pal_interface.h" +#include "pal_performance_expected.h" + +/** + @brief This API is used for checking number of perf domains + @param none + @return num of perf domains +**/ +uint32_t pal_performance_get_expected_num_domains(void) +{ + return num_perf_domains; +} + +/** + @brief This API is used for checking perf statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_performance_get_expected_stats_addr_low(void) +{ + return statistics_address_low_perf; +} + +/** + @brief This API is used for checking perf statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_performance_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_perf + statistics_address_len_perf); +} + +/** + @brief This API is used for checking statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_performance_get_expected_stats_addr_len(void) +{ + return statistics_address_len_perf; +} + +/** + @brief This API is used for checking domain name + @param perf domain id + @return perf domain name +**/ +uint8_t *pal_performance_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)&performance_domain_names[domain_id][0]; +} + +/** + @brief This API is used for checking num of level for perf domain + @param perf domain id + @return num of level for perf domain +**/ +uint32_t pal_performance_get_expected_number_of_level(uint32_t domain_id) +{ + return perf_num_performance_levels[domain_id]; +} + +#endif diff --git a/platform/linux/juno/pal_platform.c b/platform/linux/juno/pal_platform.c new file mode 100644 index 0000000..9d14ff2 --- /dev/null +++ b/platform/linux/juno/pal_platform.c @@ -0,0 +1,141 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_platform.h" +#include "pal_interface.h" + +/** + @brief This API is used to map a physical memory area to a virtual one. + @param paddr physical address to map + @param length size of the memory to map + @param vaddr the mapped resulting virtual address + @return 0 on Success +**/ +int pal_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vaddr) +{ + return linux_map_phys_to_virt(paddr, length, vaddr); +} + +/** + @brief This API is used to unmap a previously mapped memory area + @param paddr physical address that has been mapped + @param length size of the mapped memory + @param vaddr the mapped virtual address + @return 0 on Success +**/ +int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length) +{ + return linux_unmap_phys_to_virt(paddr, vaddr, length); +} + +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to initialize platform to run tests if needed + @param platform info + @return success / failure +**/ +uint32_t pal_initialize_system(void *info) +{ + return linux_initialize_system(info); +} + +/** + @brief This API is used to print test log + @param args values to be printed + @return none +**/ +void pal_print(uint32_t print_level, const char *format, va_list args) +{ + FILE *file_ptr = fopen(LOG_FILE, "a"); + if (file_ptr) { + vfprintf(file_ptr, format, args); + fclose(file_ptr); + } else { + printf("ERROR: Log File opening failed"); + } +} + +/** + @brief This API is used to receive delayed response + @param message header received + @param status of command processed + @param return values count + @param return values list + **/ +void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_response(message_header_rcv, status, + return_values_count, return_values, NULL, timeout); +} + +/** + @brief This API is used to receive notifications from platform + @param message header received + @param return values count + @param return values list + **/ +void pal_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, + uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_notification(message_header_rcv, + return_values_count, return_values, timeout); +} + diff --git a/platform/linux/juno/pal_power_domain.c b/platform/linux/juno/pal_power_domain.c new file mode 100644 index 0000000..12c0140 --- /dev/null +++ b/platform/linux/juno/pal_power_domain.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef POWER_DOMAIN_PROTOCOL + +#include "pal_interface.h" +#include "pal_power_domain_expected.h" + +/** + @brief This API is used for checking num of power domain + @param none + @return num of power domain +**/ +uint32_t pal_power_get_expected_num_domains(void) +{ + return num_power_domains; +} + +/** + @brief This API is used for checking power domain statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_power_get_expected_stats_addr_low(void) +{ + return statistics_address_low_pow; +} + +/** + @brief This API is used for checking power domain statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_power_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_pow + statistics_address_len_pow); +} + +/** + @brief This API is used for checking power domain statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_power_get_expected_stats_addr_len(void) +{ + return statistics_address_len_pow; +} + +#endif diff --git a/platform/linux/juno/pal_reset.c b/platform/linux/juno/pal_reset.c new file mode 100644 index 0000000..510e0cd --- /dev/null +++ b/platform/linux/juno/pal_reset.c @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef RESET_PROTOCOL + +#include "pal_interface.h" +#include "pal_reset_expected.h" + +/** + @brief This API is used for checking num of reset domain + @param none + @return num of reset domain +**/ +uint32_t pal_reset_get_expected_num_domains(void) +{ + return num_reset_domains; +} + +/** + @brief This API is used for checking reset domain name + @param domain id + @return reset domain name +**/ +uint8_t *pal_reset_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)reset_domain_names[domain_id]; +} + +#endif + diff --git a/platform/linux/juno/pal_sensor.c b/platform/linux/juno/pal_sensor.c new file mode 100644 index 0000000..d93a3b1 --- /dev/null +++ b/platform/linux/juno/pal_sensor.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef SENSOR_PROTOCOL + +#include "pal_interface.h" +#include "pal_sensor_expected.h" + +/** + @brief This API is used for checking num of sensors + @param none + @return num of sensors +**/ +uint32_t pal_sensor_get_expected_num_sensors(void) +{ + return num_sensors; +} + +/** + @brief This API is used for checking sensor statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_sensor_get_expected_stats_addr_low(void) +{ + return statistics_address_low_snsr; +} + +/** + @brief This API is used for checking sensor statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_sensor_get_expected_stats_addr_high(void) +{ + return (statistics_address_low_snsr + statistics_address_len_snsr); +} + +/** + @brief This API is used for checking sensor statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_sensor_get_expected_stats_addr_len(void) +{ + return statistics_address_len_snsr; +} + +#endif diff --git a/platform/linux/juno/pal_voltage.c b/platform/linux/juno/pal_voltage.c new file mode 100755 index 0000000..9fb1c68 --- /dev/null +++ b/platform/linux/juno/pal_voltage.c @@ -0,0 +1,43 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifdef VOLTAGE_PROTOCOL + +#include "pal_interface.h" +#include "pal_voltage_expected.h" + +/** + @brief This API is used for checking num of voltage domain + @param none + @return num of voltage domain +**/ +uint32_t pal_voltage_get_expected_num_domains(void) +{ + return num_voltage_domains; +} + +/** + @brief This API is used for checking voltage domain name + @param domain id + @return voltage domain name +**/ +uint8_t *pal_voltage_get_expected_name(uint32_t domain_id) +{ + return (uint8_t *)voltage_domain_names[domain_id]; +} + +#endif -- GitLab From 89cf6c00c1aeae2654c2e86e9e2c33d96c9f6ec3 Mon Sep 17 00:00:00 2001 From: Cristian Marussi Date: Tue, 19 Jul 2022 19:11:53 +0100 Subject: [PATCH 11/11] Add TARGET generic_scmi for linux platform When building for Linux platform, add support for a generic_scmi target not enforcing any specific expectations in terms of agents, resources and protocols available on the SCMI server under test. Signed-off-by: Cristian Marussi --- Makefile | 3 + docs/user_guide.md | 7 + platform/linux/generic_scmi/Makefile | 18 +++ .../generic_scmi/include/pal_base_expected.h | 25 +++ .../generic_scmi/include/pal_clock_expected.h | 28 ++++ .../linux/generic_scmi/include/pal_platform.h | 57 +++++++ platform/linux/generic_scmi/pal_base.c | 109 ++++++++++++++ platform/linux/generic_scmi/pal_clock.c | 62 ++++++++ platform/linux/generic_scmi/pal_performance.c | 81 ++++++++++ platform/linux/generic_scmi/pal_platform.c | 142 ++++++++++++++++++ .../linux/generic_scmi/pal_power_domain.c | 61 ++++++++ platform/linux/generic_scmi/pal_reset.c | 42 ++++++ platform/linux/generic_scmi/pal_sensor.c | 61 ++++++++ platform/linux/generic_scmi/pal_voltage.c | 42 ++++++ val/include/pal_interface.h | 3 + val/val_interface.c | 10 ++ 16 files changed, 751 insertions(+) create mode 100644 platform/linux/generic_scmi/Makefile create mode 100644 platform/linux/generic_scmi/include/pal_base_expected.h create mode 100644 platform/linux/generic_scmi/include/pal_clock_expected.h create mode 100644 platform/linux/generic_scmi/include/pal_platform.h create mode 100644 platform/linux/generic_scmi/pal_base.c create mode 100644 platform/linux/generic_scmi/pal_clock.c create mode 100644 platform/linux/generic_scmi/pal_performance.c create mode 100644 platform/linux/generic_scmi/pal_platform.c create mode 100644 platform/linux/generic_scmi/pal_power_domain.c create mode 100644 platform/linux/generic_scmi/pal_reset.c create mode 100644 platform/linux/generic_scmi/pal_sensor.c create mode 100755 platform/linux/generic_scmi/pal_voltage.c diff --git a/Makefile b/Makefile index 9a0a464..765000e 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ LINUX=linux SGM776=sgm776 TC=tc JUNO=juno +GENERIC_SCMI=generic_scmi COMMON=common #Set PLATFORM @@ -51,6 +52,8 @@ ifeq ($(PLAT),$(LINUX)) PLAT_DIR=$(DIR)/$(TC) $(DIR)/$(COMMON) else ifeq ($(TARGET),$(JUNO)) PLAT_DIR=$(DIR)/$(JUNO) $(DIR)/$(COMMON) + else ifeq ($(TARGET),$(GENERIC_SCMI)) + PLAT_DIR=$(DIR)/$(GENERIC_SCMI) $(DIR)/$(COMMON) else $(error TARGET $(TARGET) is invalid. Provide valid TARGET value) endif diff --git a/docs/user_guide.md b/docs/user_guide.md index 6ec6ccd..a8c5456 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -111,6 +111,13 @@ Instead of using the mailbox test driver, alternatively, the SCMI test suite can **NOTE**: * In both cases you must rebuild the Linux kernel (and the device tree in the mailbox test driver case) for LINUX by following the [Guide to test SCMI on LINUX]. +##### 2.2.1 OSPM Agent Generic SCMI target support - EXPERIMENTAL +Additionally, it is possible to alternatively built the SCMI test suite to run against a generic SCMI implementation specifying TARGET=generic_scmi as in: + +make PLAT=linux TARGET=generic_scmi PROTOCOLS=base,clock,power_domain,performance,system_power,sensor,reset,voltage VERBOSE=1 + +Such generic target relaxes its expectations about number and name of agents, resources and protocols expected to be found on the system: in other words it tries to test whatever protocol and resource it could find during the initial BASE discovery phase without enforcing any specific assumption like with SGM/TX targets. + #### 2.3 Baremetal The SCMI test suite can be complied as libscmi_test.a and integrated with your baremetal test framework. Please refer to [Validation Methodology Document] for PAL API's which needs to be ported for baremetal. diff --git a/platform/linux/generic_scmi/Makefile b/platform/linux/generic_scmi/Makefile new file mode 100644 index 0000000..e1f163b --- /dev/null +++ b/platform/linux/generic_scmi/Makefile @@ -0,0 +1,18 @@ +#/** @file +# * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# * SPDX-License-Identifier : Apache-2.0 +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +#**/ + +include ${TOP}/platform/build_platform.mk diff --git a/platform/linux/generic_scmi/include/pal_base_expected.h b/platform/linux/generic_scmi/include/pal_base_expected.h new file mode 100644 index 0000000..bbe7161 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_base_expected.h @@ -0,0 +1,25 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_BASE_EXPECTED_H__ +#define __PAL_BASE_EXPECTED_H__ + +#include + +#define UNTRUSTED 0 + +#endif /* __PAL_BASE_EXPECTED_H__ */ diff --git a/platform/linux/generic_scmi/include/pal_clock_expected.h b/platform/linux/generic_scmi/include/pal_clock_expected.h new file mode 100644 index 0000000..92b92b4 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_clock_expected.h @@ -0,0 +1,28 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_CLOCK_EXPECTED_H__ +#define __PAL_CLOCK_EXPECTED_H__ + +/* Expected CLOCK parameters */ +#ifdef CLOCK_PROTOCOL + +#define UNSUPPORTED 1 + +#endif + +#endif /* __PAL_CLOCK_EXPECTED_H__ */ diff --git a/platform/linux/generic_scmi/include/pal_platform.h b/platform/linux/generic_scmi/include/pal_platform.h new file mode 100644 index 0000000..2f977c4 --- /dev/null +++ b/platform/linux/generic_scmi/include/pal_platform.h @@ -0,0 +1,57 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifndef __PAL_PLATFORM_H__ +#define __PAL_PLATFORM_H__ + +#include +#include +#include + +#define TIMEOUT 100 + +#define LOG_FILE "arm_scmi_test_log.txt" + +int linux_map_phys_to_virt(unsigned long paddr, size_t length, + unsigned long *vaddr); + +int linux_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, + size_t length); + +uint32_t linux_initialize_system(void *info); + +int32_t linux_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int32_t linux_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values); + +int linux_wait_for_notification(uint32_t *message_header_rcv, + size_t *return_values_count, uint32_t *return_values, + uint32_t timeout); + +int linux_wait_for_response(uint32_t *message_header_rcv, + int32_t *status, size_t *return_values_count, uint32_t *return_values, + bool *message_ready, uint32_t timeout); + +uint32_t linux_agent_get_accessible_device(uint32_t agent_id); +uint32_t linux_agent_get_inaccessible_device(uint32_t agent_id); +uint32_t linux_device_get_accessible_protocol(uint32_t device_id); + +#endif diff --git a/platform/linux/generic_scmi/pal_base.c b/platform/linux/generic_scmi/pal_base.c new file mode 100644 index 0000000..32c036f --- /dev/null +++ b/platform/linux/generic_scmi/pal_base.c @@ -0,0 +1,109 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_interface.h" +#include "pal_base_expected.h" + +/** + @brief This API is used to check vendor name + @param none + @return vendor name +**/ +char *pal_base_get_expected_vendor_name(void) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking subvendor name + @param none + @return subvendor name +**/ +char *pal_base_get_expected_subvendor_name(void) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking implementation version + @param none + @return implementation version +**/ +uint32_t pal_base_get_expected_implementation_version(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of agents + @param none + @return num of agents +**/ +uint32_t pal_base_get_expected_num_agents(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of protocols agent have access + @param none + @return num of protocols +**/ +uint32_t pal_base_get_expected_num_protocols(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking if agent is trusted + @param agent id + @return true/false +**/ +uint32_t pal_check_trusted_agent(uint32_t agent_id) +{ + return UNTRUSTED; +} + +/** + @brief This API is used to get device which agent can access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_accessible_device(uint32_t agent_id) +{ + return linux_agent_get_accessible_device(agent_id); +} + +/** + @brief This API is used to get device which agent cannot access + @param agent id + @return device id +**/ +uint32_t pal_agent_get_inaccessible_device(uint32_t agent_id) +{ + return linux_agent_get_inaccessible_device(agent_id); +} + +/** + @brief This API is used to get protocol by which given device can be access + @param device id + @return protocol id +**/ +uint32_t pal_device_get_accessible_protocol(uint32_t device_id) +{ + return linux_device_get_accessible_protocol(device_id); +} diff --git a/platform/linux/generic_scmi/pal_clock.c b/platform/linux/generic_scmi/pal_clock.c new file mode 100644 index 0000000..04b0f06 --- /dev/null +++ b/platform/linux/generic_scmi/pal_clock.c @@ -0,0 +1,62 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef CLOCK_PROTOCOL + +#include "pal_interface.h" +#include "pal_clock_expected.h" + +/** + @brief This API is used for checking num of clocks + @param none + @return num of clocks +**/ +uint32_t pal_clock_get_expected_num_clocks(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking max num of pending async cmd support for clock + @param none + @return max num of pending async cmd +**/ +uint32_t pal_clock_get_expected_max_async_cmd(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking num of rates a clock supports + @param clock id + @return num of rates a clock supports +**/ +uint32_t pal_clock_get_expected_number_of_rates(uint32_t clock_id) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API checks if clock supports config change + @param clock id + @return supported / unsupported +**/ +uint32_t pal_check_clock_config_change_support(uint32_t clock_id) +{ + return UNSUPPORTED; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_performance.c b/platform/linux/generic_scmi/pal_performance.c new file mode 100644 index 0000000..229a7e3 --- /dev/null +++ b/platform/linux/generic_scmi/pal_performance.c @@ -0,0 +1,81 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef PERFORMANCE_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking number of perf domains + @param none + @return num of perf domains +**/ +uint32_t pal_performance_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking perf statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_performance_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking perf statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_performance_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_performance_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking domain name + @param perf domain id + @return perf domain name +**/ +uint8_t *pal_performance_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +/** + @brief This API is used for checking num of level for perf domain + @param perf domain id + @return num of level for perf domain +**/ +uint32_t pal_performance_get_expected_number_of_level(uint32_t domain_id) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_platform.c b/platform/linux/generic_scmi/pal_platform.c new file mode 100644 index 0000000..c2b8712 --- /dev/null +++ b/platform/linux/generic_scmi/pal_platform.c @@ -0,0 +1,142 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#include "pal_platform.h" +#include "pal_interface.h" + +/** + @brief This API is used to map a physical memory area to a virtual one. + @param paddr physical address to map + @param length size of the memory to map + @param vaddr the mapped resulting virtual address + @return 0 on Success +**/ +int pal_map_phys_to_virt(unsigned long paddr, size_t length, unsigned long *vaddr) +{ + return linux_map_phys_to_virt(paddr, length, vaddr); +} + +/** + @brief This API is used to unmap a previously mapped memory area + @param paddr physical address that has been mapped + @param length size of the mapped memory + @param vaddr the mapped virtual address + @return 0 on Success +**/ +int pal_unmap_phys_to_virt(unsigned long paddr, unsigned long vaddr, size_t length) +{ + return linux_unmap_phys_to_virt(paddr, vaddr, length); +} + +/** + @brief This API is used to call platform function to send command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to call platform function to send async command + @param cmd message header + @param num of cmd parameter + @param parameter list + @param response message header + @param cmd status + @param return values count + @param return values list + @return vendor name +**/ +void pal_send_message_async(uint32_t message_header_send, size_t parameter_count, + const uint32_t *parameters, uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + linux_send_message_async(message_header_send, parameter_count, parameters, + message_header_rcv, status, return_values_count, + return_values); +} + +/** + @brief This API is used to initialize platform to run tests if needed + @param platform info + @return success / failure +**/ +uint32_t pal_initialize_system(void *info) +{ + return linux_initialize_system(info); +} + +/** + @brief This API is used to print test log + @param args values to be printed + @return none +**/ +void pal_print(uint32_t print_level, const char *format, va_list args) +{ + FILE *file_ptr = fopen(LOG_FILE, "a"); + if (file_ptr) + { + vfprintf(file_ptr, format, args); + fclose(file_ptr); + } + else + printf("ERROR: Log File opening failed"); +} + +/** + @brief This API is used to receive delayed response + @param message header received + @param status of command processed + @param return values count + @param return values list + **/ +void pal_receive_delayed_response(uint32_t *message_header_rcv, int32_t *status, + size_t *return_values_count, uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_response(message_header_rcv, status, + return_values_count, return_values, NULL, timeout); +} + +/** + @brief This API is used to receive notifications from platform + @param message header received + @param return values count + @param return values list + **/ +void pal_receive_notification(uint32_t *message_header_rcv, size_t *return_values_count, + uint32_t *return_values) +{ + uint32_t timeout = TIMEOUT; /* In ms*/ + + linux_wait_for_notification(message_header_rcv, + return_values_count, return_values, timeout); +} + diff --git a/platform/linux/generic_scmi/pal_power_domain.c b/platform/linux/generic_scmi/pal_power_domain.c new file mode 100644 index 0000000..c5ec0a8 --- /dev/null +++ b/platform/linux/generic_scmi/pal_power_domain.c @@ -0,0 +1,61 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef POWER_DOMAIN_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of power domain + @param none + @return num of power domain +**/ +uint32_t pal_power_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_power_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_power_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking power domain statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_power_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_reset.c b/platform/linux/generic_scmi/pal_reset.c new file mode 100644 index 0000000..ebf7582 --- /dev/null +++ b/platform/linux/generic_scmi/pal_reset.c @@ -0,0 +1,42 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef RESET_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of reset domain + @param none + @return num of reset domain +**/ +uint32_t pal_reset_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking reset domain name + @param domain id + @return reset domain name +**/ +uint8_t *pal_reset_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +#endif + diff --git a/platform/linux/generic_scmi/pal_sensor.c b/platform/linux/generic_scmi/pal_sensor.c new file mode 100644 index 0000000..1a61b0a --- /dev/null +++ b/platform/linux/generic_scmi/pal_sensor.c @@ -0,0 +1,61 @@ +/** @file + * Copyright (c) 2023 Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ +#ifdef SENSOR_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of sensors + @param none + @return num of sensors +**/ +uint32_t pal_sensor_get_expected_num_sensors(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr low + @param none + @return statistics addr low +**/ +uint32_t pal_sensor_get_expected_stats_addr_low(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr high + @param none + @return statistics addr high +**/ +uint32_t pal_sensor_get_expected_stats_addr_high(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking sensor statistics addr len + @param none + @return statistics addr len +**/ +uint32_t pal_sensor_get_expected_stats_addr_len(void) +{ + return PAL_SCMI_ANYTHING; +} + +#endif diff --git a/platform/linux/generic_scmi/pal_voltage.c b/platform/linux/generic_scmi/pal_voltage.c new file mode 100755 index 0000000..6b10fa2 --- /dev/null +++ b/platform/linux/generic_scmi/pal_voltage.c @@ -0,0 +1,42 @@ +/** @file + * Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. + * SPDX-License-Identifier : Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +**/ + +#ifdef VOLTAGE_PROTOCOL + +#include "pal_interface.h" + +/** + @brief This API is used for checking num of voltage domain + @param none + @return num of voltage domain +**/ +uint32_t pal_voltage_get_expected_num_domains(void) +{ + return PAL_SCMI_ANYTHING; +} + +/** + @brief This API is used for checking voltage domain name + @param domain id + @return voltage domain name +**/ +uint8_t *pal_voltage_get_expected_name(uint32_t domain_id) +{ + return PAL_SCMI_ANYNAME; +} + +#endif diff --git a/val/include/pal_interface.h b/val/include/pal_interface.h index 9c2dac6..5802f98 100644 --- a/val/include/pal_interface.h +++ b/val/include/pal_interface.h @@ -40,6 +40,9 @@ #define PAL_STATUS_PASS 0x0 #define PAL_STATUS_NO_TESTS 0x1 +#define PAL_SCMI_ANYNAME NULL +#define PAL_SCMI_ANYTHING 0xFFFFFFFF + #define SCMI_NAME_STR_SIZE 16 #define NUM_ELEMS(x) (sizeof(x) / sizeof((x)[0])) #define MAX_RETURNS_SIZE 32 diff --git a/val/val_interface.c b/val/val_interface.c index 2afa63a..cdd56df 100644 --- a/val/val_interface.c +++ b/val/val_interface.c @@ -189,6 +189,11 @@ uint32_t val_compare_msg_hdr(uint32_t sent_msg_hdr, uint32_t rcvd_msg_hdr) **/ uint32_t val_compare(char *parameter, uint32_t rcvd_val, uint32_t exp_val) { + if (exp_val == PAL_SCMI_ANYTHING) { + val_print(VAL_PRINT_TEST, "\n CHECK %s: PASSED [0x%08x] ", parameter, rcvd_val); + return VAL_STATUS_PASS; + } + if (rcvd_val != exp_val) { val_print(VAL_PRINT_ERR, "\n CHECK %s: FAILED", parameter); val_print(VAL_PRINT_ERR, "\n EXPECTED : 0x%08x ", exp_val); @@ -211,6 +216,11 @@ uint32_t val_compare(char *parameter, uint32_t rcvd_val, uint32_t exp_val) **/ uint32_t val_compare_str(char *parameter, char *rcvd_val, char *exp_val, uint32_t len) { + if (exp_val == PAL_SCMI_ANYNAME) { + val_print(VAL_PRINT_TEST, "\n CHECK %s: PASSED [%s] ", parameter, rcvd_val); + return VAL_STATUS_PASS; + } + if (val_strcmp((uint8_t *)rcvd_val, (uint8_t *)exp_val, len)) { val_print(VAL_PRINT_ERR, "\n CHECK %s: FAILED", parameter); val_print(VAL_PRINT_ERR, "\n EXPECTED : %s ", exp_val); -- GitLab