Skip to contentSkip to conversation

Create device FW version call back

PATCH In review [email protected] 6 participants 23 messages Jun 15, 2016 – Jun 23, 2016 7 messages not in the archive

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover Create device FW version call back

From: Ira Weiny <[email protected]>

Currently there are 3 ways to get the firmware version for an RDMA device.

1) verbs query device
2) ethtool
3) sysfs entry

Both 1 and 2 are expecting a 64bit field which is vendor specific and encodes a 3 number version. Some hardware, like OPA, only has 2 numbers in it's version, while other hardware like cxgb4 has 4.

Support for the sysfs entry was left to the devices but generally done in a "common" way.

This series moves to unify firmware version reporting by creating the ib_get_device_fw_str method within the ib_device. With this we can then do 3 things.

1) Support device dependent formats of version strings with ethtool (IPoIB)

2) Support a common sysfs entry in the core for backwards compatibility which can either be changed to a common FW version string with the new verbs interface or simply removed in favor of using ethtool.

3) Eventually drop the sysfs entry once we can get user space tools off of it. If we decide not to have an interface through verbs (require the use of ethtool via IPoIB) iWarp and RoCE devices don't even have to have this support at all and the code can be eliminated for those devices.

1 and 2 are done with this patch series. 3 needs to be decided by the community if, and when, sysfs support can be dropped.

NOTE: I have tested these patches with mlx4, qib, and hfi1. Other drivers were compile tested only.

---
Changes from V0:
Address comments by Jason and Leon
Rebase to upstream
Add Reviewed-by for cxgb4

Ira Weiny (13):
IB/core: Add get FW version string to the core
IB/cxgb3: Support device FW version string
IB/cxgb4: Support device FW version string
IB/i40iw: Support device FW version string
IB/mlx4: Support device FW version string
IB/mlx5: Support device FW version string
IB/mthca: Supprot device FW version string
IB/nes: Support device FW version string
IB/ocrdma: Support device FW version string
IB/usnic: Support device FW version string
IB/ipoib: Use new device FW version string
IB/core: Export a common fw_ver sysfs entry
IB/hfi1: Add device FW version string

 drivers/infiniband/core/device.c             |  9 ++++++++
 drivers/infiniband/core/sysfs.c              | 15 ++++++++++++-
 drivers/infiniband/hw/cxgb3/iwch_provider.c  | 27 +++++++++++------------
 drivers/infiniband/hw/cxgb4/provider.c       | 31 +++++++++++++-------------
 drivers/infiniband/hw/hfi1/hfi.h             |  2 ++
 drivers/infiniband/hw/hfi1/verbs.c           | 15 +++++++++++++
 drivers/infiniband/hw/i40iw/i40iw_verbs.c    | 24 +++++++++-----------
 drivers/infiniband/hw/mlx4/main.c            | 24 ++++++++++----------
 drivers/infiniband/hw/mlx5/main.c            | 21 +++++++++---------
 drivers/infiniband/hw/mthca/mthca_provider.c | 24 ++++++++++----------
 drivers/infiniband/hw/nes/nes_verbs.c        | 33 ++++++++++++----------------
 drivers/infiniband/hw/ocrdma/ocrdma_main.c   | 19 ++++++++--------
 drivers/infiniband/hw/usnic/usnic_ib_main.c  | 16 ++++++++++++++
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 17 --------------
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c |  6 ++---
 include/rdma/ib_verbs.h                      |  3 +++
 16 files changed, 156 insertions(+), 130 deletions(-)
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1465971728-24104-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/13 IB/core: Add get FW version string to the core

From: Ira Weiny <[email protected]>

Allow for a common core function to get firmware version strings from the individual devices.

In later patches this format can then then be used to pass a properly formated version string through the IPoIB layer.

The problem with the current code in the IPoIB layer is that it is specific to certain hardware types.

Furthermore, this gives us a common function through which the core can provide a common sysfs entry. Eventually we may want to remove the sysfs export but this provides for user space backwards compatibility.

---
Changes from V0:
Add parameter names to function signature
change default string assignment

 drivers/infiniband/core/device.c | 9 +++++++++
 include/rdma/ib_verbs.h          | 3 +++
 2 files changed, 12 insertions(+)
drivers/infiniband/core/device.c +9 -0
index 5c155fa91eec..760ef603a468 100644
@@ -311,6 +311,15 @@ static int read_port_immutable(struct ib_device *device)
 	return 0;
 }
 
+void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len)
+{
+	if (dev->get_dev_fw_str)
+		dev->get_dev_fw_str(dev, str, str_len);
+	else
+		str[0] = '\0';
+}
+EXPORT_SYMBOL(ib_get_device_fw_str);
+
 /**
  * ib_register_device - Register an IB device with IB core
  * @device:Device to register
include/rdma/ib_verbs.h +3 -0
index 7e440d41487a..1dc3d0d90202 100644
@@ -1956,6 +1956,7 @@ struct ib_device {
 	 * in fast paths.
 	 */
 	int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *);
+	void (*get_dev_fw_str)(struct ib_device *, char *str, size_t str_len);
 };
 
 struct ib_client {
@@ -1991,6 +1992,8 @@ struct ib_client {
 struct ib_device *ib_alloc_device(size_t size);
 void ib_dealloc_device(struct ib_device *device);
 
+void ib_get_device_fw_str(struct ib_device *device, char *str, size_t str_len);
+
 int ib_register_device(struct ib_device *device,
 		       int (*port_callback)(struct ib_device *,
 					    u8, struct kobject *));
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1465971728-24104-2-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH V1 01/13] IB/core: Add get FW version string to the core

Quoted 33 lines · On Wed, Jun 15, 2016 at 02:21:56AM -0400…

From: Ira Weiny <[email protected]>

Allow for a common core function to get firmware version strings from the individual devices.

In later patches this format can then then be used to pass a properly formated version string through the IPoIB layer.

The problem with the current code in the IPoIB layer is that it is specific to certain hardware types.

Furthermore, this gives us a common function through which the core can provide a common sysfs entry. Eventually we may want to remove the sysfs export but this provides for user space backwards compatibility.

---
Changes from V0:
Add parameter names to function signature
change default string assignment

 drivers/infiniband/core/device.c | 9 +++++++++
 include/rdma/ib_verbs.h          | 3 +++
 2 files changed, 12 insertions(+)
drivers/infiniband/core/device.c +0 -0
index 5c155fa91eec..760ef603a468 100644

drivers/infiniband/core/device.c static int read_port_immutable(struct ib_device *device) · line 319

Quoted 9 lines
drivers/infiniband/core/device.c +6 -0
@@ -311,6 +311,15 @@ static int read_port_immutable(struct ib_device *device)
 	return 0;
 }
 
