From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3788AA04C2; Thu, 14 Nov 2019 10:07:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BF401BF19; Thu, 14 Nov 2019 10:05:13 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id AA74D1BEF1 for ; Thu, 14 Nov 2019 10:05:02 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2019 01:05:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,302,1569308400"; d="scan'208";a="406259696" Received: from dpdk-rosen-02.sh.intel.com ([10.67.110.156]) by fmsmga006.fm.intel.com with ESMTP; 14 Nov 2019 01:05:01 -0800 From: Rosen Xu To: dev@dpdk.org Cc: rosen.xu@intel.com, tianfei.zhang@intel.com, andy.pei@intel.com, xiaolong.ye@intel.com, ferruh.yigit@intel.com Date: Thu, 14 Nov 2019 17:03:07 +0800 Message-Id: <1573722187-148846-20-git-send-email-rosen.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573722187-148846-1-git-send-email-rosen.xu@intel.com> References: <1571917119-149534-2-git-send-email-andy.pei@intel.com> <1573722187-148846-1-git-send-email-rosen.xu@intel.com> Subject: [dpdk-dev] [PATCH v18 19/19] raw/ifpga: introducing new irq API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Tianfei zhang Introducing new register and unregister API for ifpga interrupt. 1. register FME and AFU interrupt ifpga_register_msix_irq() 2. unregister FME and AFU interrupt ifpga_unregister_msix_irq() On PAC N3000 card, there is one PCIe MSIX interrupt for FME managerment, like the error report, thermal management, we use this interrupt in ifpga_rawdev device driver. on the other hand, there are about 4 PCIe MSIX interrupts are reserved for AFU which end-user can use those interrupts in their AFU logic design. End-user can use those APIs to register interrupt handler in their AFU drivers. Signed-off-by: Tianfei zhang Signed-off-by: Andy Pei --- drivers/raw/ifpga/ifpga_rawdev.c | 105 +++++++++++++++++++++++++++------------ drivers/raw/ifpga/ifpga_rawdev.h | 14 ++++++ 2 files changed, 88 insertions(+), 31 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 775731c..e083fc5 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -79,6 +79,10 @@ static int ifpga_monitor_start; static pthread_t ifpga_monitor_start_thread; +#define IFPGA_MAX_IRQ 12 +/* 0 for FME interrupt, others are reserved for AFU irq */ +static struct rte_intr_handle ifpga_irq_handle[IFPGA_MAX_IRQ]; + static struct ifpga_rawdev * ifpga_rawdev_allocate(struct rte_rawdev *rawdev); static int set_surprise_link_check_aer( @@ -1328,53 +1332,90 @@ static int fme_clean_fme_error(struct opae_manager *mgr) fme_err_handle_catfatal_error(mgr); } -static struct rte_intr_handle fme_intr_handle; +int +ifpga_unregister_msix_irq(enum ifpga_irq_type type, + int vec_start, rte_intr_callback_fn handler, void *arg) +{ + struct rte_intr_handle intr_handle; + + if (type == IFPGA_FME_IRQ) + intr_handle = ifpga_irq_handle[0]; + else if (type == IFPGA_AFU_IRQ) + intr_handle = ifpga_irq_handle[vec_start + 1]; -static int ifpga_register_fme_interrupt(struct opae_manager *mgr) + rte_intr_efd_disable(&intr_handle); + + return rte_intr_callback_unregister(&intr_handle, + handler, arg); +} + +int +ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id, + enum ifpga_irq_type type, int vec_start, int count, + rte_intr_callback_fn handler, const char *name, + void *arg) { int ret; - struct fpga_fme_err_irq_set err_irq_set; + struct rte_intr_handle intr_handle; + struct opae_adapter *adapter; + struct opae_manager *mgr; + struct opae_accelerator *acc; - fme_intr_handle.type = RTE_INTR_HANDLE_VFIO_MSIX; + adapter = ifpga_rawdev_get_priv(dev); + if (!adapter) + return -ENODEV; - ret = rte_intr_efd_enable(&fme_intr_handle, 1); - if (ret) - return -EINVAL; + mgr = opae_adapter_get_mgr(adapter); + if (!mgr) + return -ENODEV; - fme_intr_handle.fd = fme_intr_handle.efds[0]; + if (type == IFPGA_FME_IRQ) { + intr_handle = ifpga_irq_handle[0]; + count = 1; + } else if (type == IFPGA_AFU_IRQ) + intr_handle = ifpga_irq_handle[vec_start + 1]; - IFPGA_RAWDEV_PMD_DEBUG("vfio_dev_fd=%d, efd=%d, fd=%d\n", - fme_intr_handle.vfio_dev_fd, - fme_intr_handle.efds[0], fme_intr_handle.fd); + intr_handle.type = RTE_INTR_HANDLE_VFIO_MSIX; - err_irq_set.evtfd = fme_intr_handle.efds[0]; - ret = opae_manager_ifpga_set_err_irq(mgr, &err_irq_set); + ret = rte_intr_efd_enable(&intr_handle, count); if (ret) - return -EINVAL; + return -ENODEV; + + intr_handle.fd = intr_handle.efds[0]; + + IFPGA_RAWDEV_PMD_DEBUG("register %s irq, vfio_fd=%d, fd=%d\n", + name, intr_handle.vfio_dev_fd, + intr_handle.fd); + + if (type == IFPGA_FME_IRQ) { + struct fpga_fme_err_irq_set err_irq_set; + err_irq_set.evtfd = intr_handle.efds[0]; + + ret = opae_manager_ifpga_set_err_irq(mgr, &err_irq_set); + if (ret) + return -EINVAL; + } else if (type == IFPGA_AFU_IRQ) { + acc = opae_adapter_get_acc(adapter, port_id); + if (!acc) + return -EINVAL; - /* register FME interrupt using DPDK API */ - ret = rte_intr_callback_register(&fme_intr_handle, - fme_interrupt_handler, - (void *)mgr); + ret = opae_acc_set_irq(acc, vec_start, count, intr_handle.efds); + if (ret) + return -EINVAL; + } + + /* register interrupt handler using DPDK API */ + ret = rte_intr_callback_register(&intr_handle, + handler, (void *)arg); if (ret) return -EINVAL; - IFPGA_RAWDEV_PMD_INFO("success register fme interrupt\n"); + IFPGA_RAWDEV_PMD_INFO("success register %s interrupt\n", name); return 0; } static int -ifpga_unregister_fme_interrupt(struct opae_manager *mgr) -{ - rte_intr_efd_disable(&fme_intr_handle); - - return rte_intr_callback_unregister(&fme_intr_handle, - fme_interrupt_handler, - (void *)mgr); -} - -static int ifpga_rawdev_create(struct rte_pci_device *pci_dev, int socket_id) { @@ -1463,7 +1504,8 @@ static int ifpga_register_fme_interrupt(struct opae_manager *mgr) IFPGA_RAWDEV_PMD_INFO("this is a PF function"); } - ret = ifpga_register_fme_interrupt(mgr); + ret = ifpga_register_msix_irq(rawdev, 0, IFPGA_FME_IRQ, 0, 0, + fme_interrupt_handler, "fme_irq", mgr); if (ret) goto free_adapter_data; @@ -1515,7 +1557,8 @@ static int ifpga_register_fme_interrupt(struct opae_manager *mgr) if (!mgr) return -ENODEV; - if (ifpga_unregister_fme_interrupt(mgr)) + if (ifpga_unregister_msix_irq(IFPGA_FME_IRQ, 0, + fme_interrupt_handler, mgr)) return -EINVAL; opae_adapter_data_free(adapter->data); diff --git a/drivers/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h index bd42083..7754beb 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.h +++ b/drivers/raw/ifpga/ifpga_rawdev.h @@ -62,4 +62,18 @@ struct ifpga_rawdev { struct ifpga_rawdev * ifpga_rawdev_get(const struct rte_rawdev *rawdev); +enum ifpga_irq_type { + IFPGA_FME_IRQ = 0, + IFPGA_AFU_IRQ = 1, +}; + +int +ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id, + enum ifpga_irq_type type, int vec_start, int count, + rte_intr_callback_fn handler, const char *name, + void *arg); +int +ifpga_unregister_msix_irq(enum ifpga_irq_type type, + int vec_start, rte_intr_callback_fn handler, void *arg); + #endif /* _IFPGA_RAWDEV_H_ */ -- 1.8.3.1