]> err.no Git - linux-2.6/commitdiff
IB/mlx4: Display misc device information under /sys/class/infiniband/
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Tue, 18 Sep 2007 07:14:18 +0000 (09:14 +0200)
committerRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 02:59:14 +0000 (19:59 -0700)
display the following device information under /sys/class/infiniband/mlx4_X:
board_id, fw_ver, hw_rev, hca_type.

This patch makes this information available to userspace utilities
such as ibstat and ibv_devinfo.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/mlx4/main.c
drivers/net/mlx4/main.c
drivers/net/mlx4/mlx4.h
include/linux/mlx4/device.h

index dde8fe9af47e3f24cf13574c363f873a1297fec3..d9fc822a146866a75061cc0e78edb608bb026271 100644 (file)
@@ -476,9 +476,48 @@ out:
        return err;
 }
 
+static ssize_t show_hca(struct class_device *cdev, char *buf)
+{
+       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       return sprintf(buf, "MT%d\n", dev->dev->pdev->device);
+}
+
+static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+{
+       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_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 class_device *cdev, char *buf)
+{
+       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       return sprintf(buf, "%x\n", dev->dev->rev_id);
+}
+
+static ssize_t show_board(struct class_device *cdev, char *buf)
+{
+       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id);
+}
+
+static CLASS_DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
+static CLASS_DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
+static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
+static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
+
+static struct class_device_attribute *mlx4_class_attributes[] = {
+       &class_device_attr_hw_rev,
+       &class_device_attr_fw_ver,
+       &class_device_attr_hca_type,
+       &class_device_attr_board_id
+};
+
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
        struct mlx4_ib_dev *ibdev;
+       int i;
 
        ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
        if (!ibdev) {
@@ -580,6 +619,12 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
        if (mlx4_ib_mad_init(ibdev))
                goto err_reg;
 
+       for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) {
+               if (class_device_create_file(&ibdev->ib_dev.class_dev,
+                                              mlx4_class_attributes[i]))
+                       goto err_reg;
+       }
+
        return ibdev;
 
 err_reg:
index 4b12694355869b14618106928f26ab92f67348e2..9e590e11c1cf8afbb53e3289e034cc228d79b1d0 100644 (file)
@@ -524,8 +524,8 @@ static int __devinit mlx4_init_hca(struct mlx4_dev *dev)
        }
 
        priv->eq_table.inta_pin = adapter.inta_pin;
-       priv->rev_id            = adapter.revision_id;
-       memcpy(priv->board_id, adapter.board_id, sizeof priv->board_id);
+       dev->rev_id             = adapter.revision_id;
+       memcpy(dev->board_id, adapter.board_id, sizeof dev->board_id);
 
        return 0;
 
index be304a7c2c9163bee2178c24463bdd57b955045c..b9f839761919b57a4cf0faa71f48d72d17f1f2c2 100644 (file)
@@ -55,10 +55,6 @@ enum {
        MLX4_CLR_INT_SIZE       = 0x00008
 };
 
-enum {
-       MLX4_BOARD_ID_LEN       = 64
-};
-
 enum {
        MLX4_MGM_ENTRY_SIZE     =  0x40,
        MLX4_QP_PER_MGM         = 4 * (MLX4_MGM_ENTRY_SIZE / 16 - 2),
@@ -277,9 +273,6 @@ struct mlx4_priv {
 
        struct mlx4_uar         driver_uar;
        void __iomem           *kar;
-
-       u32                     rev_id;
-       char                    board_id[MLX4_BOARD_ID_LEN];
 };
 
 static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
index cfb78fb2c0460812b1a56cbb78e5a801a8168647..a93520c76fde238093644f1366164b5552c7423c 100644 (file)
@@ -48,6 +48,10 @@ enum {
        MLX4_MAX_PORTS          = 2
 };
 
+enum {
+       MLX4_BOARD_ID_LEN = 64
+};
+
 enum {
        MLX4_DEV_CAP_FLAG_RC            = 1 <<  0,
        MLX4_DEV_CAP_FLAG_UC            = 1 <<  1,
@@ -272,6 +276,8 @@ struct mlx4_dev {
        unsigned long           flags;
        struct mlx4_caps        caps;
        struct radix_tree_root  qp_table_tree;
+       u32                     rev_id;
+       char                    board_id[MLX4_BOARD_ID_LEN];
 };
 
 struct mlx4_init_port_param {