Skip to content

Commit aec5778

Browse files
Dennis Dalessandrodledford
authored andcommitted
IB/rdmavt: Move driver helper functions to a common structure
Drivers are going to need to provide multiple functions for rdmavt to call in to. We already have one, so go ahead and push this into a data structure designated for driver supplied functions. 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 ca889e8 commit aec5778

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

drivers/infiniband/sw/rdmavt/vt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,12 @@ int rvt_register_device(struct rvt_dev_info *rdi)
280280
spin_lock_init(&rdi->n_pds_lock);
281281
rdi->n_pds_allocated = 0;
282282

283+
/* Validate that drivers have provided the right functions */
284+
if (!rdi->driver_f.port_callback)
285+
return -EINVAL;
286+
283287
/* We are now good to announce we exist */
284-
return ib_register_device(&rdi->ibdev, rdi->port_callback);
288+
return ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback);
285289
}
286290
EXPORT_SYMBOL(rvt_register_device);
287291

include/rdma/rdma_vt.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,19 @@ struct rvt_driver_params {
383383
*/
384384
};
385385

386+
/*
387+
* Functions that drivers are required to support
388+
*/
389+
struct rvt_driver_provided {
390+
/*
391+
* The work to create port files in /sys/class Infiniband is different
392+
* depending on the driver. This should not be extracted away and
393+
* instead drivers are responsible for setting the correct callback for
394+
* this.
395+
*/
396+
int (*port_callback)(struct ib_device *, u8, struct kobject *);
397+
};
398+
386399
/* Protection domain */
387400
struct rvt_pd {
388401
struct ib_pd ibpd;
@@ -407,13 +420,8 @@ struct rvt_dev_info {
407420

408421
/* PKey Table goes here */
409422

410-
/*
411-
* The work to create port files in /sys/class Infiniband is different
412-
* depending on the driver. This should not be extracted away and
413-
* instead drivers are responsible for setting the correct callback for
414-
* this.
415-
*/
416-
int (*port_callback)(struct ib_device *, u8, struct kobject *);
423+
/* Driver specific helper functions */
424+
struct rvt_driver_provided driver_f;
417425

418426
/* Internal use */
419427
int n_pds_allocated;

0 commit comments

Comments
 (0)