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 3C787A04FD; Tue, 14 Jan 2020 10:05:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3675B1C1E8; Tue, 14 Jan 2020 10:05:05 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id BB5A11C1DF for ; Tue, 14 Jan 2020 10:05:03 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00E911CI013521; Tue, 14 Jan 2020 01:05:03 -0800 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-type; s=pfpt0818; bh=ZHifDXjEen7p0t884t6xFs8A8JzcxzgFtBiH3FXXthE=; b=ivJh4KTX6b8BFma4qvKw7jMrfDKyEz5GhAUoqQ/ij/okbQ9n86J7oc1pTtdJR2zZoie0 LZQ70MqPFNkXdIZo4BLzw3FefOIIFSYObR1aLY7plN27LlIBWT3v65wQPy8rauOprV9q dVXx472SS2327w0cKEz7ayH0eKtEsZAOgwB8aCf5C1gLwOBempqogTr0x4FNMakkA95O 4IE41HxHdPAyQ+Vznu93jl5D7BJHIQJ1F44rYtZDkfi7y+6SMDM8/fOsaHGUz/kfzdiD jkxxENCTXoClakSRIOWGavYZuREbEITNnC0xASHK/C8S6gYoBtGihcSM5jdIzu83Evoz GQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2xgng4uxqr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 14 Jan 2020 01:05:03 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 14 Jan 2020 01:05:00 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 14 Jan 2020 01:05:00 -0800 Received: from localhost.localdomain (unknown [10.28.34.200]) by maili.marvell.com (Postfix) with ESMTP id 28DEE3F703F; Tue, 14 Jan 2020 01:04:58 -0800 (PST) From: Sunil Kumar Kori To: Bruce Richardson CC: , Harman Kalra , Sunil Kumar Kori Date: Tue, 14 Jan 2020 14:34:52 +0530 Message-ID: <20200114090453.4548-1-skori@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191220065645.22858-2-skori@marvell.com> References: <20191220065645.22858-2-skori@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-14_02:2020-01-13, 2020-01-14 signatures=0 Subject: [dpdk-dev] [PATCH v7 1/2] eal: add API to check if its interrupt context 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: Harman Kalra Added an API to check if current execution is in interrupt context. This will be helpful to handle nested interrupt cases. Signed-off-by: Harman Kalra Signed-off-by: Sunil Kumar Kori Reviewed-by: Jerin Jacob --- v7: - No changes. v6: - No changes. v5: - Fix shared library compilation error v4: - No changes. v3: - API Comment is updated as per man page. - Scope updated within the library/driver only. - Remove experimental tag v2: - Rebased patch on 19.11-rc4 lib/librte_eal/common/include/rte_eal_interrupts.h | 11 +++++++++++ lib/librte_eal/freebsd/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/linux/eal/eal_interrupts.c | 5 +++++ lib/librte_eal/rte_eal_version.map | 1 + 4 files changed, 22 insertions(+) diff --git a/lib/librte_eal/common/include/rte_eal_interrupts.h b/lib/librte_eal/common/include/rte_eal_interrupts.h index b370c0d26..19d1d45ab 100644 --- a/lib/librte_eal/common/include/rte_eal_interrupts.h +++ b/lib/librte_eal/common/include/rte_eal_interrupts.h @@ -220,4 +220,15 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle); int rte_intr_cap_multiple(struct rte_intr_handle *intr_handle); +/** + * @internal + * Check if currently executing in interrupt context + * + * @return + * - non zero in case of interrupt context + * - zero in case of process context + */ +int +rte_thread_is_intr(void); + #endif /* _RTE_EAL_INTERRUPTS_H_ */ diff --git a/lib/librte_eal/freebsd/eal/eal_interrupts.c b/lib/librte_eal/freebsd/eal/eal_interrupts.c index f6831b790..ce2a27b4a 100644 --- a/lib/librte_eal/freebsd/eal/eal_interrupts.c +++ b/lib/librte_eal/freebsd/eal/eal_interrupts.c @@ -671,3 +671,8 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle) { RTE_SET_USED(intr_handle); } + +int rte_thread_is_intr(void) +{ + return pthread_equal(intr_thread, pthread_self()); +} diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c index 14ebb108c..cb8e10709 100644 --- a/lib/librte_eal/linux/eal/eal_interrupts.c +++ b/lib/librte_eal/linux/eal/eal_interrupts.c @@ -1488,3 +1488,8 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle) return 0; } + +int rte_thread_is_intr(void) +{ + return pthread_equal(intr_thread, pthread_self()); +} diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index e38d02530..06ed2e9dc 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -91,6 +91,7 @@ DPDK_20.0 { rte_intr_free_epoll_fd; rte_intr_rx_ctl; rte_intr_tls_epfd; + rte_thread_is_intr; rte_keepalive_create; rte_keepalive_dispatch_pings; rte_keepalive_mark_alive; -- 2.17.1