From patchwork Thu Jun 14 08:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 10463635 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E478F600D0 for ; Thu, 14 Jun 2018 08:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D50E228990 for ; Thu, 14 Jun 2018 08:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7B0828994; Thu, 14 Jun 2018 08:42:20 +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=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 E643B28990 for ; Thu, 14 Jun 2018 08:42:19 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 415xvG1l92zF0TM for ; Thu, 14 Jun 2018 18:42:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="Y6g2q3Se"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=resnulli.us (client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=jiri@resnulli.us; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="Y6g2q3Se"; dkim-atps=neutral Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 415xv940HLzDrnp for ; Thu, 14 Jun 2018 18:42:13 +1000 (AEST) Received: by mail-wr0-x241.google.com with SMTP id o12-v6so5447486wrm.12 for ; Thu, 14 Jun 2018 01:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iPwgGVT0s9nUYbPMGR2HPy2Zmww+VXbz3Ew+//e2R9o=; b=Y6g2q3SeH35N++EgyaG9NxeMuBjKQTqzYMUyI8dDfjc75nINbj7Ysk3Ywr3jF8Qvto Bix95js99wuhewJ1fZIORQEqjAeRwHn8hJ9EYLbxOyjWf25oLVB0SQ/vD2y77ZidMBtz LVLNCyhT5vTFBkOUiSbjrE4fgC1+cT9pTHo9/UN/tUPh8TMiHq4q3APaJAJfmiwv82lX DUvjx31x/Upoix/+oXxnXq/iiXaI9ejvGE6K5UFFM8vCVrLkAVqEaNBi/3nQ4BIPR3QD kn1ekv4ctOYHSHOQrUJt4ECeq2/pAkrAvjuZFtZlpmpdVEKRBNaIZ74zKwWWc8fkfRZr TpFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iPwgGVT0s9nUYbPMGR2HPy2Zmww+VXbz3Ew+//e2R9o=; b=Z1C1EIgFCuRSw1Oe2KxzKVXPxu4+yZRDb7R8bp6lIpewP7asnuUQMNK0RB7TK22I5F eBBzzA0iW1rXSP//XXDcMkwcWz2m+is8HK6qM4bT5KsdvupJfN7CJ6hrEAm2TtVHOtTh xSuiPa5xQh/5TFi6Sl1qF0u8abW6LpU7Q6oZe0FU9Qw3C3VErSRtWWijUgeeS12jFMn2 nV5HkrEdrwMrMJl5pzp/Fx95JRfyWfJna/X6/JEJ1FiQyci/M+M+r8F7i8ABeUn6902j SvS6HBx4dbxCIYDfaPqVLCgOzc8xqMax55R8Ju+siD5//VGZU8OjhMdPJCYUNexDAQ/i TGqA== X-Gm-Message-State: APt69E2ymr9MUGE3iUFZeh8SrOf0h55Z6R1SI/b3J5WvqY7kY6at3Zqk ThP6kyd9vQ2KF8dvCp62jEK/s+hN X-Google-Smtp-Source: ADUXVKI6LesjR3bcVrOgErGO9IetrMFwnunpbfSrmnKR2sLyx3iSeb5BK95nN0L7rFoJoLRi0eGKHw== X-Received: by 2002:adf:b89b:: with SMTP id i27-v6mr1224488wrf.163.1528965730589; Thu, 14 Jun 2018 01:42:10 -0700 (PDT) Received: from localhost ([83.167.225.161]) by smtp.gmail.com with ESMTPSA id v68-v6sm6911608wmd.12.2018.06.14.01.42.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 01:42:10 -0700 (PDT) From: Jiri Pirko To: linux-internal@mellanox.com Subject: [patch net-next/mlxsw internal 10/12] mlxsw: spectrum_acl: Implement priority setting for rules inserted to TCAM Date: Thu, 14 Jun 2018 10:42:03 +0200 Message-Id: <20180614084205.1789-1-jiri@resnulli.us> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180614084049.1689-1-jiri@resnulli.us> References: <20180614084049.1689-1-jiri@resnulli.us> X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiri Pirko For Spectrum2, we need to insert priority to C-TCAM as well because HW needs in order to correctly process scenarios where rules are in both C-TCAM and A-TCAM. So extend the mlxsw_sp_acl_ctcam_entry_add() args to accept indication if priority needs to be filled up and implement the priority computation and fill-up. Signed-off-by: Jiri Pirko --- .../ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c | 5 +++-- .../ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c | 17 ++++++++++++---- .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 23 ++++++++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_acl_tcam.h | 6 +++++- 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c index 752c2ecd7a02..04f0c9cfae24 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum1_acl_tcam.c @@ -91,7 +91,8 @@ mlxsw_sp1_acl_ctcam_region_catchall_add(struct mlxsw_sp *mlxsw_sp, goto err_rulei_commit; err = mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion, ®ion->catchall.cchunk, - ®ion->catchall.centry, rulei); + ®ion->catchall.centry, + rulei, false); if (err) goto err_entry_add; region->catchall.rulei = rulei; @@ -178,7 +179,7 @@ static int mlxsw_sp1_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp, return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, ®ion->cregion, &chunk->cchunk, &entry->centry, - rulei); + rulei, false); } static void mlxsw_sp1_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c index 34546abb3fe5..ef0d4c0a5a1f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_ctcam.c @@ -71,16 +71,24 @@ static int mlxsw_sp_acl_ctcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region, unsigned int offset, - struct mlxsw_sp_acl_rule_info *rulei) + struct mlxsw_sp_acl_rule_info *rulei, + bool fillup_priority) { struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); char ptce2_pl[MLXSW_REG_PTCE2_LEN]; char *act_set; + u32 priority; char *mask; char *key; + int err; + + err = mlxsw_sp_acl_tcam_priority_get(mlxsw_sp, rulei, &priority, + fillup_priority); + if (err) + return err; mlxsw_reg_ptce2_pack(ptce2_pl, true, MLXSW_REG_PTCE2_OP_WRITE_WRITE, - region->tcam_region_info, offset, 0); + 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); @@ -172,7 +180,8 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_ctcam_region *cregion, struct mlxsw_sp_acl_ctcam_chunk *cchunk, struct mlxsw_sp_acl_ctcam_entry *centry, - struct mlxsw_sp_acl_rule_info *rulei) + struct mlxsw_sp_acl_rule_info *rulei, + bool fillup_priority) { int err; @@ -183,7 +192,7 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp, err = mlxsw_sp_acl_ctcam_region_entry_insert(mlxsw_sp, cregion->region, centry->parman_item.index, - rulei); + rulei, fillup_priority); if (err) goto err_rule_insert; return 0; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index f5015a787964..53fe51a8d720 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -112,6 +112,29 @@ void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp, kfree(tcam->used_regions); } +int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_rule_info *rulei, + u32 *priority, bool fillup_priority) +{ + u64 max_priority; + + if (!fillup_priority) { + *priority = 0; + return 0; + } + + if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, KVD_SIZE)) + return -EIO; + + max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE); + if (rulei->priority > max_priority) + return -EINVAL; + + /* Unlike in TC, in HW, higher number means higher priority. */ + *priority = max_priority - rulei->priority; + return 0; +} + static int mlxsw_sp_acl_tcam_region_id_get(struct mlxsw_sp_acl_tcam *tcam, u16 *p_id) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h index e01b75bcf009..cef769764505 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.h @@ -57,6 +57,9 @@ int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam *tcam); void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam *tcam); +int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp, + struct mlxsw_sp_acl_rule_info *rulei, + u32 *priority, bool fillup_priority); struct mlxsw_sp_acl_profile_ops { size_t ruleset_priv_size; @@ -128,7 +131,8 @@ int mlxsw_sp_acl_ctcam_entry_add(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_ctcam_region *cregion, struct mlxsw_sp_acl_ctcam_chunk *cchunk, struct mlxsw_sp_acl_ctcam_entry *centry, - struct mlxsw_sp_acl_rule_info *rulei); + struct mlxsw_sp_acl_rule_info *rulei, + bool fillup_priority); void mlxsw_sp_acl_ctcam_entry_del(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_ctcam_region *cregion, struct mlxsw_sp_acl_ctcam_chunk *cchunk,