From patchwork Fri Dec 2 07:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 13062343 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 A92DAC4332F for ; Fri, 2 Dec 2022 07:53:25 +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=HNKl5Sb7xK5nfcvW0cO+EOczjlpGVD8QH9DPWA9/HcI=; b=Xun8o82zO27trX kuuGgbSgTC9Q8kOylCw67rGzaUBq0AXzOFj2u79w+vv3rn+5beYBSKaruSItKRYIFu028GHlvDyI/ XIVByIRhNwjY/OMmr9B2GnsqQFn+06HpNURHU2Z3NkmO/QUU8F4QipmOPjkcH9lO4fdpVL8fdCvvQ LPphxSV7HFiBGhUjPvzUTR2yqD0MC3vtDPI+w7RNmwXnmgWLa63Hd0lWlcX4feIIemmqSTp6fF4DE MHlCkze0G8f1zCZBD2gdij9jggwpshjPpfl0EfYh5aUeLjaJKcqE3kZD8N7+5AZieSoVWDO1Aa8mr zW5xDk2FNipMixjVHF/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p10qU-00EGc1-Uq; Fri, 02 Dec 2022 07:52:31 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p10pg-00EG6S-4K for linux-arm-kernel@lists.infradead.org; Fri, 02 Dec 2022 07:51:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669967500; x=1701503500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2gb0KVEJxLkfgfWcqwC2lUhZWa+6fkte1PAYqx1Oljc=; b=NvLC7ZhnbS2CWQbpnrH+UkcEt+74BABPRXFibwMvOksdDcPrID8k5qGS B7Fnskbb0boOC0r+c1a28EkmPGu71uf9jzucE3EAxNfPf9hp28KDLZ4bU ahLwRKxgk4pZjVbxmNOlxi4+hL8CVIYaw9q9UjKJtJrb5o6MCUUACLvlx j7RHIa/+zBfqUadIqZMVxOcaLGqPJwfjqy0PXCBLnvACs1QOrey/I7C2H 9IaueVjB1K6HF3CAzgGWeOsObJrJevwIuT7mdxRtfHLZeNCb0Epq/u9wn 1rWCD24DOcPg9sAtlJWuIxiVAneV3JL0KlzBDF7oPR/g+RTww2QhK3XdQ g==; X-IronPort-AV: E=Sophos;i="5.96,210,1665471600"; d="scan'208";a="126141913" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Dec 2022 00:51:38 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 2 Dec 2022 00:51:33 -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; Fri, 2 Dec 2022 00:51:30 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next v2 3/4] net: microchip: vcap: Add vcap_rule_get_key_u32 Date: Fri, 2 Dec 2022 08:56:20 +0100 Message-ID: <20221202075621.1504908-4-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221202075621.1504908-1-horatiu.vultur@microchip.com> References: <20221202075621.1504908-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_235140_272339_2C294C99 X-CRM114-Status: GOOD ( 11.12 ) 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 Add the function vcap_rule_get_key_u32 which allows to get the value and the mask of a key that exist on the rule. If the key doesn't exist, it would return error. Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/vcap/vcap_api.c | 16 ++++++++++++++++ .../ethernet/microchip/vcap/vcap_api_client.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index eae4e9fe0e147..05e915ea858d6 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -2338,6 +2338,22 @@ int vcap_rule_add_key_u128(struct vcap_rule *rule, enum vcap_key_field key, } EXPORT_SYMBOL_GPL(vcap_rule_add_key_u128); +int vcap_rule_get_key_u32(struct vcap_rule *rule, enum vcap_key_field key, + u32 *value, u32 *mask) +{ + struct vcap_client_keyfield *ckf; + + ckf = vcap_find_keyfield(rule, key); + if (!ckf) + return -ENOENT; + + *value = ckf->data.u32.value; + *mask = ckf->data.u32.mask; + + return 0; +} +EXPORT_SYMBOL_GPL(vcap_rule_get_key_u32); + /* Find a client action field in a rule */ static struct vcap_client_actionfield * vcap_find_actionfield(struct vcap_rule *rule, enum vcap_action_field act) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h index fdfc5d58813bb..0319866f9c94d 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h @@ -258,4 +258,8 @@ int vcap_rule_mod_action_u32(struct vcap_rule *rule, enum vcap_action_field action, u32 value); +/* Get a 32 bit key field value and mask from the rule */ +int vcap_rule_get_key_u32(struct vcap_rule *rule, enum vcap_key_field key, + u32 *value, u32 *mask); + #endif /* __VCAP_API_CLIENT__ */