From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 9A5EC374; Mon, 17 Dec 2018 05:40:33 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Dec 2018 20:40:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,364,1539673200"; d="scan'208";a="126524870" Received: from unknown (HELO broadwell-dev-4.localdomain) ([10.224.122.193]) by fmsmga002.fm.intel.com with ESMTP; 16 Dec 2018 20:40:30 -0800 From: Nikhil Rao To: dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, Nikhil Rao , stable@dpdk.org Date: Mon, 17 Dec 2018 10:09:41 +0530 Message-Id: <1545021581-107579-1-git-send-email-nikhil.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543489908-60688-1-git-send-email-nikhil.rao@intel.com> References: <1543489908-60688-1-git-send-email-nikhil.rao@intel.com> Subject: [dpdk-stable] [PATCH v3] eventdev: fix eth Tx adapter queue count checks X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2018 04:40:34 -0000 rte_event_eth_tx_adapter_queue_add() - add a check that returns an error if the ethdev has zero Tx queues configured. rte_event_eth_tx_adapter_queue_del() - remove the checks for ethdev queue count, instead check for queues added to the adapter which maybe different from the current ethdev queue count. Fixes: a3bbf2e09756 ("eventdev: add eth Tx adapter implementation") Cc: stable@dpdk.org Signed-off-by: Nikhil Rao --- v2: - none (missed adding changes, now in v3) v3: - enclosed macro parameter queue in () lib/librte_eventdev/rte_event_eth_tx_adapter.c | 54 ++++++++++++++++++-------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/lib/librte_eventdev/rte_event_eth_tx_adapter.c b/lib/librte_eventdev/rte_event_eth_tx_adapter.c index ccf8a75..67216a3 100644 --- a/lib/librte_eventdev/rte_event_eth_tx_adapter.c +++ b/lib/librte_eventdev/rte_event_eth_tx_adapter.c @@ -59,6 +59,20 @@ return -EINVAL; \ } while (0) +#define TXA_CHECK_TXQ(dev, queue) \ +do {\ + if ((dev)->data->nb_tx_queues == 0) { \ + RTE_EDEV_LOG_ERR("No tx queues configured"); \ + return -EINVAL; \ + } \ + if ((queue) != -1 && \ + (uint16_t)(queue) >= (dev)->data->nb_tx_queues) { \ + RTE_EDEV_LOG_ERR("Invalid tx queue_id %" PRIu16, \ + (uint16_t)(queue)); \ + return -EINVAL; \ + } \ +} while (0) + /* Tx retry callback structure */ struct txa_retry { /* Ethernet port id */ @@ -795,20 +809,35 @@ static int txa_service_queue_del(uint8_t id, struct rte_eth_dev_tx_buffer *tb; uint16_t port_id; + txa = txa_service_id_to_data(id); + port_id = dev->data->port_id; + if (tx_queue_id == -1) { - uint16_t i; - int ret = -1; + uint16_t i, q, nb_queues; + int ret = 0; - for (i = 0; i < dev->data->nb_tx_queues; i++) { - ret = txa_service_queue_del(id, dev, i); - if (ret != 0) - break; + nb_queues = txa->nb_queues; + if (nb_queues == 0) + return 0; + + i = 0; + q = 0; + tqi = txa->txa_ethdev[port_id].queues; + + while (i < nb_queues) { + + if (tqi[q].added) { + ret = txa_service_queue_del(id, dev, q); + if (ret != 0) + break; + } + i++; + q++; } return ret; } txa = txa_service_id_to_data(id); - port_id = dev->data->port_id; tqi = txa_service_queue(txa, port_id, tx_queue_id); if (tqi == NULL || !tqi->added) @@ -999,11 +1028,7 @@ static int txa_service_queue_del(uint8_t id, TXA_CHECK_OR_ERR_RET(id); eth_dev = &rte_eth_devices[eth_dev_id]; - if (queue != -1 && (uint16_t)queue >= eth_dev->data->nb_tx_queues) { - RTE_EDEV_LOG_ERR("Invalid tx queue_id %" PRIu16, - (uint16_t)queue); - return -EINVAL; - } + TXA_CHECK_TXQ(eth_dev, queue); caps = 0; if (txa_dev_caps_get(id)) @@ -1034,11 +1059,6 @@ static int txa_service_queue_del(uint8_t id, TXA_CHECK_OR_ERR_RET(id); eth_dev = &rte_eth_devices[eth_dev_id]; - if (queue != -1 && (uint16_t)queue >= eth_dev->data->nb_tx_queues) { - RTE_EDEV_LOG_ERR("Invalid tx queue_id %" PRIu16, - (uint16_t)queue); - return -EINVAL; - } caps = 0; -- 1.8.3.1