1 // SPDX-License-Identifier: GPL-2.0
3 * Shared Memory Communications over RDMA (SMC-R) and RoCE
5 * Work Requests exploiting Infiniband API
7 * Work requests (WR) of type ib_post_send or ib_post_recv respectively
8 * are submitted to either RC SQ or RC RQ respectively
9 * (reliably connected send/receive queue)
10 * and become work queue entries (WQEs).
11 * While an SQ WR/WQE is pending, we track it until transmission completion.
12 * Through a send or receive completion queue (CQ) respectively,
13 * we get completion queue entries (CQEs) [aka work completions (WCs)].
14 * Since the CQ callback is called from IRQ context, we split work by using
15 * bottom halves implemented by tasklets.
17 * SMC uses this to exchange LLC (link layer control)
18 * and CDC (connection data control) messages.
20 * Copyright IBM Corp. 2016
22 * Author(s): Steffen Maier <maier@linux.vnet.ibm.com>
25 #include <linux/atomic.h>
26 #include <linux/hashtable.h>
27 #include <linux/wait.h>
28 #include <rdma/ib_verbs.h>
29 #include <asm/div64.h>
34 #define SMC_WR_MAX_POLL_CQE 10 /* max. # of compl. queue elements in 1 poll */
36 #define SMC_WR_RX_HASH_BITS 4
37 static DEFINE_HASHTABLE(smc_wr_rx_hash
, SMC_WR_RX_HASH_BITS
);
38 static DEFINE_SPINLOCK(smc_wr_rx_hash_lock
);
40 struct smc_wr_tx_pend
{ /* control data for a pending send request */
41 u64 wr_id
; /* work request id sent */
42 smc_wr_tx_handler handler
;
43 enum ib_wc_status wc_status
; /* CQE status */
44 struct smc_link
*link
;
46 struct smc_wr_tx_pend_priv priv
;
49 /******************************** send queue *********************************/
51 /*------------------------------- completion --------------------------------*/
53 static inline int smc_wr_tx_find_pending_index(struct smc_link
*link
, u64 wr_id
)
57 for (i
= 0; i
< link
->wr_tx_cnt
; i
++) {
58 if (link
->wr_tx_pends
[i
].wr_id
== wr_id
)
61 return link
->wr_tx_cnt
;
64 static inline void smc_wr_tx_process_cqe(struct ib_wc
*wc
)
66 struct smc_wr_tx_pend pnd_snd
;
67 struct smc_link
*link
;
71 link
= wc
->qp
->qp_context
;
73 if (wc
->opcode
== IB_WC_REG_MR
) {
75 link
->wr_reg_state
= FAILED
;
77 link
->wr_reg_state
= CONFIRMED
;
78 wake_up(&link
->wr_reg_wait
);
82 pnd_snd_idx
= smc_wr_tx_find_pending_index(link
, wc
->wr_id
);
83 if (pnd_snd_idx
== link
->wr_tx_cnt
)
85 link
->wr_tx_pends
[pnd_snd_idx
].wc_status
= wc
->status
;
86 memcpy(&pnd_snd
, &link
->wr_tx_pends
[pnd_snd_idx
], sizeof(pnd_snd
));
87 /* clear the full struct smc_wr_tx_pend including .priv */
88 memset(&link
->wr_tx_pends
[pnd_snd_idx
], 0,
89 sizeof(link
->wr_tx_pends
[pnd_snd_idx
]));
90 memset(&link
->wr_tx_bufs
[pnd_snd_idx
], 0,
91 sizeof(link
->wr_tx_bufs
[pnd_snd_idx
]));
92 if (!test_and_clear_bit(pnd_snd_idx
, link
->wr_tx_mask
))
95 struct smc_link_group
*lgr
;
97 for_each_set_bit(i
, link
->wr_tx_mask
, link
->wr_tx_cnt
) {
98 /* clear full struct smc_wr_tx_pend including .priv */
99 memset(&link
->wr_tx_pends
[i
], 0,
100 sizeof(link
->wr_tx_pends
[i
]));
101 memset(&link
->wr_tx_bufs
[i
], 0,
102 sizeof(link
->wr_tx_bufs
[i
]));
103 clear_bit(i
, link
->wr_tx_mask
);
105 /* terminate connections of this link group abnormally */
106 lgr
= container_of(link
, struct smc_link_group
,
107 lnk
[SMC_SINGLE_LINK
]);
108 smc_lgr_terminate(lgr
);
111 pnd_snd
.handler(&pnd_snd
.priv
, link
, wc
->status
);
112 wake_up(&link
->wr_tx_wait
);
115 static void smc_wr_tx_tasklet_fn(unsigned long data
)
117 struct smc_ib_device
*dev
= (struct smc_ib_device
*)data
;
118 struct ib_wc wc
[SMC_WR_MAX_POLL_CQE
];
125 rc
= ib_poll_cq(dev
->roce_cq_send
, SMC_WR_MAX_POLL_CQE
, wc
);
127 ib_req_notify_cq(dev
->roce_cq_send
,
129 IB_CQ_REPORT_MISSED_EVENTS
);
133 for (i
= 0; i
< rc
; i
++)
134 smc_wr_tx_process_cqe(&wc
[i
]);
140 void smc_wr_tx_cq_handler(struct ib_cq
*ib_cq
, void *cq_context
)
142 struct smc_ib_device
*dev
= (struct smc_ib_device
*)cq_context
;
144 tasklet_schedule(&dev
->send_tasklet
);
147 /*---------------------------- request submission ---------------------------*/
149 static inline int smc_wr_tx_get_free_slot_index(struct smc_link
*link
, u32
*idx
)
151 *idx
= link
->wr_tx_cnt
;
152 for_each_clear_bit(*idx
, link
->wr_tx_mask
, link
->wr_tx_cnt
) {
153 if (!test_and_set_bit(*idx
, link
->wr_tx_mask
))
156 *idx
= link
->wr_tx_cnt
;
161 * smc_wr_tx_get_free_slot() - returns buffer for message assembly,
162 * and sets info for pending transmit tracking
163 * @link: Pointer to smc_link used to later send the message.
164 * @handler: Send completion handler function pointer.
165 * @wr_buf: Out value returns pointer to message buffer.
166 * @wr_pend_priv: Out value returns pointer serving as handler context.
168 * Return: 0 on success, or -errno on error.
170 int smc_wr_tx_get_free_slot(struct smc_link
*link
,
171 smc_wr_tx_handler handler
,
172 struct smc_wr_buf
**wr_buf
,
173 struct smc_wr_tx_pend_priv
**wr_pend_priv
)
175 struct smc_wr_tx_pend
*wr_pend
;
176 struct ib_send_wr
*wr_ib
;
182 *wr_pend_priv
= NULL
;
184 rc
= smc_wr_tx_get_free_slot_index(link
, &idx
);
188 rc
= wait_event_interruptible_timeout(
190 (smc_wr_tx_get_free_slot_index(link
, &idx
) != -EBUSY
),
191 SMC_WR_TX_WAIT_FREE_SLOT_TIME
);
193 /* timeout - terminate connections */
194 struct smc_link_group
*lgr
;
196 lgr
= container_of(link
, struct smc_link_group
,
197 lnk
[SMC_SINGLE_LINK
]);
198 smc_lgr_terminate(lgr
);
201 if (rc
== -ERESTARTSYS
)
203 if (idx
== link
->wr_tx_cnt
)
206 wr_id
= smc_wr_tx_get_next_wr_id(link
);
207 wr_pend
= &link
->wr_tx_pends
[idx
];
208 wr_pend
->wr_id
= wr_id
;
209 wr_pend
->handler
= handler
;
210 wr_pend
->link
= link
;
212 wr_ib
= &link
->wr_tx_ibs
[idx
];
213 wr_ib
->wr_id
= wr_id
;
214 *wr_buf
= &link
->wr_tx_bufs
[idx
];
215 *wr_pend_priv
= &wr_pend
->priv
;
219 int smc_wr_tx_put_slot(struct smc_link
*link
,
220 struct smc_wr_tx_pend_priv
*wr_pend_priv
)
222 struct smc_wr_tx_pend
*pend
;
224 pend
= container_of(wr_pend_priv
, struct smc_wr_tx_pend
, priv
);
225 if (pend
->idx
< link
->wr_tx_cnt
) {
226 /* clear the full struct smc_wr_tx_pend including .priv */
227 memset(&link
->wr_tx_pends
[pend
->idx
], 0,
228 sizeof(link
->wr_tx_pends
[pend
->idx
]));
229 memset(&link
->wr_tx_bufs
[pend
->idx
], 0,
230 sizeof(link
->wr_tx_bufs
[pend
->idx
]));
231 test_and_clear_bit(pend
->idx
, link
->wr_tx_mask
);
238 /* Send prepared WR slot via ib_post_send.
239 * @priv: pointer to smc_wr_tx_pend_priv identifying prepared message buffer
241 int smc_wr_tx_send(struct smc_link
*link
, struct smc_wr_tx_pend_priv
*priv
)
243 struct ib_send_wr
*failed_wr
= NULL
;
244 struct smc_wr_tx_pend
*pend
;
247 ib_req_notify_cq(link
->smcibdev
->roce_cq_send
,
248 IB_CQ_NEXT_COMP
| IB_CQ_REPORT_MISSED_EVENTS
);
249 pend
= container_of(priv
, struct smc_wr_tx_pend
, priv
);
250 rc
= ib_post_send(link
->roce_qp
, &link
->wr_tx_ibs
[pend
->idx
],
253 smc_wr_tx_put_slot(link
, priv
);
257 /* Register a memory region and wait for result. */
258 int smc_wr_reg_send(struct smc_link
*link
, struct ib_mr
*mr
)
260 struct ib_send_wr
*failed_wr
= NULL
;
263 ib_req_notify_cq(link
->smcibdev
->roce_cq_send
,
264 IB_CQ_NEXT_COMP
| IB_CQ_REPORT_MISSED_EVENTS
);
265 link
->wr_reg_state
= POSTED
;
266 link
->wr_reg
.wr
.wr_id
= (u64
)(uintptr_t)mr
;
267 link
->wr_reg
.mr
= mr
;
268 link
->wr_reg
.key
= mr
->rkey
;
269 failed_wr
= &link
->wr_reg
.wr
;
270 rc
= ib_post_send(link
->roce_qp
, &link
->wr_reg
.wr
, &failed_wr
);
271 WARN_ON(failed_wr
!= &link
->wr_reg
.wr
);
275 rc
= wait_event_interruptible_timeout(link
->wr_reg_wait
,
276 (link
->wr_reg_state
!= POSTED
),
277 SMC_WR_REG_MR_WAIT_TIME
);
279 /* timeout - terminate connections */
280 struct smc_link_group
*lgr
;
282 lgr
= container_of(link
, struct smc_link_group
,
283 lnk
[SMC_SINGLE_LINK
]);
284 smc_lgr_terminate(lgr
);
287 if (rc
== -ERESTARTSYS
)
289 switch (link
->wr_reg_state
) {
303 void smc_wr_tx_dismiss_slots(struct smc_link
*link
, u8 wr_rx_hdr_type
,
304 smc_wr_tx_filter filter
,
305 smc_wr_tx_dismisser dismisser
,
308 struct smc_wr_tx_pend_priv
*tx_pend
;
309 struct smc_wr_rx_hdr
*wr_rx
;
312 for_each_set_bit(i
, link
->wr_tx_mask
, link
->wr_tx_cnt
) {
313 wr_rx
= (struct smc_wr_rx_hdr
*)&link
->wr_rx_bufs
[i
];
314 if (wr_rx
->type
!= wr_rx_hdr_type
)
316 tx_pend
= &link
->wr_tx_pends
[i
].priv
;
317 if (filter(tx_pend
, data
))
322 bool smc_wr_tx_has_pending(struct smc_link
*link
, u8 wr_rx_hdr_type
,
323 smc_wr_tx_filter filter
, unsigned long data
)
325 struct smc_wr_tx_pend_priv
*tx_pend
;
326 struct smc_wr_rx_hdr
*wr_rx
;
329 for_each_set_bit(i
, link
->wr_tx_mask
, link
->wr_tx_cnt
) {
330 wr_rx
= (struct smc_wr_rx_hdr
*)&link
->wr_rx_bufs
[i
];
331 if (wr_rx
->type
!= wr_rx_hdr_type
)
333 tx_pend
= &link
->wr_tx_pends
[i
].priv
;
334 if (filter(tx_pend
, data
))
340 /****************************** receive queue ********************************/
342 int smc_wr_rx_register_handler(struct smc_wr_rx_handler
*handler
)
344 struct smc_wr_rx_handler
*h_iter
;
347 spin_lock(&smc_wr_rx_hash_lock
);
348 hash_for_each_possible(smc_wr_rx_hash
, h_iter
, list
, handler
->type
) {
349 if (h_iter
->type
== handler
->type
) {
354 hash_add(smc_wr_rx_hash
, &handler
->list
, handler
->type
);
356 spin_unlock(&smc_wr_rx_hash_lock
);
360 /* Demultiplex a received work request based on the message type to its handler.
361 * Relies on smc_wr_rx_hash having been completely filled before any IB WRs,
362 * and not being modified any more afterwards so we don't need to lock it.
364 static inline void smc_wr_rx_demultiplex(struct ib_wc
*wc
)
366 struct smc_link
*link
= (struct smc_link
*)wc
->qp
->qp_context
;
367 struct smc_wr_rx_handler
*handler
;
368 struct smc_wr_rx_hdr
*wr_rx
;
372 if (wc
->byte_len
< sizeof(*wr_rx
))
373 return; /* short message */
374 temp_wr_id
= wc
->wr_id
;
375 index
= do_div(temp_wr_id
, link
->wr_rx_cnt
);
376 wr_rx
= (struct smc_wr_rx_hdr
*)&link
->wr_rx_bufs
[index
];
377 hash_for_each_possible(smc_wr_rx_hash
, handler
, list
, wr_rx
->type
) {
378 if (handler
->type
== wr_rx
->type
)
379 handler
->handler(wc
, wr_rx
);
383 static inline void smc_wr_rx_process_cqes(struct ib_wc wc
[], int num
)
385 struct smc_link
*link
;
388 for (i
= 0; i
< num
; i
++) {
389 link
= wc
[i
].qp
->qp_context
;
390 if (wc
[i
].status
== IB_WC_SUCCESS
) {
391 smc_wr_rx_demultiplex(&wc
[i
]);
392 smc_wr_rx_post(link
); /* refill WR RX */
394 struct smc_link_group
*lgr
;
396 /* handle status errors */
397 switch (wc
[i
].status
) {
398 case IB_WC_RETRY_EXC_ERR
:
399 case IB_WC_RNR_RETRY_EXC_ERR
:
400 case IB_WC_WR_FLUSH_ERR
:
401 /* terminate connections of this link group
404 lgr
= container_of(link
, struct smc_link_group
,
405 lnk
[SMC_SINGLE_LINK
]);
406 smc_lgr_terminate(lgr
);
409 smc_wr_rx_post(link
); /* refill WR RX */
416 static void smc_wr_rx_tasklet_fn(unsigned long data
)
418 struct smc_ib_device
*dev
= (struct smc_ib_device
*)data
;
419 struct ib_wc wc
[SMC_WR_MAX_POLL_CQE
];
426 memset(&wc
, 0, sizeof(wc
));
427 rc
= ib_poll_cq(dev
->roce_cq_recv
, SMC_WR_MAX_POLL_CQE
, wc
);
429 ib_req_notify_cq(dev
->roce_cq_recv
,
431 | IB_CQ_REPORT_MISSED_EVENTS
);
435 smc_wr_rx_process_cqes(&wc
[0], rc
);
441 void smc_wr_rx_cq_handler(struct ib_cq
*ib_cq
, void *cq_context
)
443 struct smc_ib_device
*dev
= (struct smc_ib_device
*)cq_context
;
445 tasklet_schedule(&dev
->recv_tasklet
);
448 int smc_wr_rx_post_init(struct smc_link
*link
)
453 for (i
= 0; i
< link
->wr_rx_cnt
; i
++)
454 rc
= smc_wr_rx_post(link
);
458 /***************************** init, exit, misc ******************************/
460 void smc_wr_remember_qp_attr(struct smc_link
*lnk
)
462 struct ib_qp_attr
*attr
= &lnk
->qp_attr
;
463 struct ib_qp_init_attr init_attr
;
465 memset(attr
, 0, sizeof(*attr
));
466 memset(&init_attr
, 0, sizeof(init_attr
));
467 ib_query_qp(lnk
->roce_qp
, attr
,
480 IB_QP_MIN_RNR_TIMER
|
482 IB_QP_PATH_MIG_STATE
|
487 lnk
->wr_tx_cnt
= min_t(size_t, SMC_WR_BUF_CNT
,
488 lnk
->qp_attr
.cap
.max_send_wr
);
489 lnk
->wr_rx_cnt
= min_t(size_t, SMC_WR_BUF_CNT
* 3,
490 lnk
->qp_attr
.cap
.max_recv_wr
);
493 static void smc_wr_init_sge(struct smc_link
*lnk
)
497 for (i
= 0; i
< lnk
->wr_tx_cnt
; i
++) {
498 lnk
->wr_tx_sges
[i
].addr
=
499 lnk
->wr_tx_dma_addr
+ i
* SMC_WR_BUF_SIZE
;
500 lnk
->wr_tx_sges
[i
].length
= SMC_WR_TX_SIZE
;
501 lnk
->wr_tx_sges
[i
].lkey
= lnk
->roce_pd
->local_dma_lkey
;
502 lnk
->wr_tx_ibs
[i
].next
= NULL
;
503 lnk
->wr_tx_ibs
[i
].sg_list
= &lnk
->wr_tx_sges
[i
];
504 lnk
->wr_tx_ibs
[i
].num_sge
= 1;
505 lnk
->wr_tx_ibs
[i
].opcode
= IB_WR_SEND
;
506 lnk
->wr_tx_ibs
[i
].send_flags
=
507 IB_SEND_SIGNALED
| IB_SEND_SOLICITED
;
509 for (i
= 0; i
< lnk
->wr_rx_cnt
; i
++) {
510 lnk
->wr_rx_sges
[i
].addr
=
511 lnk
->wr_rx_dma_addr
+ i
* SMC_WR_BUF_SIZE
;
512 lnk
->wr_rx_sges
[i
].length
= SMC_WR_BUF_SIZE
;
513 lnk
->wr_rx_sges
[i
].lkey
= lnk
->roce_pd
->local_dma_lkey
;
514 lnk
->wr_rx_ibs
[i
].next
= NULL
;
515 lnk
->wr_rx_ibs
[i
].sg_list
= &lnk
->wr_rx_sges
[i
];
516 lnk
->wr_rx_ibs
[i
].num_sge
= 1;
518 lnk
->wr_reg
.wr
.next
= NULL
;
519 lnk
->wr_reg
.wr
.num_sge
= 0;
520 lnk
->wr_reg
.wr
.send_flags
= IB_SEND_SIGNALED
;
521 lnk
->wr_reg
.wr
.opcode
= IB_WR_REG_MR
;
522 lnk
->wr_reg
.access
= IB_ACCESS_LOCAL_WRITE
| IB_ACCESS_REMOTE_WRITE
;
525 void smc_wr_free_link(struct smc_link
*lnk
)
527 struct ib_device
*ibdev
;
529 memset(lnk
->wr_tx_mask
, 0,
530 BITS_TO_LONGS(SMC_WR_BUF_CNT
) * sizeof(*lnk
->wr_tx_mask
));
534 ibdev
= lnk
->smcibdev
->ibdev
;
536 if (lnk
->wr_rx_dma_addr
) {
537 ib_dma_unmap_single(ibdev
, lnk
->wr_rx_dma_addr
,
538 SMC_WR_BUF_SIZE
* lnk
->wr_rx_cnt
,
540 lnk
->wr_rx_dma_addr
= 0;
542 if (lnk
->wr_tx_dma_addr
) {
543 ib_dma_unmap_single(ibdev
, lnk
->wr_tx_dma_addr
,
544 SMC_WR_BUF_SIZE
* lnk
->wr_tx_cnt
,
546 lnk
->wr_tx_dma_addr
= 0;
550 void smc_wr_free_link_mem(struct smc_link
*lnk
)
552 kfree(lnk
->wr_tx_pends
);
553 lnk
->wr_tx_pends
= NULL
;
554 kfree(lnk
->wr_tx_mask
);
555 lnk
->wr_tx_mask
= NULL
;
556 kfree(lnk
->wr_tx_sges
);
557 lnk
->wr_tx_sges
= NULL
;
558 kfree(lnk
->wr_rx_sges
);
559 lnk
->wr_rx_sges
= NULL
;
560 kfree(lnk
->wr_rx_ibs
);
561 lnk
->wr_rx_ibs
= NULL
;
562 kfree(lnk
->wr_tx_ibs
);
563 lnk
->wr_tx_ibs
= NULL
;
564 kfree(lnk
->wr_tx_bufs
);
565 lnk
->wr_tx_bufs
= NULL
;
566 kfree(lnk
->wr_rx_bufs
);
567 lnk
->wr_rx_bufs
= NULL
;
570 int smc_wr_alloc_link_mem(struct smc_link
*link
)
572 /* allocate link related memory */
573 link
->wr_tx_bufs
= kcalloc(SMC_WR_BUF_CNT
, SMC_WR_BUF_SIZE
, GFP_KERNEL
);
574 if (!link
->wr_tx_bufs
)
576 link
->wr_rx_bufs
= kcalloc(SMC_WR_BUF_CNT
* 3, SMC_WR_BUF_SIZE
,
578 if (!link
->wr_rx_bufs
)
579 goto no_mem_wr_tx_bufs
;
580 link
->wr_tx_ibs
= kcalloc(SMC_WR_BUF_CNT
, sizeof(link
->wr_tx_ibs
[0]),
582 if (!link
->wr_tx_ibs
)
583 goto no_mem_wr_rx_bufs
;
584 link
->wr_rx_ibs
= kcalloc(SMC_WR_BUF_CNT
* 3,
585 sizeof(link
->wr_rx_ibs
[0]),
587 if (!link
->wr_rx_ibs
)
588 goto no_mem_wr_tx_ibs
;
589 link
->wr_tx_sges
= kcalloc(SMC_WR_BUF_CNT
, sizeof(link
->wr_tx_sges
[0]),
591 if (!link
->wr_tx_sges
)
592 goto no_mem_wr_rx_ibs
;
593 link
->wr_rx_sges
= kcalloc(SMC_WR_BUF_CNT
* 3,
594 sizeof(link
->wr_rx_sges
[0]),
596 if (!link
->wr_rx_sges
)
597 goto no_mem_wr_tx_sges
;
598 link
->wr_tx_mask
= kzalloc(
599 BITS_TO_LONGS(SMC_WR_BUF_CNT
) * sizeof(*link
->wr_tx_mask
),
601 if (!link
->wr_tx_mask
)
602 goto no_mem_wr_rx_sges
;
603 link
->wr_tx_pends
= kcalloc(SMC_WR_BUF_CNT
,
604 sizeof(link
->wr_tx_pends
[0]),
606 if (!link
->wr_tx_pends
)
607 goto no_mem_wr_tx_mask
;
611 kfree(link
->wr_tx_mask
);
613 kfree(link
->wr_rx_sges
);
615 kfree(link
->wr_tx_sges
);
617 kfree(link
->wr_rx_ibs
);
619 kfree(link
->wr_tx_ibs
);
621 kfree(link
->wr_rx_bufs
);
623 kfree(link
->wr_tx_bufs
);
628 void smc_wr_remove_dev(struct smc_ib_device
*smcibdev
)
630 tasklet_kill(&smcibdev
->recv_tasklet
);
631 tasklet_kill(&smcibdev
->send_tasklet
);
634 void smc_wr_add_dev(struct smc_ib_device
*smcibdev
)
636 tasklet_init(&smcibdev
->recv_tasklet
, smc_wr_rx_tasklet_fn
,
637 (unsigned long)smcibdev
);
638 tasklet_init(&smcibdev
->send_tasklet
, smc_wr_tx_tasklet_fn
,
639 (unsigned long)smcibdev
);
642 int smc_wr_create_link(struct smc_link
*lnk
)
644 struct ib_device
*ibdev
= lnk
->smcibdev
->ibdev
;
647 smc_wr_tx_set_wr_id(&lnk
->wr_tx_id
, 0);
649 lnk
->wr_rx_dma_addr
= ib_dma_map_single(
650 ibdev
, lnk
->wr_rx_bufs
, SMC_WR_BUF_SIZE
* lnk
->wr_rx_cnt
,
652 if (ib_dma_mapping_error(ibdev
, lnk
->wr_rx_dma_addr
)) {
653 lnk
->wr_rx_dma_addr
= 0;
657 lnk
->wr_tx_dma_addr
= ib_dma_map_single(
658 ibdev
, lnk
->wr_tx_bufs
, SMC_WR_BUF_SIZE
* lnk
->wr_tx_cnt
,
660 if (ib_dma_mapping_error(ibdev
, lnk
->wr_tx_dma_addr
)) {
664 smc_wr_init_sge(lnk
);
665 memset(lnk
->wr_tx_mask
, 0,
666 BITS_TO_LONGS(SMC_WR_BUF_CNT
) * sizeof(*lnk
->wr_tx_mask
));
667 init_waitqueue_head(&lnk
->wr_tx_wait
);
668 init_waitqueue_head(&lnk
->wr_reg_wait
);
672 ib_dma_unmap_single(ibdev
, lnk
->wr_rx_dma_addr
,
673 SMC_WR_BUF_SIZE
* lnk
->wr_rx_cnt
,
675 lnk
->wr_rx_dma_addr
= 0;