From: Moshe Shemesh <moshe@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
Adrian Pop <pop.adrian61@gmail.com>,
"Michal Kubecek" <mkubecek@suse.cz>,
Don Bollinger <don@thebollingers.org>, <netdev@vger.kernel.org>
Cc: Vladyslav Tarasiuk <vladyslavt@nvidia.com>,
Moshe Shemesh <moshe@nvidia.com>
Subject: [RFC PATCH V3 net-next 3/5] net/mlx5: Implement get_module_eeprom_data_by_page()
Date: Mon, 15 Mar 2021 19:12:41 +0200 [thread overview]
Message-ID: <1615828363-464-4-git-send-email-moshe@nvidia.com> (raw)
In-Reply-To: <1615828363-464-1-git-send-email-moshe@nvidia.com>
From: Vladyslav Tarasiuk <vladyslavt@nvidia.com>
Implement ethtool_ops::get_module_eeprom_data_by_page() to enable
support of new SFP standards.
Signed-off-by: Vladyslav Tarasiuk <vladyslavt@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/en_ethtool.c | 44 +++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/port.c | 33 ++++++++++++++
include/linux/mlx5/port.h | 2 +
3 files changed, 79 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index abdf721bb264..5da9edea4d07 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1769,6 +1769,49 @@ static int mlx5e_get_module_eeprom(struct net_device *netdev,
return 0;
}
+static int mlx5e_get_module_eeprom_data_by_page(struct net_device *netdev,
+ const struct ethtool_eeprom_data *page_data,
+ struct netlink_ext_ack *extack)
+{
+ struct mlx5e_priv *priv = netdev_priv(netdev);
+ struct mlx5_module_eeprom_query_params query;
+ struct mlx5_core_dev *mdev = priv->mdev;
+ u8 *data = page_data->data;
+ int size_read;
+ int i = 0;
+
+ if (!page_data->length)
+ return -EINVAL;
+
+ memset(data, 0, page_data->length);
+
+ query.offset = page_data->offset;
+ query.i2c_address = page_data->i2c_address;
+ query.bank = page_data->bank;
+ query.page = page_data->page;
+ while (i < page_data->length) {
+ query.size = page_data->length - i;
+ size_read = mlx5_query_module_eeprom_data(mdev, &query, data + i);
+
+ /* Done reading, return how many bytes was read */
+ if (!size_read)
+ return i;
+
+ if (size_read == -EINVAL)
+ return -EINVAL;
+ if (size_read < 0) {
+ netdev_err(priv->netdev, "%s: mlx5_query_module_eeprom_data failed:0x%x\n",
+ __func__, size_read);
+ return i;
+ }
+
+ i += size_read;
+ query.offset += size_read;
+ }
+
+ return i;
+}
+
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
struct ethtool_flash *flash)
{
@@ -2148,6 +2191,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
.set_wol = mlx5e_set_wol,
.get_module_info = mlx5e_get_module_info,
.get_module_eeprom = mlx5e_get_module_eeprom,
+ .get_module_eeprom_data_by_page = mlx5e_get_module_eeprom_data_by_page,
.flash_device = mlx5e_flash_device,
.get_priv_flags = mlx5e_get_priv_flags,
.set_priv_flags = mlx5e_set_priv_flags,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c
index 9b9f870d67a4..f7a16fdfb8d3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
@@ -428,6 +428,39 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
}
EXPORT_SYMBOL_GPL(mlx5_query_module_eeprom);
+int mlx5_query_module_eeprom_data(struct mlx5_core_dev *dev,
+ struct mlx5_module_eeprom_query_params *params,
+ u8 *data)
+{
+ u8 module_id;
+ int err;
+
+ err = mlx5_query_module_num(dev, ¶ms->module_number);
+ if (err)
+ return err;
+
+ err = mlx5_query_module_id(dev, params->module_number, &module_id);
+ if (err)
+ return err;
+
+ if (module_id != MLX5_MODULE_ID_SFP &&
+ module_id != MLX5_MODULE_ID_QSFP &&
+ module_id != MLX5_MODULE_ID_QSFP28 &&
+ module_id != MLX5_MODULE_ID_QSFP_PLUS) {
+ mlx5_core_err(dev, "Module ID not recognized: 0x%x\n", module_id);
+ return -EINVAL;
+ }
+
+ if (params->i2c_address != MLX5_I2C_ADDR_HIGH &&
+ params->i2c_address != MLX5_I2C_ADDR_LOW) {
+ mlx5_core_err(dev, "I2C address not recognized: 0x%x\n", params->i2c_address);
+ return -EINVAL;
+ }
+
+ return mlx5_query_mcia(dev, params, data);
+}
+EXPORT_SYMBOL_GPL(mlx5_query_module_eeprom_data);
+
static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc,
int pvlc_size, u8 local_port)
{
diff --git a/include/linux/mlx5/port.h b/include/linux/mlx5/port.h
index 90b87aa82db3..887cd43b41e8 100644
--- a/include/linux/mlx5/port.h
+++ b/include/linux/mlx5/port.h
@@ -209,6 +209,8 @@ void mlx5_query_port_fcs(struct mlx5_core_dev *mdev, bool *supported,
bool *enabled);
int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
u16 offset, u16 size, u8 *data);
+int mlx5_query_module_eeprom_data(struct mlx5_core_dev *dev,
+ struct mlx5_module_eeprom_query_params *params, u8 *data);
int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
--
2.26.2
next prev parent reply other threads:[~2021-03-15 17:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 17:12 [RFC PATCH V3 net-next 0/5] ethtool: Extend module EEPROM dump API Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 1/5] ethtool: Allow network drivers to dump arbitrary EEPROM data Moshe Shemesh
2021-03-15 21:01 ` Jakub Kicinski
2021-03-16 17:59 ` Moshe Shemesh
2021-03-15 22:31 ` Don Bollinger
2021-03-16 18:23 ` Moshe Shemesh
2021-03-16 21:00 ` Don Bollinger
2021-03-18 22:36 ` Andrew Lunn
2021-03-18 13:03 ` Andrew Lunn
2021-03-18 14:25 ` Moshe Shemesh
2021-03-18 22:16 ` Andrew Lunn
2021-03-18 15:16 ` Michal Kubecek
2021-03-15 17:12 ` [RFC PATCH V3 net-next 2/5] net/mlx5: Refactor module EEPROM query Moshe Shemesh
2021-03-15 17:12 ` Moshe Shemesh [this message]
2021-03-15 17:12 ` [RFC PATCH V3 net-next 4/5] net/mlx5: Add support for DSFP module EEPROM dumps Moshe Shemesh
2021-03-15 17:12 ` [RFC PATCH V3 net-next 5/5] ethtool: Add fallback to get_module_eeprom from netlink command Moshe Shemesh
2021-03-15 22:31 ` Don Bollinger
2021-03-16 18:26 ` Moshe Shemesh
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=1615828363-464-4-git-send-email-moshe@nvidia.com \
--to=moshe@nvidia.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=don@thebollingers.org \
--cc=kuba@kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=pop.adrian61@gmail.com \
--cc=vladyslavt@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).