From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EB58D45BFE; Mon, 28 Oct 2024 12:02:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7D3FD40E6E; Mon, 28 Oct 2024 12:02:34 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 22D4640E2D for ; Mon, 28 Oct 2024 12:01:55 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49SA0kts010689; Mon, 28 Oct 2024 04:01:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=D EWvcuV/FuJuAW1o4BwvpfAKT6eb/d/0SBssx3fJqAY=; b=Ygqtw7bzhFvYbIVjS S8F4mdwn6UuVQOoMJPtkAo/q3WZ1WawT8KBpi7kmD629DtFrt0knvu4HurO6mv6D lf4SKnv22RDoL8l0GovcWoLhDus57WHwx/wxHCBTRHrpwQs5OcST3jfzaDA3NN/g 4Wi2IgKwVrItuXNJsXNOR8I+sq+458Cu0MhjmK2bNBNj/zriZL0tIJrgdvy/toCk +kPskdKuApbXNSw85OFsnoadmpT133ES1pePV4scbcqSciXvKjYvowuQ+/2IMblS /3rUz978jCC0QC0MGXo0HG96XJqE7MfzoPfIoAFNYZ67Ew1KW/xzCHMi/zTqmEFT esHOg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42j7v2055u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2024 04:01:53 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 28 Oct 2024 04:01:52 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 28 Oct 2024 04:01:52 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 5F5AF5C68EF; Mon, 28 Oct 2024 04:01:49 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , Akhil Goyal Subject: [PATCH v6 9/9] raw/cnxk_rvu_lf: add selftest Date: Mon, 28 Oct 2024 16:31:15 +0530 Message-ID: <20241028110115.1070655-10-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241028110115.1070655-1-gakhil@marvell.com> References: <20241024131759.3337333-1-gakhil@marvell.com> <20241028110115.1070655-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: r2F7GecXOQ7lWhGwsBa5Y6LLHU1PW8SU X-Proofpoint-ORIG-GUID: r2F7GecXOQ7lWhGwsBa5Y6LLHU1PW8SU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added raw device selftest for cnxk_rvu_lf to verify various PMD APIs. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 20 +++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 2 +- drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h | 2 + .../raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c | 166 ++++++++++++++++++ drivers/raw/cnxk_rvu_lf/meson.build | 1 + 5 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 708c9410fd..1ac7d6b84b 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -81,9 +81,29 @@ and provides an opaque pointer for a response and its length. PF and VF out of tree driver can define its own request and response based on the message id of the mailbox. +For sample usage of the APIs, refer ``rvu_lf_rawdev_selftest()``. + Get BAR addresses ----------------- Out of tree drivers can retrieve PCI BAR addresses of the device using the API ``rte_pmd_rvu_lf_bar_get()``. This helps PF/VF drivers to configure the registers of the hardware device. + +Self test +--------- + +On EAL initialization RVU_LF devices will be probed and populated into +the raw devices. The rawdev ID of the device can be obtained using invocation +of ``rte_rawdev_get_dev_id("NAME:x")`` from the test application, where: + +- NAME is the desired subsystem: use "RVU_LF". +- x is the device's bus id specified in "bus:device.func" (BDF) format. BDF follows convention + used by lspci i.e bus, device and func are specified using respectively two, two and one hex + digit(s). + +Use this identifier for further rawdev function calls. + +Selftest rawdev API can be used to verify the mailbox communication between +PF and VF devices based applications. There can be multiple VFs for a particular PF. +Each VF can send mailboxes to PF and PF can broadcast message to all VFs. diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index 3a3971ecd3..54c58a8552 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -155,7 +155,7 @@ rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id) } static const struct rte_rawdev_ops rvu_lf_rawdev_ops = { - .dev_selftest = NULL, + .dev_selftest = rvu_lf_rawdev_selftest, }; static void diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h index 65cc1bb64d..e64643dcee 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h @@ -21,4 +21,6 @@ extern int cnxk_logtype_rvu_lf; #define CNXK_RVU_LF_LOG(level, ...) \ RTE_LOG_LINE_PREFIX(level, CNXK_RVU_LF, "%s(): ", __func__, __VA_ARGS__) +int rvu_lf_rawdev_selftest(uint16_t dev_id); + #endif /* _CNXK_RVU_LF_H_ */ diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c new file mode 100644 index 0000000000..e33973f24b --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_selftest.c @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "cnxk_rvu_lf.h" +#include "cnxk_rvu_lf_driver.h" + +#define PF 0 +#define VF 0 +#define RSP_LEN 64 +#define REQ_LEN 64 +#define MSG_ID_FROM 0x3000 +#define MSG_ID_TO 0x4000 +#define MAX_BAR 6 + +static int +msg_process_notify_cb(uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, void **rsp, uint16_t *rsp_len) +{ + uint8_t *resp; + int i; + + printf("\nReceived message(0x%x) from VF0x%x\n", msg_id, vf); + rte_hexdump(stdout, "req_data received", req, req_len); + + resp = malloc(RSP_LEN); + if (resp == NULL) + return -ENOMEM; + for (i = 0; i < RSP_LEN; i++) + resp[i] = 0xB0; + *rsp = resp; + *rsp_len = RSP_LEN; + rte_hexdump(stdout, "rsp_data_filled", *rsp, RSP_LEN); + + return 0; +} + +int +rvu_lf_rawdev_selftest(uint16_t dev_id) +{ + char *dev_name = rte_rawdevs[dev_id].name; + uint8_t req[REQ_LEN] = {0}; + uint8_t rsp[RSP_LEN] = {0}; + size_t bar_mask = 0; + size_t bar_va = 0; + unsigned int i, j; + uint16_t pf_func; + char *token[2]; + int func, ret; + + token[0] = strtok_r(dev_name, ".", &dev_name); + token[1] = strtok_r(dev_name, ".", &dev_name); + func = atoi(token[1]); + + ret = rte_rawdev_start(dev_id); + if (ret) + return ret; + + pf_func = rte_pmd_rvu_lf_npa_pf_func_get(); + if (pf_func == 0) + CNXK_RVU_LF_LOG(WARNING, "NPA pf_func is invalid"); + + pf_func = rte_pmd_rvu_lf_sso_pf_func_get(); + if (pf_func == 0) + CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid"); + + pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id); + if (pf_func == 0) + CNXK_RVU_LF_LOG(WARNING, "RVU-LF pf_func is invalid"); + + for (i = 0; i < MAX_BAR; i++) { + if (!rte_pmd_rvu_lf_bar_get(dev_id, i, &bar_va, &bar_mask)) + printf("\n BAR[%d]: addr: 0x%" PRIx64 ", mask: 0x%" PRIx64 "\n", + i, bar_va, bar_mask); + } + + ret = rte_pmd_rvu_lf_msg_id_range_set(dev_id, MSG_ID_FROM, MSG_ID_TO); + if (ret) { + CNXK_RVU_LF_LOG(ERR, "RVU message ID range invalid"); + goto out; + } + + ret = rte_pmd_rvu_lf_msg_handler_register(dev_id, msg_process_notify_cb); + if (ret) { + CNXK_RVU_LF_LOG(ERR, "RVU message handler register failed, ret: %d", ret); + goto out; + } + + if (func == 0) { + j = 50; + printf("\n"); + while (j--) { + /* PF will wait for RVU message callbacks to be called */ + rte_delay_ms(1000); + printf("PF waiting for VF messages for %d sec.\r", j); + } + /* PF will send the messages and receive responses. */ + for (i = 0; i < REQ_LEN; i++) + req[i] = 0xC0; + /* + * Range is set as between MSG_ID_FROM and MSG_ID_TO. + * Messages sent with this id will be serviced by VF.. + */ + ret = rte_pmd_rvu_lf_msg_process(dev_id, + VF /* Send to VF0 */, + MSG_ID_FROM + 0x2, + req, REQ_LEN, rsp, RSP_LEN); + if (ret) { + CNXK_RVU_LF_LOG(ERR, "rvu lf PF->VF message send failed"); + goto unregister; + } + CNXK_RVU_LF_LOG(INFO, "RVU PF->VF message processed"); + rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN); + j = 50; + printf("\n"); + while (j--) { + rte_delay_ms(1000); + printf("PF waiting for VF to exit for %d sec.\r", j); + } + + } else { + /* VF will send the messages and receive responses. */ + for (i = 0; i < REQ_LEN; i++) + req[i] = 0xA0; + /* + * Range is set as between MSG_ID_FROM and MSG_ID_TO + * Messages sent with this id will be serviced by PF and will + * not be forwarded to AF. + */ + ret = rte_pmd_rvu_lf_msg_process(dev_id, + PF /* Send to PF */, + MSG_ID_FROM + 0x1, + req, REQ_LEN, rsp, RSP_LEN); + if (ret) { + CNXK_RVU_LF_LOG(ERR, "rvu lf VF->PF message send failed"); + goto unregister; + } + CNXK_RVU_LF_LOG(INFO, "RVU VF->PF message processed"); + rte_hexdump(stdout, "rsp_data received", rsp, RSP_LEN); + j = 50; + printf("\n"); + while (j--) { + rte_delay_ms(1000); + printf("VF waiting for PF to send msg for %d sec.\r", j); + } + } +unregister: + rte_pmd_rvu_lf_msg_handler_unregister(dev_id); +out: + rte_rawdev_stop(dev_id); + + return ret; +} + + diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build index 7ea1c3916c..c960989bb7 100644 --- a/drivers/raw/cnxk_rvu_lf/meson.build +++ b/drivers/raw/cnxk_rvu_lf/meson.build @@ -5,6 +5,7 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev'] sources = files( 'cnxk_rvu_lf.c', + 'cnxk_rvu_lf_selftest.c', ) driver_sdk_headers += files('cnxk_rvu_lf_driver.h') require_iova_in_mbuf = false -- 2.25.1