From patchwork Tue Jul 24 12:26:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10542059 X-Patchwork-Delegate: jiri@resnulli.us Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AECD113BB for ; Tue, 24 Jul 2018 12:27:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC4C2870F for ; Tue, 24 Jul 2018 12:27:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9055928751; Tue, 24 Jul 2018 12:27:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE05F28722 for ; Tue, 24 Jul 2018 12:27:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41Zd0Y2q3nzDsGm for ; Tue, 24 Jul 2018 22:27:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="wlb1Lake"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=40.107.0.44; helo=eur02-am5-obe.outbound.protection.outlook.com; envelope-from=idosch@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="wlb1Lake"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00044.outbound.protection.outlook.com [40.107.0.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41Zd052QBMzDrS7 for ; Tue, 24 Jul 2018 22:27:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G/2jhMvUbIFxD7EVJfAzJI1mXl6x2VmAAmlK1FydoCQ=; b=wlb1Lake53jLHjVDix1eFyfaf7OEumOQPbBj5XbOlVnCdAD1lkINmfie8+d/CuJT0XZhYPjAqwktSSR8BbHqBIqY8uADtee8zMOaZEHGEsPc+7XpXNbTq5YdPskkJtDC9QXu2tw61cCpVw2t5re+2fUzUpwx/ws5eHyOsPOTpMw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Tue, 24 Jul 2018 12:26:46 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw v3 10/18] mlxsw: spectrum_acl: Allow encoding a partial key Date: Tue, 24 Jul 2018 15:26:03 +0300 Message-Id: <20180724122611.13150-11-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180724122611.13150-1-idosch@mellanox.com> References: <20180724122611.13150-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM4PR0101CA0050.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::18) To VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec3acba8-8e27-4557-741f-08d5f160b987 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2333; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2333; 3:tgxuH2N/16P1bNWvnblS+eyu2LjBFMwgG719U6wJPwh9bR/TEYAlDL5EbAabyTRa6R8lmDW+frLtChGW4zFp3IeEdRxWJwVrItTzunUi1kh34txt8Zrg7BZXUl7o82gD9RM8zr4qUN/iEfSmDg9iozEuM2qbdrfAacv/PXqQBPMGHf18MVVb6hFoCwxbVEHFqB3UWsBqqQjuEfqkNkDrQpL5tcD0npiEijAO4GaJfJAKv3b5mDJ3cZY5wQ0aXUp0; 25:UOPXlZZrcScWt/XfmXmDt0l/xP37B9kyY06ok6Gwbqh2a70Gv+YXMH9un0EFH2JD6c+DZeexrA7W8l0dKkPdglbHFwI/C7/9dEwLP/kdWD/OTPNTIrXkL0RRuLzEoLy7jtdLab94CMvt8GDW1otEznepxeflJ0wWXqRjNGhAc5qvLiz2+g/9J6h0a40aVg2nEqg0sVYt/jfxM+FTjevJI9E/PUs3GZ0Xz++WT//LN3IBfGz4Ps8czSj8b5gEe/ZPj882MEX5w44Zs5DU2wbZAzH8JcCB5bdOi92Or2kiEpyIBB4oAF4+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b5d/XH53z62QqbP1h2lOhIn9by6gLg+97ZM2YFfKI6V65ekFOulwpw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2333; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2333; X-Forefront-PRVS: 0743E8D0A6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39860400002)(346002)(376002)(366004)(136003)(396003)(199004)(189003)(446003)(8936002)(6512007)(48376002)(81166006)(50466002)(97736004)(1076002)(47776003)(66066001)(2361001)(2351001)(50226002)(34206002)(16526019)(7736002)(107886003)(14444005)(6486002)(53936002)(5660300001)(6636002)(6666003)(305945005)(68736007)(11346002)(53416004)(6506007)(386003)(6116002)(8676002)(81156014)(36756003)(105586002)(106356001)(956004)(76176011)(486006)(3846002)(51416003)(2616005)(26005)(476003)(4326008)(478600001)(37006003)(86362001)(316002)(25786009)(16586007)(52116002)(2906002)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2333; H:splinter.mtl.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2333; 23:yA4zjHFY6/HpFx2PQz5ArUnvyxdntRwaIdBqqNq?= T38e/Xtadw5/rWv44lLmOh7d3FivIkTgJlSRNfr4i6IyGYZ4twMrd39lxgvCl9HEwCh4ZQ8ZpI/NdZjDDoLwxJabUBxFJU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Pt0Z9A95pH7eY/SDsviZhyIpO41WGXfXUl2qd9LOB4L/NNZO7JWqA81cWeoV1CAVkR7DuI5Q0V8W6KjNYMapEc5QUFaKENk8sXh+Vl813BFJwJx7TtcyPqO+6XqViCS4Z0TjFQtcajfFQaoyV18g== X-Microsoft-Antispam-Message-Info: mMu+PGwNVfqzsnzg8WFU2hP1hPzH+vahx90bovKQuipS+8m9tOTdE/7ZDWdFLL+MHVam9GXXCymZKWvizwyppWxeC9yueday/VUHeeXuTJlZAev7bSH74D5o+WAjIuSTRvhPMnAyxq8b8nwjsrAJL7F/hjzt+9nSBDExrzcjfldAYLQeYm0/qmixt+ibkQtfMGvUnB09OEK3lxYBXKRa0C0knXtbkEvv+VKg5bDehzyx8ZXehDW5zRXvTBOHo268LEJDJh8NJmGK9ITIDMQOdYREHPLYm1GhxXzqnc3lLpvkHXVO2kxCA20ryGRv6miYGNrYxbOey0+6yOlMfSEfsF1/gxPb430p8RFMVoPa18Q= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2333; 6:9JuM+pwaz2RL1ZrKTHleHfKCCfaLElw+j7BIc1VKnYgFa5wWFOy2yQBytZREh8tE/XA1JEf/4ESkIF5I9pVFhV7O6RLVp1aRDiqi3wX2mye8G9PPZcWo740Z+8r7cIT93C2kuszLmY+sArUslSRgITWrLeEcCmzUicfglXXoqUWJ9DsT3r/aqOe24kVnNwNDC460cKm9Rqd/DxBZo7pijbAiiMvANPDL5rUPIVS89lNxc+bgWqeZQIrBbf/in2rx5y5p1H/eGgDwSwwjMD6hKajGT6ygQEBbsox/Ps/oOICuTTsWO2/KsrE42KPafJcGJohPmN+C0VSt9va0ajsq6iY9lyqjToWSc2rhRkR0xh5ofH46n0yxaxBXeAJn/gqdyYC91O6iC7vbk6J6jMHO2BvjQNloMcI66IR4kDA/XpI1argjb/iqw7NWf1N6AW1bF617GSR8mJs+rRk3lz5lEQ==; 5:66Icz241DQhIQaGv43n/RwqRWY5I3i1Ww33DiN6sNNgMRfdf0q7+tVXvmKmxCj/ah/QO4/wey7s0rlv2axBR9paknaTXVWQ7CTM7PpuZZrBl08A6oIz29b7CCjLetZww3R03W6X1UNv6LbaSzV3BlDe2tfgffv1jLFn48QoHwlA=; 7:1D9j7c0l9T4foryDL6CVSWBXONpGq2scRf5wRb4qjXAWgUD8KF++wrheA5lwPaqCXHgFwB+reHggAsTKFjwxiB20yvNiLaVbgJR34ftlQte0HH/+vM9SAuWLY58K9KBx1GC7KEhvw5z7YV8BS2t4Cxd8uoZ9nyKqYbih5+CMvxok/AINVLhyK6nO0MaF23hmE9axyI7ryc3i5QZML8T5ppPA2M41TdtGd2hwYSlScRiwzDOp0nEVP+nD8atC6m8P SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2018 12:26:46.9365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec3acba8-8e27-4557-741f-08d5f160b987 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2333 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP When working with 12 key blocks in the A-TCAM, rules are split into two records, which constitute two lookups. The two records are linked using a "large entry key ID". The ID is assigned to key blocks 6 to 11 and resolved during the first lookup. The second lookup is performed using the ID and the remaining key blocks. Allow encoding a partial key so that it can be later used to check if an ID can be reused. This is done by adding two arguments to the existing encode function that specify the range of the block indexes we would like to encode. The key and mask arguments become optional, as we will not need to encode both of them all the time. Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko --- Notes: v2: * Extend mlxsw_afk_encode() instead of creating a new function .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 10 ++++++---- .../net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 2 +- .../net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c index 5f8485c7640e..9649b4d9349a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c @@ -457,7 +457,7 @@ mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst, void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_values *values, - char *key, char *mask) + char *key, char *mask, int block_start, int block_end) { char block_mask[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE]; char block_key[MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE]; @@ -465,7 +465,7 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, enum mlxsw_afk_element element; int block_index, i; - for (i = 0; i < key_info->blocks_count; i++) { + for (i = block_start; i <= block_end; i++) { memset(block_key, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE); memset(block_mask, 0, MLXSW_SP_AFK_KEY_BLOCK_MAX_SIZE); @@ -482,8 +482,10 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, values->storage.mask); } - mlxsw_afk->ops->encode_block(block_key, i, key); - mlxsw_afk->ops->encode_block(block_mask, i, mask); + if (key) + mlxsw_afk->ops->encode_block(block_key, i, key); + if (mask) + mlxsw_afk->ops->encode_block(block_mask, i, mask); } } EXPORT_SYMBOL(mlxsw_afk_encode); diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h index 2ffde915349b..18d9bfed6001 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h @@ -259,6 +259,6 @@ void mlxsw_afk_values_add_buf(struct mlxsw_afk_element_values *values, void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk, struct mlxsw_afk_key_info *key_info, struct mlxsw_afk_element_values *values, - char *key, char *mask); + char *key, char *mask, int block_start, int block_end); #endif diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index ef0d4c0a5a1f..11b19272ab13 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -76,6 +76,7 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, { struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); char ptce2_pl[MLXSW_REG_PTCE2_LEN]; + unsigned int blocks_count; char *act_set; u32 priority; char *mask; @@ -91,7 +92,9 @@ mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, region->tcam_region_info, offset, priority); key = mlxsw_reg_ptce2_flex_key_blocks_data(ptce2_pl); mask = mlxsw_reg_ptce2_mask_data(ptce2_pl); - mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask); + blocks_count = mlxsw_afk_key_info_blocks_count_get(region->key_info); + mlxsw_afk_encode(afk, region->key_info, &rulei->values, key, mask, 0, + blocks_count - 1); /* Only the first action set belongs here, the rest is in KVD */ act_set = mlxsw_afa_block_first_set(rulei->act_block);