IB/rdmavt: Add device specific info prints
authorDennis Dalessandro <dennis.dalessandro@intel.com>
Wed, 6 Jan 2016 18:02:59 +0000 (10:02 -0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 11 Mar 2016 01:37:11 +0000 (20:37 -0500)
Follow hfi1's example for printing information about the driver and
incorporate into rdmavt. This requires two new functions to be
provided by the driver, one to get_card_name and one to get_pci_dev.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/sw/rdmavt/vt.c
drivers/infiniband/sw/rdmavt/vt.h
include/rdma/rdma_vt.h

index b4ce97e6ff12497048f8059349d33306affbed64..2a13e361c8089e798ea376f1e7b4bf1a3caad991 100644 (file)
@@ -213,9 +213,18 @@ static int rvt_get_port_immutable(struct ib_device *ibdev, u8 port_num,
 
 int rvt_register_device(struct rvt_dev_info *rdi)
 {
+       /* Validate that drivers have provided the right information */
        if (!rdi)
                return -EINVAL;
 
+       if ((!rdi->driver_f.port_callback) ||
+           (!rdi->driver_f.get_card_name) ||
+           (!rdi->driver_f.get_pci_dev)) {
+               return -EINVAL;
+       }
+
+       /* Once we get past here we can use the rvt_pr macros */
+
        /* Dev Ops */
        CHECK_DRIVER_OVERRIDE(rdi, query_device);
        CHECK_DRIVER_OVERRIDE(rdi, modify_device);
@@ -280,9 +289,7 @@ int rvt_register_device(struct rvt_dev_info *rdi)
        spin_lock_init(&rdi->n_pds_lock);
        rdi->n_pds_allocated = 0;
 
-       /* Validate that drivers have provided the right functions */
-       if (!rdi->driver_f.port_callback)
-               return -EINVAL;
+       rvt_pr_info(rdi, "Registration with rdmavt done.\n");
 
        /* We are now good to announce we exist */
        return ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);
index fdb52a8221bc2a7cb13d62a2dfdb4021b373590b..54ee05a4a9b9e65b5f114cbe1954b7112b7a1f88 100644 (file)
@@ -49,6 +49,7 @@
  */
 
 #include <rdma/rdma_vt.h>
+#include <linux/pci.h>
 #include "dma.h"
 #include "pd.h"
 #include "qp.h"
 #include "mmap.h"
 #include "cq.h"
 
+#define rvt_pr_info(rdi, fmt, ...) \
+       __rvt_pr_info(rdi->driver_f.get_pci_dev(rdi), \
+                     rdi->driver_f.get_card_name(rdi), \
+                     fmt, \
+                     ##__VA_ARGS__)
+
+#define rvt_pr_warn(rdi, fmt, ...) \
+       __rvt_pr_warn(rdi->driver_f.get_pci_dev(rdi), \
+                     rdi->driver_f.get_card_name(rdi), \
+                     fmt, \
+                     ##__VA_ARGS__)
+
+#define rvt_pr_err(rdi, fmt, ...) \
+       __rvt_pr_err(rdi->driver_f.get_pci_dev(rdi), \
+                    rdi->driver_f.get_card_name(rdi), \
+                    fmt, \
+                    ##__VA_ARGS__)
+
+#define __rvt_pr_info(pdev, name, fmt, ...) \
+       dev_info(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
+
+#define __rvt_pr_warn(pdev, name, fmt, ...) \
+       dev_warn(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
+
+#define __rvt_pr_err(pdev, name, fmt, ...) \
+       dev_err(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
+
 #endif          /* DEF_RDMAVT_H */
index e0beedc6110ebf88b272fd2e7d9667626c4a9cdd..4b83770bc3120b1126fb3297fc63aff6a8382ae6 100644 (file)
@@ -386,6 +386,7 @@ struct rvt_driver_params {
 /*
  * Functions that drivers are required to support
  */
+struct rvt_dev_info;
 struct rvt_driver_provided {
        /*
         * The work to create port files in /sys/class Infiniband is different
@@ -394,6 +395,8 @@ struct rvt_driver_provided {
         * this.
         */
        int (*port_callback)(struct ib_device *, u8, struct kobject *);
+       const char * (*get_card_name)(struct rvt_dev_info *rdi);
+       struct pci_dev * (*get_pci_dev)(struct rvt_dev_info *rdi);
 };
 
 /* Protection domain */