net/mlx5_core: Use accessor functions to read from device memory
authorEli Cohen <eli@mellanox.com>
Thu, 8 Oct 2015 14:13:59 +0000 (17:13 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Oct 2015 14:27:48 +0000 (07:27 -0700)
Use ioread function to read health buffer data. In addition, print the
firmware version as a string for readability and also use dev_err to have
the device string to be printed.

Signed-off-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/health.c

index 1277c427242ac48b623ff737c638285b99ff9484..8770968fff35daeb8b108c17c3464696efb70f7c 100644 (file)
@@ -114,32 +114,41 @@ static const char *hsynd_str(u8 synd)
        }
 }
 
-static u16 read_be16(__be16 __iomem *p)
+static u16 get_maj(u32 fw)
 {
-       return swab16(readl((__force u16 __iomem *) p));
+       return fw >> 28;
 }
 
-static u32 read_be32(__be32 __iomem *p)
+static u16 get_min(u32 fw)
 {
-       return swab32(readl((__force u32 __iomem *) p));
+       return fw >> 16 & 0xfff;
+}
+
+static u16 get_sub(u32 fw)
+{
+       return fw & 0xffff;
 }
 
 static void print_health_info(struct mlx5_core_dev *dev)
 {
        struct mlx5_core_health *health = &dev->priv.health;
        struct health_buffer __iomem *h = health->health;
+       char fw_str[18];
+       u32 fw;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(h->assert_var); i++)
-               pr_info("assert_var[%d] 0x%08x\n", i, read_be32(h->assert_var + i));
-
-       pr_info("assert_exit_ptr 0x%08x\n", read_be32(&h->assert_exit_ptr));
-       pr_info("assert_callra 0x%08x\n", read_be32(&h->assert_callra));
-       pr_info("fw_ver 0x%08x\n", read_be32(&h->fw_ver));
-       pr_info("hw_id 0x%08x\n", read_be32(&h->hw_id));
-       pr_info("irisc_index %d\n", readb(&h->irisc_index));
-       pr_info("synd 0x%x: %s\n", readb(&h->synd), hsynd_str(readb(&h->synd)));
-       pr_info("ext_sync 0x%04x\n", read_be16(&h->ext_synd));
+               dev_err(&dev->pdev->dev, "assert_var[%d] 0x%08x\n", i, ioread32be(h->assert_var + i));
+
+       dev_err(&dev->pdev->dev, "assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr));
+       dev_err(&dev->pdev->dev, "assert_callra 0x%08x\n", ioread32be(&h->assert_callra));
+       fw = ioread32be(&h->fw_ver);
+       sprintf(fw_str, "%d.%d.%d", get_maj(fw), get_min(fw), get_sub(fw));
+       dev_err(&dev->pdev->dev, "fw_ver %s\n", fw_str);
+       dev_err(&dev->pdev->dev, "hw_id 0x%08x\n", ioread32be(&h->hw_id));
+       dev_err(&dev->pdev->dev, "irisc_index %d\n", ioread8(&h->irisc_index));
+       dev_err(&dev->pdev->dev, "synd 0x%x: %s\n", ioread8(&h->synd), hsynd_str(ioread8(&h->synd)));
+       dev_err(&dev->pdev->dev, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
 }
 
 static void poll_health(unsigned long data)