From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6298B45BC0; Thu, 24 Oct 2024 15:02:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A1414347A; Thu, 24 Oct 2024 15:02:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id AE6F443461 for ; Thu, 24 Oct 2024 15:01:51 +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 49O9iOfp027547; Thu, 24 Oct 2024 06:01:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=k 3zhsTebwF3LFeBYvnq8KYAIVzSeMc5gWsqqVag5tIE=; b=UxM3haVOUXMfLUg1Q VBClN/xkGoQQeiNm2M35RhM2AxPOjYFBcfNuuV4k8YCJqq9pA8F2aSLgN1vLvkD2 3mPJ4e8fB40wOxXtnHI7AxfeExteMr071AspF2lenYQv1jIcW9CYq1Ynt29pyX4e uHVwydUoN1S9GQn0SoQhEQs+GVCUjfoCOd3rCQLrkfHcCZF0N2+aBAc8Ngh+kKnJ /YjVKC+q+JiiBL2W+GnifGX19KXIJYVivVUQXvcX8/E075ur/TydR4ZBSKQf+3XG 0/iOIwYRkPe2xqmAkYk2Glizkj1QKrQa29LCval2NB8hteBraiQbaqyBr3sL2f6r +zpog== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42fkv4gag1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Oct 2024 06:01:49 -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; Thu, 24 Oct 2024 06:01:47 -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; Thu, 24 Oct 2024 06:01:47 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id AD4113F7098; Thu, 24 Oct 2024 06:01:44 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , , , , Akhil Goyal Subject: [PATCH v4 3/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Date: Thu, 24 Oct 2024 18:31:24 +0530 Message-ID: <20241024130130.3330978-4-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241024130130.3330978-1-gakhil@marvell.com> References: <20241008184915.1356089-1-gakhil@marvell.com> <20241024130130.3330978-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: se1YL-UKHBu5vEGZX-yyr1LgPMaMfqaH X-Proofpoint-GUID: se1YL-UKHBu5vEGZX-yyr1LgPMaMfqaH 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 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/cnxk_rvu_lf_driver.h | 46 ++++++++++++++++++++ drivers/raw/cnxk_rvu_lf/version.map | 2 + 7 files changed, 119 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 13184ad4dc..52e4f12e3c 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -45,3 +45,11 @@ 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. + +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 d4c3e6c425..4e687c1cb8 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -551,5 +551,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 c8490ccbab..c108931f97 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 "cnxk_rvu_lf_driver.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); +} + uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void) { diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h index 3837a6066d..61bbcb7c04 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf_driver.h @@ -40,6 +40,52 @@ uint16_t rte_pmd_rvu_lf_npa_pf_func_get(void); __rte_internal uint16_t rte_pmd_rvu_lf_sso_pf_func_get(void); +/** + * 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_internal +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_internal +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 diff --git a/drivers/raw/cnxk_rvu_lf/version.map b/drivers/raw/cnxk_rvu_lf/version.map index 3b81544aac..a2e8a2c9b3 100644 --- a/drivers/raw/cnxk_rvu_lf/version.map +++ b/drivers/raw/cnxk_rvu_lf/version.map @@ -1,6 +1,8 @@ INTERNAL { global: + rte_pmd_rvu_lf_irq_register; + rte_pmd_rvu_lf_irq_unregister; rte_pmd_rvu_lf_npa_pf_func_get; rte_pmd_rvu_lf_sso_pf_func_get; -- 2.25.1