Skip to content

Commit b534875

Browse files
Dennis Dalessandrodledford
authored andcommitted
IB/rdmavt: Add device specific info prints
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 <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent aec5778 commit b534875

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

drivers/infiniband/sw/rdmavt/vt.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,18 @@ static int rvt_get_port_immutable(struct ib_device *ibdev, u8 port_num,
213213

214214
int rvt_register_device(struct rvt_dev_info *rdi)
215215
{
216+
/* Validate that drivers have provided the right information */
216217
if (!rdi)
217218
return -EINVAL;
218219

220+
if ((!rdi->driver_f.port_callback) ||
221+
(!rdi->driver_f.get_card_name) ||
222+
(!rdi->driver_f.get_pci_dev)) {
223+
return -EINVAL;
224+
}
225+
226+
/* Once we get past here we can use the rvt_pr macros */
227+
219228
/* Dev Ops */
220229
CHECK_DRIVER_OVERRIDE(rdi, query_device);
221230
CHECK_DRIVER_OVERRIDE(rdi, modify_device);
@@ -280,9 +289,7 @@ int rvt_register_device(struct rvt_dev_info *rdi)
280289
spin_lock_init(&rdi->n_pds_lock);
281290
rdi->n_pds_allocated = 0;
282291

283-
/* Validate that drivers have provided the right functions */
284-
if (!rdi->driver_f.port_callback)
285-
return -EINVAL;
292+
rvt_pr_info(rdi, "Registration with rdmavt done.\n");
286293

287294
/* We are now good to announce we exist */
288295
return ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);

drivers/infiniband/sw/rdmavt/vt.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
*/
5050

5151
#include <rdma/rdma_vt.h>
52+
#include <linux/pci.h>
5253
#include "dma.h"
5354
#include "pd.h"
5455
#include "qp.h"
@@ -59,4 +60,31 @@
5960
#include "mmap.h"
6061
#include "cq.h"
6162

63+
#define rvt_pr_info(rdi, fmt, ...) \
64+
__rvt_pr_info(rdi->driver_f.get_pci_dev(rdi), \
65+
rdi->driver_f.get_card_name(rdi), \
66+
fmt, \
67+
##__VA_ARGS__)
68+
69+
#define rvt_pr_warn(rdi, fmt, ...) \
70+
__rvt_pr_warn(rdi->driver_f.get_pci_dev(rdi), \
71+
rdi->driver_f.get_card_name(rdi), \
72+
fmt, \
73+
##__VA_ARGS__)
74+
75+
#define rvt_pr_err(rdi, fmt, ...) \
76+
__rvt_pr_err(rdi->driver_f.get_pci_dev(rdi), \
77+
rdi->driver_f.get_card_name(rdi), \
78+
fmt, \
79+
##__VA_ARGS__)
80+
81+
#define __rvt_pr_info(pdev, name, fmt, ...) \
82+
dev_info(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
83+
84+
#define __rvt_pr_warn(pdev, name, fmt, ...) \
85+
dev_warn(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
86+
87+
#define __rvt_pr_err(pdev, name, fmt, ...) \
88+
dev_err(&pdev->dev, "%s: " fmt, name, ##__VA_ARGS__)
89+
6290
#endif /* DEF_RDMAVT_H */

include/rdma/rdma_vt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ struct rvt_driver_params {
386386
/*
387387
* Functions that drivers are required to support
388388
*/
389+
struct rvt_dev_info;
389390
struct rvt_driver_provided {
390391
/*
391392
* The work to create port files in /sys/class Infiniband is different
@@ -394,6 +395,8 @@ struct rvt_driver_provided {
394395
* this.
395396
*/
396397
int (*port_callback)(struct ib_device *, u8, struct kobject *);
398+
const char * (*get_card_name)(struct rvt_dev_info *rdi);
399+
struct pci_dev * (*get_pci_dev)(struct rvt_dev_info *rdi);
397400
};
398401

399402
/* Protection domain */

0 commit comments

Comments
 (0)