DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data
@ 2019-09-09 11:04 Dekel Peled
  2019-09-10  6:12 ` Slava Ovsiienko
  2019-09-10 13:46 ` Raslan Darawsheh
  0 siblings, 2 replies; 3+ messages in thread
From: Dekel Peled @ 2019-09-09 11:04 UTC (permalink / raw)
  To: matan, viacheslavo, shahafs; +Cc: orika, dev

This patch implements ethdev operations get_module_info and
get_module_eeprom, to support ethtool commands ETHTOOL_GMODULEINFO
and ETHTOOL_GMODULEEEPROM.

New functions mlx5_get_module_info() and mlx5_get_module_eeprom()
added in mlx5_ethdev.c.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5.c        |  6 +++
 drivers/net/mlx5/mlx5.h        |  4 ++
 drivers/net/mlx5/mlx5_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index dc7b10b..3be53c6 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -988,6 +988,8 @@ struct mlx5_dev_spawn_data {
 	.rx_queue_intr_disable = mlx5_rx_intr_disable,
 	.is_removed = mlx5_is_removed,
 	.udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
 };
 
 /* Available operations from secondary process. */
@@ -1001,6 +1003,8 @@ struct mlx5_dev_spawn_data {
 	.dev_infos_get = mlx5_dev_infos_get,
 	.rx_descriptor_status = mlx5_rx_descriptor_status,
 	.tx_descriptor_status = mlx5_tx_descriptor_status,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
 };
 
 /* Available operations in flow isolated mode. */
@@ -1044,6 +1048,8 @@ struct mlx5_dev_spawn_data {
 	.rx_queue_intr_enable = mlx5_rx_intr_enable,
 	.rx_queue_intr_disable = mlx5_rx_intr_disable,
 	.is_removed = mlx5_is_removed,
+	.get_module_info = mlx5_get_module_info,
+	.get_module_eeprom = mlx5_get_module_eeprom,
 };
 
 /**
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 09ca4b1..86a272e 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -724,6 +724,10 @@ void mlx5_translate_port_name(const char *port_name_in,
 			      struct mlx5_switch_info *port_info_out);
 void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
 				   rte_intr_callback_fn cb_fn, void *cb_arg);
+int mlx5_get_module_info(struct rte_eth_dev *dev,
+			 struct rte_eth_dev_module_info *modinfo);
+int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
+			   struct rte_dev_eeprom_info *info);
 
 /* mlx5_mac.c */
 
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 33a32fc..c68e773 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -1928,3 +1928,89 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
 	port_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;
 	return;
 }
