Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3337854rwb; Sat, 3 Dec 2022 03:20:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jZsgSWHLDmjiQ+bSRLQAzhzcfrz63qz924Fo6WfLvE6dAtRTolExPz3UKLhC4K2Ys1qif X-Received: by 2002:a05:6402:3789:b0:467:7664:c7f4 with SMTP id et9-20020a056402378900b004677664c7f4mr24678119edb.99.1670066433729; Sat, 03 Dec 2022 03:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670066433; cv=none; d=google.com; s=arc-20160816; b=Eu+KTijCNmkNWkjRkg5ZzVjlKqV/XDhyU3bYEt93ZS9pb3hNwFPPAhwYv6xfayB3Nm i2wqjInUzDVUm4zetIYG0cTdbNDEOPvdy+MYwewh7SEm8P85ZYaJT6n4czlKw4EAlX0t kBxm9pqs6LMhRUOCwTChnVe8HBi0sgXZ3AqBSFrAOxTMsrwDruGfeP0SGBzZ3QPd4m3Z ObIAihBT28u4wRJJ4oekftLpl0+jlfPMnnx76ZbjXmTYpdeIJYixK6uyhBhRkYPKbclj GG14HOf5nHqMrhrKI/Z7FXqRNPGxUhRhZACggfVPs1XiX2E6IrfT0hoCI1hhKdcHr4UJ UDTA== 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=YII3tvlo9O5it76eruMN3ZNh6K9YGfCxZYll7tKcjSw=; b=qy1IFP1K8uPi5Zn0VZMFQl0PEqmcIOhR5aFv3dmcIQxy0pcOqBHRzwHD+gq6ut4TN6 D2OQmctpOKyKWJmH0dHnt4Ega4gDxh4TwA1NDoo+X5fkSPqsUvmm6ZPKk1Npz6WCKmJ0 2o8Itsf2TgrR/O2qEhI/7/U2AUkapZbze+2HfIwpDjKM0XUapjt2VNByP1ZKOubSjIju zr+3Z9Bv65vDfmRa+R3vS1cXUz+2sMolrR4hUIXABlcNjG2qNYbGyPcACIIUAQ8gXCsW lu+OPnAIVQVYtHhcylSBS9S38uapcum3Ea0XJlzlbbMyseNc+WqXbv6oi5Gsh5sskQ8i bPOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=oKSITuDw; 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 cr12-20020a170906d54c00b007a45e4f4ff0si8510178ejc.885.2022.12.03.03.20.14; Sat, 03 Dec 2022 03:20:33 -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=oKSITuDw; 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 S229477AbiLCKqr (ORCPT + 82 others); Sat, 3 Dec 2022 05:46:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbiLCKqn (ORCPT ); Sat, 3 Dec 2022 05:46:43 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A2E5A6CA; Sat, 3 Dec 2022 02:46:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670064402; x=1701600402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2gb0KVEJxLkfgfWcqwC2lUhZWa+6fkte1PAYqx1Oljc=; b=oKSITuDwQlNnwk9uL9FONK3oridswB+aieLzz3kzVGSjtAsJL0lzPReJ VTcCorUxnGBsyECSYqJOELvFE/NQCbQB29kF8SFMgHhC9quZZWGO2SAPl EpD0x1xn7X4WrNmMLcso9HJ4V43ngPC6zXAgWUnOuGBRiYNkPlv4PSazp LGONEztmfpzXQwa3QA10sDfYFprmao3iHzeY3d9G0fzEPC+7YP8c448b+ 1BQ39JB+HAsQCrKhSXhTbc6AW2wKJqKBeWE1GRbZmQrvKVKGMDpRwQRL3 hjvnA/ZMZS5ArWMTU0j3Kh+EThZKTfUIP8JRCp7JNNas4cb0UoiPX+sYV w==; X-IronPort-AV: E=Sophos;i="5.96,214,1665471600"; d="scan'208";a="189861164" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 03 Dec 2022 03:46:41 -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; Sat, 3 Dec 2022 03:46:41 -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; Sat, 3 Dec 2022 03:46:38 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next v3 3/4] net: microchip: vcap: Add vcap_rule_get_key_u32 Date: Sat, 3 Dec 2022 11:43:47 +0100 Message-ID: <20221203104348.1749811-4-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221203104348.1749811-1-horatiu.vultur@microchip.com> References: <20221203104348.1749811-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, 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_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__ */ -- 2.38.0