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 DABA6A04B5; Thu, 10 Sep 2020 16:37:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D8341C123; Thu, 10 Sep 2020 16:37:19 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id EEDCA1C119 for ; Thu, 10 Sep 2020 16:37:16 +0200 (CEST) IronPort-SDR: Rj7QsbfJkJN3iXWd1dOPxDb6p9DCxTB7Q0M1F5gZPR4g8+zDADyQMTk1g+vQtp4dq6h3hHkDeK YsKvkwi8Utjw== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="138058427" X-IronPort-AV: E=Sophos;i="5.76,413,1592895600"; d="scan'208";a="138058427" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 07:37:16 -0700 IronPort-SDR: fAGT+5YtjoUYGjHs6BXMG2AnaxZjtW7xH/NEjpSx1MDlLws7Te3nvaIxsDZpBGXkENJ4tWMzIe 9mM6nohVS5YA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,413,1592895600"; d="scan'208";a="304900412" Received: from silpixa00399126.ir.intel.com ([10.237.222.27]) by orsmga006.jf.intel.com with ESMTP; 10 Sep 2020 07:37:15 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: thomas@monjalon.net, Bruce Richardson , Kevin Laatz , Nipun Gupta , Hemant Agrawal Date: Thu, 10 Sep 2020 15:36:08 +0100 Message-Id: <20200910143609.986696-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200910143609.986696-1-bruce.richardson@intel.com> References: <20200709152047.167730-1-bruce.richardson@intel.com> <20200910143609.986696-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 6/7] rawdev: mark start and stop functions optional 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" Not all rawdevs will require a device start/stop function, so rather than requiring such drivers to provide dummy functions, just set the started/stopped rawdev flag from the rawdev layer and return success. Signed-off-by: Kevin Laatz Signed-off-by: Bruce Richardson Acked-by: Nipun Gupta --- lib/librte_rawdev/rte_rawdev.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index fd123bb848..36f3acf2b7 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -398,20 +398,21 @@ rte_rawdev_start(uint16_t dev_id) RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); dev = &rte_rawdevs[dev_id]; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP); - if (dev->started != 0) { RTE_RDEV_ERR("Device with dev_id=%" PRIu8 "already started", dev_id); return 0; } + if (dev->dev_ops->dev_start == NULL) + goto mark_started; + diag = (*dev->dev_ops->dev_start)(dev); - if (diag == 0) - dev->started = 1; - else + if (diag != 0) return diag; +mark_started: + dev->started = 1; return 0; } @@ -425,15 +426,18 @@ rte_rawdev_stop(uint16_t dev_id) RTE_RAWDEV_VALID_DEVID_OR_RET(dev_id); dev = &rte_rawdevs[dev_id]; - RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop); - if (dev->started == 0) { RTE_RDEV_ERR("Device with dev_id=%" PRIu8 "already stopped", dev_id); return; } + if (dev->dev_ops->dev_stop == NULL) + goto mark_stopped; + (*dev->dev_ops->dev_stop)(dev); + +mark_stopped: dev->started = 0; } -- 2.25.1