Lines Matching defs:hwc

46 mana_hwc_get_msg_index(struct hw_channel_context *hwc, uint16_t *msg_id)
48 struct gdma_resource *r = &hwc->inflight_msg_res;
51 sema_wait(&hwc->sema);
55 index = find_first_zero_bit(hwc->inflight_msg_res.map,
56 hwc->inflight_msg_res.size);
58 bitmap_set(hwc->inflight_msg_res.map, index, 1);
68 mana_hwc_put_msg_index(struct hw_channel_context *hwc, uint16_t msg_id)
70 struct gdma_resource *r = &hwc->inflight_msg_res;
73 bitmap_clear(hwc->inflight_msg_res.map, msg_id, 1);
76 sema_post(&hwc->sema);
94 mana_hwc_handle_resp(struct hw_channel_context *hwc, uint32_t resp_len,
101 hwc->inflight_msg_res.map)) {
102 device_printf(hwc->dev, "hwc_rx: invalid msg_id = %u\n",
107 ctx = hwc->caller_ctx + resp_msg->response.hwc_msg_id;
124 device_t dev = hwc_rxq->hwc->dev;
149 struct hw_channel_context *hwc = ctx;
150 struct gdma_dev *gd = hwc->gdma_dev;
158 hwc->cq->gdma_eq->id = eq_db.eq_id;
169 hwc->cq->gdma_cq->id = val;
173 hwc->rxq->gdma_wq->id = val;
177 hwc->txq->gdma_wq->id = val;
181 hwc->hwc_init_q_depth_max = (uint16_t)val;
185 hwc->hwc_init_max_req_msg_size = val;
189 hwc->hwc_init_max_resp_msg_size = val;
197 hwc->gdma_dev->pdid = val;
201 hwc->rxq->msg_buf->gpa_mkey = val;
202 hwc->txq->msg_buf->gpa_mkey = val;
209 complete(&hwc->hwc_init_eqe_comp);
222 struct hw_channel_context *hwc = ctx;
223 struct hwc_wq *hwc_rxq = hwc->rxq;
251 rx_req_idx = (sge->address - rq_base_addr) / hwc->max_req_msg_size;
260 if (resp->response.hwc_msg_id >= hwc->num_inflight_msg) {
261 device_printf(hwc->dev, "HWC RX: wrong msg_id=%u\n",
266 mana_hwc_handle_resp(hwc, rx_oob->tx_oob_data_size, resp);
284 struct hw_channel_context *hwc = ctx;
285 struct hwc_wq *hwc_txq = hwc->txq;
298 mana_hwc_create_gdma_wq(struct hw_channel_context *hwc,
311 return mana_gd_create_hwc_queue(hwc->gdma_dev, &spec, queue);
315 mana_hwc_create_gdma_cq(struct hw_channel_context *hwc,
330 return mana_gd_create_hwc_queue(hwc->gdma_dev, &spec, queue);
334 mana_hwc_create_gdma_eq(struct hw_channel_context *hwc,
348 return mana_gd_create_hwc_queue(hwc->gdma_dev, &spec, queue);
397 mana_hwc_create_cq(struct hw_channel_context *hwc,
420 err = mana_hwc_create_gdma_eq(hwc, eq_size, ctx, callback, &eq);
422 device_printf(hwc->dev,
428 err = mana_hwc_create_gdma_cq(hwc, cq_size, hwc_cq,
431 device_printf(hwc->dev,
440 hwc_cq->hwc = hwc;
451 mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc_cq);
456 mana_hwc_alloc_dma_buf(struct hw_channel_context *hwc, uint16_t q_depth,
460 struct gdma_context *gc = hwc->gdma_dev->gdma_context;
481 device_printf(hwc->dev,
506 mana_hwc_dealloc_dma_buf(struct hw_channel_context *hwc,
518 mana_hwc_destroy_wq(struct hw_channel_context *hwc,
521 mana_hwc_dealloc_dma_buf(hwc, hwc_wq->msg_buf);
524 mana_gd_destroy_queue(hwc->gdma_dev->gdma_context,
531 mana_hwc_create_wq(struct hw_channel_context *hwc,
556 err = mana_hwc_create_gdma_wq(hwc, q_type, queue_size, &queue);
560 hwc_wq->hwc = hwc;
565 err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size,
574 mana_hwc_destroy_wq(hwc, hwc_wq);
584 device_t dev = hwc_txq->hwc->dev;
626 mana_hwc_init_inflight_msg(struct hw_channel_context *hwc, uint16_t num_msg)
630 sema_init(&hwc->sema, num_msg, "gdma hwc sema");
632 err = mana_gd_alloc_res_map(num_msg, &hwc->inflight_msg_res,
633 "gdma hwc res lock");
635 device_printf(hwc->dev,
642 mana_hwc_test_channel(struct hw_channel_context *hwc, uint16_t q_depth,
645 struct gdma_context *gc = hwc->gdma_dev->gdma_context;
646 struct hwc_wq *hwc_rxq = hwc->rxq;
666 hwc->caller_ctx = ctx;
668 return mana_gd_test_eq(gc, hwc->cq->gdma_eq);
676 struct hw_channel_context *hwc = gc->hwc.driver_data;
677 struct gdma_queue *rq = hwc->rxq->gdma_wq;
678 struct gdma_queue *sq = hwc->txq->gdma_wq;
679 struct gdma_queue *eq = hwc->cq->gdma_eq;
680 struct gdma_queue *cq = hwc->cq->gdma_cq;
683 init_completion(&hwc->hwc_init_eqe_comp);
694 if (wait_for_completion_timeout(&hwc->hwc_init_eqe_comp, 60 * hz))
697 *q_depth = hwc->hwc_init_q_depth_max;
698 *max_req_msg_size = hwc->hwc_init_max_req_msg_size;
699 *max_resp_msg_size = hwc->hwc_init_max_resp_msg_size;
716 mana_hwc_init_queues(struct hw_channel_context *hwc, uint16_t q_depth,
721 err = mana_hwc_init_inflight_msg(hwc, q_depth);
728 err = mana_hwc_create_cq(hwc, q_depth * 2,
729 mana_hwc_init_event_handler, hwc,
730 mana_hwc_rx_event_handler, hwc,
731 mana_hwc_tx_event_handler, hwc, &hwc->cq);
733 device_printf(hwc->dev, "Failed to create HWC CQ: %d\n", err);
737 err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_req_msg_size,
738 hwc->cq, &hwc->rxq);
740 device_printf(hwc->dev, "Failed to create HWC RQ: %d\n", err);
744 err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_resp_msg_size,
745 hwc->cq, &hwc->txq);
747 device_printf(hwc->dev, "Failed to create HWC SQ: %d\n", err);
751 hwc->num_inflight_msg = q_depth;
752 hwc->max_req_msg_size = max_req_msg_size;
764 struct gdma_dev *gd = &gc->hwc;
765 struct hw_channel_context *hwc;
769 hwc = malloc(sizeof(*hwc), M_DEVBUF, M_WAITOK | M_ZERO);
772 gd->driver_data = hwc;
773 hwc->gdma_dev = gd;
774 hwc->dev = gc->dev;
787 err = mana_hwc_init_queues(hwc, HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH,
791 device_printf(hwc->dev, "Failed to initialize HWC: %d\n",
799 device_printf(hwc->dev, "Failed to establish HWC: %d\n", err);
803 err = mana_hwc_test_channel(gc->hwc.driver_data,
808 device_printf(hwc->dev, "Failed to test HWC: %d\n", err);
821 struct hw_channel_context *hwc = gc->hwc.driver_data;
823 if (!hwc)
835 free(hwc->caller_ctx, M_DEVBUF);
836 hwc->caller_ctx = NULL;
838 if (hwc->txq)
839 mana_hwc_destroy_wq(hwc, hwc->txq);
841 if (hwc->rxq)
842 mana_hwc_destroy_wq(hwc, hwc->rxq);
844 if (hwc->cq)
845 mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc->cq);
847 mana_gd_free_res_map(&hwc->inflight_msg_res);
849 hwc->num_inflight_msg = 0;
851 hwc->gdma_dev->doorbell = INVALID_DOORBELL;
852 hwc->gdma_dev->pdid = INVALID_PDID;
854 free(hwc, M_DEVBUF);
855 gc->hwc.driver_data = NULL;
856 gc->hwc.gdma_context = NULL;
863 mana_hwc_send_request(struct hw_channel_context *hwc, uint32_t req_len,
867 struct hwc_wq *txq = hwc->txq;
873 mana_hwc_get_msg_index(hwc, &msg_id);
878 device_printf(hwc->dev,
885 ctx = hwc->caller_ctx + msg_id;
899 device_printf(hwc->dev,
905 device_printf(hwc->dev, "HWC: Request timed out!\n");
916 device_printf(hwc->dev,
922 mana_hwc_put_msg_index(hwc, msg_id);