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 84498A04F5 for ; Wed, 11 Dec 2019 22:28:08 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A6A62C6A; Wed, 11 Dec 2019 22:28:08 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id BF0861BC25 for ; Wed, 11 Dec 2019 22:28:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576099686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1DqBtFtHLgEt5vFgQJvMFE0UPoJoTy4E73SJr2I8dvc=; b=IINZLXc2Df+pLGOeyxT07ZGd9d9Qwo2TLzFtXoLm2iyYgXDBSBA+7Y+x62OdxrxcjsVMzt noldkFjx1JT2WKKWvxD0LSipQi7EzrSLXeIEz/h94T6mHzxWCkLqiA5AayAj6DVtnbXk24 zT5JIrXaa1wSLE2gpyaGv9aUNVfiTOQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-wYXf8v2wN-iz52aRCBHwcQ-1; Wed, 11 Dec 2019 16:28:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F85CDBE5; Wed, 11 Dec 2019 21:28:02 +0000 (UTC) Received: from rh.redhat.com (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBE4F10013A1; Wed, 11 Dec 2019 21:27:58 +0000 (UTC) From: Kevin Traynor To: Nithin Dabilpuram Cc: Jerin Jacob , Shahed Shaikh , David Marchand , dpdk stable Date: Wed, 11 Dec 2019 21:26:09 +0000 Message-Id: <20191211212702.27851-17-ktraynor@redhat.com> In-Reply-To: <20191211212702.27851-1-ktraynor@redhat.com> References: <20191211212702.27851-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: wYXf8v2wN-iz52aRCBHwcQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'eal: add ack interrupt API' has been queued to LTS release 18.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/17/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasi= ng (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/3e41c8bc75845ff157= a00581797431bf5fb35770 Thanks. Kevin. --- >From 3e41c8bc75845ff157a00581797431bf5fb35770 Mon Sep 17 00:00:00 2001 From: Nithin Dabilpuram Date: Tue, 23 Jul 2019 10:04:18 +0200 Subject: [PATCH] eal: add ack interrupt API [upstream commit a159730c2f3ae3fdabc52c20565470a9d8abd98a] Add new ack interrupt API to avoid using VFIO_IRQ_SET_ACTION_TRIGGER(rte_intr_enable()) for acking interrupt purpose for VFIO based interrupt handlers. This implementation is specific to Linux. Using rte_intr_enable() for acking interrupt has below issues * Time consuming to do for every interrupt received as it will free_irq() followed by request_irq() and all other initializations * A race condition because of a window between free_irq() and request_irq() with packet reception still on and device still enabled and would throw warning messages like below. [158764.159833] do_IRQ: 9.34 No irq handler for vector In this patch, rte_intr_ack() is a no-op for VFIO_MSIX/VFIO_MSI interrupts as they are edge triggered and kernel would not mask the interrupt before delivering the event to userspace and we don't need to ack. Signed-off-by: Nithin Dabilpuram Signed-off-by: Jerin Jacob Tested-by: Shahed Shaikh Signed-off-by: David Marchand (cherry picked from commit a159730c2f3ae3fdabc52c20565470a9d8abd98a) --- lib/librte_eal/bsdapp/eal/eal_interrupts.c | 9 ++ .../common/include/rte_interrupts.h | 21 +++++ lib/librte_eal/linuxapp/eal/eal_interrupts.c | 82 +++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 113 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal_interrupts.c b/lib/librte_eal/bs= dapp/eal/eal_interrupts.c index 2feee2d52..9aa9178d5 100644 --- a/lib/librte_eal/bsdapp/eal/eal_interrupts.c +++ b/lib/librte_eal/bsdapp/eal/eal_interrupts.c @@ -328,4 +328,13 @@ rte_intr_disable(const struct rte_intr_handle *intr_ha= ndle) } =20 +int +rte_intr_ack(const struct rte_intr_handle *intr_handle) +{ +=09if (intr_handle && intr_handle->type =3D=3D RTE_INTR_HANDLE_VDEV) +=09=09return 0; + +=09return -1; +} + static void eal_intr_process_interrupts(struct kevent *events, int nfds) diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_ea= l/common/include/rte_interrupts.h index bcd935805..9d9bda171 100644 --- a/lib/librte_eal/common/include/rte_interrupts.h +++ b/lib/librte_eal/common/include/rte_interrupts.h @@ -7,4 +7,5 @@ =20 #include +#include =20 /** @@ -86,4 +87,24 @@ int rte_intr_enable(const struct rte_intr_handle *intr_h= andle); int rte_intr_disable(const struct rte_intr_handle *intr_handle); =20 +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * It acknowledges an interrupt raised for the specified handle. + * + * This function should be called at the end of each interrupt handler eit= her + * from application or driver, so that currently raised interrupt is acked= and + * further new interrupts are raised. + * + * @param intr_handle + * pointer to the interrupt handle. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +__rte_experimental +int rte_intr_ack(const struct rte_intr_handle *intr_handle); + #ifdef __cplusplus } diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/= linuxapp/eal/eal_interrupts.c index cbac451e1..102a9549e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -196,4 +196,26 @@ vfio_disable_intx(const struct rte_intr_handle *intr_h= andle) { } =20 +/* unmask/ack legacy (INTx) interrupts */ +static int +vfio_ack_intx(const struct rte_intr_handle *intr_handle) +{ +=09struct vfio_irq_set irq_set; + +=09/* unmask INTx */ +=09memset(&irq_set, 0, sizeof(irq_set)); +=09irq_set.argsz =3D sizeof(irq_set); +=09irq_set.count =3D 1; +=09irq_set.flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK; +=09irq_set.index =3D VFIO_PCI_INTX_IRQ_INDEX; +=09irq_set.start =3D 0; + +=09if (ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)) { +=09=09RTE_LOG(ERR, EAL, "Error unmasking INTx interrupts for fd %d\n", +=09=09=09intr_handle->fd); +=09=09return -1; +=09} +=09return 0; +} + /* enable MSI interrupts */ static int @@ -639,4 +661,64 @@ rte_intr_enable(const struct rte_intr_handle *intr_han= dle) } =20 +/** + * PMD generally calls this function at the end of its IRQ callback. + * Internally, it unmasks the interrupt if possible. + * + * For INTx, unmasking is required as the interrupt is auto-masked prior t= o + * invoking callback. + * + * For MSI/MSI-X, unmasking is typically not needed as the interrupt is no= t + * auto-masked. In fact, for interrupt handle types VFIO_MSIX and VFIO_MSI= , + * this function is no-op. + */ +int +rte_intr_ack(const struct rte_intr_handle *intr_handle) +{ +=09if (intr_handle && intr_handle->type =3D=3D RTE_INTR_HANDLE_VDEV) +=09=09return 0; + +=09if (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) +=09=09return -1; + +=09switch (intr_handle->type) { +=09/* Both acking and enabling are same for UIO */ +=09case RTE_INTR_HANDLE_UIO: +=09=09if (uio_intr_enable(intr_handle)) +=09=09=09return -1; +=09=09break; +=09case RTE_INTR_HANDLE_UIO_INTX: +=09=09if (uio_intx_intr_enable(intr_handle)) +=09=09=09return -1; +=09=09break; +=09/* not used at this moment */ +=09case RTE_INTR_HANDLE_ALARM: +=09=09return -1; +#ifdef VFIO_PRESENT +=09/* VFIO MSI* is implicitly acked unlike INTx, nothing to do */ +=09case RTE_INTR_HANDLE_VFIO_MSIX: +=09case RTE_INTR_HANDLE_VFIO_MSI: +=09=09return 0; +=09case RTE_INTR_HANDLE_VFIO_LEGACY: +=09=09if (vfio_ack_intx(intr_handle)) +=09=09=09return -1; +=09=09break; +#ifdef HAVE_VFIO_DEV_REQ_INTERFACE +=09case RTE_INTR_HANDLE_VFIO_REQ: +=09=09return -1; +#endif +#endif +=09/* not used at this moment */ +=09case RTE_INTR_HANDLE_DEV_EVENT: +=09=09return -1; +=09/* unknown handle type */ +=09default: +=09=09RTE_LOG(ERR, EAL, "Unknown handle type of fd %d\n", +=09=09=09intr_handle->fd); +=09=09return -1; +=09} + +=09return 0; +} + int rte_intr_disable(const struct rte_intr_handle *intr_handle) diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_ve= rsion.map index 3fe78260d..f39c18f4d 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -319,4 +319,5 @@ EXPERIMENTAL { =09rte_fbarray_set_free; =09rte_fbarray_set_used; +=09rte_intr_ack; =09rte_log_register_type_and_pick_level; =09rte_malloc_dump_heaps; --=20 2.21.0