diff options
author | Vladimir Sokolovsky <vlad@mellanox.co.il> | 2010-04-14 10:23:01 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-04-21 19:37:48 -0400 |
commit | 5e80ba8ff0bd33ff4af2365969a231cbdb98cafb (patch) | |
tree | e8cde0f8245a377eeafa8b2717bf9a1bf4526c97 /include | |
parent | 0eddb519b9127c73d53db4bf3ec1d45b13f844d1 (diff) |
IB/core: Add support for masked atomic operations
- Add new IB_WR_MASKED_ATOMIC_CMP_AND_SWP and IB_WR_MASKED_ATOMIC_FETCH_AND_ADD
send opcodes that can be used to post "masked atomic compare and
swap" and "masked atomic fetch and add" work request respectively.
- Add masked_atomic_cap capability.
- Add mask fields to atomic struct of ib_send_wr
- Add new opcodes to ib_wc_opcode
The new operations are described more precisely below:
* Masked Compare and Swap (MskCmpSwap)
The MskCmpSwap atomic operation is an extension to the CmpSwap
operation defined in the IB spec. MskCmpSwap allows the user to
select a portion of the 64 bit target data for the “compare” check as
well as to restrict the swap to a (possibly different) portion. The
pseudo code below describes the operation:
| atomic_response = *va
| if (!((compare_add ^ *va) & compare_add_mask)) then
| *va = (*va & ~(swap_mask)) | (swap & swap_mask)
|
| return atomic_response
The additional operands are carried in the Extended Transport Header.
Atomic response generation and packet format for MskCmpSwap is as for
standard IB Atomic operations.
* Masked Fetch and Add (MFetchAdd)
The MFetchAdd Atomic operation extends the functionality of the
standard IB FetchAdd by allowing the user to split the target into
multiple fields of selectable length. The atomic add is done
independently on each one of this fields. A bit set in the
field_boundary parameter specifies the field boundaries. The pseudo
code below describes the operation:
| bit_adder(ci, b1, b2, *co)
| {
| value = ci + b1 + b2
| *co = !!(value & 2)
|
| return value & 1
| }
|
| #define MASK_IS_SET(mask, attr) (!!((mask)&(attr)))
| bit_position = 1
| carry = 0
| atomic_response = 0
|
| for i = 0 to 63
| {
| if ( i != 0 )
| bit_position = bit_position << 1
|
| bit_add_res = bit_adder(carry, MASK_IS_SET(*va, bit_position),
| MASK_IS_SET(compare_add, bit_position), &new_carry)
| if (bit_add_res)
| atomic_response |= bit_position
|
| carry = ((new_carry) && (!MASK_IS_SET(compare_add_mask, bit_position)))
| }
|
| return atomic_response
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/rdma/ib_verbs.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index a585e0f92bc3..310d31474034 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -136,6 +136,7 @@ struct ib_device_attr { | |||
136 | int max_qp_init_rd_atom; | 136 | int max_qp_init_rd_atom; |
137 | int max_ee_init_rd_atom; | 137 | int max_ee_init_rd_atom; |
138 | enum ib_atomic_cap atomic_cap; | 138 | enum ib_atomic_cap atomic_cap; |
139 | enum ib_atomic_cap masked_atomic_cap; | ||
139 | int max_ee; | 140 | int max_ee; |
140 | int max_rdd; | 141 | int max_rdd; |
141 | int max_mw; | 142 | int max_mw; |
@@ -467,6 +468,8 @@ enum ib_wc_opcode { | |||
467 | IB_WC_LSO, | 468 | IB_WC_LSO, |
468 | IB_WC_LOCAL_INV, | 469 | IB_WC_LOCAL_INV, |
469 | IB_WC_FAST_REG_MR, | 470 | IB_WC_FAST_REG_MR, |
471 | IB_WC_MASKED_COMP_SWAP, | ||
472 | IB_WC_MASKED_FETCH_ADD, | ||
470 | /* | 473 | /* |
471 | * Set value of IB_WC_RECV so consumers can test if a completion is a | 474 | * Set value of IB_WC_RECV so consumers can test if a completion is a |
472 | * receive by testing (opcode & IB_WC_RECV). | 475 | * receive by testing (opcode & IB_WC_RECV). |
@@ -689,6 +692,8 @@ enum ib_wr_opcode { | |||
689 | IB_WR_RDMA_READ_WITH_INV, | 692 | IB_WR_RDMA_READ_WITH_INV, |
690 | IB_WR_LOCAL_INV, | 693 | IB_WR_LOCAL_INV, |
691 | IB_WR_FAST_REG_MR, | 694 | IB_WR_FAST_REG_MR, |
695 | IB_WR_MASKED_ATOMIC_CMP_AND_SWP, | ||
696 | IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, | ||
692 | }; | 697 | }; |
693 | 698 | ||
694 | enum ib_send_flags { | 699 | enum ib_send_flags { |
@@ -731,6 +736,8 @@ struct ib_send_wr { | |||
731 | u64 remote_addr; | 736 | u64 remote_addr; |
732 | u64 compare_add; | 737 | u64 compare_add; |
733 | u64 swap; | 738 | u64 swap; |
739 | u64 compare_add_mask; | ||
740 | u64 swap_mask; | ||
734 | u32 rkey; | 741 | u32 rkey; |
735 | } atomic; | 742 | } atomic; |
736 | struct { | 743 | struct { |