From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 6648D2C8 for ; Mon, 14 May 2018 09:36:51 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id BF76C940060; Mon, 14 May 2018 07:36:49 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Mon, 14 May 2018 00:36:47 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Mon, 14 May 2018 00:36:46 -0700 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w4E7aj1E012991; Mon, 14 May 2018 08:36:45 +0100 Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id w4E7aj7r030550; Mon, 14 May 2018 08:36:45 +0100 From: Andrew Rybchenko To: CC: Ferruh Yigit , Thomas Monjalon , Shahaf Shuler , Wei Dai Date: Mon, 14 May 2018 08:36:17 +0100 Message-ID: <1526283378-30507-3-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1526283378-30507-1-git-send-email-arybchenko@solarflare.com> References: <1526055955-14027-1-git-send-email-arybchenko@solarflare.com> <1526283378-30507-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-MDID: 1526283410-D6SAfT7iKXgG Subject: [dpdk-dev] [PATCH v2 2/3] ethdev: fail if Tx queue offload is not supported 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: Mon, 14 May 2018 07:36:51 -0000 Do not allow to request unsupported Tx offload since all checks are removed from PMDs because of consistency check in ethdev. Otherwise application may rely on offload which is not actually supported and send traffic with, for example, wrong checksums, truncated packets or packets with garbage. If application is using the new offload API, queue offloads only may be added on Tx queue setup. If application is using the old offload API, it knows nothing about device level Tx offloads and requests everything required on Tx queue setup using txq_flags. So, both device level (from PMD point of view) and queue level offloads may be requested. It is assumed that no PMD yet strictly separate device and queue level offloads. If any PMD does it, it was broken for applications which use the old offload API at the moment of PMD convertion anyway. Fixes: 0330605295cf ("ethdev: new Rx/Tx offloads API") Signed-off-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 51 +++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 54e1ee771..2b673013a 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1727,25 +1727,38 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, */ local_conf.offloads &= ~dev->data->dev_conf.txmode.offloads; - /* - * New added offloadings for this queue are those not enabled in - * rte_eth_dev_configure( ) and they must be per-queue type. - * A pure per-port offloading can't be enabled on a queue while - * disabled on another queue. A pure per-port offloading can't - * be enabled for any queue as new added one if it hasn't been - * enabled in rte_eth_dev_configure( ). - */ - if ((local_conf.offloads & dev_info.tx_queue_offload_capa) != - local_conf.offloads) { - ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new " - "added offloads 0x%" PRIx64 " must be " - "within pre-queue offload capabilities 0x%" - PRIx64 " in %s( )\n", - port_id, - tx_queue_id, - local_conf.offloads, - dev_info.tx_queue_offload_capa, - __func__); + if (tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE) { + /* + * New added offloadings for this queue are those not enabled in + * rte_eth_dev_configure( ) and they must be per-queue type. + * A pure per-port offloading can't be enabled on a queue while + * disabled on another queue. A pure per-port offloading can't + * be enabled for any queue as new added one if it hasn't been + * enabled in rte_eth_dev_configure( ). + */ + if ((local_conf.offloads & dev_info.tx_queue_offload_capa) != + local_conf.offloads) { + ethdev_log(ERR, "Ethdev port_id=%d tx_queue_id=%d, new " + "added offloads 0x%" PRIx64 " must be " + "within pre-queue offload capabilities 0x%" + PRIx64 " in %s( )\n", + port_id, + tx_queue_id, + local_conf.offloads, + dev_info.tx_queue_offload_capa, + __func__); + } + } else { + /* + * Applications which are not converted yet to the new + * Tx offload API may request device level offloads on + * queue level (and nothing is requested on device level). + * However, if the offload is not supported at all, + * Tx queue setup must fail. + */ + if ((local_conf.offloads & dev_info.tx_offload_capa) != + local_conf.offloads) + return -EINVAL; } return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev, -- 2.17.0