+
+/**
+ * DPDK callback to retrieve plug-in module EEPROM information (type and size).
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param[out] modinfo
+ *   Storage for plug-in module EEPROM information.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_get_module_info(struct rte_eth_dev *dev,
+		     struct rte_eth_dev_module_info *modinfo)
+{
+	struct ethtool_modinfo info = {
+		.cmd = ETHTOOL_GMODULEINFO,
+	};
+	struct ifreq ifr = (struct ifreq) {
+		.ifr_data = (void *)&info,
+	};
+	int ret = 0;
+
+	if (!dev || !modinfo) {
+		DRV_LOG(WARNING, "missing argument, cannot get module info");
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "port %u ioctl(SIOCETHTOOL) failed: %s",
+			dev->data->port_id, strerror(rte_errno));
+		return ret;
+	}
+	modinfo->type = info.type;
+	modinfo->eeprom_len = info.eeprom_len;
+	return ret;
+}
+
+/**
+ * DPDK callback to retrieve plug-in module EEPROM data.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param[out] info
+ *   Storage for plug-in module EEPROM data.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
+			   struct rte_dev_eeprom_info *info)
+{
+	struct ethtool_eeprom *eeprom;
+	struct ifreq ifr;
+	int ret = 0;
+
+	if (!dev || !info) {
+		DRV_LOG(WARNING, "missing argument, cannot get module eeprom");
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+	eeprom = rte_calloc(__func__, 1,
+			    (sizeof(struct ethtool_eeprom) + info->length), 0);
+	if (!eeprom) {
+		DRV_LOG(WARNING, "port %u cannot allocate memory for "
+			"eeprom data", dev->data->port_id);
+		rte_errno = ENOMEM;
+		return -rte_errno;
+	}
+	eeprom->cmd = ETHTOOL_GMODULEEEPROM;
+	eeprom->offset = info->offset;
+	eeprom->len = info->length;
+	ifr = (struct ifreq) {
+		.ifr_data = (void *)eeprom,
+	};
+	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
+	if (ret)
+		DRV_LOG(WARNING, "port %u ioctl(SIOCETHTOOL) failed: %s",
+			dev->data->port_id, strerror(rte_errno));
+	else
+		rte_memcpy(info->data, eeprom->data, info->length);
+	rte_free(eeprom);
+	return ret;
+}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data
  2019-09-09 11:04 [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data Dekel Peled
@ 2019-09-10  6:12 ` Slava Ovsiienko
  2019-09-10 13:46 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Slava Ovsiienko @ 2019-09-10  6:12 UTC (permalink / raw)
  To: Dekel Peled, Matan Azrad, Shahaf Shuler; +Cc: Ori Kam, dev

> -----Original Message-----
> From: Dekel Peled <dekelp@mellanox.com>
> Sent: Monday, September 9, 2019 14:05
> To: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: Ori Kam <orika@mellanox.com>; dev@dpdk.org
> Subject: [PATCH] net/mlx5: support reading module EEPROM data
> 
> This patch implements ethdev operations get_module_info and
> get_module_eeprom, to support ethtool commands
> ETHTOOL_GMODULEINFO and ETHTOOL_GMODULEEEPROM.
> 
> New functions mlx5_get_module_info() and mlx5_get_module_eeprom()
> added in mlx5_ethdev.c.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  drivers/net/mlx5/mlx5.c        |  6 +++
>  drivers/net/mlx5/mlx5.h        |  4 ++
>  drivers/net/mlx5/mlx5_ethdev.c | 86
> ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 96 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> dc7b10b..3be53c6 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -988,6 +988,8 @@ struct mlx5_dev_spawn_data {
>  	.rx_queue_intr_disable = mlx5_rx_intr_disable,
>  	.is_removed = mlx5_is_removed,
>  	.udp_tunnel_port_add  = mlx5_udp_tunnel_port_add,
> +	.get_module_info = mlx5_get_module_info,
> +	.get_module_eeprom = mlx5_get_module_eeprom,
>  };
> 
>  /* Available operations from secondary process. */ @@ -1001,6 +1003,8
> @@ struct mlx5_dev_spawn_data {
>  	.dev_infos_get = mlx5_dev_infos_get,
>  	.rx_descriptor_status = mlx5_rx_descriptor_status,
>  	.tx_descriptor_status = mlx5_tx_descriptor_status,
> +	.get_module_info = mlx5_get_module_info,
> +	.get_module_eeprom = mlx5_get_module_eeprom,
>  };
> 
>  /* Available operations in flow isolated mode. */ @@ -1044,6 +1048,8 @@
> struct mlx5_dev_spawn_data {
>  	.rx_queue_intr_enable = mlx5_rx_intr_enable,
>  	.rx_queue_intr_disable = mlx5_rx_intr_disable,
>  	.is_removed = mlx5_is_removed,
> +	.get_module_info = mlx5_get_module_info,
> +	.get_module_eeprom = mlx5_get_module_eeprom,
>  };
> 
>  /**
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> 09ca4b1..86a272e 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -724,6 +724,10 @@ void mlx5_translate_port_name(const char
> *port_name_in,
>  			      struct mlx5_switch_info *port_info_out);  void
> mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
>  				   rte_intr_callback_fn cb_fn, void *cb_arg);
> +int mlx5_get_module_info(struct rte_eth_dev *dev,
> +			 struct rte_eth_dev_module_info *modinfo); int
> +mlx5_get_module_eeprom(struct rte_eth_dev *dev,
> +			   struct rte_dev_eeprom_info *info);
> 
>  /* mlx5_mac.c */
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 33a32fc..c68e773 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1928,3 +1928,89 @@ int mlx5_fw_version_get(struct rte_eth_dev
> *dev, char *fw_ver, size_t fw_size)
>  	port_info_out->name_type =
> MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;
>  	return;
>  }
> +
> +/**
> + * DPDK callback to retrieve plug-in module EEPROM information (type and
> size).
> + *
> + * @param dev
> + *   Pointer to Ethernet device structure.
> + * @param[out] modinfo
> + *   Storage for plug-in module EEPROM information.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int
> +mlx5_get_module_info(struct rte_eth_dev *dev,
> +		     struct rte_eth_dev_module_info *modinfo) {
> +	struct ethtool_modinfo info = {
> +		.cmd = ETHTOOL_GMODULEINFO,
> +	};
> +	struct ifreq ifr = (struct ifreq) {
> +		.ifr_data = (void *)&info,
> +	};
> +	int ret = 0;
> +
> +	if (!dev || !modinfo) {
> +		DRV_LOG(WARNING, "missing argument, cannot get module
> info");
> +		rte_errno = EINVAL;
> +		return -rte_errno;
> +	}
> +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> +	if (ret) {
> +		DRV_LOG(WARNING, "port %u ioctl(SIOCETHTOOL) failed:
> %s",
> +			dev->data->port_id, strerror(rte_errno));
> +		return ret;
> +	}
> +	modinfo->type = info.type;
> +	modinfo->eeprom_len = info.eeprom_len;
> +	return ret;
> +}
> +
> +/**
> + * DPDK callback to retrieve plug-in module EEPROM data.
> + *
> + * @param dev
> + *   Pointer to Ethernet device structure.
> + * @param[out] info
> + *   Storage for plug-in module EEPROM data.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
> +			   struct rte_dev_eeprom_info *info) {
> +	struct ethtool_eeprom *eeprom;
> +	struct ifreq ifr;
> +	int ret = 0;
> +
> +	if (!dev || !info) {
> +		DRV_LOG(WARNING, "missing argument, cannot get module
> eeprom");
> +		rte_errno = EINVAL;
> +		return -rte_errno;
> +	}
> +	eeprom = rte_calloc(__func__, 1,
> +			    (sizeof(struct ethtool_eeprom) + info->length), 0);
> +	if (!eeprom) {
> +		DRV_LOG(WARNING, "port %u cannot allocate memory for "
> +			"eeprom data", dev->data->port_id);
> +		rte_errno = ENOMEM;
> +		return -rte_errno;
> +	}
> +	eeprom->cmd = ETHTOOL_GMODULEEEPROM;
> +	eeprom->offset = info->offset;
> +	eeprom->len = info->length;
> +	ifr = (struct ifreq) {
> +		.ifr_data = (void *)eeprom,
> +	};
> +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> +	if (ret)
> +		DRV_LOG(WARNING, "port %u ioctl(SIOCETHTOOL) failed:
> %s",
> +			dev->data->port_id, strerror(rte_errno));
> +	else
> +		rte_memcpy(info->data, eeprom->data, info->length);
> +	rte_free(eeprom);
> +	return ret;
> +}
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data
  2019-09-09 11:04 [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data Dekel Peled
  2019-09-10  6:12 ` Slava Ovsiienko
@ 2019-09-10 13:46 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2019-09-10 13:46 UTC (permalink / raw)
  To: Dekel Peled, Matan Azrad, Slava Ovsiienko, Shahaf Shuler; +Cc: Ori Kam, dev

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Monday, September 9, 2019 2:05 PM
> To: Matan Azrad <matan@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: Ori Kam <orika@mellanox.com>; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM
> data
> 
> This patch implements ethdev operations get_module_info and
> get_module_eeprom, to support ethtool commands
> ETHTOOL_GMODULEINFO
> and ETHTOOL_GMODULEEEPROM.
> 
> New functions mlx5_get_module_info() and mlx5_get_module_eeprom()
> added in mlx5_ethdev.c.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 11:04 [dpdk-dev] [PATCH] net/mlx5: support reading module EEPROM data Dekel Peled
2019-09-10  6:12 ` Slava Ovsiienko
2019-09-10 13:46 ` Raslan Darawsheh

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox