Lines Matching +full:single +full:- +full:wire
3 * Copyright (c) 2013-2014 Mellanox Technologies. All rights reserved.
15 * - Redistributions of source code must retain the above
19 * - Redistributions in binary form must reproduce the above
48 struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; in iser_reg_desc_get_fr()
52 spin_lock_irqsave(&fr_pool->lock, flags); in iser_reg_desc_get_fr()
53 desc = list_first_entry(&fr_pool->list, in iser_reg_desc_get_fr()
55 list_del(&desc->list); in iser_reg_desc_get_fr()
56 spin_unlock_irqrestore(&fr_pool->lock, flags); in iser_reg_desc_get_fr()
64 struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; in iser_reg_desc_put_fr()
67 spin_lock_irqsave(&fr_pool->lock, flags); in iser_reg_desc_put_fr()
68 list_add(&desc->list, &fr_pool->list); in iser_reg_desc_put_fr()
69 spin_unlock_irqrestore(&fr_pool->lock, flags); in iser_reg_desc_put_fr()
76 struct iser_data_buf *data = &iser_task->data[iser_dir]; in iser_dma_map_task_data()
79 iser_task->dir[iser_dir] = 1; in iser_dma_map_task_data()
80 dev = iser_task->iser_conn->ib_conn.device->ib_device; in iser_dma_map_task_data()
82 data->dma_nents = ib_dma_map_sg(dev, data->sg, data->size, dma_dir); in iser_dma_map_task_data()
83 if (unlikely(data->dma_nents == 0)) { in iser_dma_map_task_data()
85 return -EINVAL; in iser_dma_map_task_data()
88 if (scsi_prot_sg_count(iser_task->sc)) { in iser_dma_map_task_data()
89 struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; in iser_dma_map_task_data()
91 pdata->dma_nents = ib_dma_map_sg(dev, pdata->sg, pdata->size, dma_dir); in iser_dma_map_task_data()
92 if (unlikely(pdata->dma_nents == 0)) { in iser_dma_map_task_data()
101 ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); in iser_dma_map_task_data()
102 return -EINVAL; in iser_dma_map_task_data()
110 struct iser_data_buf *data = &iser_task->data[iser_dir]; in iser_dma_unmap_task_data()
113 dev = iser_task->iser_conn->ib_conn.device->ib_device; in iser_dma_unmap_task_data()
114 ib_dma_unmap_sg(dev, data->sg, data->size, dma_dir); in iser_dma_unmap_task_data()
116 if (scsi_prot_sg_count(iser_task->sc)) { in iser_dma_unmap_task_data()
117 struct iser_data_buf *pdata = &iser_task->prot[iser_dir]; in iser_dma_unmap_task_data()
119 ib_dma_unmap_sg(dev, pdata->sg, pdata->size, dma_dir); in iser_dma_unmap_task_data()
126 struct scatterlist *sg = mem->sg; in iser_reg_dma()
128 reg->sge.lkey = device->pd->local_dma_lkey; in iser_reg_dma()
134 if (device->pd->flags & IB_PD_UNSAFE_GLOBAL_RKEY) in iser_reg_dma()
135 reg->rkey = device->pd->unsafe_global_rkey; in iser_reg_dma()
137 reg->rkey = 0; in iser_reg_dma()
138 reg->sge.addr = sg_dma_address(&sg[0]); in iser_reg_dma()
139 reg->sge.length = sg_dma_len(&sg[0]); in iser_reg_dma()
141 iser_dbg("Single DMA entry: lkey=0x%x, rkey=0x%x, addr=0x%llx," in iser_reg_dma()
142 " length=0x%x\n", reg->sge.lkey, reg->rkey, in iser_reg_dma()
143 reg->sge.addr, reg->sge.length); in iser_reg_dma()
151 struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; in iser_unreg_mem_fastreg()
155 desc = reg->desc; in iser_unreg_mem_fastreg()
162 * SCSI-Response is received. And the signature MR is not checked if in iser_unreg_mem_fastreg()
167 if (unlikely(desc->sig_protected)) { in iser_unreg_mem_fastreg()
168 desc->sig_protected = false; in iser_unreg_mem_fastreg()
169 ib_check_mr_status(desc->rsc.sig_mr, IB_MR_CHECK_SIG_STATUS, in iser_unreg_mem_fastreg()
172 iser_reg_desc_put_fr(&iser_task->iser_conn->ib_conn, reg->desc); in iser_unreg_mem_fastreg()
173 reg->desc = NULL; in iser_unreg_mem_fastreg()
179 domain->sig_type = IB_SIG_TYPE_T10_DIF; in iser_set_dif_domain()
180 domain->sig.dif.pi_interval = scsi_prot_interval(sc); in iser_set_dif_domain()
181 domain->sig.dif.ref_tag = t10_pi_ref_tag(scsi_cmd_to_rq(sc)); in iser_set_dif_domain()
186 domain->sig.dif.apptag_check_mask = 0xffff; in iser_set_dif_domain()
187 domain->sig.dif.app_escape = true; in iser_set_dif_domain()
188 domain->sig.dif.ref_escape = true; in iser_set_dif_domain()
189 if (sc->prot_flags & SCSI_PROT_REF_INCREMENT) in iser_set_dif_domain()
190 domain->sig.dif.ref_remap = true; in iser_set_dif_domain()
199 sig_attrs->mem.sig_type = IB_SIG_TYPE_NONE; in iser_set_sig_attrs()
200 iser_set_dif_domain(sc, &sig_attrs->wire); in iser_set_sig_attrs()
201 sig_attrs->wire.sig.dif.bg_type = IB_T10DIF_CRC; in iser_set_sig_attrs()
205 sig_attrs->wire.sig_type = IB_SIG_TYPE_NONE; in iser_set_sig_attrs()
206 iser_set_dif_domain(sc, &sig_attrs->mem); in iser_set_sig_attrs()
207 sig_attrs->mem.sig.dif.bg_type = sc->prot_flags & SCSI_PROT_IP_CHECKSUM ? in iser_set_sig_attrs()
212 iser_set_dif_domain(sc, &sig_attrs->wire); in iser_set_sig_attrs()
213 sig_attrs->wire.sig.dif.bg_type = IB_T10DIF_CRC; in iser_set_sig_attrs()
214 iser_set_dif_domain(sc, &sig_attrs->mem); in iser_set_sig_attrs()
215 sig_attrs->mem.sig.dif.bg_type = sc->prot_flags & SCSI_PROT_IP_CHECKSUM ? in iser_set_sig_attrs()
221 return -EINVAL; in iser_set_sig_attrs()
230 if (sc->prot_flags & SCSI_PROT_REF_CHECK) in iser_set_prot_checks()
232 if (sc->prot_flags & SCSI_PROT_GUARD_CHECK) in iser_set_prot_checks()
239 inv_wr->opcode = IB_WR_LOCAL_INV; in iser_inv_rkey()
240 inv_wr->wr_cqe = cqe; in iser_inv_rkey()
241 inv_wr->ex.invalidate_rkey = mr->rkey; in iser_inv_rkey()
242 inv_wr->send_flags = 0; in iser_inv_rkey()
243 inv_wr->num_sge = 0; in iser_inv_rkey()
244 inv_wr->next = next_wr; in iser_inv_rkey()
253 struct iser_tx_desc *tx_desc = &iser_task->desc; in iser_reg_sig_mr()
254 struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; in iser_reg_sig_mr()
255 struct ib_mr *mr = rsc->sig_mr; in iser_reg_sig_mr()
256 struct ib_sig_attrs *sig_attrs = mr->sig_attrs; in iser_reg_sig_mr()
257 struct ib_reg_wr *wr = &tx_desc->reg_wr; in iser_reg_sig_mr()
261 ret = iser_set_sig_attrs(iser_task->sc, sig_attrs); in iser_reg_sig_mr()
265 iser_set_prot_checks(iser_task->sc, &sig_attrs->check_mask); in iser_reg_sig_mr()
267 if (rsc->mr_valid) in iser_reg_sig_mr()
268 iser_inv_rkey(&tx_desc->inv_wr, mr, cqe, &wr->wr); in iser_reg_sig_mr()
270 ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); in iser_reg_sig_mr()
272 ret = ib_map_mr_sg_pi(mr, mem->sg, mem->dma_nents, NULL, in iser_reg_sig_mr()
273 sig_mem->sg, sig_mem->dma_nents, NULL, SZ_4K); in iser_reg_sig_mr()
276 mem->dma_nents + sig_mem->dma_nents); in iser_reg_sig_mr()
281 wr->wr.next = &tx_desc->send_wr; in iser_reg_sig_mr()
282 wr->wr.opcode = IB_WR_REG_MR_INTEGRITY; in iser_reg_sig_mr()
283 wr->wr.wr_cqe = cqe; in iser_reg_sig_mr()
284 wr->wr.num_sge = 0; in iser_reg_sig_mr()
285 wr->wr.send_flags = 0; in iser_reg_sig_mr()
286 wr->mr = mr; in iser_reg_sig_mr()
287 wr->key = mr->rkey; in iser_reg_sig_mr()
288 wr->access = IB_ACCESS_LOCAL_WRITE | in iser_reg_sig_mr()
291 rsc->mr_valid = 1; in iser_reg_sig_mr()
293 sig_reg->sge.lkey = mr->lkey; in iser_reg_sig_mr()
294 sig_reg->rkey = mr->rkey; in iser_reg_sig_mr()
295 sig_reg->sge.addr = mr->iova; in iser_reg_sig_mr()
296 sig_reg->sge.length = mr->length; in iser_reg_sig_mr()
299 sig_reg->sge.lkey, sig_reg->rkey, sig_reg->sge.addr, in iser_reg_sig_mr()
300 sig_reg->sge.length); in iser_reg_sig_mr()
310 struct iser_tx_desc *tx_desc = &iser_task->desc; in iser_fast_reg_mr()
311 struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; in iser_fast_reg_mr()
312 struct ib_mr *mr = rsc->mr; in iser_fast_reg_mr()
313 struct ib_reg_wr *wr = &tx_desc->reg_wr; in iser_fast_reg_mr()
316 if (rsc->mr_valid) in iser_fast_reg_mr()
317 iser_inv_rkey(&tx_desc->inv_wr, mr, cqe, &wr->wr); in iser_fast_reg_mr()
319 ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); in iser_fast_reg_mr()
321 n = ib_map_mr_sg(mr, mem->sg, mem->dma_nents, NULL, SZ_4K); in iser_fast_reg_mr()
322 if (unlikely(n != mem->dma_nents)) { in iser_fast_reg_mr()
324 n, mem->dma_nents); in iser_fast_reg_mr()
325 return n < 0 ? n : -EINVAL; in iser_fast_reg_mr()
328 wr->wr.next = &tx_desc->send_wr; in iser_fast_reg_mr()
329 wr->wr.opcode = IB_WR_REG_MR; in iser_fast_reg_mr()
330 wr->wr.wr_cqe = cqe; in iser_fast_reg_mr()
331 wr->wr.send_flags = 0; in iser_fast_reg_mr()
332 wr->wr.num_sge = 0; in iser_fast_reg_mr()
333 wr->mr = mr; in iser_fast_reg_mr()
334 wr->key = mr->rkey; in iser_fast_reg_mr()
335 wr->access = IB_ACCESS_LOCAL_WRITE | in iser_fast_reg_mr()
339 rsc->mr_valid = 1; in iser_fast_reg_mr()
341 reg->sge.lkey = mr->lkey; in iser_fast_reg_mr()
342 reg->rkey = mr->rkey; in iser_fast_reg_mr()
343 reg->sge.addr = mr->iova; in iser_fast_reg_mr()
344 reg->sge.length = mr->length; in iser_fast_reg_mr()
347 reg->sge.lkey, reg->rkey, reg->sge.addr, reg->sge.length); in iser_fast_reg_mr()
356 struct ib_conn *ib_conn = &task->iser_conn->ib_conn; in iser_reg_mem_fastreg()
357 struct iser_device *device = ib_conn->device; in iser_reg_mem_fastreg()
358 struct iser_data_buf *mem = &task->data[dir]; in iser_reg_mem_fastreg()
359 struct iser_mem_reg *reg = &task->rdma_reg[dir]; in iser_reg_mem_fastreg()
364 use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && in iser_reg_mem_fastreg()
365 scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; in iser_reg_mem_fastreg()
370 if (scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL) { in iser_reg_mem_fastreg()
371 err = iser_fast_reg_mr(task, mem, &desc->rsc, reg); in iser_reg_mem_fastreg()
375 err = iser_reg_sig_mr(task, mem, &task->prot[dir], in iser_reg_mem_fastreg()
376 &desc->rsc, reg); in iser_reg_mem_fastreg()
380 desc->sig_protected = true; in iser_reg_mem_fastreg()
383 reg->desc = desc; in iser_reg_mem_fastreg()