summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2019-02-06 23:25:19 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2019-02-13 12:55:38 +0100
commit714bf46ebb52152d7b17199578b35c76f835da79 (patch)
tree4d63f2c1ed8bd950f5571dacaa7e477af4012c96 /drivers/net/mlx5/mlx5_ethdev.c
parent7f4019d370f6edbd9d6ef26a9bc62442b0fd80a6 (diff)
downloaddpdk-next-eventdev-714bf46ebb52152d7b17199578b35c76f835da79.zip
dpdk-next-eventdev-714bf46ebb52152d7b17199578b35c76f835da79.tar.gz
dpdk-next-eventdev-714bf46ebb52152d7b17199578b35c76f835da79.tar.xz
net/mlx: support firmware version query
The API function rte_eth_dev_fw_version_get() is querying drivers via the operation callback fw_version_get(). The implementation of this operation is added for mlx4 and mlx5. Both functions are copying the same ibverbs field fw_ver which is retrieved when calling ibv_query_device[_ex]() during the port probing. It is tested with command "drvinfo" of examples/ethtool/. Signed-off-by: Thomas Monjalon <thomas@monjalon.net> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index d178ed6..8158b4a 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -558,6 +558,32 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
}
/**
+ * Get firmware version of a device.
+ *
+ * @param dev
+ * Ethernet device port.
+ * @param fw_ver
+ * String output allocated by caller.
+ * @param fw_size
+ * Size of the output string, including terminating null byte.
+ *
+ * @return
+ * 0 on success, or the size of the non truncated string if too big.
+ */
+int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
+{
+ struct priv *priv = dev->data->dev_private;
+ struct ibv_device_attr *attr = &priv->device_attr.orig_attr;
+ size_t size = strnlen(attr->fw_ver, sizeof(attr->fw_ver)) + 1;
+
+ if (fw_size < size)
+ return size;
+ if (fw_ver != NULL)
+ strlcpy(fw_ver, attr->fw_ver, fw_size);
+ return 0;
+}
+
+/**
* Get supported packet types.
*
* @param dev