+void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len)
+{
+	if (dev->get_dev_fw_str)
+		dev->get_dev_fw_str(dev, str, str_len);
+	else
+		str[0] = '\0';

Interesting point, what is better for the caller to get as a version? You chose empty string, but it can be all Fs or all 0s.

Quoted 2 lines
drivers/infiniband/core/device.c +2 -0
+}
+EXPORT_SYMBOL(ib_get_device_fw_str);

A message that is not in the archive (sent off-list or not yet received): 20160615064008.GS5408-2ukJVAZIZ/[email protected]

author
#6 lore raw

Re: [PATCH V1 01/13] IB/core: Add get FW version string to the core

Quoted 2 lines · Leon Romanovsky
Quoted 1 line · On Wed, Jun 15, 2016 at 02:21:56AM -0400…

From: Ira Weiny <[email protected]>

[snip]

Quoted 9 lines
Quoted 9 lines
drivers/infiniband/core/device.c +0 -0
index 5c155fa91eec..760ef603a468 100644
@@ -311,6 +311,15 @@ static int read_port_immutable(struct ib_device *device)
 	return 0;
 }
 
Quoted 9 lines

drivers/infiniband/core/device.c static int read_port_immutable(struct ib_device *device) · line 319

Quoted 6 lines
drivers/infiniband/core/device.c +6 -0
+void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len)
+{
+	if (dev->get_dev_fw_str)
+		dev->get_dev_fw_str(dev, str, str_len);
+	else
+		str[0] = '\0';

Interesting point, what is better for the caller to get as a version? You chose empty string, but it can be all Fs or all 0s.

The default here is that a device does not provide a firmware string. In that case the assumption is that there is no firmware. Hence the empty string. I don't think that reporting 0's or F's are appropriate if a device does not have firmware.

In the cases you speak of I would expect the device to supply the firmware function and report all 0s or all Fs for whatever version that may represent. (I'm assuming that would be some sort of debug or unreleased firmware...)

I could just as well done something like.

snprintf(str, str_len, "<none>");

Which may be more informative? I just don't want to get too wrapped up in the policy here. I think this is best left to the driver/hw vendor.

Ira

Quoted 3 lines

drivers/infiniband/core/device.c static int read_port_immutable(struct ib_device *device) · line 321

Quoted 3 lines
drivers/infiniband/core/device.c +2 -0
+}
+EXPORT_SYMBOL(ib_get_device_fw_str);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20160615152048.GB8690-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org

#8 lore raw

Re: [PATCH V1 01/13] IB/core: Add get FW version string to the core

Quoted 5 lines · ira.weiny

The default here is that a device does not provide a firmware string. In that case the assumption is that there is no firmware. Hence the empty string. I don't think that reporting 0's or F's are appropriate if a device does not have firmware.

Quoted 7 lines

In the cases you speak of I would expect the device to supply the firmware function and report all 0s or all Fs for whatever version that may represent. (I'm assuming that would be some sort of debug or unreleased firmware...)

I could just as well done something like.

snprintf(str, str_len, "<none>");

Just don't provide a 'fw' sysfs file at all if the driver cannot support it.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20160615165106.GA10256-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#10 lore raw

Re: [PATCH V1 01/13] IB/core: Add get FW version string to the core

Quoted 10 lines · Jason Gunthorpe
Quoted 9 lines · ira.weiny

The default here is that a device does not provide a firmware string. In that case the assumption is that there is no firmware. Hence the empty string. I don't think that reporting 0's or F's are appropriate if a device does not have firmware.

In the cases you speak of I would expect the device to supply the firmware function and report all 0s or all Fs for whatever version that may represent. (I'm assuming that would be some sort of debug or unreleased firmware...)

Quoted 6 lines
Quoted 3 lines

I could just as well done something like.

snprintf(str, str_len, "<none>");

Just don't provide a 'fw' sysfs file at all if the driver cannot support it.

This function is supporting both sysfs and ethtool.

ethtool_drvinfo->fw_version is normally up to the device. I've just provided a default.

For example I see "N/A", "n/a", and "none" all used in the network stack.

./ethernet/freescale/gianfar_ethtool.c: strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));

./rionet.c: strlcpy(info->fw_version, "n/a", sizeof(info->fw_version));

./fjes/fjes_ethtool.c: strlcpy(drvinfo->fw_version, "none", sizeof(drvinfo->fw_version));

I really think we are in the weeds here and are fine to leave it blank.

But if you wish, I can force all drivers to provide the string and then they can put something in like the above.

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20160615232602.GA4034-W4f6Xiosr+yv7QzWx2u06xL4W9x8LtSr@public.gmane.org

#12 lore raw

Re: [PATCH V1 01/13] IB/core: Add get FW version string to the core

Quoted 25 lines · ira.weiny
Quoted 10 lines · Jason Gunthorpe
Quoted 9 lines · ira.weiny

The default here is that a device does not provide a firmware string. In that case the assumption is that there is no firmware. Hence the empty string. I don't think that reporting 0's or F's are appropriate if a device does not have firmware.

In the cases you speak of I would expect the device to supply the firmware function and report all 0s or all Fs for whatever version that may represent. (I'm assuming that would be some sort of debug or unreleased firmware...)

Quoted 6 lines
Quoted 3 lines

I could just as well done something like.

snprintf(str, str_len, "<none>");

Just don't provide a 'fw' sysfs file at all if the driver cannot support it.

This function is supporting both sysfs and ethtool.

ethtool_drvinfo->fw_version is normally up to the device. I've just provided a default.

For example I see "N/A", "n/a", and "none" all used in the network stack.

Quoted 7 lines

./ethernet/freescale/gianfar_ethtool.c: strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));

