Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2432994rwb; Wed, 30 Nov 2022 06:36:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7IbB1JLRxg2qptO0FxIHmPz+v1txAewDltdysyI3rgqnybe3vTpeKRfKzF/v53aGPgvZwr X-Received: by 2002:a17:902:a605:b0:189:680e:c2e5 with SMTP id u5-20020a170902a60500b00189680ec2e5mr26421144plq.51.1669819011140; Wed, 30 Nov 2022 06:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669819011; cv=none; d=google.com; s=arc-20160816; b=bV+93c1yEvdaG7P8tMVo395iJ3+t4MKlKemroaOed1jmtMUsp/sZG41pJ3cPUMUeva Ij3NwO99vzpACOnejaiqFneu2J7WxXjTNkDX1N/rZZGmg2CUHaDVRdymoa59Zy5DCXTb aeSOiqo2fjkVMjVrl7yOoBCzCBUkos+d/5B/v/7xt8rksJYZlRdtRAtlTRfbSO0QUl7V Y2sIj5VN8Ew+TQmx902i3pB4I/JKIMdy/B3Ecbusv/BMFeQiFsjcg91mMAmdZEXAh7Nt 4LB3f8xXIw0IcwdMbZBgAlwUm6mzlPz5nJlpA+dkQYZWXNEnCBwjjwku7dNPyZ6wVWMF 4oLA== 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=aNc6nY+Mwka5iVNZlHXMDxv2SHtdgy365GronRwjcAA=; b=nLs2t98uvi1hen3h8GIiJoh14PsVYMC7cKcQfxLkM43NHKC1pa0yf1pFuwOHf1WgR3 ar/26r7N0mc+SPvO5AUPi1qPEq6Ltfi1TFCYO//hyKU5ou07UQnxsQc0OM+KkREanx2I UPET0Mmg+4YVHsQovvyY1wIlDBuOLc6YgqBFitEgPHiJU3Y6hRrckXyWSodPnO+IQTw8 TQnw+c9Ai/GEfh/LjzWft24158zDfk76QEyhcQ/ikz3MOM5yJeVAGmZ2ehenxSmuP2nE qjHkRm8XYL/br2g87GJU1AebsJeYmmHiDN6z80D1XIAiPm4bB3Q0fX7oERq3KpAe9PPn MSfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=pxV5vUXd; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a170902c38600b001898558457dsi1341525plg.123.2022.11.30.06.36.40; Wed, 30 Nov 2022 06:36:51 -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=pxV5vUXd; 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 S229660AbiK3Oc7 (ORCPT + 83 others); Wed, 30 Nov 2022 09:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229970AbiK3OcW (ORCPT ); Wed, 30 Nov 2022 09:32:22 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9801481396; Wed, 30 Nov 2022 06:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669818725; x=1701354725; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5bmNXCaH4WkjF1B9qtqchebaca/+53Y+sh38HZJtfrI=; b=pxV5vUXdrCpz5SwtXyV1uqLc0eziqE5diAjIpH4IgQ6RAuiOdrScyitF /q+ZF0KG2BSrQOj9uiBY8/beyN0aQxX7xjFwDynhTm4CAOlH6XHhtFxRU EhNKdxs8b7QmhpJ3A606iNrXZmB8RYgbJGl1Fzmm9dfjErd1ASFGOpSme H4RcieAk+Lqky5JYg5dDs/QDIcrpyxBTgAnREQ7RutsinEEAG0zonxkiC ccUWaqMDjf80l7EkijKh3ep/HVbN12vMN03nqoixniPinp6fmv7gwS8hf e1id1uzsHV6GIRpneb3Dx5XBHDfBTQe18tbfiWDGYaMOAGxZVih0IjI20 Q==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191144791" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 07:30:36 -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.12; Wed, 30 Nov 2022 07:30:34 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 07:30:32 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next 2/4] net: microchip: vcap: Add vcap_mod_rule Date: Wed, 30 Nov 2022 15:35:23 +0100 Message-ID: <20221130143525.934906-3-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221130143525.934906-1-horatiu.vultur@microchip.com> References: <20221130143525.934906-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 Add the function vcap_mod_rule which allows to update an existing rule in the vcap. It is required for the rule to exist in the vcap to be able to modify it. Signed-off-by: Horatiu Vultur --- .../net/ethernet/microchip/vcap/vcap_api.c | 36 +++++++++++++++++++ .../ethernet/microchip/vcap/vcap_api_client.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index 27128313f15f1..eae4e9fe0e147 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -1955,6 +1955,42 @@ struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id) } EXPORT_SYMBOL_GPL(vcap_get_rule); +/* Update existing rule */ +int vcap_mod_rule(struct vcap_rule *rule) +{ + struct vcap_rule_internal *ri = to_intrule(rule); + struct vcap_counter ctr; + int err; + + err = vcap_api_check(ri->vctrl); + if (err) + return err; + + if (!vcap_lookup_rule(ri->vctrl, ri->data.id)) + return -ENOENT; + + mutex_lock(&ri->admin->lock); + /* Encode the bitstreams to the VCAP cache */ + vcap_erase_cache(ri); + err = vcap_encode_rule(ri); + if (err) + goto out; + + err = vcap_write_rule(ri); + if (err) + goto out; + + memset(&ctr, 0, sizeof(ctr)); + err = vcap_write_counter(ri, &ctr); + if (err) + goto out; + +out: + mutex_unlock(&ri->admin->lock); + return err; +} +EXPORT_SYMBOL_GPL(vcap_mod_rule); + /* Return the alignment offset for a new rule address */ static int vcap_valid_rule_move(struct vcap_rule_internal *el, int offset) { diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h index a354dcd741e22..fdfc5d58813bb 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h @@ -172,6 +172,8 @@ int vcap_del_rule(struct vcap_control *vctrl, struct net_device *ndev, u32 id); struct vcap_rule *vcap_copy_rule(struct vcap_rule *rule); /* Get rule from a VCAP instance */ struct vcap_rule *vcap_get_rule(struct vcap_control *vctrl, u32 id); +/* Update existing rule */ +int vcap_mod_rule(struct vcap_rule *rule); /* Update the keyset for the rule */ int vcap_set_rule_set_keyset(struct vcap_rule *rule, -- 2.38.0