diff options
author | Roland Dreier <rolandd@cisco.com> | 2008-04-17 00:01:07 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-04-17 00:01:07 -0400 |
commit | a88f488857cd2e54789791d2b5e8d116721d5cb7 (patch) | |
tree | 9c3df1fd400e829b45fc3fa43d5404b7ac411a1f /drivers/infiniband | |
parent | d2ae16d576086bd3e539f4e94f95df4e37ea2419 (diff) |
IB/cm: Endianness annotations
Mostly update the RB tree comparisons to force __be types to normal
integers, but the change to cm_format_sidr_req() is a real fix:
param->path->pkey is already __be16.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Acked-by: Sean Hefty <sean.hefty@intel.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/cm.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index faa7ce318a6d..a47fe64e5c39 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -467,6 +467,31 @@ static int cm_compare_private_data(u8 *private_data, | |||
467 | return memcmp(src, dst_data->data, IB_CM_COMPARE_SIZE); | 467 | return memcmp(src, dst_data->data, IB_CM_COMPARE_SIZE); |
468 | } | 468 | } |
469 | 469 | ||
470 | /* | ||
471 | * Trivial helpers to strip endian annotation and compare; the | ||
472 | * endianness doesn't actually matter since we just need a stable | ||
473 | * order for the RB tree. | ||
474 | */ | ||
475 | static int be32_lt(__be32 a, __be32 b) | ||
476 | { | ||
477 | return (__force u32) a < (__force u32) b; | ||
478 | } | ||
479 | |||
480 | static int be32_gt(__be32 a, __be32 b) | ||
481 | { | ||
482 | return (__force u32) a > (__force u32) b; | ||
483 | } | ||
484 | |||
485 | static int be64_lt(__be64 a, __be64 b) | ||
486 | { | ||
487 | return (__force u64) a < (__force u64) b; | ||
488 | } | ||
489 | |||
490 | static int be64_gt(__be64 a, __be64 b) | ||
491 | { | ||
492 | return (__force u64) a > (__force u64) b; | ||
493 | } | ||
494 | |||
470 | static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) | 495 | static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) |
471 | { | 496 | { |
472 | struct rb_node **link = &cm.listen_service_table.rb_node; | 497 | struct rb_node **link = &cm.listen_service_table.rb_node; |
@@ -492,9 +517,9 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) | |||
492 | link = &(*link)->rb_left; | 517 | link = &(*link)->rb_left; |
493 | else if (cm_id_priv->id.device > cur_cm_id_priv->id.device) | 518 | else if (cm_id_priv->id.device > cur_cm_id_priv->id.device) |
494 | link = &(*link)->rb_right; | 519 | link = &(*link)->rb_right; |
495 | else if (service_id < cur_cm_id_priv->id.service_id) | 520 | else if (be64_lt(service_id, cur_cm_id_priv->id.service_id)) |
496 | link = &(*link)->rb_left; | 521 | link = &(*link)->rb_left; |
497 | else if (service_id > cur_cm_id_priv->id.service_id) | 522 | else if (be64_gt(service_id, cur_cm_id_priv->id.service_id)) |
498 | link = &(*link)->rb_right; | 523 | link = &(*link)->rb_right; |
499 | else if (data_cmp < 0) | 524 | else if (data_cmp < 0) |
500 | link = &(*link)->rb_left; | 525 | link = &(*link)->rb_left; |
@@ -527,9 +552,9 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device, | |||
527 | node = node->rb_left; | 552 | node = node->rb_left; |
528 | else if (device > cm_id_priv->id.device) | 553 | else if (device > cm_id_priv->id.device) |
529 | node = node->rb_right; | 554 | node = node->rb_right; |
530 | else if (service_id < cm_id_priv->id.service_id) | 555 | else if (be64_lt(service_id, cm_id_priv->id.service_id)) |
531 | node = node->rb_left; | 556 | node = node->rb_left; |
532 | else if (service_id > cm_id_priv->id.service_id) | 557 | else if (be64_gt(service_id, cm_id_priv->id.service_id)) |
533 | node = node->rb_right; | 558 | node = node->rb_right; |
534 | else if (data_cmp < 0) | 559 | else if (data_cmp < 0) |
535 | node = node->rb_left; | 560 | node = node->rb_left; |
@@ -552,13 +577,13 @@ static struct cm_timewait_info * cm_insert_remote_id(struct cm_timewait_info | |||
552 | parent = *link; | 577 | parent = *link; |
553 | cur_timewait_info = rb_entry(parent, struct cm_timewait_info, | 578 | cur_timewait_info = rb_entry(parent, struct cm_timewait_info, |
554 | remote_id_node); | 579 | remote_id_node); |
555 | if (remote_id < cur_timewait_info->work.remote_id) | 580 | if (be32_lt(remote_id, cur_timewait_info->work.remote_id)) |
556 | link = &(*link)->rb_left; | 581 | link = &(*link)->rb_left; |
557 | else if (remote_id > cur_timewait_info->work.remote_id) | 582 | else if (be32_gt(remote_id, cur_timewait_info->work.remote_id)) |
558 | link = &(*link)->rb_right; | 583 | link = &(*link)->rb_right; |
559 | else if (remote_ca_guid < cur_timewait_info->remote_ca_guid) | 584 | else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid)) |
560 | link = &(*link)->rb_left; | 585 | link = &(*link)->rb_left; |
561 | else if (remote_ca_guid > cur_timewait_info->remote_ca_guid) | 586 | else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid)) |
562 | link = &(*link)->rb_right; | 587 | link = &(*link)->rb_right; |
563 | else | 588 | else |
564 | return cur_timewait_info; | 589 | return cur_timewait_info; |
@@ -578,13 +603,13 @@ static struct cm_timewait_info * cm_find_remote_id(__be64 remote_ca_guid, | |||
578 | while (node) { | 603 | while (node) { |
579 | timewait_info = rb_entry(node, struct cm_timewait_info, | 604 | timewait_info = rb_entry(node, struct cm_timewait_info, |
580 | remote_id_node); | 605 | remote_id_node); |
581 | if (remote_id < timewait_info->work.remote_id) | 606 | if (be32_lt(remote_id, timewait_info->work.remote_id)) |
582 | node = node->rb_left; | 607 | node = node->rb_left; |
583 | else if (remote_id > timewait_info->work.remote_id) | 608 | else if (be32_gt(remote_id, timewait_info->work.remote_id)) |
584 | node = node->rb_right; | 609 | node = node->rb_right; |
585 | else if (remote_ca_guid < timewait_info->remote_ca_guid) | 610 | else if (be64_lt(remote_ca_guid, timewait_info->remote_ca_guid)) |
586 | node = node->rb_left; | 611 | node = node->rb_left; |
587 | else if (remote_ca_guid > timewait_info->remote_ca_guid) | 612 | else if (be64_gt(remote_ca_guid, timewait_info->remote_ca_guid)) |
588 | node = node->rb_right; | 613 | node = node->rb_right; |
589 | else | 614 | else |
590 | return timewait_info; | 615 | return timewait_info; |
@@ -605,13 +630,13 @@ static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_info | |||
605 | parent = *link; | 630 | parent = *link; |
606 | cur_timewait_info = rb_entry(parent, struct cm_timewait_info, | 631 | cur_timewait_info = rb_entry(parent, struct cm_timewait_info, |
607 | remote_qp_node); | 632 | remote_qp_node); |
608 | if (remote_qpn < cur_timewait_info->remote_qpn) | 633 | if (be32_lt(remote_qpn, cur_timewait_info->remote_qpn)) |
609 | link = &(*link)->rb_left; | 634 | link = &(*link)->rb_left; |
610 | else if (remote_qpn > cur_timewait_info->remote_qpn) | 635 | else if (be32_gt(remote_qpn, cur_timewait_info->remote_qpn)) |
611 | link = &(*link)->rb_right; | 636 | link = &(*link)->rb_right; |
612 | else if (remote_ca_guid < cur_timewait_info->remote_ca_guid) | 637 | else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid)) |
613 | link = &(*link)->rb_left; | 638 | link = &(*link)->rb_left; |
614 | else if (remote_ca_guid > cur_timewait_info->remote_ca_guid) | 639 | else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid)) |
615 | link = &(*link)->rb_right; | 640 | link = &(*link)->rb_right; |
616 | else | 641 | else |
617 | return cur_timewait_info; | 642 | return cur_timewait_info; |
@@ -635,9 +660,9 @@ static struct cm_id_private * cm_insert_remote_sidr(struct cm_id_private | |||
635 | parent = *link; | 660 | parent = *link; |
636 | cur_cm_id_priv = rb_entry(parent, struct cm_id_private, | 661 | cur_cm_id_priv = rb_entry(parent, struct cm_id_private, |
637 | sidr_id_node); | 662 | sidr_id_node); |
638 | if (remote_id < cur_cm_id_priv->id.remote_id) | 663 | if (be32_lt(remote_id, cur_cm_id_priv->id.remote_id)) |
639 | link = &(*link)->rb_left; | 664 | link = &(*link)->rb_left; |
640 | else if (remote_id > cur_cm_id_priv->id.remote_id) | 665 | else if (be32_gt(remote_id, cur_cm_id_priv->id.remote_id)) |
641 | link = &(*link)->rb_right; | 666 | link = &(*link)->rb_right; |
642 | else { | 667 | else { |
643 | int cmp; | 668 | int cmp; |
@@ -2848,7 +2873,7 @@ static void cm_format_sidr_req(struct cm_sidr_req_msg *sidr_req_msg, | |||
2848 | cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID, | 2873 | cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID, |
2849 | cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR)); | 2874 | cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR)); |
2850 | sidr_req_msg->request_id = cm_id_priv->id.local_id; | 2875 | sidr_req_msg->request_id = cm_id_priv->id.local_id; |
2851 | sidr_req_msg->pkey = cpu_to_be16(param->path->pkey); | 2876 | sidr_req_msg->pkey = param->path->pkey; |
2852 | sidr_req_msg->service_id = param->service_id; | 2877 | sidr_req_msg->service_id = param->service_id; |
2853 | 2878 | ||
2854 | if (param->private_data && param->private_data_len) | 2879 | if (param->private_data && param->private_data_len) |