netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Gal Pressman <gal@nvidia.com>,
	Maxim Mikityanskiy <maximmi@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next 13/15] net/mlx5: Query the maximum MCIA register read size from firmware
Date: Thu, 10 Mar 2022 23:40:29 -0800	[thread overview]
Message-ID: <20220311074031.645168-14-saeed@kernel.org> (raw)
In-Reply-To: <20220311074031.645168-1-saeed@kernel.org>

From: Gal Pressman <gal@nvidia.com>

The MCIA register supports either 12 or 32 dwords, use the correct value
by querying the capability from the MCAM register.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/port.c | 8 +++++++-
 include/linux/mlx5/mlx5_ifc.h                  | 4 +++-
 include/linux/mlx5/port.h                      | 1 -
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index 289b29a23418..418ab777f6e8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -365,6 +365,12 @@ static void mlx5_sfp_eeprom_params_set(u16 *i2c_addr, int *page_num, u16 *offset
 	*offset -= MLX5_EEPROM_PAGE_LENGTH;
 }
 
+static int mlx5_mcia_max_bytes(struct mlx5_core_dev *dev)
+{
+	/* mcia supports either 12 dwords or 32 dwords */
+	return (MLX5_CAP_MCAM_FEATURE(dev, mcia_32dwords) ? 32 : 12) * sizeof(u32);
+}
+
 static int mlx5_query_mcia(struct mlx5_core_dev *dev,
 			   struct mlx5_module_eeprom_query_params *params, u8 *data)
 {
@@ -374,7 +380,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,
 	void *ptr;
 	u16 size;
 
-	size = min_t(int, params->size, MLX5_EEPROM_MAX_BYTES);
+	size = min_t(int, params->size, mlx5_mcia_max_bytes(dev));
 
 	MLX5_SET(mcia_reg, in, l, 0);
 	MLX5_SET(mcia_reg, in, size, size);
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 318fae4b3560..745107ff681d 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -9691,7 +9691,9 @@ struct mlx5_ifc_pcam_reg_bits {
 };
 
 struct mlx5_ifc_mcam_enhanced_features_bits {
-	u8         reserved_at_0[0x6a];
+	u8         reserved_at_0[0x5d];
+	u8         mcia_32dwords[0x1];
+	u8         reserved_at_5e[0xc];
 	u8         reset_state[0x1];
 	u8         ptpcyc2realtime_modify[0x1];
 	u8         reserved_at_6c[0x2];
diff --git a/include/linux/mlx5/port.h b/include/linux/mlx5/port.h
index 77ea4f9c5265..402413b3e914 100644
--- a/include/linux/mlx5/port.h
+++ b/include/linux/mlx5/port.h
@@ -56,7 +56,6 @@ enum mlx5_an_status {
 	MLX5_AN_LINK_DOWN   = 4,
 };
 
-#define MLX5_EEPROM_MAX_BYTES			32
 #define MLX5_EEPROM_IDENTIFIER_BYTE_MASK	0x000000ff
 #define MLX5_I2C_ADDR_LOW		0x50
 #define MLX5_I2C_ADDR_HIGH		0x51
-- 
2.35.1


  parent reply	other threads:[~2022-03-11  7:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  7:40 [pull request][net-next 00/15] mlx5 updates 2022-03-10 Saeed Mahameed
2022-03-11  7:40 ` [net-next 01/15] net/mlx4: Delete useless moduleparam include Saeed Mahameed
2022-03-11 11:00   ` patchwork-bot+netdevbpf
2022-03-11  7:40 ` [net-next 02/15] net/mlx5: Delete useless module.h include Saeed Mahameed
2022-03-11  7:40 ` [net-next 03/15] net/mlx5: Node-aware allocation for the IRQ table Saeed Mahameed
2022-03-11  7:40 ` [net-next 04/15] net/mlx5: Node-aware allocation for the EQ table Saeed Mahameed
2022-03-11  7:40 ` [net-next 05/15] net/mlx5: Node-aware allocation for the EQs Saeed Mahameed
2022-03-11  7:40 ` [net-next 06/15] net/mlx5: Node-aware allocation for UAR Saeed Mahameed
2022-03-11  7:40 ` [net-next 07/15] net/mlx5: Node-aware allocation for the doorbell pgdir Saeed Mahameed
2022-03-11  7:40 ` [net-next 08/15] net/mlx5: CT: Introduce a platform for multiple flow steering providers Saeed Mahameed
2022-03-11  7:40 ` [net-next 09/15] net/mlx5: DR, Add helper to get backing dr table from a mlx5 flow table Saeed Mahameed
2022-03-11  7:40 ` [net-next 10/15] net/mlx5: Add smfs lib to export direct steering API to CT Saeed Mahameed
2022-03-11  7:40 ` [net-next 11/15] net/mlx5: CT: Add software steering ct flow steering provider Saeed Mahameed
2022-03-11  7:40 ` [net-next 12/15] net/mlx5: CT: Create smfs dr matchers dynamically Saeed Mahameed
2022-03-11  7:40 ` Saeed Mahameed [this message]
2022-03-11  7:40 ` [net-next 14/15] net/mlx5: Parse module mapping using mlx5_ifc Saeed Mahameed
2022-03-11  7:40 ` [net-next 15/15] net/mlx5e: Remove overzealous validations in netlink EEPROM query Saeed Mahameed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220311074031.645168-14-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).