Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2433178rwb; Wed, 30 Nov 2022 06:36:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5yz+zjlNwjxksMenZPfTPZn+XEzhkpXyXEgzGGOkIXmZQBpMOI9bY2je9uskYninHMHB1J X-Received: by 2002:a17:902:d711:b0:17f:cdd1:7ab1 with SMTP id w17-20020a170902d71100b0017fcdd17ab1mr42859552ply.86.1669819018011; Wed, 30 Nov 2022 06:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669819018; cv=none; d=google.com; s=arc-20160816; b=m1k280mWYL+EgjIqg+KcGw2WaIspfZ92s/1DQ60DFkOVhONuKZ5WiYwz+2ha0lXXQf SOtXcjDiXLCv2oEynG49lEN5ipJQxQ0o66RgmH/9o301CPUuOcuB8MKJuPXeCKlTiM2O tog01iMj5xVK5WgZBgPJgfSA076oK2357PB7HJ3Xnkp6b7EioreqaXfH3SfQalcTXzxv hSlcVk9/ocSyyoaiRUCAE4o7JkWClXzPFiBRTNLX52VwoxGbxquoHFaYX2HxXv89MAjG QbY+YTFGR9J4mwPUncIJV3ZYNsLU8haIJfg5seFpKCeuQ8URz1uPUlyJM62gazPD2yls Ei3Q== 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=KowXcyjg2AsaelfYUtFiKgWBu5B06dfrlui5aAysCffxzYsPOjc4apsvzIaHVRlzsX ePxCH1O4+DjraB+QOJju15hKAAzt0DktS1d91JMKvQ04gsNkvc5ga8LxnRrdNIlkuyVI k532pWbqvOt/qCsdqv8jwNbL3iKnIcc4zUyDO0KL2DKJ7L40fXP/R9NpZEO2flzC0cNA q8VncBoiTlDEEp+sVfsQN+hD0/Qz+PTpQlLmrsQuoI166BK/XRfwp4s+Yxx6mTgZErAi A1IZTisdNTbUhIMWqGXFzdAU7VcVzfvKeJeVIpkHeY9eA0uruqP1rgwuvB+mdHOj9Qfh 0TXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=J5vy73op; 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 d16-20020a056a00245000b0056bbdb48fcdsi1928792pfj.118.2022.11.30.06.36.45; Wed, 30 Nov 2022 06:36:57 -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=J5vy73op; 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 S230112AbiK3OdG (ORCPT + 83 others); Wed, 30 Nov 2022 09:33:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230005AbiK3OcX (ORCPT ); Wed, 30 Nov 2022 09:32:23 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDFDE6B39A; Wed, 30 Nov 2022 06:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669818726; x=1701354726; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2gb0KVEJxLkfgfWcqwC2lUhZWa+6fkte1PAYqx1Oljc=; b=J5vy73oplXp+GSUEVMnBPKf6i4rVRj1FFjPdxfcN4X3OfXI3Z8bInxku Srok2tL1iJ0H0nmEcZsPYplHzJSq2TtY83F5qGFvJPcmxXWZLjx33XfL7 v46UQWyU0TLphkxkIu2WB3reSaUrpvV7efayOJIWqJNOhjWjzNqhGgiPK 7pVM+aiot7gi76mmqRK8XlqKslLAZMB06GIjBC5Ha/zIFRt5/3kcq9UsR vgf19UHY+8UqgyTTryoOH/WmnyaNOt6G6bpjeMxoI8uhZFvH1eCbm1Cco Tk+eN8oGSv1p85rMzBnMG2TnIynm0b1eLZPzJfKbs/3DJWfWA6uuAfr5G Q==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191144800" 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:38 -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:37 -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:34 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next 3/4] net: microchip: vcap: Add vcap_rule_get_key_u32 Date: Wed, 30 Nov 2022 15:35:24 +0100 Message-ID: <20221130143525.934906-4-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_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