| .. | .. |
|---|
| 44 | 44 | #include <rdma/ib_verbs.h> |
|---|
| 45 | 45 | #include <rdma/ib_sa.h> |
|---|
| 46 | 46 | #include <rdma/ib_cm.h> |
|---|
| 47 | | -#include <rdma/ib_fmr_pool.h> |
|---|
| 48 | 47 | #include <rdma/rdma_cm.h> |
|---|
| 49 | 48 | |
|---|
| 50 | 49 | enum { |
|---|
| .. | .. |
|---|
| 67 | 66 | SRP_TAG_TSK_MGMT = 1U << 31, |
|---|
| 68 | 67 | |
|---|
| 69 | 68 | SRP_MAX_PAGES_PER_MR = 512, |
|---|
| 69 | + |
|---|
| 70 | + SRP_MAX_ADD_CDB_LEN = 16, |
|---|
| 71 | + |
|---|
| 72 | + SRP_MAX_IMM_SGE = 2, |
|---|
| 73 | + SRP_MAX_SGE = SRP_MAX_IMM_SGE + 1, |
|---|
| 74 | + /* |
|---|
| 75 | + * Choose the immediate data offset such that a 32 byte CDB still fits. |
|---|
| 76 | + */ |
|---|
| 77 | + SRP_IMM_DATA_OFFSET = sizeof(struct srp_cmd) + |
|---|
| 78 | + SRP_MAX_ADD_CDB_LEN + |
|---|
| 79 | + sizeof(struct srp_imm_buf), |
|---|
| 70 | 80 | }; |
|---|
| 71 | 81 | |
|---|
| 72 | 82 | enum srp_target_state { |
|---|
| .. | .. |
|---|
| 84 | 94 | /* |
|---|
| 85 | 95 | * @mr_page_mask: HCA memory registration page mask. |
|---|
| 86 | 96 | * @mr_page_size: HCA memory registration page size. |
|---|
| 87 | | - * @mr_max_size: Maximum size in bytes of a single FMR / FR registration |
|---|
| 88 | | - * request. |
|---|
| 97 | + * @mr_max_size: Maximum size in bytes of a single FR registration request. |
|---|
| 89 | 98 | */ |
|---|
| 90 | 99 | struct srp_device { |
|---|
| 91 | 100 | struct list_head dev_list; |
|---|
| .. | .. |
|---|
| 96 | 105 | int mr_page_size; |
|---|
| 97 | 106 | int mr_max_size; |
|---|
| 98 | 107 | int max_pages_per_mr; |
|---|
| 99 | | - bool has_fmr; |
|---|
| 100 | 108 | bool has_fr; |
|---|
| 101 | | - bool use_fmr; |
|---|
| 102 | 109 | bool use_fast_reg; |
|---|
| 103 | 110 | }; |
|---|
| 104 | 111 | |
|---|
| .. | .. |
|---|
| 116 | 123 | struct srp_request { |
|---|
| 117 | 124 | struct scsi_cmnd *scmnd; |
|---|
| 118 | 125 | struct srp_iu *cmd; |
|---|
| 119 | | - union { |
|---|
| 120 | | - struct ib_pool_fmr **fmr_list; |
|---|
| 121 | | - struct srp_fr_desc **fr_list; |
|---|
| 122 | | - }; |
|---|
| 123 | | - u64 *map_page; |
|---|
| 126 | + struct srp_fr_desc **fr_list; |
|---|
| 124 | 127 | struct srp_direct_buf *indirect_desc; |
|---|
| 125 | 128 | dma_addr_t indirect_dma_addr; |
|---|
| 126 | 129 | short nmdesc; |
|---|
| .. | .. |
|---|
| 130 | 133 | /** |
|---|
| 131 | 134 | * struct srp_rdma_ch |
|---|
| 132 | 135 | * @comp_vector: Completion vector used by this RDMA channel. |
|---|
| 136 | + * @max_it_iu_len: Maximum initiator-to-target information unit length. |
|---|
| 137 | + * @max_ti_iu_len: Maximum target-to-initiator information unit length. |
|---|
| 133 | 138 | */ |
|---|
| 134 | 139 | struct srp_rdma_ch { |
|---|
| 135 | 140 | /* These are RW in the hot path, and commonly used together */ |
|---|
| .. | .. |
|---|
| 142 | 147 | struct ib_cq *send_cq; |
|---|
| 143 | 148 | struct ib_cq *recv_cq; |
|---|
| 144 | 149 | struct ib_qp *qp; |
|---|
| 145 | | - union { |
|---|
| 146 | | - struct ib_fmr_pool *fmr_pool; |
|---|
| 147 | | - struct srp_fr_pool *fr_pool; |
|---|
| 148 | | - }; |
|---|
| 150 | + struct srp_fr_pool *fr_pool; |
|---|
| 151 | + uint32_t max_it_iu_len; |
|---|
| 152 | + uint32_t max_ti_iu_len; |
|---|
| 153 | + u8 max_imm_sge; |
|---|
| 154 | + bool use_imm_data; |
|---|
| 149 | 155 | |
|---|
| 150 | 156 | /* Everything above this point is used in the hot path of |
|---|
| 151 | 157 | * command processing. Try to keep them packed into cachelines. |
|---|
| .. | .. |
|---|
| 169 | 175 | struct srp_iu **tx_ring; |
|---|
| 170 | 176 | struct srp_iu **rx_ring; |
|---|
| 171 | 177 | struct srp_request *req_ring; |
|---|
| 172 | | - int max_ti_iu_len; |
|---|
| 173 | 178 | int comp_vector; |
|---|
| 174 | 179 | |
|---|
| 175 | 180 | u64 tsk_mgmt_tag; |
|---|
| .. | .. |
|---|
| 194 | 199 | u32 ch_count; |
|---|
| 195 | 200 | u32 lkey; |
|---|
| 196 | 201 | enum srp_target_state state; |
|---|
| 197 | | - unsigned int max_iu_len; |
|---|
| 202 | + uint32_t max_it_iu_size; |
|---|
| 198 | 203 | unsigned int cmd_sg_cnt; |
|---|
| 199 | 204 | unsigned int indirect_size; |
|---|
| 200 | 205 | bool allow_ext_sg; |
|---|
| .. | .. |
|---|
| 231 | 236 | union { |
|---|
| 232 | 237 | struct sockaddr_in ip4; |
|---|
| 233 | 238 | struct sockaddr_in6 ip6; |
|---|
| 239 | + struct sockaddr sa; |
|---|
| 234 | 240 | struct sockaddr_storage ss; |
|---|
| 235 | 241 | } src; |
|---|
| 236 | 242 | union { |
|---|
| 237 | 243 | struct sockaddr_in ip4; |
|---|
| 238 | 244 | struct sockaddr_in6 ip6; |
|---|
| 245 | + struct sockaddr sa; |
|---|
| 239 | 246 | struct sockaddr_storage ss; |
|---|
| 240 | 247 | } dst; |
|---|
| 241 | 248 | bool src_specified; |
|---|
| .. | .. |
|---|
| 259 | 266 | void *buf; |
|---|
| 260 | 267 | size_t size; |
|---|
| 261 | 268 | enum dma_data_direction direction; |
|---|
| 269 | + u32 num_sge; |
|---|
| 270 | + struct ib_sge sge[SRP_MAX_SGE]; |
|---|
| 262 | 271 | struct ib_cqe cqe; |
|---|
| 263 | 272 | }; |
|---|
| 264 | 273 | |
|---|
| .. | .. |
|---|
| 289 | 298 | int max_page_list_len; |
|---|
| 290 | 299 | spinlock_t lock; |
|---|
| 291 | 300 | struct list_head free_list; |
|---|
| 292 | | - struct srp_fr_desc desc[0]; |
|---|
| 301 | + struct srp_fr_desc desc[]; |
|---|
| 293 | 302 | }; |
|---|
| 294 | 303 | |
|---|
| 295 | 304 | /** |
|---|
| .. | .. |
|---|
| 299 | 308 | * @pages: Array with DMA addresses of pages being considered for |
|---|
| 300 | 309 | * memory registration. |
|---|
| 301 | 310 | * @base_dma_addr: DMA address of the first page that has not yet been mapped. |
|---|
| 302 | | - * @dma_len: Number of bytes that will be registered with the next |
|---|
| 303 | | - * FMR or FR memory registration call. |
|---|
| 311 | + * @dma_len: Number of bytes that will be registered with the next FR |
|---|
| 312 | + * memory registration call. |
|---|
| 304 | 313 | * @total_len: Total number of bytes in the sg-list being mapped. |
|---|
| 305 | 314 | * @npages: Number of page addresses in the pages[] array. |
|---|
| 306 | | - * @nmdesc: Number of FMR or FR memory descriptors used for mapping. |
|---|
| 315 | + * @nmdesc: Number of FR memory descriptors used for mapping. |
|---|
| 307 | 316 | * @ndesc: Number of SRP buffer descriptors that have been filled in. |
|---|
| 308 | 317 | */ |
|---|
| 309 | 318 | struct srp_map_state { |
|---|
| 310 | 319 | union { |
|---|
| 311 | | - struct { |
|---|
| 312 | | - struct ib_pool_fmr **next; |
|---|
| 313 | | - struct ib_pool_fmr **end; |
|---|
| 314 | | - } fmr; |
|---|
| 315 | 320 | struct { |
|---|
| 316 | 321 | struct srp_fr_desc **next; |
|---|
| 317 | 322 | struct srp_fr_desc **end; |
|---|