From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id F0AB44F9A for ; Wed, 25 Apr 2018 13:45:05 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 04:45:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,326,1520924400"; d="scan'208";a="48978290" Received: from dpdk6.bj.intel.com ([172.16.182.201]) by fmsmga004.fm.intel.com with ESMTP; 25 Apr 2018 04:45:02 -0700 From: Wei Dai To: thomas@monjalon.net, ferruh.yigit@intel.com, qi.z.zhang@intel.com Cc: dev@dpdk.org, Wei Dai Date: Wed, 25 Apr 2018 19:26:03 +0800 Message-Id: <1524655563-37052-1-git-send-email-wei.dai@intel.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <20180328085709.28310-1-wei.dai@intel.com> References: <20180328085709.28310-1-wei.dai@intel.com> Subject: [dpdk-dev] [PATCH] ethdev: check Rx/Tx offloads 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: Wed, 25 Apr 2018 11:45:06 -0000 This patch check if a requested offloading is supported in the device capability. Any offloading is disabled by default if it is not set in rte_eth_dev_configure( ) and rte_eth_[rt]x_queue_setup(). A per port offloading can only be enabled in rte_eth_dev_configure(). If a per port offloading is sent to rte_eth_[rt]x_queue_setup( ), return error. Only per queue offloading can be sent to rte_eth_dev_configure( ). A per queue offloading is enabled only if it is enabled in rte_eth_dev_configure( ) OR if it is enabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is enabled in rte_eth_dev_configure(), it can't be disabled in rte_eth_[rt]x_queue_setup( ). If a per queue offloading is disabled in rte_eth_dev_configure( ), it can be enabled or disabled( ) in rte_eth_[rt]x_queue_setup( ). This patch can make such checking in a common way in rte_ethdev layer to avoid same checking in underlying PMD. Signed-off-by: Wei Dai --- v3: rework according to dicision of offloading API in community v2: add offloads checking in rte_eth_dev_configure( ). check if a requested offloading is supported. --- lib/librte_ether/rte_ethdev.c | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index f0f53d4..70a7904 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1196,6 +1196,28 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, ETHER_MAX_LEN; } + /* Any requested offload must be within its device capability */ + if ((local_conf.rxmode.offloads & dev_info.rx_offload_capa) != + local_conf.rxmode.offloads) { + RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Rx offloads " + "0x%" PRIx64 " doesn't match Rx offloads " + "capability 0x%" PRIx64 "\n", + port_id, + local_conf.rxmode.offloads, + dev_info.rx_offload_capa); + return -EINVAL; + } + if ((local_conf.txmode.offloads & dev_info.tx_offload_capa) != + local_conf.txmode.offloads) { + RTE_PMD_DEBUG_TRACE("ethdev port_id=%d requested Tx offloads " + "0x%" PRIx64 " doesn't match Tx offloads " + "capability 0x%" PRIx64 "\n", + port_id, + local_conf.txmode.offloads, + dev_info.tx_offload_capa); + return -EINVAL; + } + /* * Setup new number of RX/TX queues and reconfigure device. */ @@ -1547,6 +1569,33 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, &local_conf.offloads); } + /* + * Only per-queue offload can be enabled from application. + * If any pure per-port offload is sent to this function, return -EINVAL + */ + if ((local_conf.offloads & dev_info.rx_queue_offload_capa) != + local_conf.offloads) { + RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d rx_queue_id=%d " + "Requested offload 0x%" PRIx64 "doesn't " + "match per-queue capability 0x%" PRIx64 + " in rte_eth_rx_queue_setup( )\n", + port_id, + rx_queue_id, + local_conf.offloads, + dev_info.rx_queue_offload_capa); + return -EINVAL; + } + + /* + * If a per-queue offload is enabled in rte_eth_dev_configure( ), + * it is also enabled on all queues and can't be disabled here. + * If it is diabled in rte_eth_dev_configure( ), it can be enabled + * or disabled here. + * If a per-port offload is enabled in rte_eth_dev_configure( ), + * it is also enabled for all queues here. + */ + local_conf.offloads |= dev->data->dev_conf.rxmode.offloads; + ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, socket_id, &local_conf, mp); if (!ret) { @@ -1681,6 +1730,33 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, &local_conf.offloads); } + /* + * Only per-queue offload can be enabled from applcation. + * If any pure per-port offload is sent to this function, return -EINVAL + */ + if ((local_conf.offloads & dev_info.tx_queue_offload_capa) != + local_conf.offloads) { + RTE_PMD_DEBUG_TRACE("Ethdev port_id=%d tx_queue_id=%d " + "Requested offload 0x%" PRIx64 "doesn't " + "match per-queue capability 0x%" PRIx64 + " in rte_eth_tx_queue_setup( )\n", + port_id, + tx_queue_id, + local_conf.offloads, + dev_info.tx_queue_offload_capa); + return -EINVAL; + } + + /* + * If a per-queue offload is enabled in rte_eth_dev_configure( ), + * it is also enabled on all queues and can't be disabled here. + * If it is diabled in rte_eth_dev_configure( ), it can be enabled + * or disabled here. + * If a per-port offload is enabled in rte_eth_dev_configure( ), + * it is also enabled for all queues here. + */ + local_conf.offloads |= dev->data->dev_conf.txmode.offloads; + return eth_err(port_id, (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc, socket_id, &local_conf)); } -- 2.7.5