diff options
author | Tatyana Nikolova <Tatyana.E.Nikolova@intel.com> | 2012-02-25 20:45:37 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2012-02-25 20:45:37 -0500 |
commit | 8dd87fba939370e729b0ee72c163f279d310de06 (patch) | |
tree | fd849fb42bce941b9ca2fad1302d1f07dfd85543 /drivers/infiniband/hw/nes/nes_cm.c | |
parent | 6b21d18ed50c7d145220b0724ea7f2613abf0f95 (diff) |
RDMA/nes: Fixes for sparse endianness warnings
Fix endianness problems detect by sparse, introduced with the enhanced
MPA patch.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Signed-off-by: Faisal Latif <Faisal.Latif@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/nes/nes_cm.c')
-rw-r--r-- | drivers/infiniband/hw/nes/nes_cm.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c index a4972abedef1..da2c67db5ebb 100644 --- a/drivers/infiniband/hw/nes/nes_cm.c +++ b/drivers/infiniband/hw/nes/nes_cm.c | |||
@@ -338,18 +338,21 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 *type, | |||
338 | case IETF_MPA_V2: { | 338 | case IETF_MPA_V2: { |
339 | u16 ird_size; | 339 | u16 ird_size; |
340 | u16 ord_size; | 340 | u16 ord_size; |
341 | u16 rtr_ctrl_ird; | ||
342 | u16 rtr_ctrl_ord; | ||
343 | |||
341 | mpa_v2_frame = (struct ietf_mpa_v2 *)buffer; | 344 | mpa_v2_frame = (struct ietf_mpa_v2 *)buffer; |
342 | mpa_hdr_len += IETF_RTR_MSG_SIZE; | 345 | mpa_hdr_len += IETF_RTR_MSG_SIZE; |
343 | cm_node->mpa_frame_size -= IETF_RTR_MSG_SIZE; | 346 | cm_node->mpa_frame_size -= IETF_RTR_MSG_SIZE; |
344 | rtr_msg = &mpa_v2_frame->rtr_msg; | 347 | rtr_msg = &mpa_v2_frame->rtr_msg; |
345 | 348 | ||
346 | /* parse rtr message */ | 349 | /* parse rtr message */ |
347 | rtr_msg->ctrl_ird = ntohs(rtr_msg->ctrl_ird); | 350 | rtr_ctrl_ird = ntohs(rtr_msg->ctrl_ird); |
348 | rtr_msg->ctrl_ord = ntohs(rtr_msg->ctrl_ord); | 351 | rtr_ctrl_ord = ntohs(rtr_msg->ctrl_ord); |
349 | ird_size = rtr_msg->ctrl_ird & IETF_NO_IRD_ORD; | 352 | ird_size = rtr_ctrl_ird & IETF_NO_IRD_ORD; |
350 | ord_size = rtr_msg->ctrl_ord & IETF_NO_IRD_ORD; | 353 | ord_size = rtr_ctrl_ord & IETF_NO_IRD_ORD; |
351 | 354 | ||
352 | if (!(rtr_msg->ctrl_ird & IETF_PEER_TO_PEER)) { | 355 | if (!(rtr_ctrl_ird & IETF_PEER_TO_PEER)) { |
353 | /* send reset */ | 356 | /* send reset */ |
354 | return -EINVAL; | 357 | return -EINVAL; |
355 | } | 358 | } |
@@ -370,9 +373,9 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 *type, | |||
370 | } | 373 | } |
371 | } | 374 | } |
372 | 375 | ||
373 | if (rtr_msg->ctrl_ord & IETF_RDMA0_READ) { | 376 | if (rtr_ctrl_ord & IETF_RDMA0_READ) { |
374 | cm_node->send_rdma0_op = SEND_RDMA_READ_ZERO; | 377 | cm_node->send_rdma0_op = SEND_RDMA_READ_ZERO; |
375 | } else if (rtr_msg->ctrl_ord & IETF_RDMA0_WRITE) { | 378 | } else if (rtr_ctrl_ord & IETF_RDMA0_WRITE) { |
376 | cm_node->send_rdma0_op = SEND_RDMA_WRITE_ZERO; | 379 | cm_node->send_rdma0_op = SEND_RDMA_WRITE_ZERO; |
377 | } else { /* Not supported RDMA0 operation */ | 380 | } else { /* Not supported RDMA0 operation */ |
378 | return -EINVAL; | 381 | return -EINVAL; |
@@ -543,6 +546,8 @@ static void build_mpa_v2(struct nes_cm_node *cm_node, | |||
543 | { | 546 | { |
544 | struct ietf_mpa_v2 *mpa_frame = (struct ietf_mpa_v2 *)start_addr; | 547 | struct ietf_mpa_v2 *mpa_frame = (struct ietf_mpa_v2 *)start_addr; |
545 | struct ietf_rtr_msg *rtr_msg = &mpa_frame->rtr_msg; | 548 | struct ietf_rtr_msg *rtr_msg = &mpa_frame->rtr_msg; |
549 | u16 ctrl_ird; | ||
550 | u16 ctrl_ord; | ||
546 | 551 | ||
547 | /* initialize the upper 5 bytes of the frame */ | 552 | /* initialize the upper 5 bytes of the frame */ |
548 | build_mpa_v1(cm_node, start_addr, mpa_key); | 553 | build_mpa_v1(cm_node, start_addr, mpa_key); |
@@ -550,31 +555,31 @@ static void build_mpa_v2(struct nes_cm_node *cm_node, | |||
550 | mpa_frame->priv_data_len += htons(IETF_RTR_MSG_SIZE); | 555 | mpa_frame->priv_data_len += htons(IETF_RTR_MSG_SIZE); |
551 | 556 | ||
552 | /* initialize RTR msg */ | 557 | /* initialize RTR msg */ |
553 | rtr_msg->ctrl_ird = (cm_node->ird_size > IETF_NO_IRD_ORD) ? | 558 | ctrl_ird = (cm_node->ird_size > IETF_NO_IRD_ORD) ? |
554 | IETF_NO_IRD_ORD : cm_node->ird_size; | 559 | IETF_NO_IRD_ORD : cm_node->ird_size; |
555 | rtr_msg->ctrl_ord = (cm_node->ord_size > IETF_NO_IRD_ORD) ? | 560 | ctrl_ord = (cm_node->ord_size > IETF_NO_IRD_ORD) ? |
556 | IETF_NO_IRD_ORD : cm_node->ord_size; | 561 | IETF_NO_IRD_ORD : cm_node->ord_size; |
557 | 562 | ||
558 | rtr_msg->ctrl_ird |= IETF_PEER_TO_PEER; | 563 | ctrl_ird |= IETF_PEER_TO_PEER; |
559 | rtr_msg->ctrl_ird |= IETF_FLPDU_ZERO_LEN; | 564 | ctrl_ird |= IETF_FLPDU_ZERO_LEN; |
560 | 565 | ||
561 | switch (mpa_key) { | 566 | switch (mpa_key) { |
562 | case MPA_KEY_REQUEST: | 567 | case MPA_KEY_REQUEST: |
563 | rtr_msg->ctrl_ord |= IETF_RDMA0_WRITE; | 568 | ctrl_ord |= IETF_RDMA0_WRITE; |
564 | rtr_msg->ctrl_ord |= IETF_RDMA0_READ; | 569 | ctrl_ord |= IETF_RDMA0_READ; |
565 | break; | 570 | break; |
566 | case MPA_KEY_REPLY: | 571 | case MPA_KEY_REPLY: |
567 | switch (cm_node->send_rdma0_op) { | 572 | switch (cm_node->send_rdma0_op) { |
568 | case SEND_RDMA_WRITE_ZERO: | 573 | case SEND_RDMA_WRITE_ZERO: |
569 | rtr_msg->ctrl_ord |= IETF_RDMA0_WRITE; | 574 | ctrl_ord |= IETF_RDMA0_WRITE; |
570 | break; | 575 | break; |
571 | case SEND_RDMA_READ_ZERO: | 576 | case SEND_RDMA_READ_ZERO: |
572 | rtr_msg->ctrl_ord |= IETF_RDMA0_READ; | 577 | ctrl_ord |= IETF_RDMA0_READ; |
573 | break; | 578 | break; |
574 | } | 579 | } |
575 | } | 580 | } |
576 | rtr_msg->ctrl_ird = htons(rtr_msg->ctrl_ird); | 581 | rtr_msg->ctrl_ird = htons(ctrl_ird); |
577 | rtr_msg->ctrl_ord = htons(rtr_msg->ctrl_ord); | 582 | rtr_msg->ctrl_ord = htons(ctrl_ord); |
578 | } | 583 | } |
579 | 584 | ||
580 | /** | 585 | /** |