[ofa-general] [PATCH 1 of 2] net-mlx4: Show board_id string in sysfs under the pci device

Jack Morgenstein jackm at dev.mellanox.co.il
Tue Jun 19 06:41:52 PDT 2007


Show the board_id string in sysfs under the pci device (not under the infiniband
device, as with other HCAs). ConnectX will also have an enet device (which will
not be under the infiniband class) and users of this device must also have 
access to the board_id string.

This requires a small modification in the libibverbs example "ibv_devinfo"; the app
must also look under the pci device for the board_id if it does not find it 
directly under the infiniband device.

Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>

Index: connectx_kernel/drivers/net/mlx4/main.c
===================================================================
--- connectx_kernel.orig/drivers/net/mlx4/main.c	2007-05-07 18:36:02.000000000 +0300
+++ connectx_kernel/drivers/net/mlx4/main.c	2007-05-08 12:52:49.000000000 +0300
@@ -711,6 +711,18 @@
 		priv->eq_table.eq[i].irq = dev->pdev->irq;
 }
 
+static ssize_t mlx4_show_board_id(struct device *dev,
+				  struct device_attribute *attr,
+				  char *buf)
+{
+	struct mlx4_dev  *mdev  = dev->driver_data;
+	struct mlx4_priv *priv = mlx4_priv(mdev);
+
+	return snprintf(buf, MLX4_BOARD_ID_LEN, "%s\n", (char *)priv->board_id);
+}
+
+static DEVICE_ATTR(board_id, S_IRUGO, mlx4_show_board_id, NULL);
+
 static int __devinit mlx4_init_one(struct pci_dev *pdev,
 				   const struct pci_device_id *id)
 {
@@ -827,6 +839,7 @@
 		goto err_cleanup;
 
 	pci_set_drvdata(pdev, dev);
+	device_create_file(&pdev->dev, &dev_attr_board_id);
 
 	return 0;
 
@@ -875,6 +888,7 @@
 	int p;
 
 	if (dev) {
+		device_remove_file(&pdev->dev, &dev_attr_board_id);
 		mlx4_unregister_device(dev);
 
 		for (p = 1; p <= dev->caps.num_ports; ++p)



More information about the general mailing list