From patchwork Mon Aug 12 15:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 143098 X-Patchwork-Delegate: bruce.richardson@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D683A457A1; Mon, 12 Aug 2024 17:30:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AF3440E54; Mon, 12 Aug 2024 17:28:55 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by mails.dpdk.org (Postfix) with ESMTP id 9912C40DD7 for ; Mon, 12 Aug 2024 17:28:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723476525; x=1755012525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=38KJGRzJ5AN7wtMSQ5orzZpqVqWhr6XP1SJ+mURe0go=; b=CnzwXaxEi2xFKt9WRNs9Z/3eXg1h6xDpr1ZrQKhJhUiJwSMBp9KptzBo DCJHRLdsGVrOpyk/a0lnGtNq+4Zplv4u/j5ddsza5SEKijHN2UQB03Tm7 SHkSyAjpSHdpaqrTlgYY3mdK2P8GAu32+FxD5OZckdDUO5lFyY6bUngEb nwRsTMvfBQmfvZPK6YCEOd4A8CHIHfwhNqwUZjbxqsYLr9pKY8tUeKNhy RIv+tlq6QKTzfxGFd61VCSzN77oBBsQa65hbGOZnzc9bhDZz4J7aMN3fx wbKi961Vqmzud6uCYiWi+VG05m/S6hbm+2LgJ/+nBzED0+PQ0pToP3Y15 g==; X-CSE-ConnectionGUID: ePpLEH5nQDW3l4iOGQopog== X-CSE-MsgGUID: iJEgNHG7QGmxiLcJYXZtmg== X-IronPort-AV: E=McAfee;i="6700,10204,11162"; a="21743064" X-IronPort-AV: E=Sophos;i="6.09,283,1716274800"; d="scan'208";a="21743064" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2024 08:28:44 -0700 X-CSE-ConnectionGUID: BbSHULVVRJiBzfvSrHUdlw== X-CSE-MsgGUID: 6AnnB8mbSG6Dm8cgSiGykQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,283,1716274800"; d="scan'208";a="63222624" Received: from silpixa00400562.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.39]) by orviesa004.jf.intel.com with ESMTP; 12 Aug 2024 08:28:44 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH v3 16/16] net/ice: do early check on node level when adding Date: Mon, 12 Aug 2024 16:28:15 +0100 Message-ID: <20240812152815.1132697-17-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240812152815.1132697-1-bruce.richardson@intel.com> References: <20240807093407.452784-1-bruce.richardson@intel.com> <20240812152815.1132697-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When adding a new scheduler node, the parameters for leaf nodes and non-leaf nodes are different, and which parameter checks are done is determined by checking the node level i.e. if it's the lowest (leaf) node level or not. However, if the node level itself is incorrectly specified, the error messages got can be confusing since the user may add a leaf node using e.g. the testpmd command to explicitly add a leaf node, yet get error messages only relevant to non-leaf nodes due to an incorrect level parameter. We can avoid these confusing errors by doing a check that the level matches "parent->level + 1" before doing a more detailed parameter check. Signed-off-by: Bruce Richardson --- drivers/net/ice/ice_tm.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c index 3dcd091c38..e05ad8a8e7 100644 --- a/drivers/net/ice/ice_tm.c +++ b/drivers/net/ice/ice_tm.c @@ -426,6 +426,13 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, if (level_id == RTE_TM_NODE_LEVEL_ID_ANY && parent_node != NULL) level_id = parent_node->level + 1; + /* check level */ + if (parent_node != NULL && level_id != parent_node->level + 1) { + error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; + error->message = "Wrong level"; + return -EINVAL; + } + ret = ice_node_param_check(node_id, priority, weight, params, level_id == ice_get_leaf_level(hw), error); if (ret) @@ -493,12 +500,6 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, error->message = "parent is not valid"; return -EINVAL; } - /* check level */ - if (level_id != parent_node->level + 1) { - error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; - error->message = "Wrong level"; - return -EINVAL; - } /* check the max children allowed at this level */ if (parent_node->reference_count >= hw->max_children[parent_node->level]) {