Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3021981pxb; Mon, 18 Oct 2021 06:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1sqmq+OI+A2CW0sGO40l7rjQp7X7o58yLDt9JOlnMRzp9y3GlxsqUJ8bCD3F02p+Svj4Q X-Received: by 2002:a63:258:: with SMTP id 85mr23827291pgc.11.1634564808243; Mon, 18 Oct 2021 06:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564808; cv=none; d=google.com; s=arc-20160816; b=V9Vy8Jd3tMpO+gIFAd/fCvfxOmUf/WIHJ9tUIBWrPxembvqWXzSr56ZRIT/+ujTRiU vD4Z8v1D16HzE8IXZYBQpWdOvkXXApzzOgRLGPjUluvSUZpHHZytKptYncc+Z+HVoq4E 2Rr+EBGcU2OrQ+I13Bf0vMn5KqM4cvs0zppyBPoIdcL+EiZLQ7zGU8FHJ+3K5Dl/7RA+ D78HnTEk6zpYXTO2oExx4lJ1Vm2RmbhkuGxLwkUKDm11pxqvT/ApAWz+MyZq+ihrIsHE n1V/rg9JNlkAESaDNEDcInel7PRt8Ej/1D48w39sdUu6ZhAmqcDsBczxdAB9uHvc1rwQ c8cw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QVdEKuHDIO8Pir5ssBDAmU/+XkgVDM8T8cjgJfCLusc=; b=kGn6zGwCLFPdQdKGvWoYiXthWWymzzscWClBgFmlcWQlnq7ahqzMxtDfxkUbj1T1L2 k0NqJVs5h72X1rrhenL8ihkwfQTB3Y83A84iuEbun7xfj4qHMW2V3emnyWieTILWI1a9 ryjXOVo/Gpq381r0pqwrXjbKWvjPrqsXnYPa6gLrhllN2vCOT6XID8Z0W+GQWQmVBjBI 06MjihRYFVB0fM8qE6LJhq6HFTxz/4Lq+P4xcohmw4FnXVWx811GFAfsCPctt6Y35p04 PVyA6gsz0egs1ATVO41/Qfkne++OV/zKAznBxaEbGnlNjEMmLljSlwitiFj6cNY+eYCQ tMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GFZ95Utg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q28si3393542pgu.255.2021.10.18.06.46.33; Mon, 18 Oct 2021 06:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GFZ95Utg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232291AbhJRNr1 (ORCPT + 99 others); Mon, 18 Oct 2021 09:47:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:36772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbhJRNpJ (ORCPT ); Mon, 18 Oct 2021 09:45:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA288615A4; Mon, 18 Oct 2021 13:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564126; bh=HuHe8S83WxmmoP4Hyx+MT5LkkF+fxuSCD8kog9q8rsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFZ95Utgsl4jA/mQZJd8ynik4uBN54KpB2USQd22dUPdvRKvD65f80uWBBfOgNSRk KiedLu4/6/oIIi2AEwwe2xxvBywUpHJyuBLvS1YFZfN3O8SPSAgKNhIxK2bRXwqEZ+ G6BcdeJK+OBAUEjED8dzc8btu/VvAAo6UScswYfE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aya Levin , Tariq Toukan , Moshe Shemesh , Saeed Mahameed Subject: [PATCH 5.10 073/103] net/mlx5e: Mutually exclude RX-FCS and RX-port-timestamp Date: Mon, 18 Oct 2021 15:24:49 +0200 Message-Id: <20211018132337.205366925@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aya Levin commit 0bc73ad46a76ed6ece4dcacb28858e7b38561e1c upstream. Due to current HW arch limitations, RX-FCS (scattering FCS frame field to software) and RX-port-timestamp (improved timestamp accuracy on the receive side) can't work together. RX-port-timestamp is not controlled by the user and it is enabled by default when supported by the HW/FW. This patch sets RX-port-timestamp opposite to RX-FCS configuration. Fixes: 102722fc6832 ("net/mlx5e: Add support for RXFCS feature flag") Signed-off-by: Aya Levin Reviewed-by: Tariq Toukan Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 57 ++++++++++++++++++++-- include/linux/mlx5/mlx5_ifc.h | 10 +++ 2 files changed, 60 insertions(+), 7 deletions(-) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -3819,20 +3819,67 @@ static int set_feature_rx_all(struct net return mlx5_set_port_fcs(mdev, !enable); } +static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable) +{ + u32 in[MLX5_ST_SZ_DW(pcmr_reg)] = {}; + bool supported, curr_state; + int err; + + if (!MLX5_CAP_GEN(mdev, ports_check)) + return 0; + + err = mlx5_query_ports_check(mdev, in, sizeof(in)); + if (err) + return err; + + supported = MLX5_GET(pcmr_reg, in, rx_ts_over_crc_cap); + curr_state = MLX5_GET(pcmr_reg, in, rx_ts_over_crc); + + if (!supported || enable == curr_state) + return 0; + + MLX5_SET(pcmr_reg, in, local_port, 1); + MLX5_SET(pcmr_reg, in, rx_ts_over_crc, enable); + + return mlx5_set_ports_check(mdev, in, sizeof(in)); +} + static int set_feature_rx_fcs(struct net_device *netdev, bool enable) { struct mlx5e_priv *priv = netdev_priv(netdev); + struct mlx5e_channels *chs = &priv->channels; + struct mlx5_core_dev *mdev = priv->mdev; int err; mutex_lock(&priv->state_lock); - priv->channels.params.scatter_fcs_en = enable; - err = mlx5e_modify_channels_scatter_fcs(&priv->channels, enable); - if (err) - priv->channels.params.scatter_fcs_en = !enable; + if (enable) { + err = mlx5e_set_rx_port_ts(mdev, false); + if (err) + goto out; + + chs->params.scatter_fcs_en = true; + err = mlx5e_modify_channels_scatter_fcs(chs, true); + if (err) { + chs->params.scatter_fcs_en = false; + mlx5e_set_rx_port_ts(mdev, true); + } + } else { + chs->params.scatter_fcs_en = false; + err = mlx5e_modify_channels_scatter_fcs(chs, false); + if (err) { + chs->params.scatter_fcs_en = true; + goto out; + } + err = mlx5e_set_rx_port_ts(mdev, true); + if (err) { + mlx5_core_warn(mdev, "Failed to set RX port timestamp %d\n", err); + err = 0; + } + } +out: mutex_unlock(&priv->state_lock); - return err; } --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h @@ -9274,16 +9274,22 @@ struct mlx5_ifc_pcmr_reg_bits { u8 reserved_at_0[0x8]; u8 local_port[0x8]; u8 reserved_at_10[0x10]; + u8 entropy_force_cap[0x1]; u8 entropy_calc_cap[0x1]; u8 entropy_gre_calc_cap[0x1]; - u8 reserved_at_23[0x1b]; + u8 reserved_at_23[0xf]; + u8 rx_ts_over_crc_cap[0x1]; + u8 reserved_at_33[0xb]; u8 fcs_cap[0x1]; u8 reserved_at_3f[0x1]; + u8 entropy_force[0x1]; u8 entropy_calc[0x1]; u8 entropy_gre_calc[0x1]; - u8 reserved_at_43[0x1b]; + u8 reserved_at_43[0xf]; + u8 rx_ts_over_crc[0x1]; + u8 reserved_at_53[0xb]; u8 fcs_chk[0x1]; u8 reserved_at_5f[0x1]; };