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 633C6A04C2; Mon, 25 Nov 2019 12:35:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2FA1E4C99; Mon, 25 Nov 2019 12:35:50 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 96D9C28EE for ; Mon, 25 Nov 2019 12:35:47 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAPBUloa024978; Mon, 25 Nov 2019 03:35:46 -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=IPdqpmnaQ9wc8giCgyKcDw8l/Ir+HtELGkMyl521L6E=; b=t8JHwHfQCRphMr0Q9Nt9Q3R0/nlUKnKNoPReHGFl6TbsombNFrt+ff0eK7SLKTerOf// 4ThVagaomLd6e+FoeGmKPoRiVNhegKtn3M2ITH/Mti5tQZpYbH+9r6mgAvrGOJmgI2SW B0h26duXSP4eWnTDL76Ff7WjmHq5TTm6E48fJ6sYlqwnpeQva12p8YJDX90L2iKotW8n jeVthTn7izCItsRbZBRvOpKmnypmJulnJFEZkgLiIIuhQCwx0ArmNRduT4LSk7sYpM5N SUuM8kkDPnX43v42VQmWwtG0SWPnhMXVFs+KX8rn/IMw39rqxEDnb5/gDUwEeOUBTEw6 Xg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2wf93gwdsr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 25 Nov 2019 03:35:46 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 25 Nov 2019 03:35:45 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 25 Nov 2019 03:35:45 -0800 Received: from localhost.localdomain (unknown [10.28.34.200]) by maili.marvell.com (Postfix) with ESMTP id 09CA63F7041; Mon, 25 Nov 2019 03:35:43 -0800 (PST) From: Sunil Kumar Kori To: Bruce Richardson CC: , Sunil Kumar Kori , Harman Kalra Date: Mon, 25 Nov 2019 17:05:34 +0530 Message-ID: <20191125113537.25266-2-skori@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191125113537.25266-1-skori@marvell.com> References: <20191125113537.25266-1-skori@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-25_03:2019-11-21,2019-11-25 signatures=0 Subject: [dpdk-dev] [PATCH v3 2/5] 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" 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 --- V3: * Rebased patch on latest commit V2: * Removed unnecessary if statement * Reworded subject line * Updated return values of API lib/librte_eal/common/include/rte_interrupts.h | 15 +++++++++++++++ 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, 26 insertions(+) diff --git a/lib/librte_eal/common/include/rte_interrupts.h b/lib/librte_eal/common/include/rte_interrupts.h index e3b406abc..0a82e28a8 100644 --- a/lib/librte_eal/common/include/rte_interrupts.h +++ b/lib/librte_eal/common/include/rte_interrupts.h @@ -138,6 +138,21 @@ int rte_intr_disable(const struct rte_intr_handle *intr_handle); __rte_experimental int rte_intr_ack(const struct rte_intr_handle *intr_handle); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Check if currently executing in interrupt context + * + * @return + * - positive in case of interrupt context + * - zero in case of process context + * - negative if unsuccessful + */ +__rte_experimental +int +rte_thread_is_intr(void); + #ifdef __cplusplus } #endif 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 1955324d3..c00f5a575 100644 --- a/lib/librte_eal/linux/eal/eal_interrupts.c +++ b/lib/librte_eal/linux/eal/eal_interrupts.c @@ -1487,3 +1487,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..397e787cf 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -332,4 +332,5 @@ EXPERIMENTAL { # added in 19.11 rte_log_get_stream; rte_mcfg_get_single_file_segments; + rte_thread_is_intr; }; -- 2.17.1