Lines Matching +full:rx +full:- +full:eq

1 // SPDX-License-Identifier: GPL-2.0-only
27 return -ENOMEM; in mana_ib_cfg_vport_steering()
29 mana_gd_init_req_hdr(&req->hdr, MANA_CONFIG_VPORT_RX, req_buf_size, in mana_ib_cfg_vport_steering()
32 req->hdr.req.msg_version = GDMA_MESSAGE_V2; in mana_ib_cfg_vport_steering()
34 req->vport = mpc->port_handle; in mana_ib_cfg_vport_steering()
35 req->rx_enable = 1; in mana_ib_cfg_vport_steering()
36 req->update_default_rxobj = 1; in mana_ib_cfg_vport_steering()
37 req->default_rxobj = default_rxobj; in mana_ib_cfg_vport_steering()
38 req->hdr.dev_id = gc->mana.dev_id; in mana_ib_cfg_vport_steering()
42 req->rss_enable = true; in mana_ib_cfg_vport_steering()
44 req->num_indir_entries = MANA_INDIRECT_TABLE_DEF_SIZE; in mana_ib_cfg_vport_steering()
45 req->indir_tab_offset = offsetof(struct mana_cfg_rx_steer_req_v2, in mana_ib_cfg_vport_steering()
47 req->update_indir_tab = true; in mana_ib_cfg_vport_steering()
48 req->cqe_coalescing_enable = 1; in mana_ib_cfg_vport_steering()
54 ibdev_dbg(&dev->ib_dev, "ind table size %u\n", 1 << log_ind_tbl_size); in mana_ib_cfg_vport_steering()
56 req->indir_tab[i] = ind_table[i % (1 << log_ind_tbl_size)]; in mana_ib_cfg_vport_steering()
57 ibdev_dbg(&dev->ib_dev, "index %u handle 0x%llx\n", i, in mana_ib_cfg_vport_steering()
58 req->indir_tab[i]); in mana_ib_cfg_vport_steering()
61 req->update_hashkey = true; in mana_ib_cfg_vport_steering()
63 memcpy(req->hashkey, rx_hash_key, rx_hash_key_len); in mana_ib_cfg_vport_steering()
65 netdev_rss_key_fill(req->hashkey, MANA_HASH_KEY_SIZE); in mana_ib_cfg_vport_steering()
67 ibdev_dbg(&dev->ib_dev, "vport handle %llu default_rxobj 0x%llx\n", in mana_ib_cfg_vport_steering()
68 req->vport, default_rxobj); in mana_ib_cfg_vport_steering()
72 netdev_err(ndev, "Failed to configure vPort RX: %d\n", err); in mana_ib_cfg_vport_steering()
77 netdev_err(ndev, "vPort RX configuration failed: 0x%x\n", in mana_ib_cfg_vport_steering()
79 err = -EPROTO; in mana_ib_cfg_vport_steering()
84 mpc->port_handle, log_ind_tbl_size); in mana_ib_cfg_vport_steering()
97 container_of(pd->device, struct mana_ib_dev, ib_dev); in mana_ib_create_qp_rss()
98 struct ib_rwq_ind_table *ind_tbl = attr->rwq_ind_tbl; in mana_ib_create_qp_rss()
107 struct mana_eq *eq; in mana_ib_create_qp_rss() local
114 if (!udata || udata->inlen < sizeof(ucmd)) in mana_ib_create_qp_rss()
115 return -EINVAL; in mana_ib_create_qp_rss()
117 ret = ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen)); in mana_ib_create_qp_rss()
119 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
120 "Failed copy from udata for create rss-qp, err %d\n", in mana_ib_create_qp_rss()
125 if (attr->cap.max_recv_wr > mdev->adapter_caps.max_qp_wr) { in mana_ib_create_qp_rss()
126 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
128 attr->cap.max_recv_wr); in mana_ib_create_qp_rss()
129 return -EINVAL; in mana_ib_create_qp_rss()
132 if (attr->cap.max_recv_sge > MAX_RX_WQE_SGL_ENTRIES) { in mana_ib_create_qp_rss()
133 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
135 attr->cap.max_recv_sge); in mana_ib_create_qp_rss()
136 return -EINVAL; in mana_ib_create_qp_rss()
139 ind_tbl_size = 1 << ind_tbl->log_ind_tbl_size; in mana_ib_create_qp_rss()
141 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
144 return -EINVAL; in mana_ib_create_qp_rss()
148 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
149 "RX Hash function is not supported, %d\n", in mana_ib_create_qp_rss()
151 return -EINVAL; in mana_ib_create_qp_rss()
156 ndev = mana_ib_get_netdev(pd->device, port); in mana_ib_create_qp_rss()
158 ibdev_dbg(&mdev->ib_dev, "Invalid port %u in creating qp\n", in mana_ib_create_qp_rss()
160 return -EINVAL; in mana_ib_create_qp_rss()
164 ibdev_dbg(&mdev->ib_dev, "rx_hash_function %d port %d\n", in mana_ib_create_qp_rss()
170 ret = -ENOMEM; in mana_ib_create_qp_rss()
174 qp->port = port; in mana_ib_create_qp_rss()
180 ibwq = ind_tbl->ind_tbl[i]; in mana_ib_create_qp_rss()
183 ibcq = ibwq->cq; in mana_ib_create_qp_rss()
186 wq_spec.gdma_region = wq->queue.gdma_region; in mana_ib_create_qp_rss()
187 wq_spec.queue_size = wq->wq_buf_size; in mana_ib_create_qp_rss()
189 cq_spec.gdma_region = cq->queue.gdma_region; in mana_ib_create_qp_rss()
190 cq_spec.queue_size = cq->cqe * COMP_ENTRY_SIZE; in mana_ib_create_qp_rss()
192 eq = &mpc->ac->eqs[cq->comp_vector]; in mana_ib_create_qp_rss()
193 cq_spec.attached_eq = eq->eq->id; in mana_ib_create_qp_rss()
195 ret = mana_create_wq_obj(mpc, mpc->port_handle, GDMA_RQ, in mana_ib_create_qp_rss()
196 &wq_spec, &cq_spec, &wq->rx_object); in mana_ib_create_qp_rss()
198 /* Do cleanup starting with index i-1 */ in mana_ib_create_qp_rss()
199 i--; in mana_ib_create_qp_rss()
204 wq->queue.gdma_region = GDMA_INVALID_DMA_REGION; in mana_ib_create_qp_rss()
205 cq->queue.gdma_region = GDMA_INVALID_DMA_REGION; in mana_ib_create_qp_rss()
207 wq->queue.id = wq_spec.queue_index; in mana_ib_create_qp_rss()
208 cq->queue.id = cq_spec.queue_index; in mana_ib_create_qp_rss()
210 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
212 wq->rx_object, wq->queue.id, cq->queue.id); in mana_ib_create_qp_rss()
214 resp.entries[i].cqid = cq->queue.id; in mana_ib_create_qp_rss()
215 resp.entries[i].wqid = wq->queue.id; in mana_ib_create_qp_rss()
217 mana_ind_table[i] = wq->rx_object; in mana_ib_create_qp_rss()
226 ret = mana_ib_cfg_vport_steering(mdev, ndev, wq->rx_object, in mana_ib_create_qp_rss()
228 ind_tbl->log_ind_tbl_size, in mana_ib_create_qp_rss()
236 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_rss()
237 "Failed to copy to udata create rss-qp, %d\n", in mana_ib_create_qp_rss()
247 while (i-- > 0) { in mana_ib_create_qp_rss()
248 ibwq = ind_tbl->ind_tbl[i]; in mana_ib_create_qp_rss()
249 ibcq = ibwq->cq; in mana_ib_create_qp_rss()
254 mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object); in mana_ib_create_qp_rss()
269 container_of(ibpd->device, struct mana_ib_dev, ib_dev); in mana_ib_create_qp_raw()
271 container_of(attr->send_cq, struct mana_ib_cq, ibcq); in mana_ib_create_qp_raw()
281 struct mana_eq *eq; in mana_ib_create_qp_raw() local
286 if (!mana_ucontext || udata->inlen < sizeof(ucmd)) in mana_ib_create_qp_raw()
287 return -EINVAL; in mana_ib_create_qp_raw()
289 err = ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen)); in mana_ib_create_qp_raw()
291 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
292 "Failed to copy from udata create qp-raw, %d\n", err); in mana_ib_create_qp_raw()
296 if (attr->cap.max_send_wr > mdev->adapter_caps.max_qp_wr) { in mana_ib_create_qp_raw()
297 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
299 attr->cap.max_send_wr); in mana_ib_create_qp_raw()
300 return -EINVAL; in mana_ib_create_qp_raw()
303 if (attr->cap.max_send_sge > MAX_TX_WQE_SGL_ENTRIES) { in mana_ib_create_qp_raw()
304 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
306 attr->cap.max_send_sge); in mana_ib_create_qp_raw()
307 return -EINVAL; in mana_ib_create_qp_raw()
311 ndev = mana_ib_get_netdev(ibpd->device, port); in mana_ib_create_qp_raw()
313 ibdev_dbg(&mdev->ib_dev, "Invalid port %u in creating qp\n", in mana_ib_create_qp_raw()
315 return -EINVAL; in mana_ib_create_qp_raw()
318 ibdev_dbg(&mdev->ib_dev, "port %u ndev %p mpc %p\n", port, ndev, mpc); in mana_ib_create_qp_raw()
320 err = mana_ib_cfg_vport(mdev, port, pd, mana_ucontext->doorbell); in mana_ib_create_qp_raw()
322 return -ENODEV; in mana_ib_create_qp_raw()
324 qp->port = port; in mana_ib_create_qp_raw()
326 ibdev_dbg(&mdev->ib_dev, "ucmd sq_buf_addr 0x%llx port %u\n", in mana_ib_create_qp_raw()
329 err = mana_ib_create_queue(mdev, ucmd.sq_buf_addr, ucmd.sq_buf_size, &qp->raw_sq); in mana_ib_create_qp_raw()
331 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
332 "Failed to create queue for create qp-raw, err %d\n", err); in mana_ib_create_qp_raw()
337 wq_spec.gdma_region = qp->raw_sq.gdma_region; in mana_ib_create_qp_raw()
340 cq_spec.gdma_region = send_cq->queue.gdma_region; in mana_ib_create_qp_raw()
341 cq_spec.queue_size = send_cq->cqe * COMP_ENTRY_SIZE; in mana_ib_create_qp_raw()
343 eq_vec = send_cq->comp_vector; in mana_ib_create_qp_raw()
344 eq = &mpc->ac->eqs[eq_vec]; in mana_ib_create_qp_raw()
345 cq_spec.attached_eq = eq->eq->id; in mana_ib_create_qp_raw()
347 err = mana_create_wq_obj(mpc, mpc->port_handle, GDMA_SQ, &wq_spec, in mana_ib_create_qp_raw()
348 &cq_spec, &qp->qp_handle); in mana_ib_create_qp_raw()
350 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
351 "Failed to create wq for create raw-qp, err %d\n", in mana_ib_create_qp_raw()
357 qp->raw_sq.gdma_region = GDMA_INVALID_DMA_REGION; in mana_ib_create_qp_raw()
358 send_cq->queue.gdma_region = GDMA_INVALID_DMA_REGION; in mana_ib_create_qp_raw()
360 qp->raw_sq.id = wq_spec.queue_index; in mana_ib_create_qp_raw()
361 send_cq->queue.id = cq_spec.queue_index; in mana_ib_create_qp_raw()
368 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
369 "qp->qp_handle 0x%llx sq id %llu cq id %llu\n", in mana_ib_create_qp_raw()
370 qp->qp_handle, qp->raw_sq.id, send_cq->queue.id); in mana_ib_create_qp_raw()
372 resp.sqid = qp->raw_sq.id; in mana_ib_create_qp_raw()
373 resp.cqid = send_cq->queue.id; in mana_ib_create_qp_raw()
374 resp.tx_vp_offset = pd->tx_vp_offset; in mana_ib_create_qp_raw()
378 ibdev_dbg(&mdev->ib_dev, in mana_ib_create_qp_raw()
379 "Failed copy udata for create qp-raw, %d\n", in mana_ib_create_qp_raw()
390 mana_destroy_wq_obj(mpc, GDMA_SQ, qp->qp_handle); in mana_ib_create_qp_raw()
393 mana_ib_destroy_queue(mdev, &qp->raw_sq); in mana_ib_create_qp_raw()
403 refcount_set(&qp->refcount, 1); in mana_table_store_qp()
404 init_completion(&qp->free); in mana_table_store_qp()
405 return xa_insert_irq(&mdev->qp_table_wq, qp->ibqp.qp_num, qp, in mana_table_store_qp()
412 xa_erase_irq(&mdev->qp_table_wq, qp->ibqp.qp_num); in mana_table_remove_qp()
414 wait_for_completion(&qp->free); in mana_table_remove_qp()
420 struct mana_ib_dev *mdev = container_of(ibpd->device, struct mana_ib_dev, ib_dev); in mana_ib_create_rc_qp()
429 if (!udata || udata->inlen < sizeof(ucmd)) in mana_ib_create_rc_qp()
430 return -EINVAL; in mana_ib_create_rc_qp()
433 doorbell = mana_ucontext->doorbell; in mana_ib_create_rc_qp()
435 err = ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen)); in mana_ib_create_rc_qp()
437 ibdev_dbg(&mdev->ib_dev, "Failed to copy from udata, %d\n", err); in mana_ib_create_rc_qp()
442 /* skip FMR for user-level RC QPs */ in mana_ib_create_rc_qp()
444 qp->rc_qp.queues[i].id = INVALID_QUEUE_ID; in mana_ib_create_rc_qp()
445 qp->rc_qp.queues[i].gdma_region = GDMA_INVALID_DMA_REGION; in mana_ib_create_rc_qp()
449 &qp->rc_qp.queues[i]); in mana_ib_create_rc_qp()
451 ibdev_err(&mdev->ib_dev, "Failed to create queue %d, err %d\n", i, err); in mana_ib_create_rc_qp()
459 ibdev_err(&mdev->ib_dev, "Failed to create rc qp %d\n", err); in mana_ib_create_rc_qp()
462 qp->ibqp.qp_num = qp->rc_qp.queues[MANA_RC_RECV_QUEUE_RESPONDER].id; in mana_ib_create_rc_qp()
463 qp->port = attr->port_num; in mana_ib_create_rc_qp()
469 resp.queue_id[j] = qp->rc_qp.queues[i].id; in mana_ib_create_rc_qp()
472 err = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen)); in mana_ib_create_rc_qp()
474 ibdev_dbg(&mdev->ib_dev, "Failed to copy to udata, %d\n", err); in mana_ib_create_rc_qp()
488 while (i-- > 0) in mana_ib_create_rc_qp()
489 mana_ib_destroy_queue(mdev, &qp->rc_qp.queues[i]); in mana_ib_create_rc_qp()
496 switch (attr->qp_type) { in mana_ib_create_qp()
499 if (attr->rwq_ind_tbl) in mana_ib_create_qp()
500 return mana_ib_create_qp_rss(ibqp, ibqp->pd, attr, in mana_ib_create_qp()
503 return mana_ib_create_qp_raw(ibqp, ibqp->pd, attr, udata); in mana_ib_create_qp()
505 return mana_ib_create_rc_qp(ibqp, ibqp->pd, attr, udata); in mana_ib_create_qp()
507 ibdev_dbg(ibqp->device, "Creating QP type %u not supported\n", in mana_ib_create_qp()
508 attr->qp_type); in mana_ib_create_qp()
511 return -EINVAL; in mana_ib_create_qp()
517 struct mana_ib_dev *mdev = container_of(ibqp->device, struct mana_ib_dev, ib_dev); in mana_ib_gd_modify_qp()
527 req.hdr.dev_id = gc->mana_ib.dev_id; in mana_ib_gd_modify_qp()
528 req.adapter = mdev->adapter_handle; in mana_ib_gd_modify_qp()
529 req.qp_handle = qp->qp_handle; in mana_ib_gd_modify_qp()
530 req.qp_state = attr->qp_state; in mana_ib_gd_modify_qp()
532 req.path_mtu = attr->path_mtu; in mana_ib_gd_modify_qp()
533 req.rq_psn = attr->rq_psn; in mana_ib_gd_modify_qp()
534 req.sq_psn = attr->sq_psn; in mana_ib_gd_modify_qp()
535 req.dest_qpn = attr->dest_qp_num; in mana_ib_gd_modify_qp()
536 req.max_dest_rd_atomic = attr->max_dest_rd_atomic; in mana_ib_gd_modify_qp()
537 req.retry_cnt = attr->retry_cnt; in mana_ib_gd_modify_qp()
538 req.rnr_retry = attr->rnr_retry; in mana_ib_gd_modify_qp()
539 req.min_rnr_timer = attr->min_rnr_timer; in mana_ib_gd_modify_qp()
541 ndev = mana_ib_get_netdev(&mdev->ib_dev, ibqp->port); in mana_ib_gd_modify_qp()
543 ibdev_dbg(&mdev->ib_dev, "Invalid port %u in QP %u\n", in mana_ib_gd_modify_qp()
544 ibqp->port, ibqp->qp_num); in mana_ib_gd_modify_qp()
545 return -EINVAL; in mana_ib_gd_modify_qp()
548 copy_in_reverse(req.ah_attr.src_mac, mpc->mac_addr, ETH_ALEN); in mana_ib_gd_modify_qp()
549 copy_in_reverse(req.ah_attr.dest_mac, attr->ah_attr.roce.dmac, ETH_ALEN); in mana_ib_gd_modify_qp()
550 copy_in_reverse(req.ah_attr.src_addr, attr->ah_attr.grh.sgid_attr->gid.raw, in mana_ib_gd_modify_qp()
552 copy_in_reverse(req.ah_attr.dest_addr, attr->ah_attr.grh.dgid.raw, in mana_ib_gd_modify_qp()
554 if (rdma_gid_attr_network_type(attr->ah_attr.grh.sgid_attr) == RDMA_NETWORK_IPV4) { in mana_ib_gd_modify_qp()
562 req.ah_attr.src_port = rdma_get_udp_sport(attr->ah_attr.grh.flow_label, in mana_ib_gd_modify_qp()
563 ibqp->qp_num, attr->dest_qp_num); in mana_ib_gd_modify_qp()
564 req.ah_attr.traffic_class = attr->ah_attr.grh.traffic_class; in mana_ib_gd_modify_qp()
565 req.ah_attr.hop_limit = attr->ah_attr.grh.hop_limit; in mana_ib_gd_modify_qp()
570 ibdev_err(&mdev->ib_dev, "Failed modify qp err %d", err); in mana_ib_gd_modify_qp()
580 switch (ibqp->qp_type) { in mana_ib_modify_qp()
584 ibdev_dbg(ibqp->device, "Modify QP type %u not supported", ibqp->qp_type); in mana_ib_modify_qp()
585 return -EOPNOTSUPP; in mana_ib_modify_qp()
594 container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); in mana_ib_destroy_qp_rss()
601 ndev = mana_ib_get_netdev(qp->ibqp.device, qp->port); in mana_ib_destroy_qp_rss()
604 for (i = 0; i < (1 << ind_tbl->log_ind_tbl_size); i++) { in mana_ib_destroy_qp_rss()
605 ibwq = ind_tbl->ind_tbl[i]; in mana_ib_destroy_qp_rss()
607 ibdev_dbg(&mdev->ib_dev, "destroying wq->rx_object %llu\n", in mana_ib_destroy_qp_rss()
608 wq->rx_object); in mana_ib_destroy_qp_rss()
609 mana_destroy_wq_obj(mpc, GDMA_RQ, wq->rx_object); in mana_ib_destroy_qp_rss()
618 container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); in mana_ib_destroy_qp_raw()
619 struct ib_pd *ibpd = qp->ibqp.pd; in mana_ib_destroy_qp_raw()
624 ndev = mana_ib_get_netdev(qp->ibqp.device, qp->port); in mana_ib_destroy_qp_raw()
628 mana_destroy_wq_obj(mpc, GDMA_SQ, qp->qp_handle); in mana_ib_destroy_qp_raw()
630 mana_ib_destroy_queue(mdev, &qp->raw_sq); in mana_ib_destroy_qp_raw()
632 mana_ib_uncfg_vport(mdev, pd, qp->port); in mana_ib_destroy_qp_raw()
640 container_of(qp->ibqp.device, struct mana_ib_dev, ib_dev); in mana_ib_destroy_rc_qp()
650 mana_ib_destroy_queue(mdev, &qp->rc_qp.queues[i]); in mana_ib_destroy_rc_qp()
659 switch (ibqp->qp_type) { in mana_ib_destroy_qp()
661 if (ibqp->rwq_ind_tbl) in mana_ib_destroy_qp()
662 return mana_ib_destroy_qp_rss(qp, ibqp->rwq_ind_tbl, in mana_ib_destroy_qp()
669 ibdev_dbg(ibqp->device, "Unexpected QP type %u\n", in mana_ib_destroy_qp()
670 ibqp->qp_type); in mana_ib_destroy_qp()
673 return -ENOENT; in mana_ib_destroy_qp()