aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/sa_query.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 68db633711c5..9a7eaadb1688 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -57,6 +57,7 @@ MODULE_LICENSE("Dual BSD/GPL");
57struct ib_sa_sm_ah { 57struct ib_sa_sm_ah {
58 struct ib_ah *ah; 58 struct ib_ah *ah;
59 struct kref ref; 59 struct kref ref;
60 u8 src_path_mask;
60}; 61};
61 62
62struct ib_sa_port { 63struct ib_sa_port {
@@ -380,6 +381,7 @@ static void update_sm_ah(struct work_struct *work)
380 } 381 }
381 382
382 kref_init(&new_ah->ref); 383 kref_init(&new_ah->ref);
384 new_ah->src_path_mask = (1 << port_attr.lmc) - 1;
383 385
384 memset(&ah_attr, 0, sizeof ah_attr); 386 memset(&ah_attr, 0, sizeof ah_attr);
385 ah_attr.dlid = port_attr.sm_lid; 387 ah_attr.dlid = port_attr.sm_lid;
@@ -460,6 +462,25 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query)
460} 462}
461EXPORT_SYMBOL(ib_sa_cancel_query); 463EXPORT_SYMBOL(ib_sa_cancel_query);
462 464
465static u8 get_src_path_mask(struct ib_device *device, u8 port_num)
466{
467 struct ib_sa_device *sa_dev;
468 struct ib_sa_port *port;
469 unsigned long flags;
470 u8 src_path_mask;
471
472 sa_dev = ib_get_client_data(device, &sa_client);
473 if (!sa_dev)
474 return 0x7f;
475
476 port = &sa_dev->port[port_num - sa_dev->start_port];
477 spin_lock_irqsave(&port->ah_lock, flags);
478 src_path_mask = port->sm_ah ? port->sm_ah->src_path_mask : 0x7f;
479 spin_unlock_irqrestore(&port->ah_lock, flags);
480
481 return src_path_mask;
482}
483
463int ib_init_ah_from_path(struct ib_device *device, u8 port_num, 484int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
464 struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr) 485 struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
465{ 486{
@@ -469,7 +490,8 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
469 memset(ah_attr, 0, sizeof *ah_attr); 490 memset(ah_attr, 0, sizeof *ah_attr);
470 ah_attr->dlid = be16_to_cpu(rec->dlid); 491 ah_attr->dlid = be16_to_cpu(rec->dlid);
471 ah_attr->sl = rec->sl; 492 ah_attr->sl = rec->sl;
472 ah_attr->src_path_bits = be16_to_cpu(rec->slid) & 0x7f; 493 ah_attr->src_path_bits = be16_to_cpu(rec->slid) &
494 get_src_path_mask(device, port_num);
473 ah_attr->port_num = port_num; 495 ah_attr->port_num = port_num;
474 ah_attr->static_rate = rec->rate; 496 ah_attr->static_rate = rec->rate;
475 497