From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B20BA0C48; Tue, 6 Jul 2021 22:29:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C5DD413FE; Tue, 6 Jul 2021 22:29:18 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id E95DD413E3 for ; Tue, 6 Jul 2021 22:29:14 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="196470343" X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="196470343" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 13:29:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,329,1616482800"; d="scan'208";a="486522081" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:13 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Chengwen Feng , Jerin Jacob , Jerin Jacob , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson Date: Tue, 6 Jul 2021 21:28:38 +0100 Message-Id: <20210706202841.661302-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210706202841.661302-1-bruce.richardson@intel.com> References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <20210706202841.661302-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [RFC UPDATE PATCH 6/9] dmadev: allow NULL parameters to completed ops call X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Allow the user to skip passing the "out" parameters to the rte_dmadev_completed() API call, by using local replacements in the inline function. This simplifies drivers, and compilers should be able to remove the branches at compile time in many cases. Signed-off-by: Bruce Richardson --- lib/dmadev/rte_dmadev.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index 8cfe14dd2..eb78f3805 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -698,9 +698,11 @@ rte_dmadev_perform(uint16_t dev_id, uint16_t vq_id) * @param nb_cpls * The maximum number of completed operations that can be processed. * @param[out] last_idx - * The last completed operation's index, as returned when entry was enqueued + * The last completed operation's index, as returned when entry was enqueued. + * If not required, NULL can be passed in. * @param[out] has_error * Indicates if there are transfer error. + * If not required, may be passed as NULL. * * @return * The number of operations that successful completed. @@ -714,7 +716,20 @@ rte_dmadev_completed(uint16_t dev_id, uint16_t vq_id, const uint16_t nb_cpls, uint16_t *last_idx, bool *has_error) { struct rte_dmadev *dev = &rte_dmadevices[dev_id]; - has_error = false; + bool err = false; + uint16_t idx; + + /* ensure the pointer values are non-null to simplify drivers. + * In most cases these should be compile time evaluated, since this is an inline function. + * - If NULL is explicitly passed as parameter, then compiler knows the value is NULL + * - If address of local variable is passed as parameter, then compiler can + * know it's non-NULL. + */ + if (has_error == NULL) + has_error = &err; + if (last_idx == NULL) + last_idx = &idx; + return (*dev->completed)(dev, vq_id, nb_cpls, last_idx, has_error); } -- 2.30.2