diff options
| author | Shani Michaeli <shanim@mellanox.com> | 2013-02-06 11:19:12 -0500 |
|---|---|---|
| committer | Roland Dreier <roland@purestorage.com> | 2013-02-21 14:51:45 -0500 |
| commit | 7083e42ee2ff43a11481e0e7211ec4f9ac68cb79 (patch) | |
| tree | cf2c3f16075fcb37c27bff5ae4524f778df9a482 /include | |
| parent | 836dc9e3fbbab0c30aa6e664417225f5c1fb1c39 (diff) | |
IB/core: Add "type 2" memory windows support
This patch enhances the IB core support for Memory Windows (MWs).
MWs allow an application to have better/flexible control over remote
access to memory.
Two types of MWs are supported, with the second type having two flavors:
Type 1 - associated with PD only
Type 2A - associated with QPN only
Type 2B - associated with PD and QPN
Applications can allocate a MW once, and then repeatedly bind the MW
to different ranges in MRs that are associated to the same PD. Type 1
windows are bound through a verb, while type 2 windows are bound by
posting a work request.
The 32-bit memory key is composed of a 24-bit index and an 8-bit
key. The key is changed with each bind, thus allowing more control
over the peer's use of the memory key.
The changes introduced are the following:
* add memory window type enum and a corresponding parameter to ib_alloc_mw.
* type 2 memory window bind work request support.
* create a struct that contains the common part of the bind verb struct
ibv_mw_bind and the bind work request into a single struct.
* add the ib_inc_rkey helper function to advance the tag part of an rkey.
Consumer interface details:
* new device capability flags IB_DEVICE_MEM_WINDOW_TYPE_2A and
IB_DEVICE_MEM_WINDOW_TYPE_2B are added to indicate device support
for these features.
Devices can set either IB_DEVICE_MEM_WINDOW_TYPE_2A or
IB_DEVICE_MEM_WINDOW_TYPE_2B if it supports type 2A or type 2B
memory windows. It can set neither to indicate it doesn't support
type 2 windows at all.
* modify existing provides and consumers code to the new param of
ib_alloc_mw and the ib_mw_bind_info structure
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Shani Michaeli <shanim@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/rdma/ib_verbs.h | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 46bc045bbe15..98cc4b29fc5b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
| @@ -115,6 +115,8 @@ enum ib_device_cap_flags { | |||
| 115 | IB_DEVICE_XRC = (1<<20), | 115 | IB_DEVICE_XRC = (1<<20), |
| 116 | IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21), | 116 | IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21), |
| 117 | IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22), | 117 | IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22), |
| 118 | IB_DEVICE_MEM_WINDOW_TYPE_2A = (1<<23), | ||
| 119 | IB_DEVICE_MEM_WINDOW_TYPE_2B = (1<<24) | ||
| 118 | }; | 120 | }; |
| 119 | 121 | ||
| 120 | enum ib_atomic_cap { | 122 | enum ib_atomic_cap { |
| @@ -715,6 +717,11 @@ enum ib_mig_state { | |||
| 715 | IB_MIG_ARMED | 717 | IB_MIG_ARMED |
| 716 | }; | 718 | }; |
| 717 | 719 | ||
| 720 | enum ib_mw_type { | ||
| 721 | IB_MW_TYPE_1 = 1, | ||
| 722 | IB_MW_TYPE_2 = 2 | ||
| 723 | }; | ||
| 724 | |||
| 718 | struct ib_qp_attr { | 725 | struct ib_qp_attr { |
| 719 | enum ib_qp_state qp_state; | 726 | enum ib_qp_state qp_state; |
| 720 | enum ib_qp_state cur_qp_state; | 727 | enum ib_qp_state cur_qp_state; |
| @@ -758,6 +765,7 @@ enum ib_wr_opcode { | |||
| 758 | IB_WR_FAST_REG_MR, | 765 | IB_WR_FAST_REG_MR, |
| 759 | IB_WR_MASKED_ATOMIC_CMP_AND_SWP, | 766 | IB_WR_MASKED_ATOMIC_CMP_AND_SWP, |
| 760 | IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, | 767 | IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, |
| 768 | IB_WR_BIND_MW, | ||
| 761 | }; | 769 | }; |
| 762 | 770 | ||
| 763 | enum ib_send_flags { | 771 | enum ib_send_flags { |
| @@ -780,6 +788,23 @@ struct ib_fast_reg_page_list { | |||
| 780 | unsigned int max_page_list_len; | 788 | unsigned int max_page_list_len; |
| 781 | }; | 789 | }; |
| 782 | 790 | ||
| 791 | /** | ||
| 792 | * struct ib_mw_bind_info - Parameters for a memory window bind operation. | ||
| 793 | * @mr: A memory region to bind the memory window to. | ||
| 794 | * @addr: The address where the memory window should begin. | ||
| 795 | * @length: The length of the memory window, in bytes. | ||
| 796 | * @mw_access_flags: Access flags from enum ib_access_flags for the window. | ||
| 797 | * | ||
| 798 | * This struct contains the shared parameters for type 1 and type 2 | ||
| 799 | * memory window bind operations. | ||
| 800 | */ | ||
| 801 | struct ib_mw_bind_info { | ||
| 802 | struct ib_mr *mr; | ||
| 803 | u64 addr; | ||
| 804 | u64 length; | ||
| 805 | int mw_access_flags; | ||
| 806 | }; | ||
| 807 | |||
| 783 | struct ib_send_wr { | 808 | struct ib_send_wr { |
| 784 | struct ib_send_wr *next; | 809 | struct ib_send_wr *next; |
| 785 | u64 wr_id; | 810 | u64 wr_id; |
| @@ -823,6 +848,12 @@ struct ib_send_wr { | |||
| 823 | int access_flags; | 848 | int access_flags; |
| 824 | u32 rkey; | 849 | u32 rkey; |
| 825 | } fast_reg; | 850 | } fast_reg; |
| 851 | struct { | ||
| 852 | struct ib_mw *mw; | ||
| 853 | /* The new rkey for the memory window. */ | ||
| 854 | u32 rkey; | ||
| 855 | struct ib_mw_bind_info bind_info; | ||
| 856 | } bind_mw; | ||
| 826 | } wr; | 857 | } wr; |
| 827 | u32 xrc_remote_srq_num; /* XRC TGT QPs only */ | 858 | u32 xrc_remote_srq_num; /* XRC TGT QPs only */ |
| 828 | }; | 859 | }; |
| @@ -839,7 +870,8 @@ enum ib_access_flags { | |||
| 839 | IB_ACCESS_REMOTE_WRITE = (1<<1), | 870 | IB_ACCESS_REMOTE_WRITE = (1<<1), |
| 840 | IB_ACCESS_REMOTE_READ = (1<<2), | 871 | IB_ACCESS_REMOTE_READ = (1<<2), |
| 841 | IB_ACCESS_REMOTE_ATOMIC = (1<<3), | 872 | IB_ACCESS_REMOTE_ATOMIC = (1<<3), |
| 842 | IB_ACCESS_MW_BIND = (1<<4) | 873 | IB_ACCESS_MW_BIND = (1<<4), |
| 874 | IB_ZERO_BASED = (1<<5) | ||
| 843 | }; | 875 | }; |
| 844 | 876 | ||
| 845 | struct ib_phys_buf { | 877 | struct ib_phys_buf { |
| @@ -862,13 +894,16 @@ enum ib_mr_rereg_flags { | |||
| 862 | IB_MR_REREG_ACCESS = (1<<2) | 894 | IB_MR_REREG_ACCESS = (1<<2) |
| 863 | }; | 895 | }; |
| 864 | 896 | ||
| 897 | /** | ||
| 898 | * struct ib_mw_bind - Parameters for a type 1 memory window bind operation. | ||
| 899 | * @wr_id: Work request id. | ||
| 900 | * @send_flags: Flags from ib_send_flags enum. | ||
| 901 | * @bind_info: More parameters of the bind operation. | ||
| 902 | */ | ||
| 865 | struct ib_mw_bind { | 903 | struct ib_mw_bind { |
| 866 | struct ib_mr *mr; | 904 | u64 wr_id; |
| 867 | u64 wr_id; | 905 | int send_flags; |
| 868 | u64 addr; | 906 | struct ib_mw_bind_info bind_info; |
| 869 | u32 length; | ||
| 870 | int send_flags; | ||
| 871 | int mw_access_flags; | ||
| 872 | }; | 907 | }; |
| 873 | 908 | ||
| 874 | struct ib_fmr_attr { | 909 | struct ib_fmr_attr { |
| @@ -991,6 +1026,7 @@ struct ib_mw { | |||
| 991 | struct ib_pd *pd; | 1026 | struct ib_pd *pd; |
| 992 | struct ib_uobject *uobject; | 1027 | struct ib_uobject *uobject; |
| 993 | u32 rkey; | 1028 | u32 rkey; |
| 1029 | enum ib_mw_type type; | ||
| 994 | }; | 1030 | }; |
| 995 | 1031 | ||
| 996 | struct ib_fmr { | 1032 | struct ib_fmr { |
| @@ -1202,7 +1238,8 @@ struct ib_device { | |||
| 1202 | int num_phys_buf, | 1238 | int num_phys_buf, |
| 1203 | int mr_access_flags, | 1239 | int mr_access_flags, |
| 1204 | u64 *iova_start); | 1240 | u64 *iova_start); |
| 1205 | struct ib_mw * (*alloc_mw)(struct ib_pd *pd); | 1241 | struct ib_mw * (*alloc_mw)(struct ib_pd *pd, |
| 1242 | enum ib_mw_type type); | ||
| 1206 | int (*bind_mw)(struct ib_qp *qp, | 1243 | int (*bind_mw)(struct ib_qp *qp, |
| 1207 | struct ib_mw *mw, | 1244 | struct ib_mw *mw, |
| 1208 | struct ib_mw_bind *mw_bind); | 1245 | struct ib_mw_bind *mw_bind); |
| @@ -2019,6 +2056,8 @@ int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr); | |||
| 2019 | * ib_dereg_mr - Deregisters a memory region and removes it from the | 2056 | * ib_dereg_mr - Deregisters a memory region and removes it from the |
| 2020 | * HCA translation table. | 2057 | * HCA translation table. |
| 2021 | * @mr: The memory region to deregister. | 2058 | * @mr: The memory region to deregister. |
| 2059 | * | ||
| 2060 | * This function can fail, if the memory region has memory windows bound to it. | ||
| 2022 | */ | 2061 | */ |
| 2023 | int ib_dereg_mr(struct ib_mr *mr); | 2062 | int ib_dereg_mr(struct ib_mr *mr); |
| 2024 | 2063 | ||
| @@ -2071,10 +2110,22 @@ static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey) | |||
| 2071 | } | 2110 | } |
| 2072 | 2111 | ||
| 2073 | /** | 2112 | /** |
| 2113 | * ib_inc_rkey - increments the key portion of the given rkey. Can be used | ||
| 2114 | * for calculating a new rkey for type 2 memory windows. | ||
| 2115 | * @rkey - the rkey to increment. | ||
| 2116 | */ | ||
| 2117 | static inline u32 ib_inc_rkey(u32 rkey) | ||
| 2118 | { | ||
| 2119 | const u32 mask = 0x000000ff; | ||
| 2120 | return ((rkey + 1) & mask) | (rkey & ~mask); | ||
| 2121 | } | ||
| 2122 | |||
| 2123 | /** | ||
| 2074 | * ib_alloc_mw - Allocates a memory window. | 2124 | * ib_alloc_mw - Allocates a memory window. |
| 2075 | * @pd: The protection domain associated with the memory window. | 2125 | * @pd: The protection domain associated with the memory window. |
| 2126 | * @type: The type of the memory window (1 or 2). | ||
| 2076 | */ | 2127 | */ |
| 2077 | struct ib_mw *ib_alloc_mw(struct ib_pd *pd); | 2128 | struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type); |
| 2078 | 2129 | ||
| 2079 | /** | 2130 | /** |
| 2080 | * ib_bind_mw - Posts a work request to the send queue of the specified | 2131 | * ib_bind_mw - Posts a work request to the send queue of the specified |
| @@ -2084,6 +2135,10 @@ struct ib_mw *ib_alloc_mw(struct ib_pd *pd); | |||
| 2084 | * @mw: The memory window to bind. | 2135 | * @mw: The memory window to bind. |
| 2085 | * @mw_bind: Specifies information about the memory window, including | 2136 | * @mw_bind: Specifies information about the memory window, including |
| 2086 | * its address range, remote access rights, and associated memory region. | 2137 | * its address range, remote access rights, and associated memory region. |
| 2138 | * | ||
| 2139 | * If there is no immediate error, the function will update the rkey member | ||
| 2140 | * of the mw parameter to its new value. The bind operation can still fail | ||
| 2141 | * asynchronously. | ||
| 2087 | */ | 2142 | */ |
| 2088 | static inline int ib_bind_mw(struct ib_qp *qp, | 2143 | static inline int ib_bind_mw(struct ib_qp *qp, |
| 2089 | struct ib_mw *mw, | 2144 | struct ib_mw *mw, |