./rionet.c: strlcpy(info->fw_version, "n/a", sizeof(info->fw_version));

./fjes/fjes_ethtool.c: strlcpy(drvinfo->fw_version, "none", sizeof(drvinfo->fw_version));

I really think we are in the weeds here and are fine to leave it blank.

I'm fine with that.

Quoted 6 lines

But if you wish, I can force all drivers to provide the string and then they can put something in like the above.

Ira

#13 lore raw

PATCH 2/13 IB/cxgb3: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Also remove fw_ver sysfs to be replaced by the common core one.

---
 drivers/infiniband/hw/cxgb3/iwch_provider.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/infiniband/hw/cxgb3/iwch_provider.c +13 -14
index bb1a839d4d6d..3edb80644b53 100644
@@ -1183,18 +1183,6 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
 	return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
 }
 
-static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
-{
-	struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
-						 ibdev.dev);
-	struct ethtool_drvinfo info;
-	struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
-
-	PDBG("%s dev 0x%p\n", __func__, dev);
-	lldev->ethtool_ops->get_drvinfo(lldev, &info);
-	return sprintf(buf, "%s\n", info.fw_version);
-}
-
 static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
 			char *buf)
 {
@@ -1334,13 +1322,11 @@ static int iwch_get_mib(struct ib_device *ibdev, struct rdma_hw_stats *stats,
 }
 
 static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
 static struct device_attribute *iwch_class_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id,
 };
@@ -1362,6 +1348,18 @@ static int iwch_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str,
+			       size_t str_len)
+{
+	struct iwch_dev *iwch_dev = to_iwch_dev(ibdev);
+	struct ethtool_drvinfo info;
+	struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
+
+	PDBG("%s dev 0x%p\n", __func__, iwch_dev);
+	lldev->ethtool_ops->get_drvinfo(lldev, &info);
+	snprintf(str, str_len, "%s", info.fw_version);
+}
+
 int iwch_register_device(struct iwch_dev *dev)
 {
 	int ret;
@@ -1437,6 +1435,7 @@ int iwch_register_device(struct iwch_dev *dev)
 	dev->ibdev.get_hw_stats = iwch_get_mib;
 	dev->ibdev.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION;
 	dev->ibdev.get_port_immutable = iwch_port_immutable;
+	dev->ibdev.get_dev_fw_str = get_dev_fw_ver_str;
 
 	dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
 	if (!dev->ibdev.iwcm)
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1465971728-24104-3-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

author
#16 lore raw

RE: [PATCH V1 02/13] IB/cxgb3: Support device FW version string

I saw your response to cxgb4. I was not sure if you meant for both or not.

Sorry I will add this too.

Ira

Quoted 9 lines

-----Original Message-----
From: Steve Wise [mailto:[email protected]]
Sent: Wednesday, June 15, 2016 7:21 AM
To: Weiny, Ira <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; devesh.sharma-1wcpHE2jlwO1Z/[email protected]; Latif, Faisal <[email protected]>; matanb-VPRAkNaXOzVWk0Htik3J/[email protected]; leonro-VPRAkNaXOzVWk0Htik3J/[email protected]; [email protected]
Subject: RE: [PATCH V1 02/13] IB/cxgb3: Support device FW version string

Quoted 5 lines

I reviewed this previously...

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#17 lore raw

PATCH 3/13 IB/cxgb4: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove sysfs fw_ver in favor of the core.

---
Changes from V0:
Add tag Reviewed-by: Steve Wise <[email protected]>

 drivers/infiniband/hw/cxgb4/provider.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/infiniband/hw/cxgb4/provider.c +15 -16
index dd8a86b726d2..df127ce6b6ec 100644
@@ -409,20 +409,6 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
 		       CHELSIO_CHIP_RELEASE(c4iw_dev->rdev.lldi.adapter_type));
 }
 
-static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
-			   char *buf)
-{
-	struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
-						 ibdev.dev);
-	PDBG("%s dev 0x%p\n", __func__, dev);
-
-	return sprintf(buf, "%u.%u.%u.%u\n",
-			FW_HDR_FW_VER_MAJOR_G(c4iw_dev->rdev.lldi.fw_vers),
-			FW_HDR_FW_VER_MINOR_G(c4iw_dev->rdev.lldi.fw_vers),
-			FW_HDR_FW_VER_MICRO_G(c4iw_dev->rdev.lldi.fw_vers),
-			FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers));
-}
-
 static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
 			char *buf)
 {
@@ -502,13 +488,11 @@ static int c4iw_get_mib(struct ib_device *ibdev,
 }
 
 static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
 static struct device_attribute *c4iw_class_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id,
 };
