From patchwork Sat Sep 7 19:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143786 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6F24245931; Sat, 7 Sep 2024 21:33:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 258364060A; Sat, 7 Sep 2024 21:33:23 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A8F6640395 for ; Sat, 7 Sep 2024 21:33:21 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JRrD7028682; Sat, 7 Sep 2024 12:33:21 -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=l c1pzOA4RYQkjhhdgtR/UPnMuXI0hrCZbvQ4311NYec=; b=h6Y+4eaSEUZaw6VaM PHdzykgwa2vqBs5riuMrZRjCrJDNgQUh/68gm0uRBZJjMk04mgAofXLpc7/zaqz9 ih0UcAd+aKJi45SNayHImCUqbBdLYDZTFNo+AoRFa2oSkgrl+JQP3FVYo+TR5TBH SY8kH7DIDUL0d2f6F8ECyoi3RabNoykFeb7hCfzS4n9LE0NexPcvEQi4XFTihA8r JtusMyyN3toYafg9cT7w/VURt1yPlhCimKiFKTJUTN5VYwGVvTugwyOgHr4bLOD2 dWmeFjRiMpbuO9lyCJVSyqaAUv5vXXmTXEQOFqU2goy+5T42HIl10ghotBe6ygKv TTqGw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8km3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:20 -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; Sat, 7 Sep 2024 12:33:19 -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; Sat, 7 Sep 2024 12:33:19 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id CCF163F707A; Sat, 7 Sep 2024 12:33:16 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 1/9] rawdev: add API to get device from index Date: Sun, 8 Sep 2024 01:03:03 +0530 Message-ID: <20240907193311.1342310-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: uvNdI1F3Hiv3db_c7ulRIw7xWrLd82Gf X-Proofpoint-ORIG-GUID: uvNdI1F3Hiv3db_c7ulRIw7xWrLd82Gf 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 an internal API for PMDs to get raw device pointer from a device id. Signed-off-by: Akhil Goyal --- lib/rawdev/rte_rawdev_pmd.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/rawdev/rte_rawdev_pmd.h b/lib/rawdev/rte_rawdev_pmd.h index 22b406444d..8339122348 100644 --- a/lib/rawdev/rte_rawdev_pmd.h +++ b/lib/rawdev/rte_rawdev_pmd.h @@ -102,6 +102,30 @@ rte_rawdev_pmd_get_named_dev(const char *name) return NULL; } +/** + * Get the rte_rawdev structure device pointer for given device ID. + * + * @param dev_id + * raw device index. + * + * @return + * - The rte_rawdev structure pointer for the given device ID. + */ +static inline struct rte_rawdev * +rte_rawdev_pmd_get_dev(uint8_t dev_id) +{ + struct rte_rawdev *dev; + + if (dev_id >= RTE_RAWDEV_MAX_DEVS) + return NULL; + + dev = &rte_rawdevs[dev_id]; + if (dev->attached == RTE_RAWDEV_ATTACHED) + return dev; + + return NULL; +} + /** * Validate if the raw device index is a valid attached raw device. * From patchwork Sat Sep 7 19:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143787 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36ACB45931; Sat, 7 Sep 2024 21:33:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A00EB40651; Sat, 7 Sep 2024 21:33:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3BAAD40614 for ; Sat, 7 Sep 2024 21:33:24 +0200 (CEST) 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 487IQQbj000578; Sat, 7 Sep 2024 12:33:23 -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=U Br7OY5/wCxw6n8+5/mZi9sQ05XyqdXJl3MOmhQVjn0=; b=a3+BtlocUaMdDryD6 ZGqXmRVInMm9wJxD6cQJxGLGaaw6vWWk3PxNDgtxGWCwp3iDTIkuBEyBAFuhVY4H g3FUacekiOXRgnzqHi7dDLwsIChf9F8kpjzCtUZbPV8sgl0nOSt+tQQVDQ/8uSYo rZkjtFTI04k5lE3tLwFL7fCyyOP5tM/rFD7/sb//KWpJKHW3lJulOM4u4D1Jv3Tq aVBFhGEkHDlS6Ui5/X9hufxjDy2kuZFK++uol1WkNhKfFZt3ZQNfp41bNzdWMefw uOhlAfcfn9nSJhS7xYLh1Ho7UXLL+LP7Gxu4O3i8r9qnB3TTuA8Wcbh40OQ+WkbO S3diw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gm6k8ttk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:23 -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; Sat, 7 Sep 2024 12:33:22 -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; Sat, 7 Sep 2024 12:33:22 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id C12053F7063; Sat, 7 Sep 2024 12:33:19 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 2/9] drivers/raw: introduce cnxk rvu lf device driver Date: Sun, 8 Sep 2024 01:03:04 +0530 Message-ID: <20240907193311.1342310-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: qfDxm2N_lTlnL4u76v64O5zKY3qe7shI X-Proofpoint-GUID: qfDxm2N_lTlnL4u76v64O5zKY3qe7shI 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 CNXK product families can have a use case to allow PF and VF applications to communicate using mailboxes and also get notified of any interrupt that may occur on the device. Hence, a new raw device driver is added for such RVU LF devices. These devices can map to a PF or a VF which can send mailboxes to each other. Signed-off-by: Akhil Goyal --- MAINTAINERS | 6 ++ doc/guides/rawdevs/cnxk_rvu_lf.rst | 40 ++++++++ doc/guides/rawdevs/index.rst | 1 + drivers/common/cnxk/meson.build | 1 + drivers/common/cnxk/roc_api.h | 3 + drivers/common/cnxk/roc_constants.h | 2 + drivers/common/cnxk/roc_dev_priv.h | 1 + drivers/common/cnxk/roc_idev.c | 46 +++++++++ drivers/common/cnxk/roc_idev.h | 4 + drivers/common/cnxk/roc_idev_priv.h | 1 + drivers/common/cnxk/roc_priv.h | 2 + drivers/common/cnxk/roc_rvu_lf.c | 63 ++++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 24 +++++ drivers/common/cnxk/roc_rvu_lf_priv.h | 32 ++++++ drivers/common/cnxk/roc_utils.c | 2 + drivers/common/cnxk/version.map | 5 + drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 123 +++++++++++++++++++++++ drivers/raw/cnxk_rvu_lf/meson.build | 9 ++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 39 +++++++ drivers/raw/meson.build | 1 + 20 files changed, 405 insertions(+) create mode 100644 doc/guides/rawdevs/cnxk_rvu_lf.rst create mode 100644 drivers/common/cnxk/roc_rvu_lf.c create mode 100644 drivers/common/cnxk/roc_rvu_lf.h create mode 100644 drivers/common/cnxk/roc_rvu_lf_priv.h create mode 100644 drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h diff --git a/MAINTAINERS b/MAINTAINERS index c5a703b5c0..753dcd9743 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1499,6 +1499,12 @@ T: git://dpdk.org/next/dpdk-next-net-mrvl F: doc/guides/rawdevs/cnxk_gpio.rst F: drivers/raw/cnxk_gpio/ +Marvell CNXK RVU LF +M: Akhil Goyal +T: git://dpdk.org/next/dpdk-next-net-mrvl +F: doc/guides/rawdevs/cnxk_rvu_lf.rst +F: drivers/raw/cnxk_rvu_lf/ + NTB M: Jingjing Wu F: drivers/raw/ntb/ diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst new file mode 100644 index 0000000000..8a0bc22dd5 --- /dev/null +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -0,0 +1,40 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2024 Marvell. + +Marvell CNXK RVU LF Driver +========================== + +CNXK product families can have a use case to allow PF and VF +applications to communicate using mailboxes and also get notified +of any interrupt that may occur on the device. +Hence, a new raw device driver is added for such RVU LF devices. +These devices can map to a PF or a VF which can send mailboxes to +each other. + +Features +-------- + +The RVU LF device implements following features in the rawdev API: + +- Register mailbox callbacks for the other side to process mailboxes. +- Register interrupt handler callbacks. +- Process mailbox. +- Set range of message IDs allowed for communication. + +Limitations +----------- + +In multiprocess mode user-space application must ensure +no resources sharing takes place. +Otherwise, user-space application should ensure synchronization. + +Device Setup +------------ + +The RVU LF devices will need to be bound to a user-space IO driver for use. +The script ``dpdk-devbind.py`` included with DPDK can be used to +view the state of the devices and to bind them to a suitable DPDK-supported +kernel driver. When querying the status of the devices, they will appear under +the category of "Misc (rawdev) devices", i.e. the command +``dpdk-devbind.py --status-dev misc`` can be used to see the state of those +devices alone. diff --git a/doc/guides/rawdevs/index.rst b/doc/guides/rawdevs/index.rst index f34315f051..8e07cf4d6c 100644 --- a/doc/guides/rawdevs/index.rst +++ b/doc/guides/rawdevs/index.rst @@ -13,6 +13,7 @@ application through rawdev API. cnxk_bphy cnxk_gpio + cnxk_rvu_lf dpaa2_cmdif ifpga ntb diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build index e0e4600989..3d351aa730 100644 --- a/drivers/common/cnxk/meson.build +++ b/drivers/common/cnxk/meson.build @@ -71,6 +71,7 @@ sources = files( 'roc_tim_irq.c', 'roc_utils.c', 'roc_ree.c', + 'roc_rvu_lf.c', ) # Security common code diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h index 6a86863c57..93e7bf11bb 100644 --- a/drivers/common/cnxk/roc_api.h +++ b/drivers/common/cnxk/roc_api.h @@ -120,4 +120,7 @@ /* Eswitch */ #include "roc_eswitch.h" +/* RVU LF */ +#include "roc_rvu_lf.h" + #endif /* _ROC_API_H_ */ diff --git a/drivers/common/cnxk/roc_constants.h b/drivers/common/cnxk/roc_constants.h index 21b3998cee..44f28be2df 100644 --- a/drivers/common/cnxk/roc_constants.h +++ b/drivers/common/cnxk/roc_constants.h @@ -45,6 +45,8 @@ #define PCI_DEVID_CNXK_RVU_REE_VF 0xA0f5 #define PCI_DEVID_CNXK_RVU_ESWITCH_PF 0xA0E0 #define PCI_DEVID_CNXK_RVU_ESWITCH_VF 0xA0E1 +#define PCI_DEVID_CNXK_RVU_BPHY_PF 0xA0E4 +#define PCI_DEVID_CNXK_RVU_BPHY_VF 0xA0E5 #define PCI_DEVID_CN9K_CGX 0xA059 #define PCI_DEVID_CN10K_RPM 0xA060 diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h index 50e12cbf17..4af9513733 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -106,6 +106,7 @@ struct dev { void *roc_cpt; void *roc_tim; void *roc_ml; + void *roc_rvu_lf; bool disable_shared_lmt; /* false(default): shared lmt mode enabled */ const struct plt_memzone *lmt_mz; struct mbox_sync sync; diff --git a/drivers/common/cnxk/roc_idev.c b/drivers/common/cnxk/roc_idev.c index 0778d51d1e..84812f73e0 100644 --- a/drivers/common/cnxk/roc_idev.c +++ b/drivers/common/cnxk/roc_idev.c @@ -38,6 +38,7 @@ idev_set_defaults(struct idev_cfg *idev) idev->num_lmtlines = 0; idev->bphy = NULL; idev->cpt = NULL; + TAILQ_INIT(&idev->rvu_lf_list); TAILQ_INIT(&idev->mcs_list); idev->nix_inl_dev = NULL; TAILQ_INIT(&idev->roc_nix_list); @@ -188,6 +189,51 @@ roc_idev_cpt_get(void) return NULL; } +struct roc_rvu_lf * +roc_idev_rvu_lf_get(uint8_t rvu_lf_idx) +{ + struct idev_cfg *idev = idev_get_cfg(); + struct roc_rvu_lf *rvu_lf = NULL; + + if (idev != NULL) { + TAILQ_FOREACH(rvu_lf, &idev->rvu_lf_list, next) { + if (rvu_lf->idx == rvu_lf_idx) + return rvu_lf; + } + } + + return NULL; +} + +void +roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu) +{ + struct idev_cfg *idev = idev_get_cfg(); + struct roc_rvu_lf *rvu_lf_iter = NULL; + + if (idev != NULL) { + TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) { + if (rvu_lf_iter->idx == rvu->idx) + return; + } + TAILQ_INSERT_TAIL(&idev->rvu_lf_list, rvu, next); + } +} + +void +roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu) +{ + struct idev_cfg *idev = idev_get_cfg(); + struct roc_rvu_lf *rvu_lf_iter = NULL; + + if (idev != NULL) { + TAILQ_FOREACH(rvu_lf_iter, &idev->rvu_lf_list, next) { + if (rvu_lf_iter->idx == rvu->idx) + TAILQ_REMOVE(&idev->rvu_lf_list, rvu, next); + } + } +} + struct roc_mcs * roc_idev_mcs_get(uint8_t mcs_idx) { diff --git a/drivers/common/cnxk/roc_idev.h b/drivers/common/cnxk/roc_idev.h index fc0f7db54e..6edb5f83b2 100644 --- a/drivers/common/cnxk/roc_idev.h +++ b/drivers/common/cnxk/roc_idev.h @@ -29,4 +29,8 @@ uint16_t *__roc_api roc_idev_nix_rx_chan_base_get(void); void __roc_api roc_idev_nix_rx_chan_set(uint16_t port, uint16_t chan); uint16_t __roc_api roc_idev_nix_inl_dev_pffunc_get(void); + +struct roc_rvu_lf *__roc_api roc_idev_rvu_lf_get(uint8_t rvu_lf_idx); +void __roc_api roc_idev_rvu_lf_set(struct roc_rvu_lf *rvu); +void __roc_api roc_idev_rvu_lf_free(struct roc_rvu_lf *rvu); #endif /* _ROC_IDEV_H_ */ diff --git a/drivers/common/cnxk/roc_idev_priv.h b/drivers/common/cnxk/roc_idev_priv.h index 6628b18152..98b6286bfe 100644 --- a/drivers/common/cnxk/roc_idev_priv.h +++ b/drivers/common/cnxk/roc_idev_priv.h @@ -36,6 +36,7 @@ struct idev_cfg { struct roc_bphy *bphy; struct roc_cpt *cpt; struct roc_sso *sso; + struct roc_rvu_lf_head rvu_lf_list; struct roc_mcs_head mcs_list; struct nix_inl_dev *nix_inl_dev; struct idev_nix_inl_cfg inl_cfg; diff --git a/drivers/common/cnxk/roc_priv.h b/drivers/common/cnxk/roc_priv.h index 254a2d3310..8732a05ac3 100644 --- a/drivers/common/cnxk/roc_priv.h +++ b/drivers/common/cnxk/roc_priv.h @@ -53,4 +53,6 @@ /* ML */ #include "roc_ml_priv.h" +/* RVU LF */ +#include "roc_rvu_lf_priv.h" #endif /* _ROC_PRIV_H_ */ diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c new file mode 100644 index 0000000000..1ae39e746e --- /dev/null +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#include "roc_api.h" +#include "roc_priv.h" + +int +roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf) +{ + struct plt_pci_device *pci_dev; + struct dev *dev; + struct rvu_lf *rvu; + int rc; + + if (roc_rvu_lf == NULL || roc_rvu_lf->pci_dev == NULL) + return RVU_ERR_PARAM; + + rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + pci_dev = roc_rvu_lf->pci_dev; + dev = &rvu->dev; + + if (rvu->dev.drv_inited) + return 0; + + if (dev->mbox_active) + goto skip_dev_init; + + memset(rvu, 0, sizeof(*rvu)); + + /* Initialize device */ + rc = dev_init(dev, pci_dev); + if (rc) { + plt_err("Failed to init roc device"); + goto fail; + } + +skip_dev_init: + dev->roc_rvu_lf = roc_rvu_lf; + rvu->pci_dev = pci_dev; + + roc_idev_rvu_lf_set(roc_rvu_lf); + rvu->dev.drv_inited = true; + + return 0; +fail: + return rc; +} + +int +roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + + if (rvu == NULL) + return NIX_ERR_PARAM; + + rvu->dev.drv_inited = false; + + roc_idev_rvu_lf_free(roc_rvu_lf); + + return dev_fini(&rvu->dev, rvu->pci_dev); +} diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h new file mode 100644 index 0000000000..7ce8065a8b --- /dev/null +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#ifndef _ROC_RVU_LF_H_ +#define _ROC_RVU_LF_H_ + +#include "roc_platform.h" + +struct roc_rvu_lf { + TAILQ_ENTRY(roc_rvu_lf) next; + struct plt_pci_device *pci_dev; + uint8_t idx; +#define ROC_RVU_MEM_SZ (6 * 1024) + uint8_t reserved[ROC_RVU_MEM_SZ] __plt_cache_aligned; +}; + +TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf); + +/* Dev */ +int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); +int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); + +#endif /* _ROC_RVU_LF_H_ */ diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h new file mode 100644 index 0000000000..8feff82961 --- /dev/null +++ b/drivers/common/cnxk/roc_rvu_lf_priv.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#ifndef _ROC_RVU_LF_PRIV_H_ +#define _ROC_RVU_LF_PRIV_H_ + +enum rvu_err_status { + RVU_ERR_PARAM = -1, + RVU_ERR_NO_MEM = -2, +}; + +struct rvu_lf { + struct plt_pci_device *pci_dev; + struct dev dev; + uint16_t msg_id_from; + uint16_t msg_id_to; +}; + +static inline struct rvu_lf * +roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf) +{ + return (struct rvu_lf *)&roc_rvu_lf->reserved[0]; +} + +static inline struct roc_rvu_lf * +rvu_priv_to_roc_rvu_lf(struct rvu_lf *rvu_lf) +{ + return (struct roc_rvu_lf *)((char *)rvu_lf - offsetof(struct roc_rvu_lf, reserved)); +} + +#endif /* _ROC_RVU_LF_PRIV_H_ */ diff --git a/drivers/common/cnxk/roc_utils.c b/drivers/common/cnxk/roc_utils.c index 9af2ae9b69..bcc0d2de38 100644 --- a/drivers/common/cnxk/roc_utils.c +++ b/drivers/common/cnxk/roc_utils.c @@ -17,11 +17,13 @@ roc_error_msg_get(int errorcode) case NPC_ERR_PARAM: case SSO_ERR_PARAM: case MCS_ERR_PARAM: + case RVU_ERR_PARAM: case UTIL_ERR_PARAM: err_msg = "Invalid parameter"; break; case NIX_ERR_NO_MEM: case NPC_ERR_NO_MEM: + case RVU_ERR_NO_MEM: err_msg = "Out of memory"; break; case NIX_ERR_INVALID_RANGE: diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index f98738d07e..a2baa12f1a 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -118,6 +118,9 @@ INTERNAL { roc_idev_nix_rx_chan_set; roc_idev_nix_rx_inject_get; roc_idev_nix_rx_inject_set; + roc_idev_rvu_lf_free; + roc_idev_rvu_lf_get; + roc_idev_rvu_lf_set; roc_ml_reg_read64; roc_ml_reg_write64; roc_ml_reg_read32; @@ -541,5 +544,7 @@ INTERNAL { roc_ree_rule_db_get; roc_ree_rule_db_len_get; roc_ree_rule_db_prog; + roc_rvu_lf_dev_fini; + roc_rvu_lf_dev_init; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c new file mode 100644 index 0000000000..50862ca097 --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "rte_pmd_rvu_lf.h" + +static const struct rte_rawdev_ops rvu_lf_rawdev_ops = { + .dev_selftest = NULL, +}; + +static void +rvu_lf_rawdev_get_name(char *name, struct rte_pci_device *pci_dev) +{ + snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "RVU LF:%02x:%02x.%x", + pci_dev->addr.bus, pci_dev->addr.devid, + pci_dev->addr.function); +} + +static int +rvu_lf_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) +{ + char name[RTE_RAWDEV_NAME_MAX_LEN]; + struct rte_rawdev *rvu_lf_rawdev; + struct roc_rvu_lf *roc_rvu_lf; + int ret; + + RTE_SET_USED(pci_drv); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + if (!pci_dev->mem_resource[2].addr) { + CNXK_RVU_LF_LOG(ERR, "BARs have invalid values: BAR0 %p\n BAR2 %p", + pci_dev->mem_resource[2].addr, pci_dev->mem_resource[4].addr); + return -ENODEV; + } + + ret = roc_plt_init(); + if (ret) + return ret; + + rvu_lf_rawdev_get_name(name, pci_dev); + rvu_lf_rawdev = rte_rawdev_pmd_allocate(name, sizeof(*roc_rvu_lf), + rte_socket_id()); + if (rvu_lf_rawdev == NULL) { + CNXK_RVU_LF_LOG(ERR, "Failed to allocate rawdev"); + return -ENOMEM; + } + + rvu_lf_rawdev->dev_ops = &rvu_lf_rawdev_ops; + rvu_lf_rawdev->device = &pci_dev->device; + rvu_lf_rawdev->driver_name = pci_dev->driver->driver.name; + + roc_rvu_lf = (struct roc_rvu_lf *)rvu_lf_rawdev->dev_private; + roc_rvu_lf->pci_dev = pci_dev; + + ret = roc_rvu_lf_dev_init(roc_rvu_lf); + if (ret) { + rte_rawdev_pmd_release(rvu_lf_rawdev); + return ret; + } + + return 0; +} + +static int +rvu_lf_remove(struct rte_pci_device *pci_dev) +{ + char name[RTE_RAWDEV_NAME_MAX_LEN]; + struct roc_rvu_lf *roc_rvu_lf; + struct rte_rawdev *rawdev; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + if (pci_dev == NULL) { + CNXK_RVU_LF_LOG(ERR, "invalid pci_dev"); + return -EINVAL; + } + + rvu_lf_rawdev_get_name(name, pci_dev); + rawdev = rte_rawdev_pmd_get_named_dev(name); + if (rawdev == NULL) { + CNXK_RVU_LF_LOG(ERR, "invalid device name (%s)", name); + return -EINVAL; + } + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + roc_rvu_lf_dev_fini(roc_rvu_lf); + + return rte_rawdev_pmd_release(rawdev); +} + +static const struct rte_pci_id pci_rvu_lf_map[] = { + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_BPHY_PF), + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_BPHY_VF), + { + .vendor_id = 0, + }, +}; + +static struct rte_pci_driver cnxk_rvu_lf_rawdev_pmd = { + .id_table = pci_rvu_lf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA, + .probe = rvu_lf_probe, + .remove = rvu_lf_remove, +}; + +RTE_PMD_REGISTER_PCI(rvu_lf_rawdev_pci_driver, cnxk_rvu_lf_rawdev_pmd); +RTE_PMD_REGISTER_PCI_TABLE(rvu_lf_rawdev_pci_driver, pci_rvu_lf_map); +RTE_PMD_REGISTER_KMOD_DEP(rvu_lf_rawdev_pci_driver, "vfio-pci"); +RTE_LOG_REGISTER_SUFFIX(cnxk_logtype_rvu_lf, rvu_lf, INFO); diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build new file mode 100644 index 0000000000..32081e147f --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/meson.build @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2024 Marvell. +# + +deps += ['bus_pci', 'common_cnxk', 'rawdev'] +sources = files( + 'cnxk_rvu_lf.c', +) +require_iova_in_mbuf = false diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h new file mode 100644 index 0000000000..2d3cd032b7 --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#ifndef _CNXK_RVU_LF_H_ +#define _CNXK_RVU_LF_H_ + +#include + +#include +#include +#include +#include +#include + +/** + * @file rte_pmd_rvu_lf.h + * + * Marvell RVU LF raw PMD specific structures and interface + * + * This API allows applications to manage RVU LF device in user space along with + * installing interrupt handlers for low latency signal processing. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int cnxk_logtype_rvu_lf; + +#define CNXK_RVU_LF_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ + "%s(): " fmt "\n", __func__, ## args) + +#ifdef __cplusplus +} +#endif + +#endif /* _CNXK_RVU_LF_H_ */ diff --git a/drivers/raw/meson.build b/drivers/raw/meson.build index 05cad143fe..54221643d5 100644 --- a/drivers/raw/meson.build +++ b/drivers/raw/meson.build @@ -8,6 +8,7 @@ endif drivers = [ 'cnxk_bphy', 'cnxk_gpio', + 'cnxk_rvu_lf', 'dpaa2_cmdif', 'ifpga', 'ntb', From patchwork Sat Sep 7 19:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143788 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CDA445931; Sat, 7 Sep 2024 21:33:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A2E240667; Sat, 7 Sep 2024 21:33:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 55FBE40658 for ; Sat, 7 Sep 2024 21:33:27 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JHfY5012918; Sat, 7 Sep 2024 12:33:26 -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=K pAJkGJxxsnFajr1s/0jYip/mRbvAtRRUVvCN/y7Y44=; b=XY5j8itOJaAi5MV4V SqEASh2hqJe9cPuh7OQpvb/9Kmr/pSdq6kC7rgsRiiQlthO2zlj26otE2In1E/Yc GKoJNYAhNyuAdEwkIJ2jr9sMCjUZyAPb1A9k0uAlP0fTBnPSBhpluOWHN50a398J mlfwN9hdCZCtkKUbFXmIZHDaaapL/ErTz57e6WKmofdpl8PO50YYsq2E26WdYIXl nLKBHCMPghKMZ/nykLL4WawZsDGkRdULoiuVZny/wP1tQ+nIVXr9uop6zjSWC85A YlXtsparwUXXznI/H9YG9CXBnu9fc4YnSWy+xWTWp7MIQkVqBISZtXkAp2ShliPr gFyng== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8knq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:26 -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; Sat, 7 Sep 2024 12:33:25 -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; Sat, 7 Sep 2024 12:33:25 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id A88993F7063; Sat, 7 Sep 2024 12:33:22 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 3/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Date: Sun, 8 Sep 2024 01:03:05 +0530 Message-ID: <20240907193311.1342310-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: hiHW0r5lMM7ygCAiOcI1Mg4DUKkxWtSb X-Proofpoint-ORIG-GUID: hiHW0r5lMM7ygCAiOcI1Mg4DUKkxWtSb 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 rte_pmd_rvu_lf_npa_pf_func_get and rte_pmd_rvu_lf_sso_pf_func_get APIs to get NPA and SSO pffunc for the application use. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++++++ drivers/common/cnxk/roc_npa.c | 6 ++++++ drivers/common/cnxk/roc_npa.h | 3 +++ drivers/common/cnxk/roc_sso.c | 6 ++++++ drivers/common/cnxk/roc_sso.h | 3 +++ drivers/common/cnxk/version.map | 2 ++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 12 ++++++++++++ drivers/raw/cnxk_rvu_lf/meson.build | 1 + drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 18 ++++++++++++++++++ 9 files changed, 58 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 8a0bc22dd5..13184ad4dc 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -38,3 +38,10 @@ kernel driver. When querying the status of the devices, they will appear under the category of "Misc (rawdev) devices", i.e. the command ``dpdk-devbind.py --status-dev misc`` can be used to see the state of those devices alone. + +Get NPA and SSO PF FUNC +----------------------- + +APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()`` +can be used to get the cnxk NPA PF func and SSO PF func which application +can use for NPA/SSO specific configuration. diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c index 6c14c49901..6e6d50f1ce 100644 --- a/drivers/common/cnxk/roc_npa.c +++ b/drivers/common/cnxk/roc_npa.c @@ -17,6 +17,12 @@ roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb) return 0; } +uint16_t +roc_npa_pf_func_get(void) +{ + return idev_npa_pffunc_get(); +} + void roc_npa_pool_op_range_set(uint64_t aura_handle, uint64_t start_iova, uint64_t end_iova) diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h index 4ad5f044b5..1ca7348534 100644 --- a/drivers/common/cnxk/roc_npa.h +++ b/drivers/common/cnxk/roc_npa.h @@ -812,6 +812,9 @@ int __roc_api roc_npa_aura_bp_configure(uint64_t aura_id, uint16_t bpid, uint8_t typedef int (*roc_npa_lf_init_cb_t)(struct plt_pci_device *pci_dev); int __roc_api roc_npa_lf_init_cb_register(roc_npa_lf_init_cb_t cb); +/* Utility functions */ +uint16_t __roc_api roc_npa_pf_func_get(void); + /* Debug */ int __roc_api roc_npa_ctx_dump(void); int __roc_api roc_npa_dump(void); diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c index 293b0c81a1..57ed2a4fed 100644 --- a/drivers/common/cnxk/roc_sso.c +++ b/drivers/common/cnxk/roc_sso.c @@ -319,6 +319,12 @@ roc_sso_hwgrp_base_get(struct roc_sso *roc_sso, uint16_t hwgrp) return dev->bar2 + (RVU_BLOCK_ADDR_SSO << 20 | hwgrp << 12); } +uint16_t +roc_sso_pf_func_get(void) +{ + return idev_sso_pffunc_get(); +} + uint64_t roc_sso_ns_to_gw(uint64_t base, uint64_t ns) { diff --git a/drivers/common/cnxk/roc_sso.h b/drivers/common/cnxk/roc_sso.h index 4ac901762e..3e293a0a69 100644 --- a/drivers/common/cnxk/roc_sso.h +++ b/drivers/common/cnxk/roc_sso.h @@ -103,6 +103,9 @@ int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso, void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws, uint8_t nb_hws); +/* Utility function */ +uint16_t __roc_api roc_sso_pf_func_get(void); + /* Debug */ void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t hwgrp, FILE *f); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index a2baa12f1a..1f593febc3 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -449,6 +449,7 @@ INTERNAL { roc_npa_dev_unlock; roc_npa_dump; roc_npa_lf_init_cb_register; + roc_npa_pf_func_get; roc_npa_pool_create; roc_npa_pool_destroy; roc_npa_pool_op_pc_reset; @@ -516,6 +517,7 @@ INTERNAL { roc_sso_hws_gwc_invalidate; roc_sso_hws_unlink; roc_sso_ns_to_gw; + roc_sso_pf_func_get; roc_sso_rsrc_fini; roc_sso_rsrc_init; roc_tim_fini; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index 50862ca097..2fbde52966 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,18 @@ #include "rte_pmd_rvu_lf.h" +uint16_t +rte_pmd_rvu_lf_npa_pf_func_get(void) +{ + return roc_npa_pf_func_get(); +} + +uint16_t +rte_pmd_rvu_lf_sso_pf_func_get(void) +{ + return roc_sso_pf_func_get(); +} + static const struct rte_rawdev_ops rvu_lf_rawdev_ops = { .dev_selftest = NULL, }; diff --git a/drivers/raw/cnxk_rvu_lf/meson.build b/drivers/raw/cnxk_rvu_lf/meson.build index 32081e147f..d4c934709a 100644 --- a/drivers/raw/cnxk_rvu_lf/meson.build +++ b/drivers/raw/cnxk_rvu_lf/meson.build @@ -6,4 +6,5 @@ deps += ['bus_pci', 'common_cnxk', 'rawdev'] sources = files( 'cnxk_rvu_lf.c', ) +headers = files('rte_pmd_rvu_lf.h') require_iova_in_mbuf = false diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index 2d3cd032b7..c11df14553 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -32,6 +32,24 @@ extern int cnxk_logtype_rvu_lf; rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ "%s(): " fmt "\n", __func__, ## args) +/** + * Obtain NPA PF func + * + * @return + * Returns NPA pf_func on success, 0 in case of invalid pf_func. + */ +__rte_experimental +uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void); + +/** + * Obtain SSO PF func + * + * @return + * Returns SSO pf_func on success, 0 in case of invalid pf_func. + */ +__rte_experimental +uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void); + #ifdef __cplusplus } #endif From patchwork Sat Sep 7 19:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143789 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2873B45931; Sat, 7 Sep 2024 21:33:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 305CD4065F; Sat, 7 Sep 2024 21:33:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 6924D4025E for ; Sat, 7 Sep 2024 21:33:30 +0200 (CEST) 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 487Iv1iW016541; Sat, 7 Sep 2024 12:33:29 -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=T T873bnpCBbeopL2veAV7g4yc39V9Ntq7daaXrBeWvw=; b=A5dZ0aVbRGcIiWzvD TqRoN6s5u1NAI21nWdWgrb0rQapGdqK2EBz288UddISvZJjBj+c0YkZ7w3v3Ry4/ O8a7dy71xXLAWWxsTiWGAbenXT4L7w0kiaHMcobrnuMgqMKAuYUDbljEShx2V45E PLOjWPcM0RwO+LGTM6lDwLGivcSKwtXDgs1SHbTS4hUr3IukcLM4h/RJ6GEup2Ua Y3uUQeZFzwhgGwzZlSA4lkZf4MjX9swaRTCJu+pwoVVyQp4HLNLj3v4i/MtAUwT4 54xoE6i8ciZ1l8plYJpYCe+qO3Hf+VgRxnF4uKhNuCR0uskybCTARI673UZ8buF2 ULKTA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gm6k8ttt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:29 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Sep 2024 12:33:28 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sat, 7 Sep 2024 12:33:28 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 928133F7063; Sat, 7 Sep 2024 12:33:25 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 4/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Date: Sun, 8 Sep 2024 01:03:06 +0530 Message-ID: <20240907193311.1342310-5-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: FQo4WVzAVx9bipGeL4h4XMzsjmXa2D8I X-Proofpoint-GUID: FQo4WVzAVx9bipGeL4h4XMzsjmXa2D8I 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 rte_pmd_rvu_lf_bar_get() API to get BAR address for application to configure hardware. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 7 +++++++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 23 +++++++++++++++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 13184ad4dc..6dfbd466ad 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -45,3 +45,10 @@ Get NPA and SSO PF FUNC APIs ``rte_pmd_rvu_lf_npa_pf_func_get()`` and ``rte_pmd_rvu_lf_sso_pf_func_get()`` can be used to get the cnxk NPA PF func and SSO PF func which application can use for NPA/SSO specific configuration. + +Get BAR addresses +----------------- + +Application can retrieve PCI BAR addresses of the device using the API +``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the +registers of the hardware device. diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index 2fbde52966..fc9facd852 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,29 @@ #include "rte_pmd_rvu_lf.h" +int +rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask) +{ + struct roc_rvu_lf *roc_rvu_lf; + struct rte_rawdev *rawdev; + + rawdev = rte_rawdev_pmd_get_dev(dev_id); + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + if (bar_num > PCI_MAX_RESOURCE || + (roc_rvu_lf->pci_dev->mem_resource[bar_num].addr == NULL)) { + *va = 0; + *mask = 0; + return -ENOTSUP; + } + *va = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].addr); + *mask = (size_t)(roc_rvu_lf->pci_dev->mem_resource[bar_num].len - 1); + + return 0; +} + uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void) { diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index c11df14553..50b43b1785 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -50,6 +50,24 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void); __rte_experimental uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void); +/** + * Get BAR addresses for the RVU LF device. + * + * @param dev_id + * device id of RVU LF device + * @param bar_num + * BAR number for which address is required + * @param[out] va + * Virtual address of the BAR. 0 if not mapped + * @param[out] mask + * BAR address mask, 0 if not mapped + * + * @return + * Returns 0 on success, negative error code otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask); + #ifdef __cplusplus } #endif From patchwork Sat Sep 7 19:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143790 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 911F445931; Sat, 7 Sep 2024 21:33:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CDFD4066E; Sat, 7 Sep 2024 21:33:34 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id BB0C04065C for ; Sat, 7 Sep 2024 21:33:32 +0200 (CEST) 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 487IuQFN015467; Sat, 7 Sep 2024 12:33:31 -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=v EJgEXSZZVQdpRpY+XDrWBUIb1iDU9mWsF8D7SXPE3E=; b=VwRwC0O4pUd84/r9j i2VY7e1WdT4N+3Ri30x9Mi+YOYZ2tOW8wR5O3pBd0ALgrvbdk+jmEwz5VhguLOds EDniYKmpkYk3PjmCV2wGEWeN5cI1Qo+4rrsxdwCIY21LMkt9xXdX9s8mV5SX80x1 57xqgOTvGJeQ1p8MEJQAB4qE7L/JUnnYb57Pxf778YWa3DL1JrpyFMDaIzznLaLr 8jl5FDghEkq/w7X3z7ynACY4zNH4K7SlCZs1e4c8mspJiBxbcmiTI0SGhTtxU7gB juiD5ZWLPH/1XMxen7MnEFU1gS4zCMR85rjJ52JO2xCcwFg5cHM2yFBdMcD/j6Sw mf4Ow== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gm6k8tuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:31 -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; Sat, 7 Sep 2024 12:33:30 -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; Sat, 7 Sep 2024 12:33:30 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 7A3E33F7057; Sat, 7 Sep 2024 12:33:28 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Date: Sun, 8 Sep 2024 01:03:07 +0530 Message-ID: <20240907193311.1342310-6-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dxK8u7B3i2U9aJtCvG2sgMbmsz4fd7wF X-Proofpoint-GUID: dxK8u7B3i2U9aJtCvG2sgMbmsz4fd7wF 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 PMD API rte_pmd_rvu_lf_irq_register() and rte_pmd_rvu_lf_irq_unregister() to register/unregister interrupt handlers for rvu lf raw device. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 +++++ drivers/common/cnxk/roc_rvu_lf.c | 26 ++++++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 5 +++ drivers/common/cnxk/version.map | 2 ++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 ++++++++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 46 ++++++++++++++++++++++++ 6 files changed, 117 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 6dfbd466ad..7bae6b523e 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -52,3 +52,11 @@ Get BAR addresses Application can retrieve PCI BAR addresses of the device using the API ``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the registers of the hardware device. + +Register or remove interrupt handler +------------------------------------ + +Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()`` +or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``. +The irq numbers for which the interrupts are registered is negotiated separately +and is not in scope of the driver. diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 1ae39e746e..63bc149f2a 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) return dev_fini(&rvu->dev, rvu->pci_dev); } + +int +roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *data) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct plt_intr_handle *handle; + + handle = rvu->pci_dev->intr_handle; + + return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq); +} + +int +roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *data) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct plt_intr_handle *handle; + + handle = rvu->pci_dev->intr_handle; + + dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq); + + return 0; +} diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 7ce8065a8b..800bf4e674 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf); int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); +typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg); +int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *cb_arg); +int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *cb_arg); #endif /* _ROC_RVU_LF_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 1f593febc3..a948729688 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -548,5 +548,7 @@ INTERNAL { roc_ree_rule_db_prog; roc_rvu_lf_dev_fini; roc_rvu_lf_dev_init; + roc_rvu_lf_irq_register; + roc_rvu_lf_irq_unregister; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index fc9facd852..b4b6c34eb3 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,36 @@ #include "rte_pmd_rvu_lf.h" +int +rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *data) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data); +} + +int +rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *data) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data); +} + int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask) { diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index 50b43b1785..e39133f879 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -32,6 +32,52 @@ extern int cnxk_logtype_rvu_lf; rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ "%s(): " fmt "\n", __func__, ## args) +/** + * Signature of callback function called when an interrupt is received on RVU LF device. + * + * @param cb_arg + * pointer to the information received on an interrupt + */ +typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg); + +/** + * Register interrupt callback + * + * Registers an interrupt callback to be executed when interrupt is raised. + * + * @param dev_id + * device id of RVU LF device + * @param irq + * interrupt number for which interrupt will be raised + * @param cb + * callback function to be executed + * @param cb_arg + * argument to be passed to callback function + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg); + +/** + * Unregister interrupt callback + * + * @param dev_id + * device id of RVU LF device + * @param irq + * interrupt number + * @param cb + * callback function registered + * @param cb_arg + * argument to be passed to callback function + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg); + /** * Obtain NPA PF func * From patchwork Sat Sep 7 19:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143791 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4F4545931; Sat, 7 Sep 2024 21:34:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D357A40671; Sat, 7 Sep 2024 21:33:37 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6B79440671 for ; Sat, 7 Sep 2024 21:33:35 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JR38S027582; Sat, 7 Sep 2024 12:33:34 -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=C LaRs/bMlG7bvvokikugGwVbSb5gFUvnKHoJUr96FNQ=; b=HUUhMpa1QkMUC0SQm BzFWO5cmEFICX/JvjtyzADAkUR+ZTdJ5HGQFy232gPGH6LSDZzphidYHgGlPuKYn K/ZhP33fCMhHW4MLh1856zYSs9Y89k78ijlbgXVNmQP8uW8Ljlq1r9NXL+RXHYtg vA9v8Y8KlTg46zc3au78yhtmTJczTxqVPGBF7iDjdUkWY84TbE5uykHmGz8yJVNW 0RdVzFyz2Y0TJ0Z+LhYHYdqyGTWoCODADoriPWf9bC0tENd1fxYGTCA0UVRnHNuB 3VQFA4d4Elauc5PRJza5+YhUC+hDR+vmduKXf5be9PXlACI00JIcv6r/877PaXWV amc/g== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8kpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:34 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Sep 2024 12:33:34 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sat, 7 Sep 2024 12:33:33 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 624053F7057; Sat, 7 Sep 2024 12:33:31 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 6/9] raw/cnxk_rvu_lf: register/unregister msg handler Date: Sun, 8 Sep 2024 01:03:08 +0530 Message-ID: <20240907193311.1342310-7-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: YnH7rFf0fZOvu-3NJyQh6idU50wufeSM X-Proofpoint-ORIG-GUID: YnH7rFf0fZOvu-3NJyQh6idU50wufeSM 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 PMD APIs rte_pmd_rvu_lf_msg_handler_register() and rte_pmd_rvu_lf_msg_handler_unregister() to register/unregister mailbox message handlers. These handlers are needed to fill response at the other side for the request sent from one side. Signed-off-by: Akhil Goyal --- drivers/common/cnxk/roc_dev_priv.h | 6 +++ drivers/common/cnxk/roc_rvu_lf.c | 25 ++++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 7 ++++ drivers/common/cnxk/version.map | 2 + drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 28 ++++++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 49 ++++++++++++++++++++++++ 6 files changed, 117 insertions(+) diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h index 4af9513733..0235415bcf 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -39,11 +39,17 @@ typedef void (*link_status_get_t)(void *roc_nix, /* Representee notification callback */ typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg); +/* RVU Message process callback */ +typedef int (*msg_process_cb_t)(uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, + void **rsp, uint16_t *rsp_len); + struct dev_ops { link_info_t link_status_update; ptp_info_t ptp_info_update; link_status_get_t link_status_get; q_err_cb_t q_err_cb; + msg_process_cb_t msg_process_cb; repte_notify_t repte_notify; }; diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 63bc149f2a..2e1be81e52 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -87,3 +87,28 @@ roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, return 0; } + +int +roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, roc_rvu_lf_msg_handler_cb_fn cb) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct dev *dev = &rvu->dev; + + if (cb == NULL) + return -EINVAL; + + dev->ops->msg_process_cb = (msg_process_cb_t)cb; + + return 0; +} + +int +roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct dev *dev = &rvu->dev; + + dev->ops->msg_process_cb = NULL; + + return 0; +} diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 800bf4e674..90a0b5690a 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -22,8 +22,15 @@ int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg); +typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, + void **rsp, uint16_t *rsp_len); + int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, roc_rvu_lf_intr_cb_fn cb, void *cb_arg); int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, roc_rvu_lf_intr_cb_fn cb, void *cb_arg); +int __roc_api roc_rvu_lf_msg_handler_register(struct roc_rvu_lf *roc_rvu_lf, + roc_rvu_lf_msg_handler_cb_fn cb); +int __roc_api roc_rvu_lf_msg_handler_unregister(struct roc_rvu_lf *roc_rvu_lf); #endif /* _ROC_RVU_LF_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index a948729688..c850b17dbb 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -550,5 +550,7 @@ INTERNAL { roc_rvu_lf_dev_init; roc_rvu_lf_irq_register; roc_rvu_lf_irq_unregister; + roc_rvu_lf_msg_handler_register; + roc_rvu_lf_msg_handler_unregister; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index b4b6c34eb3..ced77bb36e 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,34 @@ #include "rte_pmd_rvu_lf.h" +int +rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_msg_handler_register(roc_rvu_lf, (roc_rvu_lf_msg_handler_cb_fn)cb); +} + +int +rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_msg_handler_unregister(roc_rvu_lf); +} + int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq, rte_pmd_rvu_lf_intr_callback_fn cb, void *data) diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index e39133f879..51701cc49c 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -32,6 +32,55 @@ extern int cnxk_logtype_rvu_lf; rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ "%s(): " fmt "\n", __func__, ## args) +/** + * Signature of callback function called when a message process handler is called + * on RVU LF device. + * + * @param vf + * VF number(0 to N) from which message is received (ignored in case of PF) + * @param msg_id + * message id + * @param req + * pointer to message request + * @param req_len + * pointer to message request + * @param[out] rsp + * pointer to message response + * @param[out] rsp_len + * length of message response + * + * @return 0 when response is set, negative value otherwise + */ +typedef int (*rte_pmd_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, + void **rsp, uint16_t *rsp_len); + +/** + * Register message handler callback + * + * Registers message handler callback to be executed when the message is received from peer. + * + * @param dev_id + * device id of RVU LF device + * @param cb + * callback function to be executed + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb); + +/** + * Unregister message handler callback + * + * @param dev_id + * device id of RVU LF device + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id); + /** * Signature of callback function called when an interrupt is received on RVU LF device. * From patchwork Sat Sep 7 19:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143792 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A78945931; Sat, 7 Sep 2024 21:34:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 91E2D4068A; Sat, 7 Sep 2024 21:33:40 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1DA2B4067C for ; Sat, 7 Sep 2024 21:33:39 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JGVN2010560; Sat, 7 Sep 2024 12:33:38 -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=S LDd+gvJmJk+IHT+8w3hZI7FM8ykIu+URLkVon3CSIs=; b=ZUern2mBM9gfvZ9n1 xm8pHSctJJtkrv96ulTWV1o7SXsiCKjXqq1rNgcis/YQ7/PhdhcMcNPy8g8YxcLN N2A02W58nebpl9IJ/oX6N1VFh0umw/1ovkTvwCtvPTplWnLnaYCCSZiFO9XOBJ5v JCMSIBVY7qyCxPgFuIM+qXwykIpKJ9DGsP2esuVeBC03RaCryEAW5uBJhWJO3HDx nGMUwAL+a6xDfPq17OxvyXNZ4bfgySPBP93S4mbCTI5eGwqDz+Vfyo52kiMzzYtr tcTbdmGgU3NYhA62ntTwq7kP8ePdCsXx/GZyrfzgIVR31wo6Ka9/2YLAEZ1vVS18 BQn5g== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8kqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:38 -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; Sat, 7 Sep 2024 12:33:36 -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; Sat, 7 Sep 2024 12:33:36 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 4A1A03F7057; Sat, 7 Sep 2024 12:33:34 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 7/9] raw/cnxk_rvu_lf: set message ID range Date: Sun, 8 Sep 2024 01:03:09 +0530 Message-ID: <20240907193311.1342310-8-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 5gezYRwLwVbwIDK5eDhLK9CVSs7wWuhU X-Proofpoint-ORIG-GUID: 5gezYRwLwVbwIDK5eDhLK9CVSs7wWuhU 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 PMD API rte_pmd_rvu_lf_msg_id_range_set() to set RVU mailbox message id range. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 12 ++++++++++ drivers/common/cnxk/roc_mbox.h | 1 + drivers/common/cnxk/roc_rvu_lf.c | 30 ++++++++++++++++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 3 +++ drivers/common/cnxk/version.map | 2 ++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 14 +++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 15 ++++++++++++ 7 files changed, 77 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 7bae6b523e..7f193e232c 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -60,3 +60,15 @@ Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register( or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``. The irq numbers for which the interrupts are registered is negotiated separately and is not in scope of the driver. + +RVU LF RAW MESSAGE PROCESSING +----------------------------- + +Once a RVU LF raw device is probed, a range of message ids can be configured for +which mailboxes will be sent using the API ``rte_pmd_rvu_lf_msg_id_range_set``. + +For processing of mailboxes received on PF/VF application, application +can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()`` +and fill required responses as per the request and message id received. +Application can also unregister already registered message callbacks using +``rte_pmd_rvu_lf_msg_handler_unregister()``. diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index f1a3371ef9..3018a4f73e 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -54,6 +54,7 @@ struct mbox_msghdr { #define MBOX_MSG_MASK 0xFFFF #define MBOX_MSG_INVALID 0xFFFE #define MBOX_MSG_MAX 0xFFFF +#define MBOX_MSG_GENERIC_MAX_ID 0x1FF #define MBOX_MESSAGES \ /* Generic mbox IDs (range 0x000 - 0x1FF) */ \ diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 2e1be81e52..1026ccc125 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -62,6 +62,36 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) return dev_fini(&rvu->dev, rvu->pci_dev); } +int +roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + + if (from <= MBOX_MSG_GENERIC_MAX_ID || from > to) + return -EINVAL; + + rvu->msg_id_from = from; + rvu->msg_id_to = to; + + return 0; +} + +bool +roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id) +{ + struct rvu_lf *rvu; + + if (roc_rvu_lf == NULL) + return 0; + + rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + + if (msg_id > rvu->msg_id_from && msg_id < rvu->msg_id_to) + return 1; + + return 0; +} + int roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, roc_rvu_lf_intr_cb_fn cb, void *data) diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 90a0b5690a..7243e170b9 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -21,6 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf); int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); +int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, + uint16_t from, uint16_t to); +bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id); typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg); typedef int (*roc_rvu_lf_msg_handler_cb_fn)(uint16_t vf, uint16_t msg_id, void *req, uint16_t req_len, diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index c850b17dbb..adfe7ee789 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -552,5 +552,7 @@ INTERNAL { roc_rvu_lf_irq_unregister; roc_rvu_lf_msg_handler_register; roc_rvu_lf_msg_handler_unregister; + roc_rvu_lf_msg_id_range_check; + roc_rvu_lf_msg_id_range_set; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index ced77bb36e..a21bca9ea6 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,20 @@ #include "rte_pmd_rvu_lf.h" +int +rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to); +} + int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb) { diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index 51701cc49c..9ee9c57d7d 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -32,6 +32,21 @@ extern int cnxk_logtype_rvu_lf; rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ "%s(): " fmt "\n", __func__, ## args) +/** + * Set RVU mailbox message id range. + * + * @param dev_id + * device id of RVU LF device + * @param from + * starting message id for RVU mailbox (> 0x1FF) + * @param to + * last message id for RVU mailbox (< 0xFFFF) + * + * @return 0 on success, -EINVAL for invalid range + */ +__rte_experimental +int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to); + /** * Signature of callback function called when a message process handler is called * on RVU LF device. From patchwork Sat Sep 7 19:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143793 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29E2145931; Sat, 7 Sep 2024 21:34:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C9E944067C; Sat, 7 Sep 2024 21:33:43 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id A4F264067B for ; Sat, 7 Sep 2024 21:33:41 +0200 (CEST) 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 487IuQFO015467; Sat, 7 Sep 2024 12:33:40 -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=T zPQDNdXJXnJp/DMGw+7KejNBTaJzg41IgwbUGBTQa4=; b=iR7xykfWIRim3lVDv WF4yBJrACXsdfn1NI+eJZlbOhhhRsg8fuOcGLHuWJ5RTGijEJaMW7uU1/23hQ6PW lW880ffiixeW4gK0nCIFujnxrcNobH6bpzuozk+07CAQhK6UaQTNqRLfOW1RJoHn 0nU2rWtdt99GFys4FYtNDlEPeyXRXdeSkZlX1fl+4hUtsiehw4GlIoiWIU/d0mDx GGO0vZAafwt9kak2KngBx8oyv+UUuhYPsFBZ76Z3dDSmP3n6J/NRi5ITdY/vDkc3 Yz3NamJS3YCNBY8mUnKXNwkswYZC/ViJxtypiH3YdD6FcwwinQJhJLBjAhTY64EA 1nylg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gm6k8tux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:40 -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; Sat, 7 Sep 2024 12:33:39 -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; Sat, 7 Sep 2024 12:33:39 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 339CE3F7057; Sat, 7 Sep 2024 12:33:36 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 8/9] raw/cnxk_rvu_lf: process mailbox message Date: Sun, 8 Sep 2024 01:03:10 +0530 Message-ID: <20240907193311.1342310-9-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: loKAoB-8XFW5RdEXh0lkWvCH1m4Y_vxX X-Proofpoint-GUID: loKAoB-8XFW5RdEXh0lkWvCH1m4Y_vxX 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 PMD API rte_pmd_rvu_lf_msg_process() to process mailbox messages between rvu_lf devices. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 ++ drivers/common/cnxk/roc_dev.c | 117 +++++++++++++++++++++-- drivers/common/cnxk/roc_mbox.h | 1 + drivers/common/cnxk/roc_rvu_lf.c | 58 +++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 5 + drivers/common/cnxk/roc_rvu_lf_priv.h | 5 + drivers/common/cnxk/version.map | 2 + drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 15 +++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 29 ++++++ 9 files changed, 234 insertions(+), 6 deletions(-) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 7f193e232c..7b321abd38 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -72,3 +72,11 @@ can register callbacks using ``rte_pmd_rvu_lf_msg_handler_register()`` and fill required responses as per the request and message id received. Application can also unregister already registered message callbacks using ``rte_pmd_rvu_lf_msg_handler_unregister()``. + +A PMD API ``rte_pmd_rvu_lf_msg_process()`` is created to send a request and +receive corresponding response from the other side(PF/VF). +It accepts an opaque pointer of a request and its size which can be defined by application +and provides an opaque pointer for a response and its length. +PF and VF application can define its own request and response based on the message id +of the mailbox. +For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``. diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index daf7684d8e..806d34143b 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -215,6 +215,51 @@ af_pf_wait_msg(struct dev *dev, uint16_t vf, int num_msg) return req_hdr->num_msgs; } +static int +process_rvu_lf_msgs(struct dev *dev, uint16_t vf, struct mbox_msghdr *msg, size_t size) +{ + uint16_t max_bits = sizeof(dev->active_vfs[0]) * 8; + uint8_t req[MBOX_MSG_REQ_SIZE_MAX]; + struct msg_rsp *rsp; + uint16_t rsp_len; + void *resp; + int rc = 0; + + /* Handle BPHY mailbox message in PF */ + dev->active_vfs[vf / max_bits] |= BIT_ULL(vf % max_bits); + + if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) { + plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX); + return -1; + } + mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr), + size - sizeof(struct mbox_msghdr)); + + rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req, + size - sizeof(struct mbox_msghdr), &resp, &rsp_len); + if (rc < 0) { + plt_err("Failed to process VF%d message", vf); + return -1; + } + + rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_vfpf, vf, + rsp_len + sizeof(struct mbox_msghdr)); + if (!rsp) { + plt_err("Failed to alloc VF%d response message", vf); + return -1; + } + + mbox_rsp_init(msg->id, rsp); + + mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len); + free(resp); + /* PF/VF function ID */ + rsp->hdr.pcifunc = msg->pcifunc; + rsp->hdr.rc = 0; + + return 0; +} + /* PF receives mbox DOWN messages from VF and forwards to AF */ static int vf_pf_process_msgs(struct dev *dev, uint16_t vf) @@ -261,6 +306,9 @@ vf_pf_process_msgs(struct dev *dev, uint16_t vf) /* PF/VF function ID */ rsp->hdr.pcifunc = msg->pcifunc; rsp->hdr.rc = 0; + } else if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) { + if (process_rvu_lf_msgs(dev, vf, msg, size) < 0) + continue; } else { struct mbox_msghdr *af_req; /* Reserve AF/PF mbox message */ @@ -339,8 +387,13 @@ vf_pf_process_up_msgs(struct dev *dev, uint16_t vf) dev_get_vf(msg->pcifunc)); break; default: - plt_err("Not handled UP msg 0x%x (%s) func:0x%x", - msg->id, mbox_id2name(msg->id), msg->pcifunc); + if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) + plt_base_dbg("PF: Msg 0x%x fn:0x%x (pf:%d,vf:%d)", + msg->id, msg->pcifunc, dev_get_pf(msg->pcifunc), + dev_get_vf(msg->pcifunc)); + else + plt_err("Not handled UP msg 0x%x (%s) func:0x%x", + msg->id, mbox_id2name(msg->id), msg->pcifunc); } offset = mbox->rx_start + msg->next_msgoff; } @@ -789,6 +842,49 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req) return -ENODEV; } +static int +process_rvu_lf_msgs_up(struct dev *dev, struct mbox_msghdr *msg, size_t size) +{ + uint8_t req[MBOX_MSG_REQ_SIZE_MAX]; + struct msg_rsp *rsp; + uint16_t rsp_len; + void *resp; + int rc = 0; + + /* Check if valid, if not reply with an invalid msg */ + if (msg->sig != MBOX_REQ_SIG) + return -EIO; + + if ((size - sizeof(struct mbox_msghdr)) > MBOX_MSG_REQ_SIZE_MAX) { + plt_err("MBOX request size greater than %d", MBOX_MSG_REQ_SIZE_MAX); + return -ENOMEM; + } + mbox_memcpy(req, (uint8_t *)msg + sizeof(struct mbox_msghdr), + size - sizeof(struct mbox_msghdr)); + rc = dev->ops->msg_process_cb(dev_get_vf(msg->pcifunc), msg->id, req, + size - sizeof(struct mbox_msghdr), &resp, &rsp_len); + if (rc < 0) { + plt_err("Failed to process VF%d message", dev->vf); + return rc; + } + + rsp = (struct msg_rsp *)mbox_alloc_msg(&dev->mbox_up, 0, + rsp_len + sizeof(struct mbox_msghdr)); + if (!rsp) { + plt_err("Failed to alloc VF%d response message", dev->vf); + return -ENOMEM; + } + + mbox_rsp_init(msg->id, rsp); + + mbox_memcpy((uint8_t *)rsp + sizeof(struct mbox_msghdr), resp, rsp_len); + /* PF/VF function ID */ + rsp->hdr.pcifunc = msg->pcifunc; + rsp->hdr.rc = 0; + + return rc; +} + /* Received up messages from AF (PF context) / PF (in context) */ static void process_msgs_up(struct dev *dev, struct mbox *mbox) @@ -797,6 +893,7 @@ process_msgs_up(struct dev *dev, struct mbox *mbox) struct mbox_hdr *req_hdr; struct mbox_msghdr *msg; int i, err, offset; + size_t size; req_hdr = (struct mbox_hdr *)((uintptr_t)mdev->mbase + mbox->rx_start); if (req_hdr->num_msgs == 0) @@ -809,10 +906,17 @@ process_msgs_up(struct dev *dev, struct mbox *mbox) plt_base_dbg("Message 0x%x (%s) pf:%d/vf:%d", msg->id, mbox_id2name(msg->id), dev_get_pf(msg->pcifunc), dev_get_vf(msg->pcifunc)); - err = mbox_process_msgs_up(dev, msg); - if (err) - plt_err("Error %d handling 0x%x (%s)", err, msg->id, - mbox_id2name(msg->id)); + if (roc_rvu_lf_msg_id_range_check(dev->roc_rvu_lf, msg->id)) { + size = mbox->rx_start + msg->next_msgoff - offset; + err = process_rvu_lf_msgs_up(dev, msg, size); + if (err) + plt_err("Error %d handling 0x%x RVU_LF up msg", err, msg->id); + } else { + err = mbox_process_msgs_up(dev, msg); + if (err) + plt_err("Error %d handling 0x%x (%s)", err, msg->id, + mbox_id2name(msg->id)); + } offset = mbox->rx_start + msg->next_msgoff; } /* Send mbox responses */ @@ -1272,6 +1376,7 @@ dev_vf_hwcap_update(struct plt_pci_device *pci_dev, struct dev *dev) case PCI_DEVID_CNXK_RVU_VF: case PCI_DEVID_CNXK_RVU_SDP_VF: case PCI_DEVID_CNXK_RVU_NIX_INL_VF: + case PCI_DEVID_CNXK_RVU_BPHY_VF: case PCI_DEVID_CNXK_RVU_ESWITCH_VF: dev->hwcap |= DEV_HWCAP_F_VF; break; diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 3018a4f73e..ea806ea6e8 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -55,6 +55,7 @@ struct mbox_msghdr { #define MBOX_MSG_INVALID 0xFFFE #define MBOX_MSG_MAX 0xFFFF #define MBOX_MSG_GENERIC_MAX_ID 0x1FF +#define MBOX_MSG_REQ_SIZE_MAX (16 * 1024) #define MBOX_MESSAGES \ /* Generic mbox IDs (range 0x000 - 0x1FF) */ \ diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 1026ccc125..471dfa7a46 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -62,6 +62,15 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) return dev_fini(&rvu->dev, rvu->pci_dev); } +static uint16_t +roc_rvu_lf_pf_func_get(struct roc_rvu_lf *roc_rvu_lf) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct dev *dev = &rvu->dev; + + return dev->pf_func; +} + int roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to) { @@ -92,6 +101,55 @@ roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id) return 0; } +int +roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, uint16_t vf, uint16_t msg_id, + void *req_data, uint16_t req_len, void *rsp_data, uint16_t rsp_len) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct mbox *mbox; + struct rvu_lf_msg *req; + struct rvu_lf_msg *rsp; + int rc = -ENOSPC; + int devid = 0; + + if (rvu->dev.vf == -1 && roc_rvu_lf_msg_id_range_check(roc_rvu_lf, msg_id)) { + /* This is PF context */ + if (vf >= rvu->dev.maxvf) + return -EINVAL; + devid = vf; + mbox = mbox_get(&rvu->dev.mbox_vfpf_up); + } else { + /* This is VF context */ + devid = 0; /* VF send all message to PF */ + mbox = mbox_get(rvu->dev.mbox); + } + req = (struct rvu_lf_msg *)mbox_alloc_msg_rsp(mbox, devid, + req_len + sizeof(struct rvu_lf_msg), + rsp_len + sizeof(struct rvu_lf_msg)); + if (!req) + goto fail; + mbox_memcpy(req->data, req_data, req_len); + req->hdr.sig = MBOX_REQ_SIG; + req->hdr.id = msg_id; + req->hdr.pcifunc = roc_rvu_lf_pf_func_get(roc_rvu_lf); + + if (rvu->dev.vf == -1) { + mbox_msg_send_up(mbox, devid); + rc = mbox_get_rsp(mbox, devid, (void *)&rsp); + if (rc) + goto fail; + } else { + rc = mbox_process_msg(mbox, (void *)&rsp); + if (rc) + goto fail; + } + if (rsp_len && rsp_data != NULL) + mbox_memcpy(rsp_data, rsp->data, rsp_len); +fail: + mbox_put(mbox); + return rc; +} + int roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, roc_rvu_lf_intr_cb_fn cb, void *data) diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 7243e170b9..6b4819666a 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -21,6 +21,11 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf); int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); +int __roc_api roc_rvu_lf_msg_process(struct roc_rvu_lf *roc_rvu_lf, + uint16_t vf, uint16_t msg_id, + void *req_data, uint16_t req_len, + void *rsp_data, uint16_t rsp_len); + int __roc_api roc_rvu_lf_msg_id_range_set(struct roc_rvu_lf *roc_rvu_lf, uint16_t from, uint16_t to); bool __roc_api roc_rvu_lf_msg_id_range_check(struct roc_rvu_lf *roc_rvu_lf, uint16_t msg_id); diff --git a/drivers/common/cnxk/roc_rvu_lf_priv.h b/drivers/common/cnxk/roc_rvu_lf_priv.h index 8feff82961..57bb713b21 100644 --- a/drivers/common/cnxk/roc_rvu_lf_priv.h +++ b/drivers/common/cnxk/roc_rvu_lf_priv.h @@ -17,6 +17,11 @@ struct rvu_lf { uint16_t msg_id_to; }; +struct rvu_lf_msg { + struct mbox_msghdr hdr; + uint8_t data[]; +}; + static inline struct rvu_lf * roc_rvu_lf_to_rvu_priv(struct roc_rvu_lf *roc_rvu_lf) { diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index adfe7ee789..a3e2170739 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -554,5 +554,7 @@ INTERNAL { roc_rvu_lf_msg_handler_unregister; roc_rvu_lf_msg_id_range_check; roc_rvu_lf_msg_id_range_set; + roc_rvu_lf_msg_process; + local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index a21bca9ea6..66c8e241db 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -29,6 +29,21 @@ rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to) return roc_rvu_lf_msg_id_range_set(roc_rvu_lf, from, to); } +int +rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, void *rsp, uint16_t rsp_len) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_msg_process(roc_rvu_lf, vf, msg_id, req, req_len, rsp, rsp_len); +} + int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handler_cb_fn cb) { diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index 9ee9c57d7d..cb8bced718 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -47,6 +47,35 @@ extern int cnxk_logtype_rvu_lf; __rte_experimental int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to); +/** + * Process a RVU mailbox message. + * + * Message request and response to be sent/received, + * need to be allocated/deallocated by application + * before/after processing the message. + * + * @param dev_id + * device id of RVU LF device + * @param vf + * VF number(0 to N) in case of PF->VF message. 0 is valid as VF0. + * (For VF->PF message, this field is ignored) + * @param msg_id + * message id + * @param req + * pointer to message request data to be sent + * @param req_len + * length of request data + * @param rsp + * pointer to message response expected to be received, NULL if no response + * @param rsp_len + * length of message response expected, 0 if no response + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_msg_process(uint8_t dev_id, uint16_t vf, uint16_t msg_id, + void *req, uint16_t req_len, void *rsp, uint16_t rsp_len); + /** * Signature of callback function called when a message process handler is called * on RVU LF device. From patchwork Sat Sep 7 19:33:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 143794 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4EFC45931; Sat, 7 Sep 2024 21:34:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10F2440673; Sat, 7 Sep 2024 21:33:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id C16B240693 for ; Sat, 7 Sep 2024 21:33:44 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487JQBJ8026194; Sat, 7 Sep 2024 12:33:44 -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=x X6s6MNC9cHggExOXDnXvvQuJ6VLboxNUR4vLR9NrLk=; b=be/gnDX7z+g/3DC+U G/luuT7MYQgVP81JzgSpDbWJAZAIh3uQ43drhHaFcDIB9qoaIt1SvdouoaD2G+Ru J0KcqPBu05r8r0aEcN5ziK4bLXTLk5ZF7IcKzauQI9lCujTOay25tInLT/VaNV4s y28gc6h92llA+aRhBkMENR9Tb2IZP5NF+IWr5ynu4mKRSRPNPrXcQyKOzU9kYcfc NFLKjWpTpgIvVprvn6TxL8sEKEUwb0waaK35sQsKvxBt7S1XalkTzMIeXUpbvplK WOmDzSlsAG83AuWUBm33SC/kx+ALddp0lE+1APuV+4WXESmh67rSpUskFSy9bzca ETwXw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 41gpbf8krp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:43 -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; Sat, 7 Sep 2024 12:33:42 -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; Sat, 7 Sep 2024 12:33:42 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 1C2A93F7057; Sat, 7 Sep 2024 12:33:39 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 9/9] raw/cnxk_rvu_lf: add selftest Date: Sun, 8 Sep 2024 01:03:11 +0530 Message-ID: <20240907193311.1342310-10-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: Bd7vFHon_uWYweq3F8tq8s5uNMEEvi2E X-Proofpoint-ORIG-GUID: Bd7vFHon_uWYweq3F8tq8s5uNMEEvi2E 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 | 18 ++++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 137 +++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 1 deletion(-) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 7b321abd38..59f6506ebb 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -80,3 +80,21 @@ and provides an opaque pointer for a response and its length. PF and VF application can define its own request and response based on the message id of the mailbox. For sample usage of the APIs, please refer to ``rvu_lf_rawdev_selftest()``. + +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 66c8e241db..0c3dbdee9a 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -10,11 +10,146 @@ #include #include #include +#include #include #include "rte_pmd_rvu_lf.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 + +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; +} + +static 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}; + 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"); + + 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; +} + int rte_pmd_rvu_lf_msg_id_range_set(uint8_t dev_id, uint16_t from, uint16_t to) { @@ -138,7 +273,7 @@ rte_pmd_rvu_lf_sso_pf_func_get(void) } static const struct rte_rawdev_ops rvu_lf_rawdev_ops = { - .dev_selftest = NULL, + .dev_selftest = rvu_lf_rawdev_selftest, }; static void