From patchwork Wed Jun 27 14:29:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 10491809 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 31D0860386 for ; Wed, 27 Jun 2018 14:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2284E293CC for ; Wed, 27 Jun 2018 14:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 170D3293FD; Wed, 27 Jun 2018 14:32: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 18B1C293CC for ; Wed, 27 Jun 2018 14:32:17 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41G5321DsxzF1JL for ; Thu, 28 Jun 2018 00:32:14 +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="e+2vBivc"; 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:c09::241; helo=mail-wm0-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="e+2vBivc"; dkim-atps=neutral Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::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 41G50m1lZxzF1D5 for ; Thu, 28 Jun 2018 00:30:16 +1000 (AEST) Received: by mail-wm0-x241.google.com with SMTP id u18-v6so5765812wmc.1 for ; Wed, 27 Jun 2018 07:30:15 -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=9RvUonvHlTwzdCE+HGXlMJTSSdo/iPbPH2LuIcLUsrQ=; b=e+2vBivcogVvw8rlb1DpL5oTBGqVNyLkbn3xgKNkFkxXGTD/iVUDtwERM2ZIYokgos sFo2Ema6G4SYn5ZQWAv6eHEmIqGVIRG5GS/nVsHqURPqGqyFOsjdVVlcVx83nou9+wmB aEzUYOniBUZAc5JXTqC1Owepcd+5FPQzLOf3s+3ZtXz/MxLBBrXs7zKF2MMIpPkAK0Ft Y9DjD5ZxSqEBVZki8C+Lkbqj8nbh1Gck98lC8q3Vj31II60343WOnc8dgXVkPcK556J/ XMkuiQSWPNsb9zcXqW8yLk/HuBZCfFWXULRPqkpX1cbnM1AdomQQFc9eiI36WECdOzSh Z+NA== 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=9RvUonvHlTwzdCE+HGXlMJTSSdo/iPbPH2LuIcLUsrQ=; b=RDrOWEtpf7Xk69iB8Mwb7S2dIGdrJMLo0GIkKsa6IcIaN30Ex95rcS5/5+PijC8NWd LULz7O0GKQspWpwOMv/LN4x8PAtu1pTtonRm0TC8LdOqRT3PUKZxAz1AOlb6TFU5NkFe ItKsCc45RBByfsfjZBzqPEeWn+RbFw2UT46lIPCWC77OsfPRjD5JaJGKysRD7Efp7vj2 phDTi6m0pZwfFuSFrMk2qVwVgdWwGEtVU+A7HagwHDE7AXQ/YU2fqIPxTHt2q5Yqe1zg 7VjY3f0WGb6wEdkR7CTqts04v3gbDK7NIOnFGaR6Caixnw2giasNKuw8IGpGEZW/45Cz qR/A== X-Gm-Message-State: APt69E28zaFDe2qyy+4evgk+yQDNi6JMEyuMIexnjgCnzp0GhjJhacIS Afp0DgVY+J0u2fHftQwP4OPG5Q== X-Google-Smtp-Source: AAOMgpfyU5JiGvAFTbfhTTuCOUWa6EfZ5OeYVWufljR6ifOl3XJ1sU7tScLvRI3zU8HTXDkKlr1ZcA== X-Received: by 2002:a1c:850c:: with SMTP id h12-v6mr5077688wmd.116.1530109813268; Wed, 27 Jun 2018 07:30:13 -0700 (PDT) Received: from localhost ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id r2-v6sm7074367wmb.39.2018.06.27.07.30.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 07:30:12 -0700 (PDT) From: Jiri Pirko To: linux-internal@mellanox.com Subject: [patch net-next/mlxsw internal v2 06/15] mlxsw: reg: Add support for activity information from PEFA register Date: Wed, 27 Jun 2018 16:29:56 +0200 Message-Id: <20180627143005.2016-7-jiri@resnulli.us> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180627143005.2016-1-jiri@resnulli.us> References: <20180627143005.2016-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 In Spectrum-2, the PEFA register is extend to report if the action set was hit during processing of packets. Introduce this extension and adjust the code around this accordingly. Signed-off-by: Jiri Pirko --- v1->v2: - s/Spectrum2/Spectrum-2/ - fix ca and a bits according to new PRM --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 29 ++++++++++++++++++++-- .../mellanox/mlxsw/spectrum_acl_flex_actions.c | 22 +++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index c872875c05b8..35e61e23872e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -2332,6 +2332,23 @@ MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN); */ MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24); +/* reg_pefa_a + * Index in the KVD Linear Centralized Database. + * Activity + * For a new entry: set if ca=0, clear if ca=1 + * Set if a packet lookup has hit on the specific entry + * Access: RO + */ +MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1); + +/* reg_pefa_ca + * Clear activity + * When write: activity is according to this field + * When read: after reading the activity is cleared according to ca + * Access: OP + */ +MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1); + #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8 /* reg_pefa_flex_action_set @@ -2341,12 +2358,20 @@ MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24); */ MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN); -static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, +static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca, const char *flex_action_set) { MLXSW_REG_ZERO(pefa, payload); mlxsw_reg_pefa_index_set(payload, index); - mlxsw_reg_pefa_flex_action_set_memcpy_to(payload, flex_action_set); + mlxsw_reg_pefa_ca_set(payload, ca); + if (flex_action_set) + mlxsw_reg_pefa_flex_action_set_memcpy_to(payload, + flex_action_set); +} + +static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a) +{ + *p_a = mlxsw_reg_pefa_a_get(payload); } /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c index 7649570f3b76..9119a023bc1e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_actions.c @@ -38,7 +38,7 @@ #include "spectrum_span.h" static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, - char *enc_actions, bool is_first) + char *enc_actions, bool is_first, bool ca) { struct mlxsw_sp *mlxsw_sp = priv; char pefa_pl[MLXSW_REG_PEFA_LEN]; @@ -55,7 +55,7 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, 1, &kvdl_index); if (err) return err; - mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, enc_actions); + mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, ca, enc_actions); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl); if (err) goto err_pefa_write; @@ -68,6 +68,20 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, return err; } +static int mlxsw_sp1_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, + char *enc_actions, bool is_first) +{ + return mlxsw_sp_act_kvdl_set_add(priv, p_kvdl_index, enc_actions, + is_first, false); +} + +static int mlxsw_sp2_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, + char *enc_actions, bool is_first) +{ + return mlxsw_sp_act_kvdl_set_add(priv, p_kvdl_index, enc_actions, + is_first, true); +} + static void mlxsw_sp_act_kvdl_set_del(void *priv, u32 kvdl_index, bool is_first) { @@ -158,7 +172,7 @@ mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, int span_id, bool ingress) } const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops = { - .kvdl_set_add = mlxsw_sp_act_kvdl_set_add, + .kvdl_set_add = mlxsw_sp1_act_kvdl_set_add, .kvdl_set_del = mlxsw_sp_act_kvdl_set_del, .kvdl_fwd_entry_add = mlxsw_sp_act_kvdl_fwd_entry_add, .kvdl_fwd_entry_del = mlxsw_sp_act_kvdl_fwd_entry_del, @@ -169,7 +183,7 @@ const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops = { }; const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops = { - .kvdl_set_add = mlxsw_sp_act_kvdl_set_add, + .kvdl_set_add = mlxsw_sp2_act_kvdl_set_add, .kvdl_set_del = mlxsw_sp_act_kvdl_set_del, .kvdl_fwd_entry_add = mlxsw_sp_act_kvdl_fwd_entry_add, .kvdl_fwd_entry_del = mlxsw_sp_act_kvdl_fwd_entry_del,