From patchwork Sun Jul 22 13:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10539319 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 EF0B31823 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC365281F9 for ; Sun, 22 Jul 2018 13:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF66C28372; Sun, 22 Jul 2018 13:19:03 +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 EF6F828384 for ; Sun, 22 Jul 2018 13:19:02 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41YQF10DGczDrM8 for ; Sun, 22 Jul 2018 23:19:00 +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="wcoYSbTP"; 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.8.57; helo=eur04-vi1-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="wcoYSbTP"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41YQD82L3gzDqrX for ; Sun, 22 Jul 2018 23:18:16 +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=bTs63eI02UJ7HIcvdK2FarDK8gFOh9ySq+55Ses/XqY=; b=wcoYSbTPtwgSSZT1MuZ4p70ODonypVHt/O1cvnlVRmMvzX4h9hU8nn6bAn98gVzd+s8T6ZJsjUsJrm8xslRZT+TaJ+DgLbYbE9Yy/TfdTOvJV57MHVLArETSAJ4nLSjlYthcBYKH0Z3nAEaRNa88h3CuxxJMzgbdls4WWpV3268= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by HE1PR0501MB2331.eurprd05.prod.outlook.com (2603:10a6:3:27::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Sun, 22 Jul 2018 13:18:06 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw 10/18] mlxsw: spectrum_acl: Allow encoding a partial key Date: Sun, 22 Jul 2018 16:17:04 +0300 Message-Id: <20180722131712.30578-11-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722131712.30578-1-idosch@mellanox.com> References: <20180722131712.30578-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM0PR01CA0036.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::49) To HE1PR0501MB2331.eurprd05.prod.outlook.com (2603:10a6:3:27::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f84d6abb-4efb-48c5-0013-08d5efd5902a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2331; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2331; 3:aEFDBNrBnIZHadZNepbaEHTK4Jq1JPmdKyjrt1HgNDu6RYIwMcOKJsQ2ipvJR2xmKgC8tcArniVBQp59cYwSD1nMeL5V90SjJ4ZvlK6HIugXd0pF0MOvO6qWv0z7EV8yj/hfAQflZSVtChSR90CYYzyaG78U06DPgS5H424jWxXybPxd1dIzz7jrBNkkmoQMYPuPl6aYPqAwCaSCF7PH8SvzOG44ip03BXpy8VAZYzdu2HTltajgXevdVlDMMYCi; 25:fB6OXxeOGsBf38TBMYJLgtdRJYS8CN1uRZfE/CwmioXfhBLBKFRJCzSXbbyuJlXkebHE3jX+THoRX5sL1Z1lRSOL+UUgsslr4ajRRAVv+MAXDsU0tfAzmSPidyXGOOoIy+ZZC6pq3ZQs0QYB+Hm7IrfP36iD/UpDwo17XOjylkTlKPiupK0/AkfKeuwYVnuL8GMKAT/B0q2G26e95KzBATIA1a6YX7m6tY44fv65SxayodQEdKZWwZAf4VyszEZU+F1I9EulE8mDt0hHu7JqjG86WiNoeLyj6G7aaR+WEgPSwaBMnb5BaVfY2LY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p0tig9pkkdoB+138O89D08juD7FFolbBq5u5a6I3F4noovExUWVTEsOSZ6kQSCYI6ZrQ== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:HE1PR0501MB2331; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2331; X-Forefront-PRVS: 0741C77572 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(376002)(366004)(136003)(346002)(396003)(39860400002)(199004)(189003)(47776003)(956004)(14444005)(81156014)(106356001)(66066001)(3846002)(6116002)(2361001)(486006)(97736004)(68736007)(81166006)(1076002)(36756003)(4326008)(2906002)(86362001)(16526019)(11346002)(26005)(105586002)(6636002)(386003)(6506007)(478600001)(446003)(8676002)(8936002)(575784001)(5660300001)(53936002)(48376002)(34206002)(107886003)(50226002)(76176011)(316002)(53416004)(305945005)(476003)(6512007)(25786009)(2616005)(2351001)(37006003)(7736002)(51416003)(16586007)(50466002)(52116002)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2331; 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; HE1PR0501MB2331; 23:m2cIF0tY3x0PjFuhd91svWmMPwSzWZ4EOoUuMSC?= 374IIT55oieWJvtxDiI1oALAU2qE2X+OnoFsh15hEOp1lirBH0UWyRuhIUA7RikkravtkXZx9W4Ww3a7qhf/Okr/mTrvseNqR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nNEIgdGIzzPLTf4aaC2Hqhb+eAyE2tvEPbZlfAqyyB5UiHAVepcSK1nrlDldc8gf9Rnn/hGjhscRb7+zZV6dkleWPTRkkER8XkW6hQSXvQzP4ihwi0=; 7:j2FwvYWQ2/HyqPW3VnYVb83x/IyCjDiSLLYIh0sjv7BLXPaozhF1K+PSBHYoJRUtlSn7eCcC3Jb6XjK9yyNz97qMY725Wt9oILulWFK9ChSBxCh8Nu7iVDCt92BcqhmvzJcM5kTy3jPRrhQ902JI4pGOSRvREn5QH4Oxiks5C4dI6EJJUzNP3jTtIGHKoAJQt4QnQgrBqPTuDrZNOKYvtwX2YT6bUKRr/gpjH7dz24L3GtjteVgHRCELbt0fGnzG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2018 13:18:06.2912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f84d6abb-4efb-48c5-0013-08d5efd5902a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2331 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 --- 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);