@@ -530,6 +514,20 @@ static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_str(struct ib_device *dev, char *str,
+			   size_t str_len)
+{
+	struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
+						 ibdev);
+	PDBG("%s dev 0x%p\n", __func__, dev);
+
+	snprintf(str, str_len, "%u.%u.%u.%u",
+		 FW_HDR_FW_VER_MAJOR_G(c4iw_dev->rdev.lldi.fw_vers),
+		 FW_HDR_FW_VER_MINOR_G(c4iw_dev->rdev.lldi.fw_vers),
+		 FW_HDR_FW_VER_MICRO_G(c4iw_dev->rdev.lldi.fw_vers),
+		 FW_HDR_FW_VER_BUILD_G(c4iw_dev->rdev.lldi.fw_vers));
+}
+
 int c4iw_register_device(struct c4iw_dev *dev)
 {
 	int ret;
@@ -605,6 +603,7 @@ int c4iw_register_device(struct c4iw_dev *dev)
 	dev->ibdev.get_hw_stats = c4iw_get_mib;
 	dev->ibdev.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION;
 	dev->ibdev.get_port_immutable = c4iw_port_immutable;
+	dev->ibdev.get_dev_fw_str = get_dev_fw_str;
 	dev->ibdev.drain_sq = c4iw_drain_sq;
 	dev->ibdev.drain_rq = c4iw_drain_rq;
 
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#18 lore raw

PATCH 4/13 IB/i40iw: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove sysfs support in favor of the core version.

---
 drivers/infiniband/hw/i40iw/i40iw_verbs.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_verbs.c +10 -14
index 02a735b64208..39096a246863 100644
@@ -1973,18 +1973,6 @@ static ssize_t i40iw_show_rev(struct device *dev,
 }
 
 /**
- * i40iw_show_fw_ver
- */
-static ssize_t i40iw_show_fw_ver(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	u32 firmware_version = I40IW_FW_VERSION;
-
-	return sprintf(buf, "%u.%u\n", firmware_version,
-		       (firmware_version & 0x000000ff));
-}
-
-/**
  * i40iw_show_hca
  */
 static ssize_t i40iw_show_hca(struct device *dev,
@@ -2004,13 +1992,11 @@ static ssize_t i40iw_show_board(struct device *dev,
 }
 
 static DEVICE_ATTR(hw_rev, S_IRUGO, i40iw_show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, i40iw_show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, i40iw_show_hca, NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, i40iw_show_board, NULL);
 
 static struct device_attribute *i40iw_dev_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id
 };
@@ -2427,6 +2413,15 @@ static const char * const i40iw_hw_stat_names[] = {
 		"iwRdmaInv"
 };
 
+static void i40iw_get_dev_fw_str(struct ib_device *dev, char *str,
+				 size_t str_len)
+{
+	u32 firmware_version = I40IW_FW_VERSION;
+
+	snprintf(str, str_len, "%u.%u", firmware_version,
+		       (firmware_version & 0x000000ff));
+}
+
 /**
  * i40iw_alloc_hw_stats - Allocate a hw stats structure
  * @ibdev: device pointer from stack
@@ -2650,6 +2645,7 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
 	memcpy(iwibdev->ibdev.iwcm->ifname, netdev->name,
 	       sizeof(iwibdev->ibdev.iwcm->ifname));
 	iwibdev->ibdev.get_port_immutable   = i40iw_port_immutable;
+	iwibdev->ibdev.get_dev_fw_str       = i40iw_get_dev_fw_str;
 	iwibdev->ibdev.poll_cq = i40iw_poll_cq;
 	iwibdev->ibdev.req_notify_cq = i40iw_req_notify_cq;
 	iwibdev->ibdev.post_send = i40iw_post_send;
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#19 lore raw

PATCH 5/13 IB/mlx4: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove the sysfs in favor of common core version.

---
 drivers/infiniband/hw/mlx4/main.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/infiniband/hw/mlx4/main.c +12 -12
index 0eb09e104542..1cbd075ce7e4 100644
@@ -2022,16 +2022,6 @@ static ssize_t show_hca(struct device *device, struct device_attribute *attr,
 	return sprintf(buf, "MT%d\n", dev->dev->persist->pdev->device);
 }
 
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
-			   char *buf)
-{
-	struct mlx4_ib_dev *dev =
-		container_of(device, struct mlx4_ib_dev, ib_dev.dev);
-	return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32),
-		       (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
-		       (int) dev->dev->caps.fw_ver & 0xffff);
-}
-
 static ssize_t show_rev(struct device *device, struct device_attribute *attr,
 			char *buf)
 {
@@ -2050,13 +2040,11 @@ static ssize_t show_board(struct device *device, struct device_attribute *attr,
 }
 
 static DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
-static DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
 
 static struct device_attribute *mlx4_class_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id
 };
@@ -2277,6 +2265,17 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_fw_ver_str(struct ib_device *device, char *str,
+			   size_t str_len)
+{
+	struct mlx4_ib_dev *dev =
+		container_of(device, struct mlx4_ib_dev, ib_dev);
+	snprintf(str, str_len, "%d.%d.%d",
+		 (int) (dev->dev->caps.fw_ver >> 32),
+		 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
+		 (int) dev->dev->caps.fw_ver & 0xffff);
+}
+
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
 	struct mlx4_ib_dev *ibdev;
@@ -2410,6 +2409,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 	ibdev->ib_dev.detach_mcast	= mlx4_ib_mcg_detach;
 	ibdev->ib_dev.process_mad	= mlx4_ib_process_mad;
 	ibdev->ib_dev.get_port_immutable = mlx4_port_immutable;
+	ibdev->ib_dev.get_dev_fw_str    = get_fw_ver_str;
 	ibdev->ib_dev.disassociate_ucontext = mlx4_ib_disassociate_ucontext;
 
 	if (!mlx4_is_slave(ibdev->dev)) {
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#20 lore raw

PATCH 6/13 IB/mlx5: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove sysfs entry in favor of the common code.

---
Changes from V0:
Update to new format which was in upstream code

 drivers/infiniband/hw/mlx5/main.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/infiniband/hw/mlx5/main.c +10 -11
index b48ad85315dc..3fa8557eddbd 100644
@@ -1804,15 +1804,6 @@ static ssize_t show_hca(struct device *device, struct device_attribute *attr,
 	return sprintf(buf, "MT%d\n", dev->mdev->pdev->device);
 }
 
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
-			   char *buf)
-{
-	struct mlx5_ib_dev *dev =
-		container_of(device, struct mlx5_ib_dev, ib_dev.dev);
-	return sprintf(buf, "%d.%d.%04d\n", fw_rev_maj(dev->mdev),
-		       fw_rev_min(dev->mdev), fw_rev_sub(dev->mdev));
-}
-
 static ssize_t show_rev(struct device *device, struct device_attribute *attr,
 			char *buf)
 {
@@ -1831,7 +1822,6 @@ static ssize_t show_board(struct device *device, struct device_attribute *attr,
 }
 
 static DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
-static DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
 static DEVICE_ATTR(fw_pages, S_IRUGO, show_fw_pages, NULL);
@@ -1839,7 +1829,6 @@ static DEVICE_ATTR(reg_pages, S_IRUGO, show_reg_pages, NULL);
 
 static struct device_attribute *mlx5_class_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id,
 	&dev_attr_fw_pages,
@@ -2275,6 +2264,15 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_str(struct ib_device *ibdev, char *str,
+			   size_t str_len)
+{
+	struct mlx5_ib_dev *dev =
+		container_of(ibdev, struct mlx5_ib_dev, ib_dev);
+	snprintf(str, str_len, "%d.%d.%04d", fw_rev_maj(dev->mdev),
+		       fw_rev_min(dev->mdev), fw_rev_sub(dev->mdev));
+}
+
 static int mlx5_enable_roce(struct mlx5_ib_dev *dev)
 {
 	int err;
@@ -2421,6 +2419,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
 	dev->ib_dev.map_mr_sg		= mlx5_ib_map_mr_sg;
 	dev->ib_dev.check_mr_status	= mlx5_ib_check_mr_status;
 	dev->ib_dev.get_port_immutable  = mlx5_port_immutable;
+	dev->ib_dev.get_dev_fw_str      = get_dev_fw_str;
 	if (mlx5_core_is_pf(mdev)) {
 		dev->ib_dev.get_vf_config	= mlx5_ib_get_vf_config;
 		dev->ib_dev.set_vf_link_state	= mlx5_ib_set_vf_link_state;
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#21 lore raw

PATCH 7/13 IB/mthca: Supprot device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove the sysfs entry in favor of the core support.

---
 drivers/infiniband/hw/mthca/mthca_provider.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/infiniband/hw/mthca/mthca_provider.c +12 -12
index 9866c35cc977..da2335f7f7c3 100644
@@ -1081,16 +1081,6 @@ static ssize_t show_rev(struct device *device, struct device_attribute *attr,
 	return sprintf(buf, "%x\n", dev->rev_id);
 }
 
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
-			   char *buf)
-{
-	struct mthca_dev *dev =
-		container_of(device, struct mthca_dev, ib_dev.dev);
-	return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32),
-		       (int) (dev->fw_ver >> 16) & 0xffff,
-		       (int) dev->fw_ver & 0xffff);
-}
-
 static ssize_t show_hca(struct device *device, struct device_attribute *attr,
 			char *buf)
 {
@@ -1120,13 +1110,11 @@ static ssize_t show_board(struct device *device, struct device_attribute *attr,
 }
 
 static DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
-static DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
 
 static struct device_attribute *mthca_dev_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id
 };
@@ -1187,6 +1175,17 @@ static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_str(struct ib_device *device, char *str,
+			   size_t str_len)
+{
+	struct mthca_dev *dev =
+		container_of(device, struct mthca_dev, ib_dev);
+	snprintf(str, str_len, "%d.%d.%d",
+		 (int) (dev->fw_ver >> 32),
+		 (int) (dev->fw_ver >> 16) & 0xffff,
+		 (int) dev->fw_ver & 0xffff);
+}
+
 int mthca_register_device(struct mthca_dev *dev)
 {
 	int ret;
@@ -1266,6 +1265,7 @@ int mthca_register_device(struct mthca_dev *dev)
 	dev->ib_dev.reg_user_mr          = mthca_reg_user_mr;
 	dev->ib_dev.dereg_mr             = mthca_dereg_mr;
 	dev->ib_dev.get_port_immutable   = mthca_port_immutable;
+	dev->ib_dev.get_dev_fw_str       = get_dev_fw_str;
 
 	if (dev->mthca_flags & MTHCA_FLAG_FMR) {
 		dev->ib_dev.alloc_fmr            = mthca_alloc_fmr;
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#22 lore raw

PATCH 8/13 IB/nes: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove the sysfs in favor of the core version.

---
 drivers/infiniband/hw/nes/nes_verbs.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/infiniband/hw/nes/nes_verbs.c +14 -19
index 464d6da5fe91..bd69125731c1 100644
@@ -2606,23 +2606,6 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
 
 
 /**
- * show_fw_ver
- */
-static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
-			   char *buf)
-{
-	struct nes_ib_device *nesibdev =
-			container_of(dev, struct nes_ib_device, ibdev.dev);
-	struct nes_vnic *nesvnic = nesibdev->nesvnic;
-
-	nes_debug(NES_DBG_INIT, "\n");
-	return sprintf(buf, "%u.%u\n",
-		(nesvnic->nesdev->nesadapter->firmware_version >> 16),
-		(nesvnic->nesdev->nesadapter->firmware_version & 0x000000ff));
-}
-
-
-/**
  * show_hca
  */
 static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
