From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id AA17F695D for ; Wed, 22 Mar 2017 15:58:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490194711; x=1521730711; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=M5SJTnl3BvI76/I/SMp2ay34LP822n5ZuDomC3nw+LM=; b=CuKtWGiSxpPkPvEDqhuC6v4UeX8qmDJfF7E057sLoQIt0p73y/IKMfhO tvitFbnQY4l5+vb86vCS1sIVToWK3w==; Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2017 07:58:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,205,1486454400"; d="scan'208";a="239163044" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by fmsmga004.fm.intel.com with ESMTP; 22 Mar 2017 07:58:29 -0700 From: Gage Eads To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, bruce.richardson@intel.com, hemant.agrawal@nxp.com, harry.van.haaren@intel.com, nipun.gupta@nxp.com, "Eads, Gage" Date: Wed, 22 Mar 2017 09:58:00 -0500 Message-Id: <1490194680-25484-1-git-send-email-gage.eads@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489762288-4710-1-git-send-email-gage.eads@intel.com> References: <1489762288-4710-1-git-send-email-gage.eads@intel.com> Subject: [dpdk-dev] [PATCH v5] eventdev: add errno-style return values 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: , X-List-Received-Date: Wed, 22 Mar 2017 14:58:32 -0000 From: "Eads, Gage" This commit adds rte_errno return values to rte_event_enqueue_burst() and rte_event_dequeue_burst(). These return values allows user software to differentiate between an invalid argument (such as an invalid queue_id or sched_type in an enqueued event) and backpressure from the event device. The port and device ID checks are placed in RTE_LIBRTE_EVENTDEV_DEBUG header guards to avoid the performance hit in non-debug execution. Signed-off-by: Gage Eads --- Changes for v2: - Remove rte_errno initialization Changes for v3: - Fix checkpatch and check-git-log.sh errors Changes for v4: - v3 was incorrectly based on v1, v4 is instead based on v2's changes Changes for v5: - Clarify -ENOSPC description and fix compilation errors lib/librte_eventdev/rte_eventdev.h | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h index 2b30a35..b450622 100644 --- a/lib/librte_eventdev/rte_eventdev.h +++ b/lib/librte_eventdev/rte_eventdev.h @@ -245,6 +245,7 @@ extern "C" { #include #include +#include struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */ @@ -1118,9 +1119,15 @@ rte_event_schedule(uint8_t dev_id) * The number of event objects actually enqueued on the event device. The * return value can be less than the value of the *nb_events* parameter when * the event devices queue is full or if invalid parameters are specified in a - * *rte_event*. If return value is less than *nb_events*, the remaining events - * at the end of ev[] are not consumed,and the caller has to take care of them - * + * *rte_event*. If the return value is less than *nb_events*, the remaining + * events at the end of ev[] are not consumed and the caller has to take care + * of them, and rte_errno is set accordingly. Possible errno values include: + * -(-EINVAL) The port ID is invalid, device ID is invalid, an event's queue + * ID is invalid, or an event's sched type doesn't match the + * capabilities of the destination queue. + * -(-ENOSPC) The event port was backpressured and unable to enqueue + * one or more events. This error code is only applicable to + * closed systems. * @see rte_event_port_enqueue_depth() */ static inline uint16_t @@ -1129,6 +1136,18 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id, { struct rte_eventdev *dev = &rte_eventdevs[dev_id]; +#ifdef RTE_LIBRTE_EVENTDEV_DEBUG + if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) { + rte_errno = -EINVAL; + return 0; + } + + if (port_id >= dev->data->nb_ports) { + rte_errno = -EINVAL; + return 0; + } +#endif + /* * Allow zero cost non burst mode routine invocation if application * requests nb_events as const one @@ -1239,6 +1258,18 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[], { struct rte_eventdev *dev = &rte_eventdevs[dev_id]; +#ifdef RTE_LIBRTE_EVENTDEV_DEBUG + if (dev_id >= RTE_EVENT_MAX_DEVS || !rte_eventdevs[dev_id].attached) { + rte_errno = -EINVAL; + return 0; + } + + if (port_id >= dev->data->nb_ports) { + rte_errno = -EINVAL; + return 0; + } +#endif + /* * Allow zero cost non burst mode routine invocation if application * requests nb_events as const one -- 2.7.4