From patchwork Tue Oct 8 18:49: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: 145490 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 507BA45AE7; Tue, 8 Oct 2024 20:49:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F136B40671; Tue, 8 Oct 2024 20:49:28 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 811F64025D for ; Tue, 8 Oct 2024 20:49:27 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498DOpp6015500; Tue, 8 Oct 2024 11:49: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=a AzO91I2FJbjDX4aEJUqCKVZXh9gGTl/JkMeEVKFp+4=; b=REVS9i/Y/uOKFj1tU Ea3QqtEnjD+ElaZ5a/Ze4dHjT6mWuqrS/XX9BN+MpowFMGI/QJ48kW6TQlhjIzIq xQv2eeerY805qPbfcdBtDTjxNUHtpcarc+FjOJW8KOsnm2Fe2Rfn+VP//tnVUFEq 9cq2wwtYYznxT54viBMIHVAy2eLKeItiAV4vgsI236farebiDAbJV8118f54ufxb l71pm6Tizj5HFM4vdbVI+GuJtdz80ry/SazVkcWbJuAvQcngaHMq1MnReCtgl7Uo UGNKRhViIzpE7xpxda8hxwa++0ALhQIK88QGSnBVX6uyFWZSTpKcRzpSnUTVJd9N K2VxQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4255kb8s0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:25 -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; Tue, 8 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:22 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id BAF943F7043; Tue, 8 Oct 2024 11:49:20 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 1/9] drivers/raw: introduce cnxk rvu lf device driver Date: Wed, 9 Oct 2024 00:19:07 +0530 Message-ID: <20241008184915.1356089-2-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: lWtngsDk8pL7f_u7D_1nSplD7zlZTrfC X-Proofpoint-ORIG-GUID: lWtngsDk8pL7f_u7D_1nSplD7zlZTrfC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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 | 3 + 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/cnxk_rvu_lf.h | 35 ++++++++ drivers/raw/cnxk_rvu_lf/meson.build | 9 ++ drivers/raw/meson.build | 1 + 20 files changed, 402 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/cnxk_rvu_lf.h create mode 100644 drivers/raw/cnxk_rvu_lf/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index 812463fe9f..97e934edb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1498,6 +1498,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 dc2ddf1f20..f847aa5d34 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 0e7495a37c..67cd74b28a 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 @@ -63,6 +65,7 @@ #define PCI_SUBSYSTEM_DEVID_CNF10KB 0xBC00 #define PCI_SUBSYSTEM_DEVID_CN20KA 0xA020 +#define PCI_SUBSYSTEM_DEVID_CNF20KA 0xA000 #define PCI_SUBSYSTEM_DEVID_CN9KA 0x0000 #define PCI_SUBSYSTEM_DEVID_CN9KB 0xb400 diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h index 5ab4f72f8f..dd4949b32c 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -141,6 +141,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 6f8a2e02da..9f7c804542 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; @@ -543,5 +546,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..36067909be --- /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 "cnxk_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_CNF20KA, PCI_DEVID_CNXK_RVU_BPHY_PF), + CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF20KA, 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/cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h new file mode 100644 index 0000000000..a23a629500 --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#ifndef _CNXK_RVU_LF_H_ +#define _CNXK_RVU_LF_H_ + +#include + +#include + +/** + * @file cnxk_rvu_lf.h + * + * Marvell RVU LF raw PMD specific internal structures + * + * 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/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/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 Tue Oct 8 18:49: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: 145491 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 7C74545AE7; Tue, 8 Oct 2024 20:49:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A72E4068E; Tue, 8 Oct 2024 20:49:31 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5002C4025D for ; Tue, 8 Oct 2024 20:49:28 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498DOpp8015500; Tue, 8 Oct 2024 11:49:27 -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=j RHXqxQGI0DJPIl/uNqpNPxOV9MKnCK/c/UfySkqYqE=; b=IxaM2MmQy5F7lDoyR 4PjZWgamrsIxEDGcFk6brNCmzJ8SqaGnEQgNv6SoZZVBkWn3P7f/n6tXikGmUMhU DU1l979TraGVa3hZfrhtNCN2T4Wvg9qzRKzMB7yuz8j4IwRkSnzTx8aJ9VP9UMA0 TVVDaFbH25jK6YHZsfEKAHZuSTwtF7dP1ObM1boJ8lN4SnFihV0GXl6i++cr6LyD Jegm8YOtZkHDhHjuGPP2Um5TgfyMYwITwcr1HwDSPKNJwz3/5eQ66Pt24Py/DIV0 jVmo/ElIV6Q9SigHsf4h8fuspYCsD73Pjb51AC/r8vMpWfT19QJt0xUqHeoeWRm1 ToBew== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4255kb8s0s-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:27 -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; Tue, 8 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:25 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 6B1653F7043; Tue, 8 Oct 2024 11:49:23 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 2/9] raw/cnxk_rvu_lf: add PMD API to get npa/sso pffunc Date: Wed, 9 Oct 2024 00:19:08 +0530 Message-ID: <20241008184915.1356089-3-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: _sFbwmAJtQojRk4mo4HIHRQdkc3LS4eh X-Proofpoint-ORIG-GUID: _sFbwmAJtQojRk4mo4HIHRQdkc3LS4eh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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/api/doxy-api-index.md | 1 + 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 | 13 +++++ drivers/raw/cnxk_rvu_lf/meson.build | 1 + drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 51 +++++++++++++++++++ 10 files changed, 93 insertions(+) create mode 100644 drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index f9f0300126..b4dbe51727 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -52,6 +52,7 @@ The public API headers are grouped by topics: [cnxk_crypto](@ref rte_pmd_cnxk_crypto.h), [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h), [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h), + [cnxk_rvu_lf](@ref rte_pmd_cnxk_rvu_lf.h), [dpaa](@ref rte_pmd_dpaa.h), [dpaa2](@ref rte_pmd_dpaa2.h), [mlx5](@ref rte_pmd_mlx5.h), 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 934d7361a9..a33f9a8499 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 fbf75b2fca..f7cb4460e7 100644 --- a/drivers/common/cnxk/roc_npa.h +++ b/drivers/common/cnxk/roc_npa.h @@ -820,6 +820,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 2e3b134bfc..aed8819a1b 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 9f7c804542..dd56caef16 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -451,6 +451,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; @@ -518,6 +519,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 36067909be..43d3a6fa87 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -14,6 +14,19 @@ #include #include "cnxk_rvu_lf.h" +#include "rte_pmd_cnxk_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..a1a010319b 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_cnxk_rvu_lf.h') require_iova_in_mbuf = false diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h new file mode 100644 index 0000000000..ea03e7ac8c --- /dev/null +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2024 Marvell. + */ + +#ifndef _RTE_PMD_CNXK_RVU_LF_H_ +#define _RTE_PMD_CNXK_RVU_LF_H_ + +#include + +#include +#include +#include +#include +#include + +/** + * @file rte_pmd_cnxk_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 + +/** + * 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 + +#endif /* _RTE_PMD_CNXK_RVU_LF_H_ */ From patchwork Tue Oct 8 18:49: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: 145492 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 5DCD345AE7; Tue, 8 Oct 2024 20:49:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACFA140DCA; Tue, 8 Oct 2024 20:49:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 10ECE40B92 for ; Tue, 8 Oct 2024 20:49:30 +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 498CuLuo028717; Tue, 8 Oct 2024 11:49: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=I 4oyiXEEJE3uTwl4R9hy1upPmnJyeQCEQ+4hnv9aHw0=; b=GTG0lAOPCy8tQKRuB 0u1FyTox+k3n2Obz4wlR3GU4W5re/GuVZ2k/dxhfOJEALujCllztv+Q0tK58FGOr bKomFYHKxcpAiqae+bI3/qZ2SlVKE81kBhWQgbI1Z9ZLLfM11U+/8sd2V2TSHdAS XolSZaG2uBj8WKQkFKYSZSgmV/8tiBUIPTJ+/Fkc1A9mhwJvmdvzDxz/gfPVY7HG 2vfYZZmiXbH3NzMhseAfOm4+HDmX6hWXt8ACysMJbkqW2//uBuSf9BUG/yRI5rZc W0ju1XEta3VTSSmt/sk0282A9xXFSflHH+3M2tuReB7/MELvot8txa+OsSfd0Nat NWLkQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 424vg89wng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:28 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 220203F7043; Tue, 8 Oct 2024 11:49:25 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 3/9] raw/cnxk_rvu_lf: add PMD API to get BAR addresses Date: Wed, 9 Oct 2024 00:19:09 +0530 Message-ID: <20241008184915.1356089-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: m7useJQrTy1UvhgK1OlGqtUE-PiHdx3M X-Proofpoint-GUID: m7useJQrTy1UvhgK1OlGqtUE-PiHdx3M 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_cnxk_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 43d3a6fa87..e4ae3c937a 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -16,6 +16,29 @@ #include "cnxk_rvu_lf.h" #include "rte_pmd_cnxk_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_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index ea03e7ac8c..3d44cfc835 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -44,6 +44,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 Tue Oct 8 18:49: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: 145493 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 DEC3945AE7; Tue, 8 Oct 2024 20:49:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 289D740DD5; Tue, 8 Oct 2024 20:49:37 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 805A040BA2 for ; Tue, 8 Oct 2024 20:49:33 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498DOXME015349; Tue, 8 Oct 2024 11:49:32 -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=O m2nkveeh/RFKyAT+wn+ca3lcGQBLTmBZ+lcgu18HPU=; b=dlEYhCbr7NK6/5akX rDVv4SkocyDOLLnWtDPjY36XnrVb4HgSjW4kQ48LAX2dVZtRftHKOiQETWTAPvjR WX/5yq1ZiaFzt2b0KS/6YoypaOchsX5YGzSUhph0PnVUe3L4d6w3qHv35j20Zf7S x4g9GvCVtz68J2ZK9dEQBu9C5dZjeg2R/hCkKIJ+t7NPOBoyq+4s82GtWOZW2W27 xHCfAGwc6OR7G1y4QxB89+uV1GBNihiy0fq/yWMub2ZenLIEDNDRvsUvD4bbAdE0 2VTfdnqDZnjPTBZ71FQpkadMNHLzR/6yfqXIseS65Jqjn0ntYH8uqRP2DB3h5KAb Wy4vg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4255kb8s1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:32 -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; Tue, 8 Oct 2024 11:49:31 -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; Tue, 8 Oct 2024 11:49:31 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id C64A43F7043; Tue, 8 Oct 2024 11:49:28 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 4/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Date: Wed, 9 Oct 2024 00:19:10 +0530 Message-ID: <20241008184915.1356089-5-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: oHZUyJRdnQjNbX77eKyY0nykcTuguNru X-Proofpoint-ORIG-GUID: oHZUyJRdnQjNbX77eKyY0nykcTuguNru X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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_cnxk_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 dd56caef16..2c845cd591 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -550,5 +550,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 e4ae3c937a..6791800935 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -16,6 +16,36 @@ #include "cnxk_rvu_lf.h" #include "rte_pmd_cnxk_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_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index 3d44cfc835..54e4817604 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -62,6 +62,52 @@ uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void); __rte_experimental int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask); +/** + * 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); + #ifdef __cplusplus } #endif From patchwork Tue Oct 8 18:49: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: 145494 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 7C8B245AE7; Tue, 8 Oct 2024 20:50:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6FA7B40E11; Tue, 8 Oct 2024 20:49:38 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8582540DDC for ; Tue, 8 Oct 2024 20:49:35 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498D0HnG019815; Tue, 8 Oct 2024 11:49: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=f FXyYdsygGCcMtKac+ZkT/mkE58+0Yh0PtlaqQ09Kqc=; b=c0IuemutkYezo9z2E nqp5VEx6FpE3db0XJ5n0a0jL2O4FOJpP1RTBqqB8OK/dQIgUZRlwG7/nd7z1RpqY yp19CSk1W9A2ysDxc8z9LR4cQpvPwjrxYpWU6vnNdkIiI2t1/G/h0BvGo8I84Zo5 JLozwWPGtsT0uIkQBP59tyQjeOIngtcR8SWW3DN5eUa3GH0EcEETIexaWbUttJbf eXmTQtk01y9H8+BNCiHsh1vFxLALdswRO+Of1LehnF2ZvT1Fga0N2NWzD3jwDDf1 O4HlHRqUIfKmnHvj57PtxKX3M3RtSyRwGqJDH0jU4+7LCJbI/ZNGvdXPi6dnPce6 CQg+Q== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42557x8un8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:33 -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; Tue, 8 Oct 2024 11:49:33 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 74C6C3F7048; Tue, 8 Oct 2024 11:49:31 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 5/9] raw/cnxk_rvu_lf: register/unregister msg handler Date: Wed, 9 Oct 2024 00:19:11 +0530 Message-ID: <20241008184915.1356089-6-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: KYVMUi8jEW5vmOyEiWNqPhvEDRWbkXq9 X-Proofpoint-ORIG-GUID: KYVMUi8jEW5vmOyEiWNqPhvEDRWbkXq9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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_cnxk_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 dd4949b32c..c766183196 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -46,11 +46,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 2c845cd591..f3c48ae3cb 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -552,5 +552,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 6791800935..13d33867a8 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -16,6 +16,34 @@ #include "cnxk_rvu_lf.h" #include "rte_pmd_cnxk_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_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index 54e4817604..a570507731 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -108,6 +108,55 @@ __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); +/** + * 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); + #ifdef __cplusplus } #endif From patchwork Tue Oct 8 18:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 145495 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 84E6B45AE7; Tue, 8 Oct 2024 20:50:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6176840E31; Tue, 8 Oct 2024 20:49: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 5CBE740DF6 for ; Tue, 8 Oct 2024 20:49:38 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498D052e019675; Tue, 8 Oct 2024 11:49:37 -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 1jAi604D2AdVZ2RTtezyPd0ZQu0nQU3wLI522AJ1t0=; b=a/jJwKkpPCwMlLshk yk/8mu9Zeja6cTgCQWY++xOQU1U28YP2RThoO73XUZl91P/Z+2xSqqi7GlhdVZBc C9Ew7St17IllxfXbSUyqx48he+4mSsBOpa0U/GWJoaVjiTWHd2npoq+7AOA9I/gY k2APwEA+15DQysjCFRskMrH2YO5aAel58JJXLOHMiCmwpozWfEUy+41OY4nyP+e8 D6LrgEEL3Dhgc2vrvl8WJf+DVprHUaZAbrY01iBDbdN2A9aKfVRbjqzUHExkXzp0 ZL/oBoh+dlPdsfEU0gk2UcGz0yHMAHoDuaDP+nTtueXHWLCRdzexcZmhMORN4HGr qgYmQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42557x8uny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:37 -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; Tue, 8 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:36 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 1F32C3F7043; Tue, 8 Oct 2024 11:49:33 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 6/9] raw/cnxk_rvu_lf: set message ID range Date: Wed, 9 Oct 2024 00:19:12 +0530 Message-ID: <20241008184915.1356089-7-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: YA2OS-IuF-DwxM4Xg7_1KcwWe9DaNxLH X-Proofpoint-ORIG-GUID: YA2OS-IuF-DwxM4Xg7_1KcwWe9DaNxLH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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_cnxk_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 dd65946e9e..f8791e9f84 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 f3c48ae3cb..ed390b8575 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -554,5 +554,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 13d33867a8..fcf51da8f6 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -16,6 +16,20 @@ #include "cnxk_rvu_lf.h" #include "rte_pmd_cnxk_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_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index a570507731..a612d1cebd 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -157,6 +157,21 @@ int rte_pmd_rvu_lf_msg_handler_register(uint8_t dev_id, rte_pmd_rvu_lf_msg_handl __rte_experimental int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id); +/** + * 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); + #ifdef __cplusplus } #endif From patchwork Tue Oct 8 18:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 145496 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 E468445AE7; Tue, 8 Oct 2024 20:50:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8986440E26; Tue, 8 Oct 2024 20:49: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 2E35840E39 for ; Tue, 8 Oct 2024 20:49: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 498EJQjK016006; Tue, 8 Oct 2024 11:49: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=j 6iDbDs70b2YuD9m0LMwYRmxhS5WA7cQ3WRQ28B/2rU=; b=axWfNs3pH2wOa2BH+ 37yOImlffaTLOUij/DKZPPFCMIrbUEm7TLINYkJEtoPU6d0nfRCyDfPkRzjUf5jE ASE1B2Jm7QmVerkQpU7G9Hgdyl7mFnQ9fvjNZRz09KbLdaosMbGWFd8WNVDhTTCv IdkPrFW1VKXcHassu1RDt3kb4O3r+Igx43e3f38C16ylSHyv+mgEDlfXIMv2O8OC YyNoRn3G2Id2vBzF3Fl72GsiSFkRIaaYS/kg95zG4X6e7I+1FQ2oWcqHpJgLczhN aRk4hvM12TKkaCpd0+SfGXs5TFynxKupXiiz/DS5rugs4AQXrVOYZoYkjAeZuwR4 u8Y8g== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4256d90nbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49: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; Tue, 8 Oct 2024 11:49:38 -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; Tue, 8 Oct 2024 11:49:38 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id C03CE3F7043; Tue, 8 Oct 2024 11:49:36 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 7/9] raw/cnxk_rvu_lf: process mailbox message Date: Wed, 9 Oct 2024 00:19:13 +0530 Message-ID: <20241008184915.1356089-8-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 5hirc7arP0vCMGqV73G94gKZJ4F0FMrJ X-Proofpoint-ORIG-GUID: 5hirc7arP0vCMGqV73G94gKZJ4F0FMrJ 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 ++ doc/guides/rel_notes/release_24_11.rst | 5 + drivers/common/cnxk/roc_dev.c | 118 +++++++++++++++++- 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_cnxk_rvu_lf.h | 29 +++++ 10 files changed, 240 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/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index b2bd442ee1..dadf058278 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -75,6 +75,11 @@ New Features * Added ethdev driver support for CN20K SoC. +* **Added Marvell cnxk RVU LF rawdev driver.** + + Added a new raw device driver for Marvell cnxk based devices to allow + applications to communicate using mailboxes and notify for the interrupts. + Removed Items ------------- diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index c905d35ea6..cb8d5d03fd 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -218,6 +218,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) @@ -264,6 +309,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 */ @@ -342,8 +390,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; } @@ -792,6 +845,50 @@ 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); + free(resp); + /* 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) @@ -800,6 +897,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) @@ -812,10 +910,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 */ @@ -1304,6 +1409,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 f8791e9f84..4518680684 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 ed390b8575..cd177a7920 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -556,5 +556,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 fcf51da8f6..a54eda5de5 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -30,6 +30,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_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index a612d1cebd..b79bd8ba8e 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -172,6 +172,35 @@ int rte_pmd_rvu_lf_msg_handler_unregister(uint8_t dev_id); __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); + #ifdef __cplusplus } #endif From patchwork Tue Oct 8 18:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 145497 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 61CAC45AE7; Tue, 8 Oct 2024 20:50:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C357840E24; Tue, 8 Oct 2024 20:49:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 00F034067D for ; Tue, 8 Oct 2024 20:49:43 +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 498EJdYZ016096; Tue, 8 Oct 2024 11:49:43 -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=A 0hOn79FqEKBN2GDDoVsuX93THbT09GTYolqY+k3oBk=; b=U+/6A1rUV+OVh3uNw x9/sNLB1tvyny7xhgBtfWW5dUzN9WrJeXJHKRFCeGXgBok3/uDBB7Bkny6Qqm3nD AqVTOZYcIZPKD9TELnHMPgmSqlA8UAWLsSDoZZ9oOkw5yEYWj1jr8vOp9Srr7V6S CEBqqp8uGPcPdm8KeAofZz3NEgEUnsV8BICNpCmVqHkmAudlFuUZV7ytd249IU0u 5liHXRSE06MriVq6ZOpiS/q2rdrkNaySaYOAm6Vf99ckJ9IzbZXPc1yT7iv3+Ywh fqvG88MCIuH5Wg+K2rdKfqsMMxGJlOkhUyhztilTW7wb7g8FqZB+1s8g+42Tyb0U 5sbxg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 4256d90nbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:42 -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; Tue, 8 Oct 2024 11:49:41 -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; Tue, 8 Oct 2024 11:49:41 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 693E13F7043; Tue, 8 Oct 2024 11:49:39 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 8/9] raw/cnxk_rvu_lf: add selftest Date: Wed, 9 Oct 2024 00:19:14 +0530 Message-ID: <20241008184915.1356089-9-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: DwiBqkV_TqRQ4P5sgjtfw0mXJ99hz7ns X-Proofpoint-ORIG-GUID: DwiBqkV_TqRQ4P5sgjtfw0mXJ99hz7ns 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 a54eda5de5..209af006f3 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -10,12 +10,147 @@ #include #include #include +#include #include #include "cnxk_rvu_lf.h" #include "rte_pmd_cnxk_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) { @@ -139,7 +274,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 From patchwork Tue Oct 8 18:49:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 145498 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 2662B45AE7; Tue, 8 Oct 2024 20:50:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 72ABE40E3E; Tue, 8 Oct 2024 20:49:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E5E2F40E72 for ; Tue, 8 Oct 2024 20:49:45 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498D0HaB019789; Tue, 8 Oct 2024 11:49:45 -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=Y Au5VoZOIOpv+CiSCWK50guqoftBhaAEKXOy2sB/Ed8=; b=Py1XY6m59bNaEiXJd Xj8F2A5ZiHgfVGP9flBeumd5ggHRD/NYxUMwiSmilb3C2go8oPk7lFzwMEFhaq8v ZJBs1YDcymj/n87oLhKXWkfPoqOZjqi7+0B11xng385MAWuMUmz/YdgA6qvZ2KoC +kEsKy6lxU5VKemvGOf05KWYrRTWnrscJWoEx/VeG0uzNDyEzHEZzciOjoLD0NJG a0uoreMgqjy67yc9+lOGPwFBstYP7VdtRbIFpEdd9tKhwjChUjQylUqBEN0+bNYv Cz7PExaH+FNc8iMZkegg8QN4w0mRTDc2L1woFWRBILYK7tdmgvm9dr+DoPldc8lK ZABYA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42557x8upe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 11:49:45 -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; Tue, 8 Oct 2024 11:49:44 -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; Tue, 8 Oct 2024 11:49:44 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 168C93F7043; Tue, 8 Oct 2024 11:49:41 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH v3 9/9] raw/cnxk_rvu_lf: add PMD API to get device pffunc Date: Wed, 9 Oct 2024 00:19:15 +0530 Message-ID: <20241008184915.1356089-10-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241008184915.1356089-1-gakhil@marvell.com> References: <20241008105415.1026962-1-gakhil@marvell.com> <20241008184915.1356089-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 0XsDX5mR6VSIgb7Ds2gizqEthnlAddvN X-Proofpoint-ORIG-GUID: 0XsDX5mR6VSIgb7Ds2gizqEthnlAddvN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_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_pf_func_get`` API to get RVU LF device pffunc for the application use. Signed-off-by: Akhil Goyal --- drivers/common/cnxk/roc_rvu_lf.c | 2 +- drivers/common/cnxk/roc_rvu_lf.h | 2 ++ drivers/common/cnxk/version.map | 1 + drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 19 +++++++++++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h | 12 ++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 471dfa7a46..862a201135 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -62,7 +62,7 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) return dev_fini(&rvu->dev, rvu->pci_dev); } -static uint16_t +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); diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 6b4819666a..8c71876cbc 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -21,6 +21,8 @@ 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); +uint16_t __roc_api roc_rvu_lf_pf_func_get(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, diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index cd177a7920..980b770d9b 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -557,6 +557,7 @@ INTERNAL { roc_rvu_lf_msg_id_range_check; roc_rvu_lf_msg_id_range_set; roc_rvu_lf_msg_process; + roc_rvu_lf_pf_func_get; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index 209af006f3..5262b45569 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -73,6 +73,10 @@ rvu_lf_rawdev_selftest(uint16_t dev_id) if (pf_func == 0) CNXK_RVU_LF_LOG(WARNING, "SSO pf_func is invalid"); + pf_func = rte_pmd_rvu_lf_pf_func_get(dev_id); + if (pf_func == 0) + CNXK_RVU_LF_LOG(WARNING, "RVU LF pf_func is invalid"); + 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"); @@ -273,6 +277,21 @@ rte_pmd_rvu_lf_sso_pf_func_get(void) return roc_sso_pf_func_get(); } +uint16_t +rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id) +{ + struct roc_rvu_lf *roc_rvu_lf; + struct rte_rawdev *rawdev; + + rawdev = rte_rawdev_pmd_get_dev(dev_id); + if (rawdev == NULL) + return 0; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_pf_func_get(roc_rvu_lf); +} + static const struct rte_rawdev_ops rvu_lf_rawdev_ops = { .dev_selftest = rvu_lf_rawdev_selftest, }; diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h index b79bd8ba8e..5d167c55a0 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_cnxk_rvu_lf.h @@ -44,6 +44,18 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void); __rte_experimental uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void); +/** + * Obtain RVU LF device PF func + * + * @param dev_id + * device id of RVU LF device + * + * @return + * Returns RVU LF pf_func on success, 0 in case of invalid pf_func. + */ +__rte_experimental +uint16_t rte_pmd_rvu_lf_pf_func_get(uint8_t dev_id); + /** * Get BAR addresses for the RVU LF device. *