From patchwork Mon Feb 13 09:24:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 56121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2250813wrn; Mon, 13 Feb 2023 01:30:23 -0800 (PST) X-Google-Smtp-Source: AK7set/bJ8PQYm471ZBIvWzxuop1572bJzC9CoktbRH1mg1R9Q0v+xDlio2EiNX2GFCnW7+EEdgh X-Received: by 2002:a17:906:858d:b0:88b:b823:dad9 with SMTP id v13-20020a170906858d00b0088bb823dad9mr24905130ejx.68.1676280623070; Mon, 13 Feb 2023 01:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676280623; cv=none; d=google.com; s=arc-20160816; b=tLIX6+LPDgXvPzx+nlUG/4Oqi5XaRLuOFn0sl62XyN1O64C5AQoO29if7HGDvwMz3i IgWnoJMtivIfZF9tSh27Unay0Rj3zzVewM4fuTjQmM4VeIlPEkmFF4UxIrO5sBqegi1g 5HvlUvY1N21p24byFt9Kag7Gw+IiXDrVD9Q7pD/fumf8IbwsBLPLMh6IGrzpyfWkqCEt 9ZX177K0mWrS1Ke80j0QcIH2PcD3OaDEfXnq8W1NAP6hZHSp9rdzoFRPH+7BTCdMbNLF y5a+FlPrx47FiZZ1yn4StaVTKkyKJr+QGXzEKzCYl20etBG6ADoz98HWXyVJzAEfq0Ql cvvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bGWbhu0eDH/ygXzV3t6mClLepRu6JFTKURJ9eF4wLvE=; b=QdDgRthageu73Jr3U/NYiOPnksLltS3TXHozsCRoP7ca6cSpKx/P/FfCzXK4L/BAFp e9QQAEZuBnylHGgty4hwXDn28OQu3Je7evjOdOhK89GM1jU6+ovkiRUjhXLTVJYgTLq3 9CEreVajQQm1b1EedB4vFVrkjCJBby5ZOMC6W8mXJdYlibxA471LTUcqIDH0+GM32k2D yyfY1RuO84pF0B2x3fWxBAWsTbO7fP5dmXpDm1cb1UT2YkzzNmAIUsvlNX4NsDTKiRAF DYNaifuhjSKjtkrxG1+NnCxKbxMJjcJnF5jIb/ykmVFHJZS0p17IaXZ2GY4KBtyiBXGZ OKiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=wJkqgBQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id uo37-20020a170907cc2500b008aa6e271052si13616429ejc.540.2023.02.13.01.30.00; Mon, 13 Feb 2023 01:30:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=wJkqgBQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbjBMJZ0 (ORCPT + 99 others); Mon, 13 Feb 2023 04:25:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbjBMJZD (ORCPT ); Mon, 13 Feb 2023 04:25:03 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D361314E8A; Mon, 13 Feb 2023 01:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676280301; x=1707816301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Dz6X4Xb9XGpExKsggN/aLNn8f0s4UocxH2zuKRm47Y=; b=wJkqgBQTEoYHrKPqsrEbpnuhzmQfPjFiKAR48qhGMVbhggauR+iXCskL Fivtadi63ns73GTNFg6JtwPDJTxQAZR+7GYxl2T4SkiD9xlH56tTq7KmI uLoaDdiVv71n6Z4tvFfV1JJu7GKS2fFMPcQRFb6aMIGkDZmsOVW6ff3Va EreiW58tQ5NijuXaBXuLjSXSiPoePVsr6aWyeHXR/6lYzbc8cu1j+6z/M J32VBzBcjH4PdXQQhkKXmwIex+qe/Hv6K+GYZSdqoLAdUM3FOzR0VkskP ft/XpzyxVR/+ydUk9XcjWLsAQ0gxeE+b9dbYIlnIYFlz+IEkq+Aku29fw Q==; X-IronPort-AV: E=Sophos;i="5.97,293,1669100400"; d="scan'208";a="196611601" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Feb 2023 02:24:58 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 13 Feb 2023 02:24:54 -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; Mon, 13 Feb 2023 02:24:51 -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 05/10] net: microchip: sparx5: Improve the error handling for linked rules Date: Mon, 13 Feb 2023 10:24:21 +0100 Message-ID: <20230213092426.1331379-6-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213092426.1331379-1-steen.hegelund@microchip.com> References: <20230213092426.1331379-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757707630604197758?= X-GMAIL-MSGID: =?utf-8?q?1757707630604197758?= 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 */