From patchwork Tue Jun 15 11:03:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 94246 X-Patchwork-Delegate: thomas@monjalon.net 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 060F7A0C47; Tue, 15 Jun 2021 13:07:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F17541202; Tue, 15 Jun 2021 13:04:59 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id C0F8E411B2 for ; Tue, 15 Jun 2021 13:04:57 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15FAxxFk011584 for ; Tue, 15 Jun 2021 04:04:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=RS5+fa/RQU6Xt2ldh8Yv/WNKYjddkWwI0iF858GRP64=; b=L9r5YkI5X/qrRk6CNmo0P+R2hKS2nwK61cEFtxmtuRhzNJy12e+DOq++IXi51ym6CXBT KqGPxM1Eant58JtWIM+pl8Xl39mK09bSEIEvAdn1sS7iBU3TAgjbxNQg5UmOiS61byIt NYSb7mksTWx02K35n021XyMnLWQBqce3+LjhPog4LKoTgLY5FEh+WRxhaLvkJ6SzeYHJ /OzTjVGJNtli7Lqja4Fq3hKAD07qpNVGzWzUuk+wAaycCiCnJvoIrveSicq+wQQVygNW Pe1TXApFRpMAQ1iEKXYkfzaAx5t68X2xNhY1Er3NxGX/rDwEc3k2/iCQV/uNkO1GapOp XQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 396tagr54u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 15 Jun 2021 04:04:57 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Jun 2021 04:04:54 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 15 Jun 2021 04:04:55 -0700 Received: from EH-LT0048.marvell.com (unknown [10.193.32.52]) by maili.marvell.com (Postfix) with ESMTP id 3B3383F70BA; Tue, 15 Jun 2021 04:04:53 -0700 (PDT) From: Tomasz Duszynski To: Jakub Palider , Tomasz Duszynski CC: Date: Tue, 15 Jun 2021 13:03:44 +0200 Message-ID: <20210615110345.11057-32-tduszynski@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210615110345.11057-1-tduszynski@marvell.com> References: <20210531214142.30167-1-tduszynski@marvell.com> <20210615110345.11057-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: u1tx2hVyhK1nmIMUhqKd9Wq0Fzt9Lnxf X-Proofpoint-GUID: u1tx2hVyhK1nmIMUhqKd9Wq0Fzt9Lnxf X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-06-15_04:2021-06-14, 2021-06-15 signatures=0 Subject: [dpdk-dev] [PATCH v2 31/32] raw/cnxk_bphy: support for registering bphy irq handlers 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 Sender: "dev" Custom irq handlers may be registered/removed on demand. Since registration and removal are related they are in the same patch. Signed-off-by: Jakub Palider Signed-off-by: Tomasz Duszynski --- doc/guides/rawdevs/cnxk_bphy.rst | 13 ++++++++ drivers/raw/cnxk_bphy/cnxk_bphy.c | 11 +++++++ drivers/raw/cnxk_bphy/cnxk_bphy_irq.c | 33 ++++++++++++++++++++ drivers/raw/cnxk_bphy/cnxk_bphy_irq.h | 4 +++ drivers/raw/cnxk_bphy/rte_pmd_bphy.h | 45 +++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/doc/guides/rawdevs/cnxk_bphy.rst b/doc/guides/rawdevs/cnxk_bphy.rst index e031f4148..899557df0 100644 --- a/doc/guides/rawdevs/cnxk_bphy.rst +++ b/doc/guides/rawdevs/cnxk_bphy.rst @@ -18,6 +18,7 @@ The BPHY CGX/RPM implements following features in the rawdev API: - Access to BPHY CGX/RPM via a set of predefined messages - Access to BPHY memory +- Custom interrupt handlers Device Setup ------------ @@ -117,6 +118,18 @@ are also two convenience functions namely ``rte_pmd_bphy_intr_init()`` and ``rte_pmd_bphy_intr_fini()`` that take care of all details. +Register or remove interrupt handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Message is used setup custom interrupt handler. + +Message must have type set to ``CNXK_BPHY_IRQ_MSG_TYPE_REGISTER`` or +``CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER``. The former will register an interrupt handler while the +latter will remove it. Prior sending actual message payload i.e ``struct cnxk_bphy_irq_info`` needs +to be filled with relevant information. There are also two convenience functions namely +``rte_pmd_bphy_intr_register()`` and ``rte_pmd_bphy_intr_unregister()`` that take care of all +details. + Get device memory ~~~~~~~~~~~~~~~~~ diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy.c b/drivers/raw/cnxk_bphy/cnxk_bphy.c index 278e26af0..2a516ae73 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy.c +++ b/drivers/raw/cnxk_bphy/cnxk_bphy.c @@ -38,6 +38,7 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev, struct bphy_device *bphy_dev = (struct bphy_device *)dev->dev_private; struct cnxk_bphy_irq_msg *msg = buffers[0]->buf_addr; unsigned int queue = (size_t)context; + struct cnxk_bphy_irq_info *info; int ret = 0; if (queue >= RTE_DIM(bphy_dev->queues)) @@ -53,6 +54,16 @@ cnxk_bphy_irq_enqueue_bufs(struct rte_rawdev *dev, case CNXK_BPHY_IRQ_MSG_TYPE_FINI: cnxk_bphy_intr_fini(dev->dev_id); break; + case CNXK_BPHY_IRQ_MSG_TYPE_REGISTER: + info = (struct cnxk_bphy_irq_info *)msg->data; + ret = cnxk_bphy_intr_register(dev->dev_id, info->irq_num, + info->handler, info->data, + info->cpu); + break; + case CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER: + info = (struct cnxk_bphy_irq_info *)msg->data; + cnxk_bphy_intr_unregister(dev->dev_id, info->irq_num); + break; case CNXK_BPHY_IRQ_MSG_TYPE_MEM_GET: bphy_dev->queues[queue].rsp = &bphy_dev->mem; break; diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c index 13a0d8ad1..bbcc285a7 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c +++ b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.c @@ -58,6 +58,39 @@ cnxk_bphy_intr_fini(uint16_t dev_id) bphy_dev->irq_chip = NULL; } +int +cnxk_bphy_intr_register(uint16_t dev_id, int irq_num, + cnxk_bphy_intr_handler_t handler, void *data, int cpu) +{ + struct roc_bphy_intr intr = { + .irq_num = irq_num, + .intr_handler = handler, + .isr_data = data, + .cpu = cpu + }; + + struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); + struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip; + + if (!irq_chip) + return -ENODEV; + if (!handler || !data) + return -EINVAL; + + return roc_bphy_intr_register(irq_chip, &intr); +} + +void +cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num) +{ + struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); + + if (bphy_dev->irq_chip) + roc_bphy_handler_clear(bphy_dev->irq_chip, irq_num); + else + plt_err("Missing irq chip"); +} + struct bphy_mem * cnxk_bphy_mem_get(uint16_t dev_id) { diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h index 5f87143a0..b55147b93 100644 --- a/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h +++ b/drivers/raw/cnxk_bphy/cnxk_bphy_irq.h @@ -32,6 +32,10 @@ struct bphy_device { int cnxk_bphy_intr_init(uint16_t dev_id); void cnxk_bphy_intr_fini(uint16_t dev_id); struct bphy_mem *cnxk_bphy_mem_get(uint16_t dev_id); +int cnxk_bphy_intr_register(uint16_t dev_id, int irq_num, + cnxk_bphy_intr_handler_t handler, + void *isr_data, int cpu); +void cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num); uint64_t cnxk_bphy_irq_max_get(uint16_t dev_id); #endif /* _CNXK_BPHY_IRQ_ */ diff --git a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h index d08b14b57..f3387f38e 100644 --- a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h +++ b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h @@ -118,6 +118,8 @@ struct cnxk_bphy_irq_msg { enum cnxk_bphy_irq_msg_type type; /* * The data field, depending on message type, may point to + * - (enq) full struct cnxk_bphy_irq_info for registration request + * - (enq) struct cnxk_bphy_irq_info with irq_num set for unregistration * - (deq) struct cnxk_bphy_mem for memory range request response * - (xxx) NULL */ @@ -161,6 +163,49 @@ rte_pmd_bphy_intr_fini(uint16_t dev_id) rte_rawdev_enqueue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE); } +static __rte_always_inline int +rte_pmd_bphy_intr_register(uint16_t dev_id, int irq_num, + cnxk_bphy_intr_handler_t handler, void *data, + int cpu) +{ + struct cnxk_bphy_irq_info info = { + .irq_num = irq_num, + .handler = handler, + .data = data, + .cpu = cpu, + }; + struct cnxk_bphy_irq_msg msg = { + .type = CNXK_BPHY_IRQ_MSG_TYPE_REGISTER, + .data = &info + }; + struct rte_rawdev_buf *bufs[1]; + struct rte_rawdev_buf buf; + + buf.buf_addr = &msg; + bufs[0] = &buf; + + return rte_rawdev_enqueue_buffers(dev_id, bufs, 1, CNXK_BPHY_DEF_QUEUE); +} + +static __rte_always_inline void +rte_pmd_bphy_intr_unregister(uint16_t dev_id, int irq_num) +{ + struct cnxk_bphy_irq_info info = { + .irq_num = irq_num, + }; + struct cnxk_bphy_irq_msg msg = { + .type = CNXK_BPHY_IRQ_MSG_TYPE_UNREGISTER, + .data = &info + }; + struct rte_rawdev_buf *bufs[1]; + struct rte_rawdev_buf buf; + + buf.buf_addr = &msg; + bufs[0] = &buf; + + rte_rawdev_enqueue_buffers(dev_id, bufs, 1, 0); +} + static __rte_always_inline struct cnxk_bphy_mem * rte_pmd_bphy_intr_mem_get(uint16_t dev_id) {