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 911F445931; Sat, 7 Sep 2024 21:33:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CDFD4066E; Sat, 7 Sep 2024 21:33:34 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id BB0C04065C for ; Sat, 7 Sep 2024 21:33:32 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 487IuQFN015467; Sat, 7 Sep 2024 12:33:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=v EJgEXSZZVQdpRpY+XDrWBUIb1iDU9mWsF8D7SXPE3E=; b=VwRwC0O4pUd84/r9j i2VY7e1WdT4N+3Ri30x9Mi+YOYZ2tOW8wR5O3pBd0ALgrvbdk+jmEwz5VhguLOds EDniYKmpkYk3PjmCV2wGEWeN5cI1Qo+4rrsxdwCIY21LMkt9xXdX9s8mV5SX80x1 57xqgOTvGJeQ1p8MEJQAB4qE7L/JUnnYb57Pxf778YWa3DL1JrpyFMDaIzznLaLr 8jl5FDghEkq/w7X3z7ynACY4zNH4K7SlCZs1e4c8mspJiBxbcmiTI0SGhTtxU7gB juiD5ZWLPH/1XMxen7MnEFU1gS4zCMR85rjJ52JO2xCcwFg5cHM2yFBdMcD/j6Sw mf4Ow== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gm6k8tuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Sep 2024 12:33:31 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Sat, 7 Sep 2024 12:33:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Sat, 7 Sep 2024 12:33:30 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id 7A3E33F7057; Sat, 7 Sep 2024 12:33:28 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , "Akhil Goyal" Subject: [PATCH 5/9] raw/cnxk_rvu_lf: register/unregister interrupt handler Date: Sun, 8 Sep 2024 01:03:07 +0530 Message-ID: <20240907193311.1342310-6-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240907193311.1342310-1-gakhil@marvell.com> References: <20240907193311.1342310-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: dxK8u7B3i2U9aJtCvG2sgMbmsz4fd7wF X-Proofpoint-GUID: dxK8u7B3i2U9aJtCvG2sgMbmsz4fd7wF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Added PMD API rte_pmd_rvu_lf_irq_register() and rte_pmd_rvu_lf_irq_unregister() to register/unregister interrupt handlers for rvu lf raw device. Signed-off-by: Akhil Goyal --- doc/guides/rawdevs/cnxk_rvu_lf.rst | 8 +++++ drivers/common/cnxk/roc_rvu_lf.c | 26 ++++++++++++++ drivers/common/cnxk/roc_rvu_lf.h | 5 +++ drivers/common/cnxk/version.map | 2 ++ drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c | 30 ++++++++++++++++ drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h | 46 ++++++++++++++++++++++++ 6 files changed, 117 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_rvu_lf.rst b/doc/guides/rawdevs/cnxk_rvu_lf.rst index 6dfbd466ad..7bae6b523e 100644 --- a/doc/guides/rawdevs/cnxk_rvu_lf.rst +++ b/doc/guides/rawdevs/cnxk_rvu_lf.rst @@ -52,3 +52,11 @@ Get BAR addresses Application can retrieve PCI BAR addresses of the device using the API ``rte_pmd_rvu_lf_bar_get()``. This helps application to configure the registers of the hardware device. + +Register or remove interrupt handler +------------------------------------ + +Application can register interrupt handlers using ``rte_pmd_rvu_lf_irq_register()`` +or remove interrupt handler using ``rte_pmd_rvu_lf_irq_unregister()``. +The irq numbers for which the interrupts are registered is negotiated separately +and is not in scope of the driver. diff --git a/drivers/common/cnxk/roc_rvu_lf.c b/drivers/common/cnxk/roc_rvu_lf.c index 1ae39e746e..63bc149f2a 100644 --- a/drivers/common/cnxk/roc_rvu_lf.c +++ b/drivers/common/cnxk/roc_rvu_lf.c @@ -61,3 +61,29 @@ roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf) return dev_fini(&rvu->dev, rvu->pci_dev); } + +int +roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *data) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct plt_intr_handle *handle; + + handle = rvu->pci_dev->intr_handle; + + return dev_irq_register(handle, (plt_intr_callback_fn)cb, data, irq); +} + +int +roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *data) +{ + struct rvu_lf *rvu = roc_rvu_lf_to_rvu_priv(roc_rvu_lf); + struct plt_intr_handle *handle; + + handle = rvu->pci_dev->intr_handle; + + dev_irq_unregister(handle, (plt_intr_callback_fn)cb, data, irq); + + return 0; +} diff --git a/drivers/common/cnxk/roc_rvu_lf.h b/drivers/common/cnxk/roc_rvu_lf.h index 7ce8065a8b..800bf4e674 100644 --- a/drivers/common/cnxk/roc_rvu_lf.h +++ b/drivers/common/cnxk/roc_rvu_lf.h @@ -21,4 +21,9 @@ TAILQ_HEAD(roc_rvu_lf_head, roc_rvu_lf); int __roc_api roc_rvu_lf_dev_init(struct roc_rvu_lf *roc_rvu_lf); int __roc_api roc_rvu_lf_dev_fini(struct roc_rvu_lf *roc_rvu_lf); +typedef void (*roc_rvu_lf_intr_cb_fn)(void *cb_arg); +int __roc_api roc_rvu_lf_irq_register(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *cb_arg); +int __roc_api roc_rvu_lf_irq_unregister(struct roc_rvu_lf *roc_rvu_lf, unsigned int irq, + roc_rvu_lf_intr_cb_fn cb, void *cb_arg); #endif /* _ROC_RVU_LF_H_ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 1f593febc3..a948729688 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -548,5 +548,7 @@ INTERNAL { roc_ree_rule_db_prog; roc_rvu_lf_dev_fini; roc_rvu_lf_dev_init; + roc_rvu_lf_irq_register; + roc_rvu_lf_irq_unregister; local: *; }; diff --git a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c index fc9facd852..b4b6c34eb3 100644 --- a/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c +++ b/drivers/raw/cnxk_rvu_lf/cnxk_rvu_lf.c @@ -15,6 +15,36 @@ #include "rte_pmd_rvu_lf.h" +int +rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *data) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_irq_register(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data); +} + +int +rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *data) +{ + struct rte_rawdev *rawdev = rte_rawdev_pmd_get_dev(dev_id); + struct roc_rvu_lf *roc_rvu_lf; + + if (rawdev == NULL) + return -EINVAL; + + roc_rvu_lf = (struct roc_rvu_lf *)rawdev->dev_private; + + return roc_rvu_lf_irq_unregister(roc_rvu_lf, irq, (roc_rvu_lf_intr_cb_fn)cb, data); +} + int rte_pmd_rvu_lf_bar_get(uint8_t dev_id, uint8_t bar_num, size_t *va, size_t *mask) { diff --git a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h index 50b43b1785..e39133f879 100644 --- a/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h +++ b/drivers/raw/cnxk_rvu_lf/rte_pmd_rvu_lf.h @@ -32,6 +32,52 @@ extern int cnxk_logtype_rvu_lf; rte_log(RTE_LOG_ ## level, cnxk_logtype_rvu_lf, \ "%s(): " fmt "\n", __func__, ## args) +/** + * Signature of callback function called when an interrupt is received on RVU LF device. + * + * @param cb_arg + * pointer to the information received on an interrupt + */ +typedef void (*rte_pmd_rvu_lf_intr_callback_fn)(void *cb_arg); + +/** + * Register interrupt callback + * + * Registers an interrupt callback to be executed when interrupt is raised. + * + * @param dev_id + * device id of RVU LF device + * @param irq + * interrupt number for which interrupt will be raised + * @param cb + * callback function to be executed + * @param cb_arg + * argument to be passed to callback function + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_irq_register(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg); + +/** + * Unregister interrupt callback + * + * @param dev_id + * device id of RVU LF device + * @param irq + * interrupt number + * @param cb + * callback function registered + * @param cb_arg + * argument to be passed to callback function + * + * @return 0 on success, negative value otherwise + */ +__rte_experimental +int rte_pmd_rvu_lf_irq_unregister(uint8_t dev_id, unsigned int irq, + rte_pmd_rvu_lf_intr_callback_fn cb, void *cb_arg); + /** * Obtain NPA PF func * -- 2.25.1