diff options
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/sa_query.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c index 501cc054cb3b..08d9dd5e0487 100644 --- a/drivers/infiniband/core/sa_query.c +++ b/drivers/infiniband/core/sa_query.c | |||
@@ -47,6 +47,7 @@ | |||
47 | 47 | ||
48 | #include <rdma/ib_pack.h> | 48 | #include <rdma/ib_pack.h> |
49 | #include <rdma/ib_sa.h> | 49 | #include <rdma/ib_sa.h> |
50 | #include <rdma/ib_cache.h> | ||
50 | 51 | ||
51 | MODULE_AUTHOR("Roland Dreier"); | 52 | MODULE_AUTHOR("Roland Dreier"); |
52 | MODULE_DESCRIPTION("InfiniBand subnet administration query support"); | 53 | MODULE_DESCRIPTION("InfiniBand subnet administration query support"); |
@@ -441,6 +442,36 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query) | |||
441 | } | 442 | } |
442 | EXPORT_SYMBOL(ib_sa_cancel_query); | 443 | EXPORT_SYMBOL(ib_sa_cancel_query); |
443 | 444 | ||
445 | int ib_init_ah_from_path(struct ib_device *device, u8 port_num, | ||
446 | struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr) | ||
447 | { | ||
448 | int ret; | ||
449 | u16 gid_index; | ||
450 | |||
451 | memset(ah_attr, 0, sizeof *ah_attr); | ||
452 | ah_attr->dlid = be16_to_cpu(rec->dlid); | ||
453 | ah_attr->sl = rec->sl; | ||
454 | ah_attr->src_path_bits = be16_to_cpu(rec->slid) & 0x7f; | ||
455 | ah_attr->port_num = port_num; | ||
456 | |||
457 | if (rec->hop_limit > 1) { | ||
458 | ah_attr->ah_flags = IB_AH_GRH; | ||
459 | ah_attr->grh.dgid = rec->dgid; | ||
460 | |||
461 | ret = ib_find_cached_gid(device, &rec->sgid, &port_num, | ||
462 | &gid_index); | ||
463 | if (ret) | ||
464 | return ret; | ||
465 | |||
466 | ah_attr->grh.sgid_index = gid_index; | ||
467 | ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label); | ||
468 | ah_attr->grh.hop_limit = rec->hop_limit; | ||
469 | ah_attr->grh.traffic_class = rec->traffic_class; | ||
470 | } | ||
471 | return 0; | ||
472 | } | ||
473 | EXPORT_SYMBOL(ib_init_ah_from_path); | ||
474 | |||
444 | static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) | 475 | static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) |
445 | { | 476 | { |
446 | unsigned long flags; | 477 | unsigned long flags; |