• Home
  • Raw
  • Download

Lines Matching full:link

17  * SMC uses this to exchange LLC (link layer control)
44 struct smc_link *link; member
54 /* returns true if at least one tx work request is pending on the given link */
55 static inline bool smc_wr_is_tx_pend(struct smc_link *link) in smc_wr_is_tx_pend() argument
57 if (find_first_bit(link->wr_tx_mask, link->wr_tx_cnt) != in smc_wr_is_tx_pend()
58 link->wr_tx_cnt) { in smc_wr_is_tx_pend()
64 /* wait till all pending tx work requests on the given link are completed */
65 void smc_wr_tx_wait_no_pending_sends(struct smc_link *link) in smc_wr_tx_wait_no_pending_sends() argument
67 wait_event(link->wr_tx_wait, !smc_wr_is_tx_pend(link)); in smc_wr_tx_wait_no_pending_sends()
70 static inline int smc_wr_tx_find_pending_index(struct smc_link *link, u64 wr_id) in smc_wr_tx_find_pending_index() argument
74 for (i = 0; i < link->wr_tx_cnt; i++) { in smc_wr_tx_find_pending_index()
75 if (link->wr_tx_pends[i].wr_id == wr_id) in smc_wr_tx_find_pending_index()
78 return link->wr_tx_cnt; in smc_wr_tx_find_pending_index()
84 struct smc_link *link; in smc_wr_tx_process_cqe() local
87 link = wc->qp->qp_context; in smc_wr_tx_process_cqe()
91 link->wr_reg_state = FAILED; in smc_wr_tx_process_cqe()
93 link->wr_reg_state = CONFIRMED; in smc_wr_tx_process_cqe()
94 smc_wr_wakeup_reg_wait(link); in smc_wr_tx_process_cqe()
98 pnd_snd_idx = smc_wr_tx_find_pending_index(link, wc->wr_id); in smc_wr_tx_process_cqe()
99 if (pnd_snd_idx == link->wr_tx_cnt) in smc_wr_tx_process_cqe()
101 link->wr_tx_pends[pnd_snd_idx].wc_status = wc->status; in smc_wr_tx_process_cqe()
102 if (link->wr_tx_pends[pnd_snd_idx].compl_requested) in smc_wr_tx_process_cqe()
103 complete(&link->wr_tx_compl[pnd_snd_idx]); in smc_wr_tx_process_cqe()
104 memcpy(&pnd_snd, &link->wr_tx_pends[pnd_snd_idx], sizeof(pnd_snd)); in smc_wr_tx_process_cqe()
106 memset(&link->wr_tx_pends[pnd_snd_idx], 0, in smc_wr_tx_process_cqe()
107 sizeof(link->wr_tx_pends[pnd_snd_idx])); in smc_wr_tx_process_cqe()
108 memset(&link->wr_tx_bufs[pnd_snd_idx], 0, in smc_wr_tx_process_cqe()
109 sizeof(link->wr_tx_bufs[pnd_snd_idx])); in smc_wr_tx_process_cqe()
110 if (!test_and_clear_bit(pnd_snd_idx, link->wr_tx_mask)) in smc_wr_tx_process_cqe()
113 /* terminate link */ in smc_wr_tx_process_cqe()
114 smcr_link_down_cond_sched(link); in smc_wr_tx_process_cqe()
117 pnd_snd.handler(&pnd_snd.priv, link, wc->status); in smc_wr_tx_process_cqe()
118 wake_up(&link->wr_tx_wait); in smc_wr_tx_process_cqe()
156 static inline int smc_wr_tx_get_free_slot_index(struct smc_link *link, u32 *idx) in smc_wr_tx_get_free_slot_index() argument
158 *idx = link->wr_tx_cnt; in smc_wr_tx_get_free_slot_index()
159 if (!smc_link_sendable(link)) in smc_wr_tx_get_free_slot_index()
161 for_each_clear_bit(*idx, link->wr_tx_mask, link->wr_tx_cnt) { in smc_wr_tx_get_free_slot_index()
162 if (!test_and_set_bit(*idx, link->wr_tx_mask)) in smc_wr_tx_get_free_slot_index()
165 *idx = link->wr_tx_cnt; in smc_wr_tx_get_free_slot_index()
172 * @link: Pointer to smc_link used to later send the message.
180 int smc_wr_tx_get_free_slot(struct smc_link *link, in smc_wr_tx_get_free_slot() argument
186 struct smc_link_group *lgr = smc_get_lgr(link); in smc_wr_tx_get_free_slot()
188 u32 idx = link->wr_tx_cnt; in smc_wr_tx_get_free_slot()
196 rc = smc_wr_tx_get_free_slot_index(link, &idx); in smc_wr_tx_get_free_slot()
201 link->wr_tx_wait, in smc_wr_tx_get_free_slot()
202 !smc_link_sendable(link) || in smc_wr_tx_get_free_slot()
204 (smc_wr_tx_get_free_slot_index(link, &idx) != -EBUSY), in smc_wr_tx_get_free_slot()
207 /* timeout - terminate link */ in smc_wr_tx_get_free_slot()
208 smcr_link_down_cond_sched(link); in smc_wr_tx_get_free_slot()
211 if (idx == link->wr_tx_cnt) in smc_wr_tx_get_free_slot()
214 wr_id = smc_wr_tx_get_next_wr_id(link); in smc_wr_tx_get_free_slot()
215 wr_pend = &link->wr_tx_pends[idx]; in smc_wr_tx_get_free_slot()
218 wr_pend->link = link; in smc_wr_tx_get_free_slot()
220 wr_ib = &link->wr_tx_ibs[idx]; in smc_wr_tx_get_free_slot()
222 *wr_buf = &link->wr_tx_bufs[idx]; in smc_wr_tx_get_free_slot()
224 *wr_rdma_buf = &link->wr_tx_rdmas[idx]; in smc_wr_tx_get_free_slot()
229 int smc_wr_tx_put_slot(struct smc_link *link, in smc_wr_tx_put_slot() argument
235 if (pend->idx < link->wr_tx_cnt) { in smc_wr_tx_put_slot()
239 memset(&link->wr_tx_pends[idx], 0, in smc_wr_tx_put_slot()
240 sizeof(link->wr_tx_pends[idx])); in smc_wr_tx_put_slot()
241 memset(&link->wr_tx_bufs[idx], 0, in smc_wr_tx_put_slot()
242 sizeof(link->wr_tx_bufs[idx])); in smc_wr_tx_put_slot()
243 test_and_clear_bit(idx, link->wr_tx_mask); in smc_wr_tx_put_slot()
244 wake_up(&link->wr_tx_wait); in smc_wr_tx_put_slot()
254 int smc_wr_tx_send(struct smc_link *link, struct smc_wr_tx_pend_priv *priv) in smc_wr_tx_send() argument
259 ib_req_notify_cq(link->smcibdev->roce_cq_send, in smc_wr_tx_send()
262 rc = ib_post_send(link->roce_qp, &link->wr_tx_ibs[pend->idx], NULL); in smc_wr_tx_send()
264 smc_wr_tx_put_slot(link, priv); in smc_wr_tx_send()
265 smcr_link_down_cond_sched(link); in smc_wr_tx_send()
274 int smc_wr_tx_send_wait(struct smc_link *link, struct smc_wr_tx_pend_priv *priv, in smc_wr_tx_send_wait() argument
284 init_completion(&link->wr_tx_compl[pnd_idx]); in smc_wr_tx_send_wait()
286 rc = smc_wr_tx_send(link, priv); in smc_wr_tx_send_wait()
291 &link->wr_tx_compl[pnd_idx], timeout); in smc_wr_tx_send_wait()
300 int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr) in smc_wr_reg_send() argument
304 ib_req_notify_cq(link->smcibdev->roce_cq_send, in smc_wr_reg_send()
306 link->wr_reg_state = POSTED; in smc_wr_reg_send()
307 link->wr_reg.wr.wr_id = (u64)(uintptr_t)mr; in smc_wr_reg_send()
308 link->wr_reg.mr = mr; in smc_wr_reg_send()
309 link->wr_reg.key = mr->rkey; in smc_wr_reg_send()
310 rc = ib_post_send(link->roce_qp, &link->wr_reg.wr, NULL); in smc_wr_reg_send()
314 atomic_inc(&link->wr_reg_refcnt); in smc_wr_reg_send()
315 rc = wait_event_interruptible_timeout(link->wr_reg_wait, in smc_wr_reg_send()
316 (link->wr_reg_state != POSTED), in smc_wr_reg_send()
318 if (atomic_dec_and_test(&link->wr_reg_refcnt)) in smc_wr_reg_send()
319 wake_up_all(&link->wr_reg_wait); in smc_wr_reg_send()
321 /* timeout - terminate link */ in smc_wr_reg_send()
322 smcr_link_down_cond_sched(link); in smc_wr_reg_send()
327 switch (link->wr_reg_state) { in smc_wr_reg_send()
367 struct smc_link *link = (struct smc_link *)wc->qp->qp_context; in smc_wr_rx_demultiplex() local
376 index = do_div(temp_wr_id, link->wr_rx_cnt); in smc_wr_rx_demultiplex()
377 wr_rx = (struct smc_wr_rx_hdr *)&link->wr_rx_bufs[index]; in smc_wr_rx_demultiplex()
386 struct smc_link *link; in smc_wr_rx_process_cqes() local
390 link = wc[i].qp->qp_context; in smc_wr_rx_process_cqes()
392 link->wr_rx_tstamp = jiffies; in smc_wr_rx_process_cqes()
394 smc_wr_rx_post(link); /* refill WR RX */ in smc_wr_rx_process_cqes()
401 smcr_link_down_cond_sched(link); in smc_wr_rx_process_cqes()
404 smc_wr_rx_post(link); /* refill WR RX */ in smc_wr_rx_process_cqes()
443 int smc_wr_rx_post_init(struct smc_link *link) in smc_wr_rx_post_init() argument
448 for (i = 0; i < link->wr_rx_cnt; i++) in smc_wr_rx_post_init()
449 rc = smc_wr_rx_post(link); in smc_wr_rx_post_init()
589 int smc_wr_alloc_link_mem(struct smc_link *link) in smc_wr_alloc_link_mem() argument
591 /* allocate link related memory */ in smc_wr_alloc_link_mem()
592 link->wr_tx_bufs = kcalloc(SMC_WR_BUF_CNT, SMC_WR_BUF_SIZE, GFP_KERNEL); in smc_wr_alloc_link_mem()
593 if (!link->wr_tx_bufs) in smc_wr_alloc_link_mem()
595 link->wr_rx_bufs = kcalloc(SMC_WR_BUF_CNT * 3, SMC_WR_BUF_SIZE, in smc_wr_alloc_link_mem()
597 if (!link->wr_rx_bufs) in smc_wr_alloc_link_mem()
599 link->wr_tx_ibs = kcalloc(SMC_WR_BUF_CNT, sizeof(link->wr_tx_ibs[0]), in smc_wr_alloc_link_mem()
601 if (!link->wr_tx_ibs) in smc_wr_alloc_link_mem()
603 link->wr_rx_ibs = kcalloc(SMC_WR_BUF_CNT * 3, in smc_wr_alloc_link_mem()
604 sizeof(link->wr_rx_ibs[0]), in smc_wr_alloc_link_mem()
606 if (!link->wr_rx_ibs) in smc_wr_alloc_link_mem()
608 link->wr_tx_rdmas = kcalloc(SMC_WR_BUF_CNT, in smc_wr_alloc_link_mem()
609 sizeof(link->wr_tx_rdmas[0]), in smc_wr_alloc_link_mem()
611 if (!link->wr_tx_rdmas) in smc_wr_alloc_link_mem()
613 link->wr_tx_rdma_sges = kcalloc(SMC_WR_BUF_CNT, in smc_wr_alloc_link_mem()
614 sizeof(link->wr_tx_rdma_sges[0]), in smc_wr_alloc_link_mem()
616 if (!link->wr_tx_rdma_sges) in smc_wr_alloc_link_mem()
618 link->wr_tx_sges = kcalloc(SMC_WR_BUF_CNT, sizeof(link->wr_tx_sges[0]), in smc_wr_alloc_link_mem()
620 if (!link->wr_tx_sges) in smc_wr_alloc_link_mem()
622 link->wr_rx_sges = kcalloc(SMC_WR_BUF_CNT * 3, in smc_wr_alloc_link_mem()
623 sizeof(link->wr_rx_sges[0]), in smc_wr_alloc_link_mem()
625 if (!link->wr_rx_sges) in smc_wr_alloc_link_mem()
627 link->wr_tx_mask = kcalloc(BITS_TO_LONGS(SMC_WR_BUF_CNT), in smc_wr_alloc_link_mem()
628 sizeof(*link->wr_tx_mask), in smc_wr_alloc_link_mem()
630 if (!link->wr_tx_mask) in smc_wr_alloc_link_mem()
632 link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT, in smc_wr_alloc_link_mem()
633 sizeof(link->wr_tx_pends[0]), in smc_wr_alloc_link_mem()
635 if (!link->wr_tx_pends) in smc_wr_alloc_link_mem()
637 link->wr_tx_compl = kcalloc(SMC_WR_BUF_CNT, in smc_wr_alloc_link_mem()
638 sizeof(link->wr_tx_compl[0]), in smc_wr_alloc_link_mem()
640 if (!link->wr_tx_compl) in smc_wr_alloc_link_mem()
645 kfree(link->wr_tx_pends); in smc_wr_alloc_link_mem()
647 kfree(link->wr_tx_mask); in smc_wr_alloc_link_mem()
649 kfree(link->wr_rx_sges); in smc_wr_alloc_link_mem()
651 kfree(link->wr_tx_sges); in smc_wr_alloc_link_mem()
653 kfree(link->wr_tx_rdma_sges); in smc_wr_alloc_link_mem()
655 kfree(link->wr_tx_rdmas); in smc_wr_alloc_link_mem()
657 kfree(link->wr_rx_ibs); in smc_wr_alloc_link_mem()
659 kfree(link->wr_tx_ibs); in smc_wr_alloc_link_mem()
661 kfree(link->wr_rx_bufs); in smc_wr_alloc_link_mem()
663 kfree(link->wr_tx_bufs); in smc_wr_alloc_link_mem()