diff options
author | Sean Hefty <sean.hefty@intel.com> | 2006-06-17 23:37:39 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-06-17 23:37:39 -0400 |
commit | 6d969a471ba107d94cf03dab3c69f45b9733f500 (patch) | |
tree | 7a9fea5c2a321434e5c4c3bc590393728b85b4dd | |
parent | 4e00d69454a8747798de11dc4eeef1edeee5ce98 (diff) |
IB/sa: Add ib_init_ah_from_path()
Add a call to initialize address handle attributes given a path record.
This is used by the CM, and would be useful for users of UD QPs.
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | drivers/infiniband/core/sa_query.c | 31 | ||||
-rw-r--r-- | include/rdma/ib_sa.h | 7 |
2 files changed, 38 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; |
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index ad63c215efe5..c99e4420fd7e 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h | |||
@@ -370,5 +370,12 @@ ib_sa_mcmember_rec_delete(struct ib_device *device, u8 port_num, | |||
370 | context, query); | 370 | context, query); |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | ||
374 | * ib_init_ah_from_path - Initialize address handle attributes based on an SA | ||
375 | * path record. | ||
376 | */ | ||
377 | int ib_init_ah_from_path(struct ib_device *device, u8 port_num, | ||
378 | struct ib_sa_path_rec *rec, | ||
379 | struct ib_ah_attr *ah_attr); | ||
373 | 380 | ||
374 | #endif /* IB_SA_H */ | 381 | #endif /* IB_SA_H */ |