@@ -2645,13 +2628,11 @@ static ssize_t show_board(struct device *dev, struct device_attribute *attr,
 
 
 static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
 static struct device_attribute *nes_dev_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type,
 	&dev_attr_board_id
 };
@@ -3703,6 +3684,19 @@ static int nes_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_str(struct ib_device *dev, char *str,
+			   size_t str_len)
+{
+	struct nes_ib_device *nesibdev =
+			container_of(dev, struct nes_ib_device, ibdev);
+	struct nes_vnic *nesvnic = nesibdev->nesvnic;
+
+	nes_debug(NES_DBG_INIT, "\n");
+	snprintf(str, str_len, "%u.%u",
+		 (nesvnic->nesdev->nesadapter->firmware_version >> 16),
+		 (nesvnic->nesdev->nesadapter->firmware_version & 0x000000ff));
+}
+
 /**
  * nes_init_ofa_device
  */
@@ -3802,6 +3796,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
 	nesibdev->ibdev.iwcm->create_listen = nes_create_listen;
 	nesibdev->ibdev.iwcm->destroy_listen = nes_destroy_listen;
 	nesibdev->ibdev.get_port_immutable   = nes_port_immutable;
+	nesibdev->ibdev.get_dev_fw_str   = get_dev_fw_str;
 	memcpy(nesibdev->ibdev.iwcm->ifname, netdev->name,
 	       sizeof(nesibdev->ibdev.iwcm->ifname));
 
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#23 lore raw

