Lines Matching +full:cmdq +full:- +full:sync

2  * Broadcom NetXtreme-E RoCE driver.
4 * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
57 * bnxt_qplib_map_rc - map return type based on opcode
95 return -ETIMEDOUT; in bnxt_qplib_map_rc()
100 * bnxt_re_is_fw_stalled - Check firmware health
105 * rcfw->max_timeout, consider firmware as stalled.
109 * -ENODEV if firmware is not responding
114 struct bnxt_qplib_cmdq_ctx *cmdq; in bnxt_re_is_fw_stalled() local
117 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_re_is_fw_stalled()
118 cmdq = &rcfw->cmdq; in bnxt_re_is_fw_stalled()
120 if (time_after(jiffies, cmdq->last_seen + in bnxt_re_is_fw_stalled()
121 (rcfw->max_timeout * HZ))) { in bnxt_re_is_fw_stalled()
122 dev_warn_ratelimited(&rcfw->pdev->dev, in bnxt_re_is_fw_stalled()
123 "%s: FW STALL Detected. cmdq[%#x]=%#x waited (%d > %d) msec active %d ", in bnxt_re_is_fw_stalled()
124 __func__, cookie, crsqe->opcode, in bnxt_re_is_fw_stalled()
125 jiffies_to_msecs(jiffies - cmdq->last_seen), in bnxt_re_is_fw_stalled()
126 rcfw->max_timeout * 1000, in bnxt_re_is_fw_stalled()
127 crsqe->is_in_used); in bnxt_re_is_fw_stalled()
128 return -ENODEV; in bnxt_re_is_fw_stalled()
135 * __wait_for_resp - Don't hold the cpu context and wait for response
147 struct bnxt_qplib_cmdq_ctx *cmdq; in __wait_for_resp() local
151 cmdq = &rcfw->cmdq; in __wait_for_resp()
152 crsqe = &rcfw->crsqe_tbl[cookie]; in __wait_for_resp()
155 if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags)) in __wait_for_resp()
156 return bnxt_qplib_map_rc(crsqe->opcode); in __wait_for_resp()
157 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __wait_for_resp()
158 return -ETIMEDOUT; in __wait_for_resp()
160 wait_event_timeout(cmdq->waitq, in __wait_for_resp()
161 !crsqe->is_in_used || in __wait_for_resp()
162 test_bit(ERR_DEVICE_DETACHED, &cmdq->flags), in __wait_for_resp()
163 msecs_to_jiffies(rcfw->max_timeout * 1000)); in __wait_for_resp()
165 if (!crsqe->is_in_used) in __wait_for_resp()
168 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __wait_for_resp()
170 if (!crsqe->is_in_used) in __wait_for_resp()
181 * __block_for_resp - hold the cpu context and wait for response
185 * This function will hold the cpu (non-sleepable context) and
189 * -ETIMEOUT if command is not completed in specific time interval.
194 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __block_for_resp() local
199 crsqe = &rcfw->crsqe_tbl[cookie]; in __block_for_resp()
202 if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags)) in __block_for_resp()
203 return bnxt_qplib_map_rc(crsqe->opcode); in __block_for_resp()
204 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __block_for_resp()
205 return -ETIMEDOUT; in __block_for_resp()
209 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __block_for_resp()
210 if (!crsqe->is_in_used) in __block_for_resp()
215 return -ETIMEDOUT; in __block_for_resp()
218 /* __send_message_no_waiter - get cookie and post the message.
223 * Current design of this function is -
224 * user must hold the completion queue hwq->lock.
228 * current use case is - send destroy_ah if create_ah is return
238 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __send_message_no_waiter() local
239 struct bnxt_qplib_hwq *hwq = &cmdq->hwq; in __send_message_no_waiter()
247 cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message_no_waiter()
248 __set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie)); in __send_message_no_waiter()
249 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message_no_waiter()
252 bsize = bnxt_qplib_set_cmd_slots(msg->req); in __send_message_no_waiter()
254 * and non-tlv commands after call to bnxt_qplib_set_cmd_slots() in __send_message_no_waiter()
256 crsqe->is_internal_cmd = true; in __send_message_no_waiter()
257 crsqe->is_waiter_alive = false; in __send_message_no_waiter()
258 crsqe->is_in_used = true; in __send_message_no_waiter()
259 crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz); in __send_message_no_waiter()
261 preq = (u8 *)msg->req; in __send_message_no_waiter()
263 /* Locate the next cmdq slot */ in __send_message_no_waiter()
264 sw_prod = HWQ_CMP(hwq->prod, hwq); in __send_message_no_waiter()
266 /* Copy a segment of the req cmd to the cmdq */ in __send_message_no_waiter()
270 bsize -= min_t(u32, bsize, sizeof(*cmdqe)); in __send_message_no_waiter()
271 hwq->prod++; in __send_message_no_waiter()
273 cmdq->seq_num++; in __send_message_no_waiter()
275 cmdq_prod = hwq->prod; in __send_message_no_waiter()
276 atomic_inc(&rcfw->timeout_send); in __send_message_no_waiter()
277 /* ring CMDQ DB */ in __send_message_no_waiter()
279 writel(cmdq_prod, cmdq->cmdq_mbox.prod); in __send_message_no_waiter()
280 writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db); in __send_message_no_waiter()
287 struct bnxt_qplib_cmdq_ctx *cmdq; in __send_message() local
296 cmdq = &rcfw->cmdq; in __send_message()
297 hwq = &cmdq->hwq; in __send_message()
298 pdev = rcfw->pdev; in __send_message()
300 /* Cmdq are in 16-byte units, each request can consume 1 or more in __send_message()
303 spin_lock_bh(&hwq->lock); in __send_message()
304 required_slots = bnxt_qplib_get_cmd_slots(msg->req); in __send_message()
306 cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message()
307 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message()
310 dev_info_ratelimited(&pdev->dev, in __send_message()
311 "CMDQ is full req/free %d/%d!", in __send_message()
313 spin_unlock_bh(&hwq->lock); in __send_message()
314 return -EAGAIN; in __send_message()
316 if (msg->block) in __send_message()
318 __set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie)); in __send_message()
320 bsize = bnxt_qplib_set_cmd_slots(msg->req); in __send_message()
321 crsqe->free_slots = free_slots; in __send_message()
322 crsqe->resp = (struct creq_qp_event *)msg->resp; in __send_message()
323 crsqe->resp->cookie = cpu_to_le16(cookie); in __send_message()
324 crsqe->is_internal_cmd = false; in __send_message()
325 crsqe->is_waiter_alive = true; in __send_message()
326 crsqe->is_in_used = true; in __send_message()
327 crsqe->opcode = opcode; in __send_message()
329 crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz); in __send_message()
330 if (__get_cmdq_base_resp_size(msg->req, msg->req_sz) && msg->sb) { in __send_message()
331 struct bnxt_qplib_rcfw_sbuf *sbuf = msg->sb; in __send_message()
333 __set_cmdq_base_resp_addr(msg->req, msg->req_sz, in __send_message()
334 cpu_to_le64(sbuf->dma_addr)); in __send_message()
335 __set_cmdq_base_resp_size(msg->req, msg->req_sz, in __send_message()
336 ALIGN(sbuf->size, in __send_message()
341 preq = (u8 *)msg->req; in __send_message()
343 /* Locate the next cmdq slot */ in __send_message()
344 sw_prod = HWQ_CMP(hwq->prod, hwq); in __send_message()
346 /* Copy a segment of the req cmd to the cmdq */ in __send_message()
350 bsize -= min_t(u32, bsize, sizeof(*cmdqe)); in __send_message()
351 hwq->prod++; in __send_message()
353 cmdq->seq_num++; in __send_message()
355 cmdq_prod = hwq->prod & 0xFFFF; in __send_message()
356 if (test_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags)) { in __send_message()
363 clear_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags); in __send_message()
365 /* ring CMDQ DB */ in __send_message()
367 writel(cmdq_prod, cmdq->cmdq_mbox.prod); in __send_message()
368 writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db); in __send_message()
369 spin_unlock_bh(&hwq->lock); in __send_message()
375 * __poll_for_resp - self poll completion for rcfw command
381 * This function can not be called from non-sleepable context.
384 * -ETIMEOUT if command is not completed in specific time interval.
389 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __poll_for_resp() local
395 crsqe = &rcfw->crsqe_tbl[cookie]; in __poll_for_resp()
398 if (test_bit(ERR_DEVICE_DETACHED, &cmdq->flags)) in __poll_for_resp()
399 return bnxt_qplib_map_rc(crsqe->opcode); in __poll_for_resp()
400 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __poll_for_resp()
401 return -ETIMEDOUT; in __poll_for_resp()
405 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __poll_for_resp()
406 if (!crsqe->is_in_used) in __poll_for_resp()
408 if (jiffies_to_msecs(jiffies - issue_time) > in __poll_for_resp()
409 (rcfw->max_timeout * 1000)) { in __poll_for_resp()
421 struct bnxt_qplib_cmdq_ctx *cmdq; in __send_message_basic_sanity() local
423 cmdq = &rcfw->cmdq; in __send_message_basic_sanity()
426 if (test_bit(ERR_DEVICE_DETACHED, &rcfw->cmdq.flags)) in __send_message_basic_sanity()
427 return -ENXIO; in __send_message_basic_sanity()
429 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __send_message_basic_sanity()
430 return -ETIMEDOUT; in __send_message_basic_sanity()
432 if (test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) && in __send_message_basic_sanity()
434 dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!"); in __send_message_basic_sanity()
435 return -EINVAL; in __send_message_basic_sanity()
438 if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) && in __send_message_basic_sanity()
442 dev_err(&rcfw->pdev->dev, in __send_message_basic_sanity()
445 return -EOPNOTSUPP; in __send_message_basic_sanity()
461 req.ah_cid = create_ah_resp->xid; in __destroy_timedout_ah()
465 dev_info_ratelimited(&rcfw->pdev->dev, in __destroy_timedout_ah()
468 atomic_read(&rcfw->timeout_send)); in __destroy_timedout_ah()
472 * __bnxt_qplib_rcfw_send_message - qplib interface to send
487 struct creq_qp_event *evnt = (struct creq_qp_event *)msg->resp; in __bnxt_qplib_rcfw_send_message()
493 opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz); in __bnxt_qplib_rcfw_send_message()
497 return rc == -ENXIO ? bnxt_qplib_map_rc(opcode) : rc; in __bnxt_qplib_rcfw_send_message()
503 cookie = le16_to_cpu(__get_cmdq_base_cookie(msg->req, msg->req_sz)) in __bnxt_qplib_rcfw_send_message()
506 if (msg->block) in __bnxt_qplib_rcfw_send_message()
508 else if (atomic_read(&rcfw->rcfw_intr_enabled)) in __bnxt_qplib_rcfw_send_message()
514 spin_lock_bh(&rcfw->cmdq.hwq.lock); in __bnxt_qplib_rcfw_send_message()
515 crsqe = &rcfw->crsqe_tbl[cookie]; in __bnxt_qplib_rcfw_send_message()
516 crsqe->is_waiter_alive = false; in __bnxt_qplib_rcfw_send_message()
517 if (rc == -ENODEV) in __bnxt_qplib_rcfw_send_message()
518 set_bit(FIRMWARE_STALL_DETECTED, &rcfw->cmdq.flags); in __bnxt_qplib_rcfw_send_message()
519 spin_unlock_bh(&rcfw->cmdq.hwq.lock); in __bnxt_qplib_rcfw_send_message()
520 return -ETIMEDOUT; in __bnxt_qplib_rcfw_send_message()
523 if (evnt->status) { in __bnxt_qplib_rcfw_send_message()
525 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n", in __bnxt_qplib_rcfw_send_message()
526 cookie, opcode, evnt->status); in __bnxt_qplib_rcfw_send_message()
527 rc = -EIO; in __bnxt_qplib_rcfw_send_message()
534 * bnxt_qplib_rcfw_send_message - qplib interface to send
543 * b. Non-blocking rcfw command send. In this path, driver can hold the
545 * for completion because of non-blocking nature.
551 * Restrict at max #RCFW_CMD_NON_BLOCKING_SHADOW_QD Non-Blocking rcfw commands.
563 if (!msg->block) { in bnxt_qplib_rcfw_send_message()
564 down(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
566 up(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
580 switch (func_event->event) { in bnxt_qplib_process_func_event()
611 return -EINVAL; in bnxt_qplib_process_func_event()
614 rc = rcfw->creq.aeq_handler(rcfw, (void *)func_event, NULL); in bnxt_qplib_process_func_event()
623 struct bnxt_qplib_hwq *hwq = &rcfw->cmdq.hwq; in bnxt_qplib_process_qp_event()
633 pdev = rcfw->pdev; in bnxt_qplib_process_qp_event()
634 switch (qp_event->event) { in bnxt_qplib_process_qp_event()
637 qp_id = le32_to_cpu(err_event->xid); in bnxt_qplib_process_qp_event()
638 spin_lock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
640 qp = rcfw->qp_tbl[tbl_indx].qp_handle; in bnxt_qplib_process_qp_event()
642 spin_unlock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
646 rc = rcfw->creq.aeq_handler(rcfw, qp_event, qp); in bnxt_qplib_process_qp_event()
647 spin_unlock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
648 dev_dbg(&pdev->dev, "Received QP error notification\n"); in bnxt_qplib_process_qp_event()
649 dev_dbg(&pdev->dev, in bnxt_qplib_process_qp_event()
651 qp_id, err_event->req_err_state_reason, in bnxt_qplib_process_qp_event()
652 err_event->res_err_state_reason); in bnxt_qplib_process_qp_event()
657 * cmdq->lock needs to be acquired to synchronie in bnxt_qplib_process_qp_event()
659 * is always called with creq->lock held. Using in bnxt_qplib_process_qp_event()
664 spin_lock_nested(&hwq->lock, SINGLE_DEPTH_NESTING); in bnxt_qplib_process_qp_event()
665 cookie = le16_to_cpu(qp_event->cookie); in bnxt_qplib_process_qp_event()
668 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_qplib_process_qp_event()
671 &rcfw->cmdq.flags), in bnxt_qplib_process_qp_event()
673 dev_info(&pdev->dev, in bnxt_qplib_process_qp_event()
675 cookie, crsqe->free_slots); in bnxt_qplib_process_qp_event()
676 spin_unlock(&hwq->lock); in bnxt_qplib_process_qp_event()
680 if (crsqe->is_internal_cmd && !qp_event->status) in bnxt_qplib_process_qp_event()
681 atomic_dec(&rcfw->timeout_send); in bnxt_qplib_process_qp_event()
683 if (crsqe->is_waiter_alive) { in bnxt_qplib_process_qp_event()
684 if (crsqe->resp) { in bnxt_qplib_process_qp_event()
685 memcpy(crsqe->resp, qp_event, sizeof(*qp_event)); in bnxt_qplib_process_qp_event()
696 req_size = crsqe->req_size; in bnxt_qplib_process_qp_event()
697 is_waiter_alive = crsqe->is_waiter_alive; in bnxt_qplib_process_qp_event()
699 crsqe->req_size = 0; in bnxt_qplib_process_qp_event()
701 crsqe->resp = NULL; in bnxt_qplib_process_qp_event()
703 crsqe->is_in_used = false; in bnxt_qplib_process_qp_event()
705 hwq->cons += req_size; in bnxt_qplib_process_qp_event()
707 /* This is a case to handle below scenario - in bnxt_qplib_process_qp_event()
719 if (!is_waiter_alive && !qp_event->status && in bnxt_qplib_process_qp_event()
720 qp_event->event == CREQ_QP_EVENT_EVENT_CREATE_AH) in bnxt_qplib_process_qp_event()
724 spin_unlock(&hwq->lock); in bnxt_qplib_process_qp_event()
730 /* SP - CREQ Completion handlers */
734 struct bnxt_qplib_creq_ctx *creq = &rcfw->creq; in bnxt_qplib_service_creq()
736 struct bnxt_qplib_hwq *hwq = &creq->hwq; in bnxt_qplib_service_creq()
742 spin_lock_bh(&hwq->lock); in bnxt_qplib_service_creq()
744 creqe = bnxt_qplib_get_qe(hwq, hwq->cons, NULL); in bnxt_qplib_service_creq()
745 if (!CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags)) in bnxt_qplib_service_creq()
751 rcfw->cmdq.last_seen = jiffies; in bnxt_qplib_service_creq()
753 type = creqe->type & CREQ_BASE_TYPE_MASK; in bnxt_qplib_service_creq()
759 creq->stats.creq_qp_event_processed++; in bnxt_qplib_service_creq()
764 creq->stats.creq_func_event_processed++; in bnxt_qplib_service_creq()
766 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
771 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
776 budget--; in bnxt_qplib_service_creq()
778 bnxt_qplib_hwq_incr_cons(hwq->max_elements, &hwq->cons, in bnxt_qplib_service_creq()
779 1, &creq->creq_db.dbinfo.flags); in bnxt_qplib_service_creq()
783 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, in bnxt_qplib_service_creq()
784 rcfw->res->cctx, true); in bnxt_qplib_service_creq()
785 spin_unlock_bh(&hwq->lock); in bnxt_qplib_service_creq()
787 wake_up_nr(&rcfw->cmdq.waitq, num_wakeup); in bnxt_qplib_service_creq()
797 creq = &rcfw->creq; in bnxt_qplib_creq_irq()
798 hwq = &creq->hwq; in bnxt_qplib_creq_irq()
800 sw_cons = HWQ_CMP(hwq->cons, hwq); in bnxt_qplib_creq_irq()
803 tasklet_schedule(&creq->creq_tasklet); in bnxt_qplib_creq_irq()
825 clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_deinit_rcfw()
842 /* Supply (log-base-2-of-host-page-size - base-page-shift) in bnxt_qplib_init_rcfw()
845 req.log2_dbr_pg_size = cpu_to_le16(PAGE_SHIFT - in bnxt_qplib_init_rcfw()
854 if (is_virtfn || bnxt_qplib_is_chip_gen_p5_p7(rcfw->res->cctx)) in bnxt_qplib_init_rcfw()
857 lvl = ctx->qpc_tbl.level; in bnxt_qplib_init_rcfw()
858 pgsz = bnxt_qplib_base_pg_size(&ctx->qpc_tbl); in bnxt_qplib_init_rcfw()
861 lvl = ctx->mrw_tbl.level; in bnxt_qplib_init_rcfw()
862 pgsz = bnxt_qplib_base_pg_size(&ctx->mrw_tbl); in bnxt_qplib_init_rcfw()
865 lvl = ctx->srqc_tbl.level; in bnxt_qplib_init_rcfw()
866 pgsz = bnxt_qplib_base_pg_size(&ctx->srqc_tbl); in bnxt_qplib_init_rcfw()
869 lvl = ctx->cq_tbl.level; in bnxt_qplib_init_rcfw()
870 pgsz = bnxt_qplib_base_pg_size(&ctx->cq_tbl); in bnxt_qplib_init_rcfw()
873 lvl = ctx->tim_tbl.level; in bnxt_qplib_init_rcfw()
874 pgsz = bnxt_qplib_base_pg_size(&ctx->tim_tbl); in bnxt_qplib_init_rcfw()
877 lvl = ctx->tqm_ctx.pde.level; in bnxt_qplib_init_rcfw()
878 pgsz = bnxt_qplib_base_pg_size(&ctx->tqm_ctx.pde); in bnxt_qplib_init_rcfw()
882 cpu_to_le64(ctx->qpc_tbl.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
884 cpu_to_le64(ctx->mrw_tbl.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
886 cpu_to_le64(ctx->srqc_tbl.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
888 cpu_to_le64(ctx->cq_tbl.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
890 cpu_to_le64(ctx->tim_tbl.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
892 cpu_to_le64(ctx->tqm_ctx.pde.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_init_rcfw()
894 req.number_of_qp = cpu_to_le32(ctx->qpc_tbl.max_elements); in bnxt_qplib_init_rcfw()
895 req.number_of_mrw = cpu_to_le32(ctx->mrw_tbl.max_elements); in bnxt_qplib_init_rcfw()
896 req.number_of_srq = cpu_to_le32(ctx->srqc_tbl.max_elements); in bnxt_qplib_init_rcfw()
897 req.number_of_cq = cpu_to_le32(ctx->cq_tbl.max_elements); in bnxt_qplib_init_rcfw()
900 if (BNXT_RE_HW_RETX(rcfw->res->dattr->dev_cap_flags)) in bnxt_qplib_init_rcfw()
902 if (_is_optimize_modify_qp_supported(rcfw->res->dattr->dev_cap_flags2)) in bnxt_qplib_init_rcfw()
904 if (rcfw->res->en_dev->flags & BNXT_EN_FLAG_ROCE_VF_RES_MGMT) in bnxt_qplib_init_rcfw()
907 req.stat_ctx_id = cpu_to_le32(ctx->stats.fw_id); in bnxt_qplib_init_rcfw()
912 set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_init_rcfw()
918 kfree(rcfw->crsqe_tbl); in bnxt_qplib_free_rcfw_channel()
919 bnxt_qplib_free_hwq(rcfw->res, &rcfw->cmdq.hwq); in bnxt_qplib_free_rcfw_channel()
920 bnxt_qplib_free_hwq(rcfw->res, &rcfw->creq.hwq); in bnxt_qplib_free_rcfw_channel()
921 rcfw->pdev = NULL; in bnxt_qplib_free_rcfw_channel()
930 struct bnxt_qplib_cmdq_ctx *cmdq; in bnxt_qplib_alloc_rcfw_channel() local
933 rcfw->pdev = res->pdev; in bnxt_qplib_alloc_rcfw_channel()
934 cmdq = &rcfw->cmdq; in bnxt_qplib_alloc_rcfw_channel()
935 creq = &rcfw->creq; in bnxt_qplib_alloc_rcfw_channel()
936 rcfw->res = res; in bnxt_qplib_alloc_rcfw_channel()
942 hwq_attr.res = rcfw->res; in bnxt_qplib_alloc_rcfw_channel()
947 if (bnxt_qplib_alloc_init_hwq(&creq->hwq, &hwq_attr)) { in bnxt_qplib_alloc_rcfw_channel()
948 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
953 rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT; in bnxt_qplib_alloc_rcfw_channel()
955 sginfo.pgsize = bnxt_qplib_cmdqe_page_size(rcfw->cmdq_depth); in bnxt_qplib_alloc_rcfw_channel()
956 hwq_attr.depth = rcfw->cmdq_depth & 0x7FFFFFFF; in bnxt_qplib_alloc_rcfw_channel()
959 if (bnxt_qplib_alloc_init_hwq(&cmdq->hwq, &hwq_attr)) { in bnxt_qplib_alloc_rcfw_channel()
960 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
961 "HW channel CMDQ allocation failed\n"); in bnxt_qplib_alloc_rcfw_channel()
965 rcfw->crsqe_tbl = kcalloc(cmdq->hwq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
966 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL); in bnxt_qplib_alloc_rcfw_channel()
967 if (!rcfw->crsqe_tbl) in bnxt_qplib_alloc_rcfw_channel()
970 spin_lock_init(&rcfw->tbl_lock); in bnxt_qplib_alloc_rcfw_channel()
972 rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout; in bnxt_qplib_alloc_rcfw_channel()
978 return -ENOMEM; in bnxt_qplib_alloc_rcfw_channel()
985 creq = &rcfw->creq; in bnxt_qplib_rcfw_stop_irq()
987 if (!creq->requested) in bnxt_qplib_rcfw_stop_irq()
990 creq->requested = false; in bnxt_qplib_rcfw_stop_irq()
992 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, rcfw->res->cctx, false); in bnxt_qplib_rcfw_stop_irq()
993 /* Sync with last running IRQ-handler */ in bnxt_qplib_rcfw_stop_irq()
994 synchronize_irq(creq->msix_vec); in bnxt_qplib_rcfw_stop_irq()
995 free_irq(creq->msix_vec, rcfw); in bnxt_qplib_rcfw_stop_irq()
996 kfree(creq->irq_name); in bnxt_qplib_rcfw_stop_irq()
997 creq->irq_name = NULL; in bnxt_qplib_rcfw_stop_irq()
998 atomic_set(&rcfw->rcfw_intr_enabled, 0); in bnxt_qplib_rcfw_stop_irq()
1000 tasklet_kill(&creq->creq_tasklet); in bnxt_qplib_rcfw_stop_irq()
1001 tasklet_disable(&creq->creq_tasklet); in bnxt_qplib_rcfw_stop_irq()
1007 struct bnxt_qplib_cmdq_ctx *cmdq; in bnxt_qplib_disable_rcfw_channel() local
1009 creq = &rcfw->creq; in bnxt_qplib_disable_rcfw_channel()
1010 cmdq = &rcfw->cmdq; in bnxt_qplib_disable_rcfw_channel()
1014 iounmap(cmdq->cmdq_mbox.reg.bar_reg); in bnxt_qplib_disable_rcfw_channel()
1015 iounmap(creq->creq_db.reg.bar_reg); in bnxt_qplib_disable_rcfw_channel()
1017 cmdq->cmdq_mbox.reg.bar_reg = NULL; in bnxt_qplib_disable_rcfw_channel()
1018 creq->creq_db.reg.bar_reg = NULL; in bnxt_qplib_disable_rcfw_channel()
1019 creq->aeq_handler = NULL; in bnxt_qplib_disable_rcfw_channel()
1020 creq->msix_vec = 0; in bnxt_qplib_disable_rcfw_channel()
1030 creq = &rcfw->creq; in bnxt_qplib_rcfw_start_irq()
1031 res = rcfw->res; in bnxt_qplib_rcfw_start_irq()
1033 if (creq->requested) in bnxt_qplib_rcfw_start_irq()
1034 return -EFAULT; in bnxt_qplib_rcfw_start_irq()
1036 creq->msix_vec = msix_vector; in bnxt_qplib_rcfw_start_irq()
1038 tasklet_setup(&creq->creq_tasklet, bnxt_qplib_service_creq); in bnxt_qplib_rcfw_start_irq()
1040 tasklet_enable(&creq->creq_tasklet); in bnxt_qplib_rcfw_start_irq()
1042 creq->irq_name = kasprintf(GFP_KERNEL, "bnxt_re-creq@pci:%s", in bnxt_qplib_rcfw_start_irq()
1043 pci_name(res->pdev)); in bnxt_qplib_rcfw_start_irq()
1044 if (!creq->irq_name) in bnxt_qplib_rcfw_start_irq()
1045 return -ENOMEM; in bnxt_qplib_rcfw_start_irq()
1046 rc = request_irq(creq->msix_vec, bnxt_qplib_creq_irq, 0, in bnxt_qplib_rcfw_start_irq()
1047 creq->irq_name, rcfw); in bnxt_qplib_rcfw_start_irq()
1049 kfree(creq->irq_name); in bnxt_qplib_rcfw_start_irq()
1050 creq->irq_name = NULL; in bnxt_qplib_rcfw_start_irq()
1051 tasklet_disable(&creq->creq_tasklet); in bnxt_qplib_rcfw_start_irq()
1054 creq->requested = true; in bnxt_qplib_rcfw_start_irq()
1056 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true); in bnxt_qplib_rcfw_start_irq()
1057 atomic_inc(&rcfw->rcfw_intr_enabled); in bnxt_qplib_rcfw_start_irq()
1068 pdev = rcfw->pdev; in bnxt_qplib_map_cmdq_mbox()
1069 mbox = &rcfw->cmdq.cmdq_mbox; in bnxt_qplib_map_cmdq_mbox()
1071 mbox->reg.bar_id = RCFW_COMM_PCI_BAR_REGION; in bnxt_qplib_map_cmdq_mbox()
1072 mbox->reg.len = RCFW_COMM_SIZE; in bnxt_qplib_map_cmdq_mbox()
1073 mbox->reg.bar_base = pci_resource_start(pdev, mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1074 if (!mbox->reg.bar_base) { in bnxt_qplib_map_cmdq_mbox()
1075 dev_err(&pdev->dev, in bnxt_qplib_map_cmdq_mbox()
1076 "QPLIB: CMDQ BAR region %d resc start is 0!\n", in bnxt_qplib_map_cmdq_mbox()
1077 mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1078 return -ENOMEM; in bnxt_qplib_map_cmdq_mbox()
1081 bar_reg = mbox->reg.bar_base + RCFW_COMM_BASE_OFFSET; in bnxt_qplib_map_cmdq_mbox()
1082 mbox->reg.len = RCFW_COMM_SIZE; in bnxt_qplib_map_cmdq_mbox()
1083 mbox->reg.bar_reg = ioremap(bar_reg, mbox->reg.len); in bnxt_qplib_map_cmdq_mbox()
1084 if (!mbox->reg.bar_reg) { in bnxt_qplib_map_cmdq_mbox()
1085 dev_err(&pdev->dev, in bnxt_qplib_map_cmdq_mbox()
1086 "QPLIB: CMDQ BAR region %d mapping failed\n", in bnxt_qplib_map_cmdq_mbox()
1087 mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1088 return -ENOMEM; in bnxt_qplib_map_cmdq_mbox()
1091 mbox->prod = (void __iomem *)(mbox->reg.bar_reg + in bnxt_qplib_map_cmdq_mbox()
1093 mbox->db = (void __iomem *)(mbox->reg.bar_reg + RCFW_COMM_TRIG_OFFSET); in bnxt_qplib_map_cmdq_mbox()
1103 pdev = rcfw->pdev; in bnxt_qplib_map_creq_db()
1104 creq_db = &rcfw->creq.creq_db; in bnxt_qplib_map_creq_db()
1106 creq_db->dbinfo.flags = 0; in bnxt_qplib_map_creq_db()
1107 creq_db->reg.bar_id = RCFW_COMM_CONS_PCI_BAR_REGION; in bnxt_qplib_map_creq_db()
1108 creq_db->reg.bar_base = pci_resource_start(pdev, creq_db->reg.bar_id); in bnxt_qplib_map_creq_db()
1109 if (!creq_db->reg.bar_id) in bnxt_qplib_map_creq_db()
1110 dev_err(&pdev->dev, in bnxt_qplib_map_creq_db()
1112 creq_db->reg.bar_id); in bnxt_qplib_map_creq_db()
1114 bar_reg = creq_db->reg.bar_base + reg_offt; in bnxt_qplib_map_creq_db()
1116 creq_db->reg.len = 8; in bnxt_qplib_map_creq_db()
1117 creq_db->reg.bar_reg = ioremap(bar_reg, creq_db->reg.len); in bnxt_qplib_map_creq_db()
1118 if (!creq_db->reg.bar_reg) { in bnxt_qplib_map_creq_db()
1119 dev_err(&pdev->dev, in bnxt_qplib_map_creq_db()
1121 creq_db->reg.bar_id); in bnxt_qplib_map_creq_db()
1122 return -ENOMEM; in bnxt_qplib_map_creq_db()
1124 creq_db->dbinfo.db = creq_db->reg.bar_reg; in bnxt_qplib_map_creq_db()
1125 creq_db->dbinfo.hwq = &rcfw->creq.hwq; in bnxt_qplib_map_creq_db()
1126 creq_db->dbinfo.xid = rcfw->creq.ring_id; in bnxt_qplib_map_creq_db()
1132 struct bnxt_qplib_cmdq_ctx *cmdq; in bnxt_qplib_start_rcfw() local
1137 cmdq = &rcfw->cmdq; in bnxt_qplib_start_rcfw()
1138 creq = &rcfw->creq; in bnxt_qplib_start_rcfw()
1139 mbox = &cmdq->cmdq_mbox; in bnxt_qplib_start_rcfw()
1141 init.cmdq_pbl = cpu_to_le64(cmdq->hwq.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_start_rcfw()
1143 cpu_to_le16(((rcfw->cmdq_depth << in bnxt_qplib_start_rcfw()
1146 ((cmdq->hwq.level << in bnxt_qplib_start_rcfw()
1149 init.creq_ring_id = cpu_to_le16(creq->ring_id); in bnxt_qplib_start_rcfw()
1151 __iowrite32_copy(mbox->reg.bar_reg, &init, sizeof(init) / 4); in bnxt_qplib_start_rcfw()
1159 struct bnxt_qplib_cmdq_ctx *cmdq; in bnxt_qplib_enable_rcfw_channel() local
1163 cmdq = &rcfw->cmdq; in bnxt_qplib_enable_rcfw_channel()
1164 creq = &rcfw->creq; in bnxt_qplib_enable_rcfw_channel()
1168 cmdq->seq_num = 0; in bnxt_qplib_enable_rcfw_channel()
1169 set_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags); in bnxt_qplib_enable_rcfw_channel()
1170 init_waitqueue_head(&cmdq->waitq); in bnxt_qplib_enable_rcfw_channel()
1172 creq->stats.creq_qp_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
1173 creq->stats.creq_func_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
1174 creq->aeq_handler = aeq_handler; in bnxt_qplib_enable_rcfw_channel()
1186 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
1192 sema_init(&rcfw->rcfw_inflight, RCFW_CMD_NON_BLOCKING_SHADOW_QD); in bnxt_qplib_enable_rcfw_channel()