From 8c658761de160266796a4cafd572236e632ff823 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Thu, 10 Sep 2020 15:36:08 +0100 Subject: [PATCH] rawdev: mark start and stop functions optional 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.20.1