PATCH 9/13 IB/ocrdma: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove sysfs in favor of the core support.

---
 drivers/infiniband/hw/ocrdma/ocrdma_main.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +9 -10
index 3d75f65ce87e..07d0c6c5b046 100644
@@ -107,6 +107,14 @@ static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void get_dev_fw_str(struct ib_device *device, char *str,
+			   size_t str_len)
+{
+	struct ocrdma_dev *dev = get_ocrdma_dev(device);
+
+	snprintf(str, str_len, "%s", &dev->attr.fw_ver[0]);
+}
+
 static int ocrdma_register_device(struct ocrdma_dev *dev)
 {
 	strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX);
@@ -193,6 +201,7 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
 
 	dev->ibdev.process_mad = ocrdma_process_mad;
 	dev->ibdev.get_port_immutable = ocrdma_port_immutable;
+	dev->ibdev.get_dev_fw_str     = get_dev_fw_str;
 
 	if (ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R) {
 		dev->ibdev.uverbs_cmd_mask |=
@@ -262,14 +271,6 @@ static ssize_t show_rev(struct device *device, struct device_attribute *attr,
 	return scnprintf(buf, PAGE_SIZE, "0x%x\n", dev->nic_info.pdev->vendor);
 }
 
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
-			char *buf)
-{
-	struct ocrdma_dev *dev = dev_get_drvdata(device);
-
-	return scnprintf(buf, PAGE_SIZE, "%s\n", &dev->attr.fw_ver[0]);
-}
-
 static ssize_t show_hca_type(struct device *device,
 			     struct device_attribute *attr, char *buf)
 {
@@ -279,12 +280,10 @@ static ssize_t show_hca_type(struct device *device,
 }
 
 static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
 static DEVICE_ATTR(hca_type, S_IRUGO, show_hca_type, NULL);
 
 static struct device_attribute *ocrdma_attributes[] = {
 	&dev_attr_hw_rev,
-	&dev_attr_fw_ver,
 	&dev_attr_hca_type
 };
 
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw

PATCH 10/13 IB/usnic: Support device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

And remove sysfs file in favor of the common core.

---
 drivers/infiniband/hw/usnic/usnic_ib_main.c  | 16 ++++++++++++++++
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 17 -----------------
 2 files changed, 16 insertions(+), 17 deletions(-)
drivers/infiniband/hw/usnic/usnic_ib_main.c +16 -0
index 565c881a44ba..c229b9f4a52d 100644
@@ -331,6 +331,21 @@ static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num,
 	return 0;
 }
 
+static void usnic_get_dev_fw_str(struct ib_device *device,
+				 char *str,
+				 size_t str_len)
+{
+	struct usnic_ib_dev *us_ibdev =
+		container_of(device, struct usnic_ib_dev, ib_dev);
+	struct ethtool_drvinfo info;
+
+	mutex_lock(&us_ibdev->usdev_lock);
+	us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
+	mutex_unlock(&us_ibdev->usdev_lock);
+
+	snprintf(str, str_len, "%s", info.fw_version);
+}
+
 /* Start of PF discovery section */
 static void *usnic_ib_device_add(struct pci_dev *dev)
 {
@@ -414,6 +429,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
 	us_ibdev->ib_dev.req_notify_cq = usnic_ib_req_notify_cq;
 	us_ibdev->ib_dev.get_dma_mr = usnic_ib_get_dma_mr;
 	us_ibdev->ib_dev.get_port_immutable = usnic_port_immutable;
+	us_ibdev->ib_dev.get_dev_fw_str     = usnic_get_dev_fw_str;
 
 
 	if (ib_register_device(&us_ibdev->ib_dev, NULL))
drivers/infiniband/hw/usnic/usnic_ib_sysfs.c +0 -17
index 3412ea06116e..80ef3f8998c8 100644
@@ -45,21 +45,6 @@
 #include "usnic_ib_verbs.h"
 #include "usnic_log.h"
 
-static ssize_t usnic_ib_show_fw_ver(struct device *device,
-					struct device_attribute *attr,
-					char *buf)
-{
-	struct usnic_ib_dev *us_ibdev =
-		container_of(device, struct usnic_ib_dev, ib_dev.dev);
-	struct ethtool_drvinfo info;
-
-	mutex_lock(&us_ibdev->usdev_lock);
-	us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
-	mutex_unlock(&us_ibdev->usdev_lock);
-
-	return scnprintf(buf, PAGE_SIZE, "%s\n", info.fw_version);
-}
-
 static ssize_t usnic_ib_show_board(struct device *device,
 					struct device_attribute *attr,
 					char *buf)
@@ -192,7 +177,6 @@ usnic_ib_show_cq_per_vf(struct device *device, struct device_attribute *attr,
 			us_ibdev->vf_res_cnt[USNIC_VNIC_RES_TYPE_CQ]);
 }
 
-static DEVICE_ATTR(fw_ver, S_IRUGO, usnic_ib_show_fw_ver, NULL);
 static DEVICE_ATTR(board_id, S_IRUGO, usnic_ib_show_board, NULL);
 static DEVICE_ATTR(config, S_IRUGO, usnic_ib_show_config, NULL);
 static DEVICE_ATTR(iface, S_IRUGO, usnic_ib_show_iface, NULL);
