From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 8678C1B1B5 for ; Tue, 14 Nov 2017 23:44:19 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2017 14:44:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,396,1505804400"; d="scan'208";a="4993625" Received: from txasoft-yocto.an.intel.com (HELO txasoft-yocto.an.intel.com.) ([10.123.72.111]) by orsmga001.jf.intel.com with ESMTP; 14 Nov 2017 14:44:16 -0800 From: Gage Eads To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, harry.van.haaren@intel.com, bruce.richardson@intel.com, hemant.agrawal@nxp.com, nipun.gupta@nxp.com, santosh.shukla@caviumnetworks.com, pbhagavatula@caviumnetworks.com Date: Tue, 14 Nov 2017 16:44:10 -0600 Message-Id: <1510699450-29204-1-git-send-email-gage.eads@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] eventdev: set rte errno in port link/unlink functions 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: Tue, 14 Nov 2017 22:44:20 -0000 The return value for rte_event_port_{link, unlink}() is defined as the "number of {links, unlinks} actually established." However, the eventdev layer's error checking returns negative error values. This commit aligns the eventdev code with the API definition by having it set rte_errno and return 0 if it detects an error. Fixes: 4f0804bbdfb9 ("eventdev: implement the northbound APIs") Signed-off-by: Gage Eads --- lib/librte_eventdev/rte_eventdev.c | 36 ++++++++++++++++++++++++---------- lib/librte_eventdev/rte_eventdev_pmd.h | 8 ++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c index 378ccb5..f000b80 100644 --- a/lib/librte_eventdev/rte_eventdev.c +++ b/lib/librte_eventdev/rte_eventdev.c @@ -830,13 +830,19 @@ rte_event_port_link(uint8_t dev_id, uint8_t port_id, uint16_t *links_map; int i, diag; - RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0); dev = &rte_eventdevs[dev_id]; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_link, -ENOTSUP); + + if (*dev->dev_ops->port_link == NULL) { + RTE_PMD_DEBUG_TRACE("Function not supported\n"); + rte_errno = -ENOTSUP; + return 0; + } if (!is_valid_port(dev, port_id)) { RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); - return -EINVAL; + rte_errno = -EINVAL; + return 0; } if (queues == NULL) { @@ -855,8 +861,10 @@ rte_event_port_link(uint8_t dev_id, uint8_t port_id, } for (i = 0; i < nb_links; i++) - if (queues[i] >= dev->data->nb_queues) - return -EINVAL; + if (queues[i] >= dev->data->nb_queues) { + rte_errno = -EINVAL; + return 0; + } diag = (*dev->dev_ops->port_link)(dev, dev->data->ports[port_id], queues, priorities, nb_links); @@ -881,13 +889,19 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, int i, diag; uint16_t *links_map; - RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0); dev = &rte_eventdevs[dev_id]; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->port_unlink, -ENOTSUP); + + if (*dev->dev_ops->port_unlink == NULL) { + RTE_PMD_DEBUG_TRACE("Function not supported\n"); + rte_errno = -ENOTSUP; + return 0; + } if (!is_valid_port(dev, port_id)) { RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id); - return -EINVAL; + rte_errno = -EINVAL; + return 0; } if (queues == NULL) { @@ -898,8 +912,10 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, } for (i = 0; i < nb_unlinks; i++) - if (queues[i] >= dev->data->nb_queues) - return -EINVAL; + if (queues[i] >= dev->data->nb_queues) { + rte_errno = -EINVAL; + return 0; + } diag = (*dev->dev_ops->port_unlink)(dev, dev->data->ports[port_id], queues, nb_unlinks); diff --git a/lib/librte_eventdev/rte_eventdev_pmd.h b/lib/librte_eventdev/rte_eventdev_pmd.h index 4369d9b..4016fef 100644 --- a/lib/librte_eventdev/rte_eventdev_pmd.h +++ b/lib/librte_eventdev/rte_eventdev_pmd.h @@ -76,6 +76,14 @@ extern "C" { } \ } while (0) +#define RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, errno, retval) do { \ + if (!rte_event_pmd_is_valid_dev((dev_id))) { \ + RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \ + rte_errno = errno; \ + return retval; \ + } \ +} while (0) + #define RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id) do { \ if (!rte_event_pmd_is_valid_dev((dev_id))) { \ RTE_EDEV_LOG_ERR("Invalid dev_id=%d\n", dev_id); \ -- 2.7.4