Lines Matching +full:software +full:- +full:locked

4  * This software is available to you under a choice of one of two
14 * - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
43 return MLX5_CAP_GEN(dev->mdev, set_deth_sqpn); in mlx5_ib_deth_sqpn_cap()
46 /* Call with gsi->lock locked */
49 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in generate_completions()
50 struct ib_cq *gsi_cq = mqp->ibqp.send_cq; in generate_completions()
54 for (index = gsi->outstanding_ci; index != gsi->outstanding_pi; in generate_completions()
56 wr = &gsi->outstanding_wrs[index % gsi->cap.max_send_wr]; in generate_completions()
58 if (!wr->completed) in generate_completions()
61 WARN_ON_ONCE(mlx5_ib_generate_wc(gsi_cq, &wr->wc)); in generate_completions()
62 wr->completed = false; in generate_completions()
65 gsi->outstanding_ci = index; in generate_completions()
70 struct mlx5_ib_gsi_qp *gsi = cq->cq_context; in handle_single_completion()
72 container_of(wc->wr_cqe, struct mlx5_ib_gsi_wr, cqe); in handle_single_completion()
77 spin_lock_irqsave(&gsi->lock, flags); in handle_single_completion()
78 wr->completed = true; in handle_single_completion()
79 wr_id = wr->wc.wr_id; in handle_single_completion()
80 wr->wc = *wc; in handle_single_completion()
81 wr->wc.wr_id = wr_id; in handle_single_completion()
82 wr->wc.qp = &mqp->ibqp; in handle_single_completion()
85 spin_unlock_irqrestore(&gsi->lock, flags); in handle_single_completion()
91 struct mlx5_ib_dev *dev = to_mdev(pd->device); in mlx5_ib_create_gsi()
94 const u8 port_num = attr->port_num; in mlx5_ib_create_gsi()
99 if (MLX5_CAP_GEN(dev->mdev, in mlx5_ib_create_gsi()
101 num_qps = pd->device->attrs.max_pkeys; in mlx5_ib_create_gsi()
102 else if (dev->lag_active) in mlx5_ib_create_gsi()
103 num_qps = dev->lag_ports; in mlx5_ib_create_gsi()
106 gsi = &mqp->gsi; in mlx5_ib_create_gsi()
107 gsi->tx_qps = kcalloc(num_qps, sizeof(*gsi->tx_qps), GFP_KERNEL); in mlx5_ib_create_gsi()
108 if (!gsi->tx_qps) in mlx5_ib_create_gsi()
109 return -ENOMEM; in mlx5_ib_create_gsi()
111 gsi->outstanding_wrs = in mlx5_ib_create_gsi()
112 kcalloc(attr->cap.max_send_wr, sizeof(*gsi->outstanding_wrs), in mlx5_ib_create_gsi()
114 if (!gsi->outstanding_wrs) { in mlx5_ib_create_gsi()
115 ret = -ENOMEM; in mlx5_ib_create_gsi()
119 if (dev->devr.ports[port_num - 1].gsi) { in mlx5_ib_create_gsi()
122 ret = -EBUSY; in mlx5_ib_create_gsi()
125 gsi->num_qps = num_qps; in mlx5_ib_create_gsi()
126 spin_lock_init(&gsi->lock); in mlx5_ib_create_gsi()
128 gsi->cap = attr->cap; in mlx5_ib_create_gsi()
129 gsi->port_num = port_num; in mlx5_ib_create_gsi()
131 gsi->cq = ib_alloc_cq(pd->device, gsi, attr->cap.max_send_wr, 0, in mlx5_ib_create_gsi()
133 if (IS_ERR(gsi->cq)) { in mlx5_ib_create_gsi()
135 PTR_ERR(gsi->cq)); in mlx5_ib_create_gsi()
136 ret = PTR_ERR(gsi->cq); in mlx5_ib_create_gsi()
141 hw_init_attr.send_cq = gsi->cq; in mlx5_ib_create_gsi()
148 gsi->rx_qp = ib_create_qp(pd, &hw_init_attr); in mlx5_ib_create_gsi()
149 if (IS_ERR(gsi->rx_qp)) { in mlx5_ib_create_gsi()
151 PTR_ERR(gsi->rx_qp)); in mlx5_ib_create_gsi()
152 ret = PTR_ERR(gsi->rx_qp); in mlx5_ib_create_gsi()
156 dev->devr.ports[attr->port_num - 1].gsi = gsi; in mlx5_ib_create_gsi()
160 ib_free_cq(gsi->cq); in mlx5_ib_create_gsi()
162 kfree(gsi->outstanding_wrs); in mlx5_ib_create_gsi()
164 kfree(gsi->tx_qps); in mlx5_ib_create_gsi()
170 struct mlx5_ib_dev *dev = to_mdev(mqp->ibqp.device); in mlx5_ib_destroy_gsi()
171 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_destroy_gsi()
172 const int port_num = gsi->port_num; in mlx5_ib_destroy_gsi()
176 ret = ib_destroy_qp(gsi->rx_qp); in mlx5_ib_destroy_gsi()
182 dev->devr.ports[port_num - 1].gsi = NULL; in mlx5_ib_destroy_gsi()
183 gsi->rx_qp = NULL; in mlx5_ib_destroy_gsi()
185 for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) { in mlx5_ib_destroy_gsi()
186 if (!gsi->tx_qps[qp_index]) in mlx5_ib_destroy_gsi()
188 WARN_ON_ONCE(ib_destroy_qp(gsi->tx_qps[qp_index])); in mlx5_ib_destroy_gsi()
189 gsi->tx_qps[qp_index] = NULL; in mlx5_ib_destroy_gsi()
192 ib_free_cq(gsi->cq); in mlx5_ib_destroy_gsi()
194 kfree(gsi->outstanding_wrs); in mlx5_ib_destroy_gsi()
195 kfree(gsi->tx_qps); in mlx5_ib_destroy_gsi()
201 struct ib_pd *pd = gsi->rx_qp->pd; in create_gsi_ud_qp()
203 .event_handler = gsi->rx_qp->event_handler, in create_gsi_ud_qp()
204 .qp_context = gsi->rx_qp->qp_context, in create_gsi_ud_qp()
205 .send_cq = gsi->cq, in create_gsi_ud_qp()
206 .recv_cq = gsi->rx_qp->recv_cq, in create_gsi_ud_qp()
208 .max_send_wr = gsi->cap.max_send_wr, in create_gsi_ud_qp()
209 .max_send_sge = gsi->cap.max_send_sge, in create_gsi_ud_qp()
210 .max_inline_data = gsi->cap.max_inline_data, in create_gsi_ud_qp()
222 struct mlx5_ib_dev *dev = to_mdev(qp->device); in modify_to_rts()
231 attr.port_num = gsi->port_num; in modify_to_rts()
235 qp->qp_num, ret); in modify_to_rts()
243 qp->qp_num, ret); in modify_to_rts()
252 qp->qp_num, ret); in modify_to_rts()
261 struct ib_device *device = gsi->rx_qp->device; in setup_qp()
270 if (MLX5_CAP_GEN(dev->mdev, port_type) != MLX5_CAP_PORT_TYPE_IB) in setup_qp()
273 ret = ib_query_pkey(device, gsi->port_num, pkey_index, &pkey); in setup_qp()
276 gsi->port_num, qp_index); in setup_qp()
282 gsi->port_num, qp_index); in setup_qp()
286 spin_lock_irqsave(&gsi->lock, flags); in setup_qp()
287 qp = gsi->tx_qps[qp_index]; in setup_qp()
288 spin_unlock_irqrestore(&gsi->lock, flags); in setup_qp()
291 gsi->port_num, qp_index); in setup_qp()
303 if (dev->lag_active) in setup_qp()
304 mqp->gsi_lag_port = qp_index + 1; in setup_qp()
309 spin_lock_irqsave(&gsi->lock, flags); in setup_qp()
310 WARN_ON_ONCE(gsi->tx_qps[qp_index]); in setup_qp()
311 gsi->tx_qps[qp_index] = qp; in setup_qp()
312 spin_unlock_irqrestore(&gsi->lock, flags); in setup_qp()
323 struct mlx5_ib_dev *dev = to_mdev(qp->device); in mlx5_ib_gsi_modify_qp()
325 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_gsi_modify_qp()
329 mlx5_ib_dbg(dev, "modifying GSI QP to state %d\n", attr->qp_state); in mlx5_ib_gsi_modify_qp()
331 ret = ib_modify_qp(gsi->rx_qp, attr, attr_mask); in mlx5_ib_gsi_modify_qp()
337 if (to_mqp(gsi->rx_qp)->state != IB_QPS_RTS) in mlx5_ib_gsi_modify_qp()
340 for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) in mlx5_ib_gsi_modify_qp()
350 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_gsi_query_qp()
353 ret = ib_query_qp(gsi->rx_qp, qp_attr, qp_attr_mask, qp_init_attr); in mlx5_ib_gsi_query_qp()
354 qp_init_attr->cap = gsi->cap; in mlx5_ib_gsi_query_qp()
358 /* Call with gsi->lock locked */
362 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_add_outstanding_wr()
363 struct mlx5_ib_dev *dev = to_mdev(gsi->rx_qp->device); in mlx5_ib_add_outstanding_wr()
366 if (gsi->outstanding_pi == gsi->outstanding_ci + gsi->cap.max_send_wr) { in mlx5_ib_add_outstanding_wr()
368 return -ENOMEM; in mlx5_ib_add_outstanding_wr()
371 gsi_wr = &gsi->outstanding_wrs[gsi->outstanding_pi % in mlx5_ib_add_outstanding_wr()
372 gsi->cap.max_send_wr]; in mlx5_ib_add_outstanding_wr()
373 gsi->outstanding_pi++; in mlx5_ib_add_outstanding_wr()
376 memset(&gsi_wr->wc, 0, sizeof(gsi_wr->wc)); in mlx5_ib_add_outstanding_wr()
377 gsi_wr->wc.pkey_index = wr->pkey_index; in mlx5_ib_add_outstanding_wr()
378 gsi_wr->wc.wr_id = wr->wr.wr_id; in mlx5_ib_add_outstanding_wr()
380 gsi_wr->wc = *wc; in mlx5_ib_add_outstanding_wr()
381 gsi_wr->completed = true; in mlx5_ib_add_outstanding_wr()
384 gsi_wr->cqe.done = &handle_single_completion; in mlx5_ib_add_outstanding_wr()
385 wr->wr.wr_cqe = &gsi_wr->cqe; in mlx5_ib_add_outstanding_wr()
390 /* Call with gsi->lock locked */
394 { .wr_id = wr->wr.wr_id }, in mlx5_ib_gsi_silent_drop()
397 .qp = &mqp->ibqp, in mlx5_ib_gsi_silent_drop()
410 /* Call with gsi->lock locked */
413 struct mlx5_ib_dev *dev = to_mdev(gsi->rx_qp->device); in get_tx_qp()
414 struct mlx5_ib_ah *ah = to_mah(wr->ah); in get_tx_qp()
415 int qp_index = wr->pkey_index; in get_tx_qp()
417 if (!gsi->num_qps) in get_tx_qp()
418 return gsi->rx_qp; in get_tx_qp()
420 if (dev->lag_active && ah->xmit_port) in get_tx_qp()
421 qp_index = ah->xmit_port - 1; in get_tx_qp()
423 if (qp_index >= gsi->num_qps) in get_tx_qp()
426 return gsi->tx_qps[qp_index]; in get_tx_qp()
433 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_gsi_post_send()
438 for (; wr; wr = wr->next) { in mlx5_ib_gsi_post_send()
443 spin_lock_irqsave(&gsi->lock, flags); in mlx5_ib_gsi_post_send()
449 spin_unlock_irqrestore(&gsi->lock, flags); in mlx5_ib_gsi_post_send()
460 gsi->outstanding_pi--; in mlx5_ib_gsi_post_send()
463 spin_unlock_irqrestore(&gsi->lock, flags); in mlx5_ib_gsi_post_send()
469 spin_unlock_irqrestore(&gsi->lock, flags); in mlx5_ib_gsi_post_send()
478 struct mlx5_ib_gsi_qp *gsi = &mqp->gsi; in mlx5_ib_gsi_post_recv()
480 return ib_post_recv(gsi->rx_qp, wr, bad_wr); in mlx5_ib_gsi_post_recv()
487 for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) in mlx5_ib_gsi_pkey_change()