Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3016517pxb; Mon, 18 Oct 2021 06:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycfpXp+8vmn3vNeVoG4rD1dy8xHMOKRcYN5Q1QxwSpuHOywTM7GImzAy5kK1e/PzqVOK4/ X-Received: by 2002:a17:90b:1e4a:: with SMTP id pi10mr33662611pjb.142.1634564422482; Mon, 18 Oct 2021 06:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564422; cv=none; d=google.com; s=arc-20160816; b=IPkogQyA+7nIkolXdj83rDz7vDCKadwp0JPVvekA8MMHG/8UQiezyF7Ky8Iqqrr2na oo/EUV+3cCFpFzq9nSTGp0/U8AqkzECTeazpzOUrZmGyEYiEVUB/5bS4IuXRsDvZt2mt cXO0LcVJ8FWdGBFtQ7X5uApfrqqJEdqTfvKkvJfg86OtJkYJwKjPftaKphnL1up/u4r/ SvKn1NXf+hw+l6CDANb6vnm8yoMA1fZQLY7WnLd+CtdlqWBLlkF/PDnr+ivdo5D0qKlF cf/gSrKWsqhwRWbd/McoFJJcF8Dh4f8h2dzHyv6aL0ONr7+mOm+9Op+Q1nlwnJtVLbqk t/Hg== 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=yuKNSHJ1pkTLNj840Ip5Oych4KLtrQothWU8BPsq9uU=; b=q5uZuDKJXW7xOAlMg7A37KERYscuxquweyutyfdAGzYJRIuMKFENVe0HDM+H9CSawN 2oJoyGqTO011MpK9Q8p/ieD5dK9jC4rVjejHwRJIaOMKtQaqvSTDApdRVkqZoIc9BWfE 9Cru4DHQuZmrgtc/yMqGaQor3TK4IUhfORsanECU+AD7qbT+6a9Z1B9M1ZBNGexa/aXx 290Lj1kafQpfyRL5AILfoB01erDJ+rJB3jxK+WaBz5RTyyyM74Uo2iT0cv/YOfYnVLfq QZM+Hf8JaB14/mRXjWYB2BUmzTJwlmAgBsjw7dtu9Gl2rUE9pYzozh9UaVJ4YMrfQliX +xtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ffwxwP0g; 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 68si17937094pfe.367.2021.10.18.06.40.09; Mon, 18 Oct 2021 06:40:22 -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=ffwxwP0g; 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 S232470AbhJRNlI (ORCPT + 99 others); Mon, 18 Oct 2021 09:41:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:54246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233885AbhJRNjB (ORCPT ); Mon, 18 Oct 2021 09:39:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0DCD961381; Mon, 18 Oct 2021 13:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563948; bh=ir5dbfz+zYqI6AoqS2crXAXXvqIJm9yc4/M5GcsdZ3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ffwxwP0gPAx1aePfYWFTVUE4rmrx5dNOe94wBy7QuGyotacwHWVUKs85b/DrXJv+r l4WAmZG8xVjkbzrBzSIx2m8Z5LEeplYEjYvWajBk/9O00t/ClBkhhUpU/hUXJY6HwC PPHTiTzqyB0vBjPkrwub4LwWFfSJhSx3Qj+KGvSs= 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.4 49/69] net/mlx5e: Mutually exclude RX-FCS and RX-port-timestamp Date: Mon, 18 Oct 2021 15:24:47 +0200 Message-Id: <20211018132331.116072515@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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 @@ -3805,20 +3805,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 @@ -8942,16 +8942,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]; };