Lines Matching +full:firmware +full:- +full:initialized

2  * Copyright (c) 2015-2024, Broadcom. All rights reserved.  The term
33 #include <linux/dma-mapping.h>
54 cmdq = &rcfw->cmdq; in __check_cmdq_stall()
56 if (*cur_prod == cmdq->hwq.prod && in __check_cmdq_stall()
57 *cur_cons == cmdq->hwq.cons) in __check_cmdq_stall()
59 return -ETIMEDOUT; in __check_cmdq_stall()
61 *cur_prod = cmdq->hwq.prod; in __check_cmdq_stall()
62 *cur_cons = cmdq->hwq.cons; in __check_cmdq_stall()
82 return -ETIMEDOUT; in bnxt_qplib_map_rc()
87 * bnxt_re_is_fw_stalled - Check firmware health
88 * @rcfw - rcfw channel instance of rdev
89 * @cookie - cookie to track the command
91 * If firmware has not responded any rcfw command within
92 * rcfw->max_timeout, consider firmware as stalled.
95 * 0 if firmware is responding
96 * -ENODEV if firmware is not responding
103 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_re_is_fw_stalled()
104 cmdq = &rcfw->cmdq; in bnxt_re_is_fw_stalled()
106 if (time_after(jiffies, cmdq->last_seen + in bnxt_re_is_fw_stalled()
107 (rcfw->max_timeout * HZ))) { in bnxt_re_is_fw_stalled()
108 dev_warn_ratelimited(&rcfw->pdev->dev, in bnxt_re_is_fw_stalled()
110 __func__, cookie, crsqe->opcode, in bnxt_re_is_fw_stalled()
111 (long)jiffies_to_msecs(jiffies - cmdq->last_seen), in bnxt_re_is_fw_stalled()
112 rcfw->max_timeout * 1000, in bnxt_re_is_fw_stalled()
113 crsqe->is_in_used); in bnxt_re_is_fw_stalled()
114 return -ENODEV; in bnxt_re_is_fw_stalled()
120 * __wait_for_resp - Don't hold the cpu context and wait for response
121 * @rcfw - rcfw channel instance of rdev
122 * @cookie - cookie to track the command
127 * 0 if command is completed by firmware.
137 cmdq = &rcfw->cmdq; in __wait_for_resp()
139 crsqe = &rcfw->crsqe_tbl[cookie]; in __wait_for_resp()
143 return bnxt_qplib_map_rc(crsqe->opcode); in __wait_for_resp()
144 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __wait_for_resp()
145 return -ETIMEDOUT; in __wait_for_resp()
148 ret = wait_event_timeout(cmdq->waitq, in __wait_for_resp()
149 !crsqe->is_in_used || in __wait_for_resp()
151 msecs_to_jiffies(rcfw->max_timeout * 1000)); in __wait_for_resp()
153 if (!crsqe->is_in_used) in __wait_for_resp()
159 dev_warn_ratelimited(&rcfw->pdev->dev, in __wait_for_resp()
160 "Non-Blocking QPLIB: cmdq[%#x]=%#x waited (%lu) msec bit %d\n", in __wait_for_resp()
161 cookie, crsqe->opcode, in __wait_for_resp()
162 (long)jiffies_to_msecs(jiffies - issue_time), in __wait_for_resp()
163 crsqe->is_in_used); in __wait_for_resp()
165 if (!crsqe->is_in_used) in __wait_for_resp()
176 * __block_for_resp - hold the cpu context and wait for response
177 * @rcfw - rcfw channel instance of rdev
178 * @cookie - cookie to track the command
180 * This function will hold the cpu (non-sleepable context) and
184 * -ETIMEOUT if command is not completed in specific time interval.
185 * 0 if command is completed by firmware.
189 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __block_for_resp()
194 crsqe = &rcfw->crsqe_tbl[cookie]; in __block_for_resp()
198 return bnxt_qplib_map_rc(crsqe->opcode); in __block_for_resp()
199 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __block_for_resp()
200 return -ETIMEDOUT; in __block_for_resp()
208 if (!crsqe->is_in_used) in __block_for_resp()
213 dev_warn_ratelimited(&rcfw->pdev->dev, in __block_for_resp()
215 cookie, crsqe->opcode, in __block_for_resp()
216 (long)jiffies_to_msecs(jiffies - issue_time)); in __block_for_resp()
218 return -ETIMEDOUT; in __block_for_resp()
221 /* __send_message_no_waiter - get cookie and post the message.
222 * @rcfw - rcfw channel instance of rdev
223 * @msg - qplib message internal
226 * Current design of this function is -
227 * user must hold the completion queue hwq->lock.
231 * current use case is - send destroy_ah if create_ah is return
241 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __send_message_no_waiter()
242 struct bnxt_qplib_hwq *cmdq_hwq = &cmdq->hwq; in __send_message_no_waiter()
249 cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message_no_waiter()
250 __set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie)); in __send_message_no_waiter()
251 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message_no_waiter()
254 bsize = bnxt_qplib_set_cmd_slots(msg->req); in __send_message_no_waiter()
256 * and non-tlv commands after call to bnxt_qplib_set_cmd_slots() in __send_message_no_waiter()
258 crsqe->send_timestamp = jiffies; in __send_message_no_waiter()
259 crsqe->is_internal_cmd = true; in __send_message_no_waiter()
260 crsqe->is_waiter_alive = false; in __send_message_no_waiter()
261 crsqe->is_in_used = true; in __send_message_no_waiter()
262 crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz); in __send_message_no_waiter()
264 preq = (u8 *)msg->req; in __send_message_no_waiter()
267 sw_prod = HWQ_CMP(cmdq_hwq->prod, cmdq_hwq); in __send_message_no_waiter()
273 bsize -= min_t(u32, bsize, sizeof(*cmdqe)); in __send_message_no_waiter()
274 cmdq_hwq->prod++; in __send_message_no_waiter()
276 cmdq->seq_num++; in __send_message_no_waiter()
278 cmdq_prod = cmdq_hwq->prod & 0xFFFF; in __send_message_no_waiter()
279 atomic_inc(&rcfw->timeout_send); in __send_message_no_waiter()
282 writel(cmdq_prod, cmdq->cmdq_mbox.prod); in __send_message_no_waiter()
283 writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db); in __send_message_no_waiter()
301 cmdq = &rcfw->cmdq; in __send_message()
302 cmdq_hwq = &cmdq->hwq; in __send_message()
303 pdev = rcfw->pdev; in __send_message()
304 opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz); in __send_message()
306 /* Cmdq are in 16-byte units, each request can consume 1 or more in __send_message()
308 spin_lock_irqsave(&cmdq_hwq->lock, flags); in __send_message()
309 required_slots = bnxt_qplib_get_cmd_slots(msg->req); in __send_message()
311 cookie = cmdq->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message()
312 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message()
315 dev_warn_ratelimited(&pdev->dev, in __send_message()
318 rcfw->cmdq_full_dbg++; in __send_message()
319 spin_unlock_irqrestore(&cmdq_hwq->lock, flags); in __send_message()
320 return -EAGAIN; in __send_message()
323 if (crsqe->is_in_used) in __send_message()
327 if (msg->block) in __send_message()
329 __set_cmdq_base_cookie(msg->req, msg->req_sz, cpu_to_le16(cookie)); in __send_message()
332 bsize = bnxt_qplib_set_cmd_slots(msg->req); in __send_message()
334 * and non-tlv commands after call to bnxt_qplib_set_cmd_slots() in __send_message()
336 crsqe->send_timestamp = jiffies; in __send_message()
337 crsqe->free_slots = free_slots; in __send_message()
338 crsqe->resp = (struct creq_qp_event *)msg->resp; in __send_message()
339 crsqe->resp->cookie = cpu_to_le16(cookie); in __send_message()
340 crsqe->is_internal_cmd = false; in __send_message()
341 crsqe->is_waiter_alive = true; in __send_message()
342 crsqe->is_in_used = true; in __send_message()
343 crsqe->opcode = opcode; in __send_message()
344 crsqe->requested_qp_state = msg->qp_state; in __send_message()
346 crsqe->req_size = __get_cmdq_base_cmd_size(msg->req, msg->req_sz); in __send_message()
347 if (__get_cmdq_base_resp_size(msg->req, msg->req_sz) && msg->sb) { in __send_message()
348 struct bnxt_qplib_rcfw_sbuf *sbuf = msg->sb; in __send_message()
350 __set_cmdq_base_resp_addr(msg->req, msg->req_sz, in __send_message()
351 cpu_to_le64(sbuf->dma_addr)); in __send_message()
352 __set_cmdq_base_resp_size(msg->req, msg->req_sz, in __send_message()
353 ALIGN(sbuf->size, BNXT_QPLIB_CMDQE_UNITS) / in __send_message()
357 preq = (u8 *)msg->req; in __send_message()
360 sw_prod = HWQ_CMP(cmdq_hwq->prod, cmdq_hwq); in __send_message()
366 bsize -= min_t(u32, bsize, sizeof(*cmdqe)); in __send_message()
367 cmdq_hwq->prod++; in __send_message()
369 cmdq->seq_num++; in __send_message()
371 cmdq_prod = cmdq_hwq->prod & 0xFFFF; in __send_message()
372 if (test_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags)) { in __send_message()
379 clear_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags); in __send_message()
383 writel(cmdq_prod, cmdq->cmdq_mbox.prod); in __send_message()
384 writel(RCFW_CMDQ_TRIG_VAL, cmdq->cmdq_mbox.db); in __send_message()
386 dev_dbg(&pdev->dev, "QPLIB: RCFW sent request with 0x%x 0x%x 0x%x\n", in __send_message()
387 cmdq_prod, cmdq_hwq->prod, crsqe->req_size); in __send_message()
388 dev_dbg(&pdev->dev, in __send_message()
391 __get_cmdq_base_cookie(msg->req, msg->req_sz), in __send_message()
393 spin_unlock_irqrestore(&cmdq_hwq->lock, flags); in __send_message()
399 * __poll_for_resp - self poll completion for rcfw command
400 * @rcfw - rcfw channel instance of rdev
401 * @cookie - cookie to track the command
405 * This function can not be called from non-sleepable context.
408 * -ETIMEOUT if command is not completed in specific time interval.
409 * 0 if command is completed by firmware.
413 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __poll_for_resp()
419 crsqe = &rcfw->crsqe_tbl[cookie]; in __poll_for_resp()
423 return bnxt_qplib_map_rc(crsqe->opcode); in __poll_for_resp()
424 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __poll_for_resp()
425 return -ETIMEDOUT; in __poll_for_resp()
430 if (!crsqe->is_in_used) in __poll_for_resp()
433 if (jiffies_to_msecs(jiffies - issue_time) > in __poll_for_resp()
434 (rcfw->max_timeout * 1000)) { in __poll_for_resp()
435 dev_warn_ratelimited(&rcfw->pdev->dev, in __poll_for_resp()
437 cookie, crsqe->opcode, in __poll_for_resp()
438 (long)jiffies_to_msecs(jiffies - issue_time)); in __poll_for_resp()
452 cmdq = &rcfw->cmdq; in __send_message_basic_sanity()
456 return -ENXIO; in __send_message_basic_sanity()
458 if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) in __send_message_basic_sanity()
459 return -ETIMEDOUT; in __send_message_basic_sanity()
461 if (test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) && in __send_message_basic_sanity()
463 dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!\n"); in __send_message_basic_sanity()
464 return -EINVAL; in __send_message_basic_sanity()
467 if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &cmdq->flags) && in __send_message_basic_sanity()
471 dev_err(&rcfw->pdev->dev, in __send_message_basic_sanity()
472 "QPLIB: RCFW not initialized, reject opcode 0x%x\n", in __send_message_basic_sanity()
474 return -ENOTSUPP; in __send_message_basic_sanity()
489 req.ah_cid = create_ah_resp->xid; in __destroy_timedout_ah()
493 dev_warn_ratelimited(&rcfw->pdev->dev, in __destroy_timedout_ah()
496 atomic_read(&rcfw->timeout_send)); in __destroy_timedout_ah()
500 * __bnxt_qplib_rcfw_send_message - qplib interface to send
502 * @rcfw - rcfw channel instance of rdev
503 * @msg - qplib message internal
509 * 0 if command completed by firmware.
510 * Non zero if the command is not completed by firmware.
522 opcode = __get_cmdq_base_opcode(msg->req, msg->req_sz); in __bnxt_qplib_rcfw_send_message()
526 return rc == -ENXIO ? bnxt_qplib_map_rc(opcode) : rc; in __bnxt_qplib_rcfw_send_message()
532 cookie = le16_to_cpu(__get_cmdq_base_cookie(msg->req, in __bnxt_qplib_rcfw_send_message()
533 msg->req_sz)) & RCFW_MAX_COOKIE_VALUE; in __bnxt_qplib_rcfw_send_message()
536 if (msg->block) in __bnxt_qplib_rcfw_send_message()
538 else if (atomic_read(&rcfw->rcfw_intr_enabled)) in __bnxt_qplib_rcfw_send_message()
547 spin_lock_irqsave(&rcfw->cmdq.hwq.lock, flags); in __bnxt_qplib_rcfw_send_message()
548 crsqe = &rcfw->crsqe_tbl[cookie]; in __bnxt_qplib_rcfw_send_message()
549 crsqe->is_waiter_alive = false; in __bnxt_qplib_rcfw_send_message()
550 if (rc == -ENODEV) in __bnxt_qplib_rcfw_send_message()
551 set_bit(FIRMWARE_STALL_DETECTED, &rcfw->cmdq.flags); in __bnxt_qplib_rcfw_send_message()
552 spin_unlock_irqrestore(&rcfw->cmdq.hwq.lock, flags); in __bnxt_qplib_rcfw_send_message()
554 return -ETIMEDOUT; in __bnxt_qplib_rcfw_send_message()
557 event = (struct creq_qp_event *)msg->resp; in __bnxt_qplib_rcfw_send_message()
558 if (event->status) { in __bnxt_qplib_rcfw_send_message()
560 dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x (%s) status %d\n", in __bnxt_qplib_rcfw_send_message()
561 cookie, opcode, GET_OPCODE_TYPE(opcode), event->status); in __bnxt_qplib_rcfw_send_message()
562 rc = -EFAULT; in __bnxt_qplib_rcfw_send_message()
573 …dev_dbg(&pdev->dev, "QPLIB: %s:%d - op 0x%x (%s), cookie 0x%x -- Return: e->status 0x%x, rc = 0x%x… in __bnxt_qplib_rcfw_send_message()
574 __func__, __LINE__, opcode, GET_OPCODE_TYPE(opcode), cookie, event->status, rc); in __bnxt_qplib_rcfw_send_message()
579 * bnxt_qplib_rcfw_send_message - qplib interface to send
581 * @rcfw - rcfw channel instance of rdev
582 * @msg - qplib message internal
584 * Driver interact with Firmware through rcfw channel/slow path in two ways.
588 * b. Non-blocking rcfw command send. In this path, driver can hold the
590 * for completion because of non-blocking nature.
594 * is not optimal for rcfw command processing in firmware.
596 * Restrict at max 64 Non-Blocking rcfw commands.
597 * Do not allow more than 64 non-blocking command to the Firmware.
601 * 0 if command completed by firmware.
602 * Non zero if the command is not completed by firmware.
609 if (!msg->block) { in bnxt_qplib_rcfw_send_message()
610 down(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
612 up(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
626 latency_msec = jiffies_to_msecs(rcfw->cmdq.last_seen - in bnxt_re_add_perf_stats()
627 crsqe->send_timestamp); in bnxt_re_add_perf_stats()
629 rcfw->rcfw_lat_slab_sec[latency_msec/1000]++; in bnxt_re_add_perf_stats()
631 if (!rcfw->sp_perf_stats_enabled) in bnxt_re_add_perf_stats()
635 rcfw->rcfw_lat_slab_msec[latency_msec]++; in bnxt_re_add_perf_stats()
637 switch (crsqe->opcode) { in bnxt_re_add_perf_stats()
639 dest_stats_id = rcfw->qp_create_stats_id++; in bnxt_re_add_perf_stats()
641 dest_stats_ptr = &rcfw->qp_create_stats[dest_stats_id]; in bnxt_re_add_perf_stats()
644 dest_stats_id = rcfw->qp_destroy_stats_id++; in bnxt_re_add_perf_stats()
646 dest_stats_ptr = &rcfw->qp_destroy_stats[dest_stats_id]; in bnxt_re_add_perf_stats()
649 dest_stats_id = rcfw->mr_create_stats_id++; in bnxt_re_add_perf_stats()
651 dest_stats_ptr = &rcfw->mr_create_stats[dest_stats_id]; in bnxt_re_add_perf_stats()
655 dest_stats_id = rcfw->mr_destroy_stats_id++; in bnxt_re_add_perf_stats()
657 dest_stats_ptr = &rcfw->mr_destroy_stats[dest_stats_id]; in bnxt_re_add_perf_stats()
660 if (crsqe->requested_qp_state != IB_QPS_ERR) in bnxt_re_add_perf_stats()
662 dest_stats_id = rcfw->qp_modify_stats_id++; in bnxt_re_add_perf_stats()
664 dest_stats_ptr = &rcfw->qp_modify_stats[dest_stats_id]; in bnxt_re_add_perf_stats()
671 (rcfw->cmdq.last_seen - crsqe->send_timestamp), 1); in bnxt_re_add_perf_stats()
680 struct bnxt_qplib_hwq *cmdq_hwq = &rcfw->cmdq.hwq; in bnxt_qplib_process_qp_event()
696 pdev = rcfw->pdev; in bnxt_qplib_process_qp_event()
697 switch (event->event) { in bnxt_qplib_process_qp_event()
699 tbl = &rcfw->res->reftbl.qpref; in bnxt_qplib_process_qp_event()
701 xid = le32_to_cpu(qperr->xid); in bnxt_qplib_process_qp_event()
703 spin_lock(&tbl->lock); in bnxt_qplib_process_qp_event()
704 qp = tbl->rec[qp_idx].handle; in bnxt_qplib_process_qp_event()
706 spin_unlock(&tbl->lock); in bnxt_qplib_process_qp_event()
710 rc = rcfw->creq.aeq_handler(rcfw, event, qp); in bnxt_qplib_process_qp_event()
711 spin_unlock(&tbl->lock); in bnxt_qplib_process_qp_event()
716 dev_dbg(&pdev->dev, "QPLIB: QP Error encountered!\n"); in bnxt_qplib_process_qp_event()
717 dev_dbg(&pdev->dev, in bnxt_qplib_process_qp_event()
719 xid, qperr->req_err_state_reason, in bnxt_qplib_process_qp_event()
720 qperr->res_err_state_reason); in bnxt_qplib_process_qp_event()
723 tbl = &rcfw->res->reftbl.cqref; in bnxt_qplib_process_qp_event()
725 xid = le32_to_cpu(cqerr->xid); in bnxt_qplib_process_qp_event()
726 spin_lock(&tbl->lock); in bnxt_qplib_process_qp_event()
727 cq = tbl->rec[GET_TBL_INDEX(xid, tbl)].handle; in bnxt_qplib_process_qp_event()
729 spin_unlock(&tbl->lock); in bnxt_qplib_process_qp_event()
732 rc = rcfw->creq.aeq_handler(rcfw, event, cq); in bnxt_qplib_process_qp_event()
733 spin_unlock(&tbl->lock); in bnxt_qplib_process_qp_event()
734 dev_dbg(&pdev->dev, "QPLIB: CQ error encountered!\n"); in bnxt_qplib_process_qp_event()
745 spin_lock_irqsave_nested(&cmdq_hwq->lock, flags, in bnxt_qplib_process_qp_event()
747 cookie = le16_to_cpu(event->cookie); in bnxt_qplib_process_qp_event()
751 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_qplib_process_qp_event()
756 &rcfw->cmdq.flags), in bnxt_qplib_process_qp_event()
758 dev_info(&pdev->dev, "rcfw timedout: cookie = %#x," in bnxt_qplib_process_qp_event()
760 (long)jiffies_to_msecs(rcfw->cmdq.last_seen - in bnxt_qplib_process_qp_event()
761 crsqe->send_timestamp), in bnxt_qplib_process_qp_event()
762 crsqe->free_slots); in bnxt_qplib_process_qp_event()
763 spin_unlock_irqrestore(&cmdq_hwq->lock, flags); in bnxt_qplib_process_qp_event()
767 if (crsqe->is_internal_cmd && !event->status) in bnxt_qplib_process_qp_event()
768 atomic_dec(&rcfw->timeout_send); in bnxt_qplib_process_qp_event()
770 if (crsqe->is_waiter_alive) { in bnxt_qplib_process_qp_event()
771 if (crsqe->resp) in bnxt_qplib_process_qp_event()
772 memcpy(crsqe->resp, event, sizeof(*event)); in bnxt_qplib_process_qp_event()
777 req_size = crsqe->req_size; in bnxt_qplib_process_qp_event()
778 is_waiter_alive = crsqe->is_waiter_alive; in bnxt_qplib_process_qp_event()
780 crsqe->req_size = 0; in bnxt_qplib_process_qp_event()
781 if (!crsqe->is_waiter_alive) in bnxt_qplib_process_qp_event()
782 crsqe->resp = NULL; in bnxt_qplib_process_qp_event()
783 crsqe->is_in_used = false; in bnxt_qplib_process_qp_event()
786 * It is safe since we are still holding cmdq_hwq->lock. in bnxt_qplib_process_qp_event()
788 cmdq_hwq->cons += req_size; in bnxt_qplib_process_qp_event()
790 /* This is a case to handle below scenario - in bnxt_qplib_process_qp_event()
791 * Create AH is completed successfully by firmware, in bnxt_qplib_process_qp_event()
798 * If destroy_ah is failued by firmware, there will be AH in bnxt_qplib_process_qp_event()
802 if (!is_waiter_alive && !event->status && in bnxt_qplib_process_qp_event()
803 event->event == CREQ_QP_EVENT_EVENT_CREATE_AH) in bnxt_qplib_process_qp_event()
808 spin_unlock_irqrestore(&cmdq_hwq->lock, flags); in bnxt_qplib_process_qp_event()
814 /* SP - CREQ Completion handlers */
818 struct bnxt_qplib_creq_ctx *creq = &rcfw->creq; in bnxt_qplib_service_creq()
821 struct bnxt_qplib_hwq *creq_hwq = &creq->hwq; in bnxt_qplib_service_creq()
828 pdev = rcfw->pdev; in bnxt_qplib_service_creq()
829 res = rcfw->res; in bnxt_qplib_service_creq()
831 spin_lock_irqsave(&creq_hwq->lock, flags); in bnxt_qplib_service_creq()
834 spin_unlock_irqrestore(&creq_hwq->lock, flags); in bnxt_qplib_service_creq()
837 creqe = bnxt_qplib_get_qe(creq_hwq, creq_hwq->cons, NULL); in bnxt_qplib_service_creq()
838 if (!CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags)) in bnxt_qplib_service_creq()
844 type = creqe->type & CREQ_BASE_TYPE_MASK; in bnxt_qplib_service_creq()
845 rcfw->cmdq.last_seen = jiffies; in bnxt_qplib_service_creq()
852 creq->stats.creq_qp_event_processed++; in bnxt_qplib_service_creq()
855 rc = rcfw->creq.aeq_handler(rcfw, creqe, NULL); in bnxt_qplib_service_creq()
857 dev_warn(&pdev->dev, in bnxt_qplib_service_creq()
860 creq->stats.creq_func_event_processed++; in bnxt_qplib_service_creq()
864 dev_warn(&pdev->dev, in bnxt_qplib_service_creq()
870 budget--; in bnxt_qplib_service_creq()
871 bnxt_qplib_hwq_incr_cons(creq_hwq->max_elements, &creq_hwq->cons, in bnxt_qplib_service_creq()
872 1, &creq->creq_db.dbinfo.flags); in bnxt_qplib_service_creq()
875 !CREQ_CMP_VALID(creqe, creq->creq_db.dbinfo.flags)) { in bnxt_qplib_service_creq()
877 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true); in bnxt_qplib_service_creq()
878 creq->stats.creq_arm_count++; in bnxt_qplib_service_creq()
879 dev_dbg(&pdev->dev, "QPLIB: Num of Func (0x%llx) \n", in bnxt_qplib_service_creq()
880 creq->stats.creq_func_event_processed); in bnxt_qplib_service_creq()
881 dev_dbg(&pdev->dev, "QPLIB: QP (0x%llx) events processed\n", in bnxt_qplib_service_creq()
882 creq->stats.creq_qp_event_processed); in bnxt_qplib_service_creq()
883 dev_dbg(&pdev->dev, "QPLIB: Armed:%#llx resched:%#llx \n", in bnxt_qplib_service_creq()
884 creq->stats.creq_arm_count, in bnxt_qplib_service_creq()
885 creq->stats.creq_tasklet_schedule_count); in bnxt_qplib_service_creq()
886 } else if (creq->requested) { in bnxt_qplib_service_creq()
892 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true); in bnxt_qplib_service_creq()
893 creq->stats.creq_tasklet_schedule_count++; in bnxt_qplib_service_creq()
895 spin_unlock_irqrestore(&creq_hwq->lock, flags); in bnxt_qplib_service_creq()
897 wake_up_all(&rcfw->cmdq.waitq); in bnxt_qplib_service_creq()
923 clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_deinit_rcfw()
938 res = rcfw->res; in bnxt_qplib_init_rcfw()
939 cctx = res->cctx; in bnxt_qplib_init_rcfw()
940 hctx = res->hctx; in bnxt_qplib_init_rcfw()
944 /* Supply (log-base-2-of-host-page-size - base-page-shift) in bnxt_qplib_init_rcfw()
947 req.log2_dbr_pg_size = cpu_to_le16(PAGE_SHIFT - in bnxt_qplib_init_rcfw()
957 hwq = &hctx->qp_ctx.hwq; in bnxt_qplib_init_rcfw()
959 req.number_of_qp = cpu_to_le32(hwq->max_elements); in bnxt_qplib_init_rcfw()
962 (u8)hwq->level; in bnxt_qplib_init_rcfw()
964 hwq = &hctx->mrw_ctx.hwq; in bnxt_qplib_init_rcfw()
966 req.number_of_mrw = cpu_to_le32(hwq->max_elements); in bnxt_qplib_init_rcfw()
969 (u8)hwq->level; in bnxt_qplib_init_rcfw()
971 hwq = &hctx->srq_ctx.hwq; in bnxt_qplib_init_rcfw()
973 req.number_of_srq = cpu_to_le32(hwq->max_elements); in bnxt_qplib_init_rcfw()
976 (u8)hwq->level; in bnxt_qplib_init_rcfw()
978 hwq = &hctx->cq_ctx.hwq; in bnxt_qplib_init_rcfw()
980 req.number_of_cq = cpu_to_le32(hwq->max_elements); in bnxt_qplib_init_rcfw()
983 (u8)hwq->level; in bnxt_qplib_init_rcfw()
985 hwq = &hctx->tim_ctx.hwq; in bnxt_qplib_init_rcfw()
989 (u8)hwq->level; in bnxt_qplib_init_rcfw()
990 hwq = &hctx->tqm_ctx.pde; in bnxt_qplib_init_rcfw()
994 (u8)hwq->level; in bnxt_qplib_init_rcfw()
996 if (BNXT_RE_HW_RETX(res->dattr->dev_cap_flags)) in bnxt_qplib_init_rcfw()
998 req.stat_ctx_id = cpu_to_le32(hctx->stats.fw_id); in bnxt_qplib_init_rcfw()
1004 set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_init_rcfw()
1011 struct bnxt_qplib_rcfw *rcfw = res->rcfw; in bnxt_qplib_free_rcfw_channel()
1013 vfree(rcfw->rcfw_lat_slab_msec); in bnxt_qplib_free_rcfw_channel()
1014 rcfw->rcfw_lat_slab_msec = NULL; in bnxt_qplib_free_rcfw_channel()
1015 vfree(rcfw->qp_create_stats); in bnxt_qplib_free_rcfw_channel()
1016 rcfw->qp_create_stats = NULL; in bnxt_qplib_free_rcfw_channel()
1017 vfree(rcfw->qp_destroy_stats); in bnxt_qplib_free_rcfw_channel()
1018 rcfw->qp_destroy_stats = NULL; in bnxt_qplib_free_rcfw_channel()
1019 vfree(rcfw->mr_create_stats); in bnxt_qplib_free_rcfw_channel()
1020 rcfw->mr_create_stats = NULL; in bnxt_qplib_free_rcfw_channel()
1021 vfree(rcfw->mr_destroy_stats); in bnxt_qplib_free_rcfw_channel()
1022 rcfw->mr_destroy_stats = NULL; in bnxt_qplib_free_rcfw_channel()
1023 vfree(rcfw->qp_modify_stats); in bnxt_qplib_free_rcfw_channel()
1024 rcfw->qp_modify_stats = NULL; in bnxt_qplib_free_rcfw_channel()
1025 rcfw->sp_perf_stats_enabled = false; in bnxt_qplib_free_rcfw_channel()
1027 kfree(rcfw->crsqe_tbl); in bnxt_qplib_free_rcfw_channel()
1028 rcfw->crsqe_tbl = NULL; in bnxt_qplib_free_rcfw_channel()
1030 bnxt_qplib_free_hwq(res, &rcfw->cmdq.hwq); in bnxt_qplib_free_rcfw_channel()
1031 bnxt_qplib_free_hwq(res, &rcfw->creq.hwq); in bnxt_qplib_free_rcfw_channel()
1032 rcfw->pdev = NULL; in bnxt_qplib_free_rcfw_channel()
1038 struct bnxt_qplib_rcfw *rcfw = res->rcfw; in bnxt_qplib_alloc_rcfw_channel()
1043 rcfw->pdev = res->pdev; in bnxt_qplib_alloc_rcfw_channel()
1044 rcfw->res = res; in bnxt_qplib_alloc_rcfw_channel()
1045 cmdq = &rcfw->cmdq; in bnxt_qplib_alloc_rcfw_channel()
1046 creq = &rcfw->creq; in bnxt_qplib_alloc_rcfw_channel()
1052 hwq_attr.res = rcfw->res; in bnxt_qplib_alloc_rcfw_channel()
1057 if (bnxt_qplib_alloc_init_hwq(&creq->hwq, &hwq_attr)) { in bnxt_qplib_alloc_rcfw_channel()
1058 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
1060 return -ENOMEM; in bnxt_qplib_alloc_rcfw_channel()
1067 if (bnxt_qplib_alloc_init_hwq(&cmdq->hwq, &hwq_attr)) { in bnxt_qplib_alloc_rcfw_channel()
1068 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
1073 rcfw->crsqe_tbl = kcalloc(cmdq->hwq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
1074 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL); in bnxt_qplib_alloc_rcfw_channel()
1075 if (!rcfw->crsqe_tbl) { in bnxt_qplib_alloc_rcfw_channel()
1076 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
1081 rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout; in bnxt_qplib_alloc_rcfw_channel()
1083 rcfw->sp_perf_stats_enabled = false; in bnxt_qplib_alloc_rcfw_channel()
1084 rcfw->rcfw_lat_slab_msec = vzalloc(sizeof(u32) * in bnxt_qplib_alloc_rcfw_channel()
1086 rcfw->qp_create_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX); in bnxt_qplib_alloc_rcfw_channel()
1087 rcfw->qp_destroy_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX); in bnxt_qplib_alloc_rcfw_channel()
1088 rcfw->mr_create_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX); in bnxt_qplib_alloc_rcfw_channel()
1089 rcfw->mr_destroy_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX); in bnxt_qplib_alloc_rcfw_channel()
1090 rcfw->qp_modify_stats = vzalloc(sizeof(u64) * RCFW_MAX_STAT_INDEX); in bnxt_qplib_alloc_rcfw_channel()
1092 if (rcfw->rcfw_lat_slab_msec && in bnxt_qplib_alloc_rcfw_channel()
1093 rcfw->qp_create_stats && in bnxt_qplib_alloc_rcfw_channel()
1094 rcfw->qp_destroy_stats && in bnxt_qplib_alloc_rcfw_channel()
1095 rcfw->mr_create_stats && in bnxt_qplib_alloc_rcfw_channel()
1096 rcfw->mr_destroy_stats && in bnxt_qplib_alloc_rcfw_channel()
1097 rcfw->qp_modify_stats) in bnxt_qplib_alloc_rcfw_channel()
1098 rcfw->sp_perf_stats_enabled = true; in bnxt_qplib_alloc_rcfw_channel()
1102 bnxt_qplib_free_hwq(res, &rcfw->cmdq.hwq); in bnxt_qplib_alloc_rcfw_channel()
1104 bnxt_qplib_free_hwq(res, &rcfw->creq.hwq); in bnxt_qplib_alloc_rcfw_channel()
1105 return -ENOMEM; in bnxt_qplib_alloc_rcfw_channel()
1113 creq = &rcfw->creq; in bnxt_qplib_rcfw_stop_irq()
1114 res = rcfw->res; in bnxt_qplib_rcfw_stop_irq()
1116 if (!creq->requested) in bnxt_qplib_rcfw_stop_irq()
1119 creq->requested = false; in bnxt_qplib_rcfw_stop_irq()
1121 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, false); in bnxt_qplib_rcfw_stop_irq()
1122 /* Sync with last running IRQ-handler */ in bnxt_qplib_rcfw_stop_irq()
1123 synchronize_irq(creq->msix_vec); in bnxt_qplib_rcfw_stop_irq()
1124 free_irq(creq->msix_vec, rcfw); in bnxt_qplib_rcfw_stop_irq()
1125 kfree(creq->irq_name); in bnxt_qplib_rcfw_stop_irq()
1126 creq->irq_name = NULL; in bnxt_qplib_rcfw_stop_irq()
1130 if (atomic_read(&rcfw->rcfw_intr_enabled) > 1) { in bnxt_qplib_rcfw_stop_irq()
1131 dev_err(&rcfw->pdev->dev, in bnxt_qplib_rcfw_stop_irq()
1132 "%s: rcfw->rcfw_intr_enabled = 0x%x\n", __func__, in bnxt_qplib_rcfw_stop_irq()
1133 atomic_read(&rcfw->rcfw_intr_enabled)); in bnxt_qplib_rcfw_stop_irq()
1135 atomic_set(&rcfw->rcfw_intr_enabled, 0); in bnxt_qplib_rcfw_stop_irq()
1136 rcfw->num_irq_stopped++; in bnxt_qplib_rcfw_stop_irq()
1144 creq = &rcfw->creq; in bnxt_qplib_disable_rcfw_channel()
1145 cmdq = &rcfw->cmdq; in bnxt_qplib_disable_rcfw_channel()
1149 creq->creq_db.reg.bar_reg = NULL; in bnxt_qplib_disable_rcfw_channel()
1150 creq->creq_db.db = NULL; in bnxt_qplib_disable_rcfw_channel()
1152 if (cmdq->cmdq_mbox.reg.bar_reg) { in bnxt_qplib_disable_rcfw_channel()
1153 iounmap(cmdq->cmdq_mbox.reg.bar_reg); in bnxt_qplib_disable_rcfw_channel()
1154 cmdq->cmdq_mbox.reg.bar_reg = NULL; in bnxt_qplib_disable_rcfw_channel()
1155 cmdq->cmdq_mbox.prod = NULL; in bnxt_qplib_disable_rcfw_channel()
1156 cmdq->cmdq_mbox.db = NULL; in bnxt_qplib_disable_rcfw_channel()
1159 creq->aeq_handler = NULL; in bnxt_qplib_disable_rcfw_channel()
1160 creq->msix_vec = 0; in bnxt_qplib_disable_rcfw_channel()
1170 creq = &rcfw->creq; in bnxt_qplib_rcfw_start_irq()
1171 res = rcfw->res; in bnxt_qplib_rcfw_start_irq()
1173 if (creq->requested) in bnxt_qplib_rcfw_start_irq()
1174 return -EFAULT; in bnxt_qplib_rcfw_start_irq()
1176 creq->msix_vec = msix_vector; in bnxt_qplib_rcfw_start_irq()
1178 creq->irq_name = kasprintf(GFP_KERNEL, "bnxt_re-creq@pci:%s\n", in bnxt_qplib_rcfw_start_irq()
1179 pci_name(res->pdev)); in bnxt_qplib_rcfw_start_irq()
1180 if (!creq->irq_name) in bnxt_qplib_rcfw_start_irq()
1181 return -ENOMEM; in bnxt_qplib_rcfw_start_irq()
1183 rc = request_irq(creq->msix_vec, bnxt_qplib_creq_irq, 0, in bnxt_qplib_rcfw_start_irq()
1184 creq->irq_name, rcfw); in bnxt_qplib_rcfw_start_irq()
1186 kfree(creq->irq_name); in bnxt_qplib_rcfw_start_irq()
1187 creq->irq_name = NULL; in bnxt_qplib_rcfw_start_irq()
1190 creq->requested = true; in bnxt_qplib_rcfw_start_irq()
1192 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, res->cctx, true); in bnxt_qplib_rcfw_start_irq()
1194 rcfw->num_irq_started++; in bnxt_qplib_rcfw_start_irq()
1198 if (atomic_read(&rcfw->rcfw_intr_enabled) > 0) { in bnxt_qplib_rcfw_start_irq()
1199 dev_err(&rcfw->pdev->dev, in bnxt_qplib_rcfw_start_irq()
1200 "%s: rcfw->rcfw_intr_enabled = 0x%x\n", __func__, in bnxt_qplib_rcfw_start_irq()
1201 atomic_read(&rcfw->rcfw_intr_enabled)); in bnxt_qplib_rcfw_start_irq()
1203 atomic_inc(&rcfw->rcfw_intr_enabled); in bnxt_qplib_rcfw_start_irq()
1213 pdev = rcfw->pdev; in bnxt_qplib_map_cmdq_mbox()
1214 mbox = &rcfw->cmdq.cmdq_mbox; in bnxt_qplib_map_cmdq_mbox()
1216 mbox->reg.bar_id = RCFW_COMM_PCI_BAR_REGION; in bnxt_qplib_map_cmdq_mbox()
1217 mbox->reg.len = RCFW_COMM_SIZE; in bnxt_qplib_map_cmdq_mbox()
1218 mbox->reg.bar_base = pci_resource_start(pdev, mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1219 if (!mbox->reg.bar_base) { in bnxt_qplib_map_cmdq_mbox()
1220 dev_err(&pdev->dev, in bnxt_qplib_map_cmdq_mbox()
1222 mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1223 return -ENOMEM; in bnxt_qplib_map_cmdq_mbox()
1226 bar_reg = mbox->reg.bar_base + RCFW_COMM_BASE_OFFSET; in bnxt_qplib_map_cmdq_mbox()
1227 mbox->reg.len = RCFW_COMM_SIZE; in bnxt_qplib_map_cmdq_mbox()
1228 mbox->reg.bar_reg = ioremap(bar_reg, mbox->reg.len); in bnxt_qplib_map_cmdq_mbox()
1229 if (!mbox->reg.bar_reg) { in bnxt_qplib_map_cmdq_mbox()
1230 dev_err(&pdev->dev, in bnxt_qplib_map_cmdq_mbox()
1232 mbox->reg.bar_id); in bnxt_qplib_map_cmdq_mbox()
1233 return -ENOMEM; in bnxt_qplib_map_cmdq_mbox()
1236 mbox->prod = (void __iomem *)((char *)mbox->reg.bar_reg + in bnxt_qplib_map_cmdq_mbox()
1238 mbox->db = (void __iomem *)((char *)mbox->reg.bar_reg + in bnxt_qplib_map_cmdq_mbox()
1249 res = rcfw->res; in bnxt_qplib_map_creq_db()
1250 creq_db = &rcfw->creq.creq_db; in bnxt_qplib_map_creq_db()
1251 dbreg = &res->dpi_tbl.ucreg; in bnxt_qplib_map_creq_db()
1253 creq_db->reg.bar_id = dbreg->bar_id; in bnxt_qplib_map_creq_db()
1254 creq_db->reg.bar_base = dbreg->bar_base; in bnxt_qplib_map_creq_db()
1255 creq_db->reg.bar_reg = dbreg->bar_reg + reg_offt; in bnxt_qplib_map_creq_db()
1256 creq_db->reg.len = _is_chip_gen_p5_p7(res->cctx) ? sizeof(u64) : in bnxt_qplib_map_creq_db()
1259 creq_db->dbinfo.db = creq_db->reg.bar_reg; in bnxt_qplib_map_creq_db()
1260 creq_db->dbinfo.hwq = &rcfw->creq.hwq; in bnxt_qplib_map_creq_db()
1261 creq_db->dbinfo.xid = rcfw->creq.ring_id; in bnxt_qplib_map_creq_db()
1262 creq_db->dbinfo.seed = rcfw->creq.ring_id; in bnxt_qplib_map_creq_db()
1263 creq_db->dbinfo.flags = 0; in bnxt_qplib_map_creq_db()
1264 spin_lock_init(&creq_db->dbinfo.lock); in bnxt_qplib_map_creq_db()
1265 creq_db->dbinfo.shadow_key = BNXT_QPLIB_DBR_KEY_INVALID; in bnxt_qplib_map_creq_db()
1266 creq_db->dbinfo.res = rcfw->res; in bnxt_qplib_map_creq_db()
1278 cmdq = &rcfw->cmdq; in bnxt_qplib_start_rcfw()
1279 creq = &rcfw->creq; in bnxt_qplib_start_rcfw()
1280 mbox = &cmdq->cmdq_mbox; in bnxt_qplib_start_rcfw()
1282 init.cmdq_pbl = cpu_to_le64(cmdq->hwq.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_start_rcfw()
1286 ((cmdq->hwq.level << CMDQ_INIT_CMDQ_LVL_SFT) & in bnxt_qplib_start_rcfw()
1288 init.creq_ring_id = cpu_to_le16(creq->ring_id); in bnxt_qplib_start_rcfw()
1290 __iowrite32_copy(mbox->reg.bar_reg, &init, sizeof(init) / 4); in bnxt_qplib_start_rcfw()
1302 cmdq = &rcfw->cmdq; in bnxt_qplib_enable_rcfw_channel()
1303 creq = &rcfw->creq; in bnxt_qplib_enable_rcfw_channel()
1306 cmdq->seq_num = 0; in bnxt_qplib_enable_rcfw_channel()
1307 set_bit(FIRMWARE_FIRST_FLAG, &cmdq->flags); in bnxt_qplib_enable_rcfw_channel()
1308 init_waitqueue_head(&cmdq->waitq); in bnxt_qplib_enable_rcfw_channel()
1310 creq->stats.creq_qp_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
1311 creq->stats.creq_func_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
1312 creq->aeq_handler = aeq_handler; in bnxt_qplib_enable_rcfw_channel()
1324 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
1330 rcfw->curr_shadow_qd = min_not_zero(cmdq_shadow_qd, in bnxt_qplib_enable_rcfw_channel()
1332 sema_init(&rcfw->rcfw_inflight, rcfw->curr_shadow_qd); in bnxt_qplib_enable_rcfw_channel()
1333 dev_dbg(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
1334 "Perf Debug: shadow qd %d\n", rcfw->curr_shadow_qd); in bnxt_qplib_enable_rcfw_channel()