From patchwork Tue Feb 14 10:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 13139853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A412C61DA4 for ; Tue, 14 Feb 2023 10:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yEdu/C/fMeU4/2NhzjavV281RP2tk1sv32N1Y+eEgFU=; b=bbTOqGZ0eWN/zC dblQyirPvlBbm3zgOUE6hT2gNH9FqVU51U/eMpFeS8nVCvsX8l2Yhh+1EFvfJsj+1mIvROCihzKHt PA6Inv1Xg6WzkGTh8duFn0Tn++cBVhTTwN8iodiTP5u7O9X7hFo5TVC/dnhH56Qq1MJq6oMtFdJPf jeghBH4Dx8G4g5cYUxclpdMypONIeaza5Ye2WlGEvLNAeUyoFiEjiVdtbNbQ4Zmxo2i0KOqMtxYOS 05wG01gx8ae3tIM4vs3IoxqLbLsHQ2Q2dI+JzM+5/U4lkeWp9a55SnO4cL2zW29K8EESROmGs8qJU VB1aSYIt/uBpPsb4Bw4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRslK-0014d7-G1; Tue, 14 Feb 2023 10:42:14 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRskO-0014Dw-8M for linux-arm-kernel@lists.infradead.org; Tue, 14 Feb 2023 10:41:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676371275; x=1707907275; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Dz6X4Xb9XGpExKsggN/aLNn8f0s4UocxH2zuKRm47Y=; b=iqtJpDZfIe2Ie5TiTMj+1PPseQdc+c6vQpuy5eDjqlWGonJaQNN0jM1n ii87EuniGpbveSD7+ca9DUxanMhdRZO7Pk5OJkzkHveNwlzvi9Ik22z5Q zRkCYbAlDC8K4uyMOUxoyCBLoxHwBQNn77Tf5wBEq0PaAD9UkFhTVtav/ sbZkXTChTgzbnHxv63wdD+vx29uftmzl+cywFPgLJilbEwyRQxEfNKMIV 71W81Do7zZoI6KOVDknS9B4NeXHQR0HSjfH2EUSsnW+sew9IzVFFeMgWx ZKwasLbW+c8UqXCanUlaicoWDU6sVR7W6oceHYmbOFrDTrKjy74sUIWBm g==; X-IronPort-AV: E=Sophos;i="5.97,296,1669100400"; d="scan'208";a="200588865" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Feb 2023 03:41:15 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 14 Feb 2023 03:41:14 -0700 Received: from den-dk-m31857.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Tue, 14 Feb 2023 03:41:11 -0700 From: Steen Hegelund To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni CC: Steen Hegelund , , Randy Dunlap , "Casper Andersson" , Russell King , Wan Jiabing , "Nathan Huckleberry" , , , , "Steen Hegelund" , Daniel Machon , Horatiu Vultur , Lars Povlsen , Dan Carpenter , Michael Walle Subject: [PATCH net-next v2 05/10] net: microchip: sparx5: Improve the error handling for linked rules Date: Tue, 14 Feb 2023 11:40:44 +0100 Message-ID: <20230214104049.1553059-6-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214104049.1553059-1-steen.hegelund@microchip.com> References: <20230214104049.1553059-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230214_024116_361669_A57C9E81 X-CRM114-Status: GOOD ( 12.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Ensure that an error is returned if the VCAP instance was not found. The chain offset (diff) is allowed to be zero as this just means that the user did not request rules to be linked. Signed-off-by: Steen Hegelund --- drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c index d73668dcc6b6..82d5138f149e 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c @@ -551,12 +551,16 @@ static int sparx5_tc_add_rule_link(struct vcap_control *vctrl, struct vcap_admin *to_admin = vcap_find_admin(vctrl, to_cid); int diff, err = 0; - diff = vcap_chain_offset(vctrl, from_cid, to_cid); - if (!(to_admin && diff > 0)) { + if (!to_admin) { pr_err("%s:%d: unsupported chain direction: %d\n", __func__, __LINE__, to_cid); return -EINVAL; } + + diff = vcap_chain_offset(vctrl, from_cid, to_cid); + if (!diff) + return 0; + if (admin->vtype == VCAP_TYPE_IS0 && to_admin->vtype == VCAP_TYPE_IS0) { /* Between IS0 instances the G_IDX value is used */