@@ -201,7 +185,6 @@ static DEVICE_ATTR(qp_per_vf, S_IRUGO, usnic_ib_show_qp_per_vf, NULL);
 static DEVICE_ATTR(cq_per_vf, S_IRUGO, usnic_ib_show_cq_per_vf, NULL);
 
 static struct device_attribute *usnic_class_attributes[] = {
-	&dev_attr_fw_ver,
 	&dev_attr_board_id,
 	&dev_attr_config,
 	&dev_attr_iface,
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#25 lore raw

PATCH 11/13 IB/ipoib: Use new device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Using this allows for devices to specify the format of their firmware version rather than forcing a format.

---
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +2 -4
index 1502199c8e56..7b6d40ff1acf 100644
@@ -62,10 +62,8 @@ static void ipoib_get_drvinfo(struct net_device *netdev,
 {
 	struct ipoib_dev_priv *priv = netdev_priv(netdev);
 
-	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
-		 "%d.%d.%d", (int)(priv->ca->attrs.fw_ver >> 32),
-		 (int)(priv->ca->attrs.fw_ver >> 16) & 0xffff,
-		 (int)priv->ca->attrs.fw_ver & 0xffff);
+	ib_get_device_fw_str(priv->ca, drvinfo->fw_version,
+			     sizeof(drvinfo->fw_version));
 
 	strlcpy(drvinfo->bus_info, dev_name(priv->ca->dma_device),
 		sizeof(drvinfo->bus_info));
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw

PATCH 12/13 IB/core: Export a common fw_ver sysfs entry

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Now that all the devices have stopped exporting their own sysfs entry points we can have the core export this on their behalf.

Eventually this may be removed but this provides for backwards compatibility.

---
Changes from V0:
Remove the use of the temp stack variable. Add trailing comma in attribute list

 drivers/infiniband/core/sysfs.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/infiniband/core/sysfs.c +14 -1
index a5793c8f1590..0d1ab73f8186 100644
@@ -38,6 +38,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/netdevice.h>
+#include <linux/ethtool.h>
 
 #include <rdma/ib_mad.h>
 #include <rdma/ib_pma.h>
@@ -1196,16 +1197,28 @@ static ssize_t set_node_desc(struct device *device,
 	return count;
 }
 
+static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
+			   char *buf)
+{
+	struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+	ib_get_device_fw_str(dev, buf, PAGE_SIZE);
+	strlcat(buf, "\n", PAGE_SIZE);
+	return strlen(buf);
+}
+
 static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
 static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
 static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
 static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
 
 static struct device_attribute *ib_class_attributes[] = {
 	&dev_attr_node_type,
 	&dev_attr_sys_image_guid,
 	&dev_attr_node_guid,
-	&dev_attr_node_desc
+	&dev_attr_node_desc,
+	&dev_attr_fw_ver,
 };
 
 static void free_port_list_attributes(struct ib_device *device)
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

PATCH 13/13 IB/hfi1: Add device FW version string

In reply to a message not in the archive

From: Ira Weiny <[email protected]>

Export the firmware version through the core.

---
 drivers/infiniband/hw/hfi1/hfi.h   |  2 ++
 drivers/infiniband/hw/hfi1/verbs.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
drivers/infiniband/hw/hfi1/hfi.h +2 -0
index 1dd48efb5b61..ac73206a8e18 100644
@@ -1174,6 +1174,8 @@ struct hfi1_devdata {
 
 /* 8051 firmware version helper */
 #define dc8051_ver(a, b) ((a) << 8 | (b))
+#define dc8051_ver_maj(a) ((a & 0xff00) >> 8)
+#define dc8051_ver_min(a)  (a & 0x00ff)
 
 /* f_put_tid types */
 #define PT_EXPECTED 0
drivers/infiniband/hw/hfi1/verbs.c +15 -0
index 849c4b9399d4..dd4be3c2b225 100644
@@ -1291,9 +1291,12 @@ int hfi1_verbs_send(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
 static void hfi1_fill_device_attr(struct hfi1_devdata *dd)
 {
 	struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
+	u16 ver = dd->dc8051_ver;
 
 	memset(&rdi->dparms.props, 0, sizeof(rdi->dparms.props));
 
+	rdi->dparms.props.fw_ver = ((u64)(dc8051_ver_maj(ver)) << 16) |
+				    (u64)dc8051_ver_min(ver);
 	rdi->dparms.props.device_cap_flags = IB_DEVICE_BAD_PKEY_CNTR |
 			IB_DEVICE_BAD_QKEY_CNTR | IB_DEVICE_SHUTDOWN_PORT |
 			IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN |
@@ -1567,6 +1570,17 @@ static void init_ibport(struct hfi1_pportdata *ppd)
 	RCU_INIT_POINTER(ibp->rvp.qp[1], NULL);
 }
 
+static void hfi1_get_dev_fw_str(struct ib_device *ibdev, char *str,
+				size_t str_len)
+{
+	struct rvt_dev_info *rdi = ib_to_rvt(ibdev);
+	struct hfi1_ibdev *dev = dev_from_rdi(rdi);
+	u16 ver = dd_from_dev(dev)->dc8051_ver;
+
+	snprintf(str, str_len, "%u.%u", dc8051_ver_maj(ver),
+		 dc8051_ver_min(ver));
+}
+
 /**
  * hfi1_register_ib_device - register our device with the infiniband core
  * @dd: the device data structure
@@ -1613,6 +1627,7 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 
 	/* keep process mad in the driver */
 	ibdev->process_mad = hfi1_process_mad;
+	ibdev->get_dev_fw_str = hfi1_get_dev_fw_str;
 
 	strncpy(ibdev->node_desc, init_utsname()->nodename,
 		sizeof(ibdev->node_desc));
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reviewed-by
#28 lore raw
In reply to a message not in the archive
Quoted 72 lines · On Wed, Jun 15, 2016 at 02:21:55AM -0400…

From: Ira Weiny <[email protected]>

Currently there are 3 ways to get the firmware version for an RDMA device.

1) verbs query device
2) ethtool
3) sysfs entry

Both 1 and 2 are expecting a 64bit field which is vendor specific and encodes a 3 number version. Some hardware, like OPA, only has 2 numbers in it's version, while other hardware like cxgb4 has 4.

Support for the sysfs entry was left to the devices but generally done in a "common" way.

This series moves to unify firmware version reporting by creating the ib_get_device_fw_str method within the ib_device. With this we can then do 3 things.

1) Support device dependent formats of version strings with ethtool (IPoIB)

2) Support a common sysfs entry in the core for backwards compatibility which can either be changed to a common FW version string with the new verbs interface or simply removed in favor of using ethtool.

3) Eventually drop the sysfs entry once we can get user space tools off of it. If we decide not to have an interface through verbs (require the use of ethtool via IPoIB) iWarp and RoCE devices don't even have to have this support at all and the code can be eliminated for those devices.

1 and 2 are done with this patch series. 3 needs to be decided by the community if, and when, sysfs support can be dropped.

NOTE: I have tested these patches with mlx4, qib, and hfi1. Other drivers were compile tested only.

---
Changes from V0:
Address comments by Jason and Leon
Rebase to upstream
Add Reviewed-by for cxgb4

Ira Weiny (13):
IB/core: Add get FW version string to the core
IB/cxgb3: Support device FW version string
IB/cxgb4: Support device FW version string
IB/i40iw: Support device FW version string
IB/mlx4: Support device FW version string
IB/mlx5: Support device FW version string
IB/mthca: Supprot device FW version string
IB/nes: Support device FW version string
IB/ocrdma: Support device FW version string
IB/usnic: Support device FW version string
IB/ipoib: Use new device FW version string
IB/core: Export a common fw_ver sysfs entry
IB/hfi1: Add device FW version string

 drivers/infiniband/core/device.c             |  9 ++++++++
 drivers/infiniband/core/sysfs.c              | 15 ++++++++++++-
 drivers/infiniband/hw/cxgb3/iwch_provider.c  | 27 +++++++++++------------
 drivers/infiniband/hw/cxgb4/provider.c       | 31 +++++++++++++-------------
 drivers/infiniband/hw/hfi1/hfi.h             |  2 ++
 drivers/infiniband/hw/hfi1/verbs.c           | 15 +++++++++++++
 drivers/infiniband/hw/i40iw/i40iw_verbs.c    | 24 +++++++++-----------
 drivers/infiniband/hw/mlx4/main.c            | 24 ++++++++++----------
 drivers/infiniband/hw/mlx5/main.c            | 21 +++++++++---------
Quoted 8 lines
 drivers/infiniband/hw/mthca/mthca_provider.c | 24 ++++++++++----------
 drivers/infiniband/hw/nes/nes_verbs.c        | 33 ++++++++++++----------------
 drivers/infiniband/hw/ocrdma/ocrdma_main.c   | 19 ++++++++--------
 drivers/infiniband/hw/usnic/usnic_ib_main.c  | 16 ++++++++++++++
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 17 --------------
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c |  6 ++---
 include/rdma/ib_verbs.h                      |  3 +++
 16 files changed, 156 insertions(+), 130 deletions(-)

Such statistic (more insertions than deletions) doesn't look good for common code.

Anyway, I'm fine with it, for mlx5/mlx4 and core:

Quoted 8 lines
Signature · 7 lines
-- 
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#29 lore raw
In reply to a message not in the archive
Quoted 72 lines · On 06/15/2016 02:21 AM, [email protected] wrote:

From: Ira Weiny <[email protected]>

Currently there are 3 ways to get the firmware version for an RDMA device.

1) verbs query device
2) ethtool
3) sysfs entry

Both 1 and 2 are expecting a 64bit field which is vendor specific and encodes a 3 number version. Some hardware, like OPA, only has 2 numbers in it's version, while other hardware like cxgb4 has 4.

Support for the sysfs entry was left to the devices but generally done in a "common" way.

This series moves to unify firmware version reporting by creating the ib_get_device_fw_str method within the ib_device. With this we can then do 3 things.

1) Support device dependent formats of version strings with ethtool (IPoIB)

2) Support a common sysfs entry in the core for backwards compatibility which can either be changed to a common FW version string with the new verbs interface or simply removed in favor of using ethtool.

3) Eventually drop the sysfs entry once we can get user space tools off of it. If we decide not to have an interface through verbs (require the use of ethtool via IPoIB) iWarp and RoCE devices don't even have to have this support at all and the code can be eliminated for those devices.

1 and 2 are done with this patch series. 3 needs to be decided by the community if, and when, sysfs support can be dropped.

NOTE: I have tested these patches with mlx4, qib, and hfi1. Other drivers were compile tested only.

---
Changes from V0:
Address comments by Jason and Leon
Rebase to upstream
Add Reviewed-by for cxgb4

Ira Weiny (13):
IB/core: Add get FW version string to the core
IB/cxgb3: Support device FW version string
IB/cxgb4: Support device FW version string
IB/i40iw: Support device FW version string
IB/mlx4: Support device FW version string
IB/mlx5: Support device FW version string
IB/mthca: Supprot device FW version string
IB/nes: Support device FW version string
IB/ocrdma: Support device FW version string
IB/usnic: Support device FW version string
IB/ipoib: Use new device FW version string
IB/core: Export a common fw_ver sysfs entry
IB/hfi1: Add device FW version string

 drivers/infiniband/core/device.c             |  9 ++++++++
 drivers/infiniband/core/sysfs.c              | 15 ++++++++++++-
 drivers/infiniband/hw/cxgb3/iwch_provider.c  | 27 +++++++++++------------
 drivers/infiniband/hw/cxgb4/provider.c       | 31 +++++++++++++-------------
 drivers/infiniband/hw/hfi1/hfi.h             |  2 ++
 drivers/infiniband/hw/hfi1/verbs.c           | 15 +++++++++++++
 drivers/infiniband/hw/i40iw/i40iw_verbs.c    | 24 +++++++++-----------
 drivers/infiniband/hw/mlx4/main.c            | 24 ++++++++++----------
 drivers/infiniband/hw/mlx5/main.c            | 21 +++++++++---------
Quoted 9 lines
 drivers/infiniband/hw/mthca/mthca_provider.c | 24 ++++++++++----------
 drivers/infiniband/hw/nes/nes_verbs.c        | 33 ++++++++++++----------------
 drivers/infiniband/hw/ocrdma/ocrdma_main.c   | 19 ++++++++--------
 drivers/infiniband/hw/usnic/usnic_ib_main.c  | 16 ++++++++++++++
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 17 --------------
 drivers/infiniband/ulp/ipoib/ipoib_ethtool.c |  6 ++---
 include/rdma/ib_verbs.h                      |  3 +++
 16 files changed, 156 insertions(+), 130 deletions(-)

Thanks Ira, series taken in for 4.8.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD