Lines Matching defs:cmdq

78 #define cmdq_to_cmdqs(cmdq)     container_of((cmdq) - (cmdq)->cmdq_type, \
79 struct hinic_cmdqs, cmdq[0])
320 static void cmdq_set_db(struct hinic_cmdq *cmdq,
332 writel(db_info, CMDQ_DB_ADDR(cmdq->db_base, prod_idx));
335 static int cmdq_sync_cmd_direct_resp(struct hinic_cmdq *cmdq,
343 struct hinic_wq *wq = cmdq->wq;
348 spin_lock_bh(&cmdq->cmdq_lock);
353 spin_unlock_bh(&cmdq->cmdq_lock);
359 wrapped = cmdq->wrapped;
364 cmdq->wrapped = !cmdq->wrapped;
368 cmdq->errcode[curr_prod_idx] = &errcode;
371 cmdq->done[curr_prod_idx] = &done;
383 cmdq_set_db(cmdq, HINIC_CMDQ_SYNC, next_prod_idx);
385 spin_unlock_bh(&cmdq->cmdq_lock);
389 spin_lock_bh(&cmdq->cmdq_lock);
391 if (cmdq->errcode[curr_prod_idx] == &errcode)
392 cmdq->errcode[curr_prod_idx] = NULL;
394 if (cmdq->done[curr_prod_idx] == &done)
395 cmdq->done[curr_prod_idx] = NULL;
397 spin_unlock_bh(&cmdq->cmdq_lock);
399 hinic_dump_ceq_info(cmdq->hwdev);
417 static int cmdq_set_arm_bit(struct hinic_cmdq *cmdq, void *buf_in,
422 struct hinic_wq *wq = cmdq->wq;
427 spin_lock(&cmdq->cmdq_lock);
432 spin_unlock(&cmdq->cmdq_lock);
438 wrapped = cmdq->wrapped;
443 cmdq->wrapped = !cmdq->wrapped;
454 /* cmdq wqe is not shadow, therefore wqe will be written to wq */
457 cmdq_set_db(cmdq, HINIC_CMDQ_SYNC, next_prod_idx);
459 spin_unlock(&cmdq->cmdq_lock);
495 return cmdq_sync_cmd_direct_resp(&cmdqs->cmdq[HINIC_CMDQ_SYNC],
510 struct hinic_cmdq *cmdq = &cmdqs->cmdq[HINIC_CMDQ_SYNC];
519 err = cmdq_set_arm_bit(cmdq, &arm_bit, sizeof(arm_bit));
528 static void clear_wqe_complete_bit(struct hinic_cmdq *cmdq,
556 * cmdq_arm_ceq_handler - cmdq completion event handler for arm command
557 * @cmdq: the cmdq of the arm command
562 static int cmdq_arm_ceq_handler(struct hinic_cmdq *cmdq,
578 clear_wqe_complete_bit(cmdq, wqe);
580 hinic_put_wqe(cmdq->wq, WQE_SCMD_SIZE);
584 static void cmdq_update_errcode(struct hinic_cmdq *cmdq, u16 prod_idx,
587 if (cmdq->errcode[prod_idx])
588 *cmdq->errcode[prod_idx] = errcode;
592 * cmdq_sync_cmd_handler - cmdq completion event handler for sync command
593 * @cmdq: the cmdq of the command
597 static void cmdq_sync_cmd_handler(struct hinic_cmdq *cmdq, u16 cons_idx,
602 spin_lock(&cmdq->cmdq_lock);
603 cmdq_update_errcode(cmdq, prod_idx, errcode);
607 if (cmdq->done[prod_idx])
608 complete(cmdq->done[prod_idx]);
609 spin_unlock(&cmdq->cmdq_lock);
612 static int cmdq_cmd_ceq_handler(struct hinic_cmdq *cmdq, u16 ci,
627 cmdq_sync_cmd_handler(cmdq, ci, errcode);
629 clear_wqe_complete_bit(cmdq, cmdq_wqe);
630 hinic_put_wqe(cmdq->wq, WQE_LCMD_SIZE);
635 * cmdq_ceq_handler - cmdq completion event handler
643 struct hinic_cmdq *cmdq = &cmdqs->cmdq[cmdq_type];
651 while ((hw_wqe = hinic_read_wqe(cmdq->wq, WQE_SCMD_SIZE, &ci))) {
662 if (cmdq_arm_ceq_handler(cmdq, &hw_wqe->cmdq_wqe))
667 hw_wqe = hinic_read_wqe(cmdq->wq, WQE_LCMD_SIZE, &ci);
671 if (cmdq_cmd_ceq_handler(cmdq, ci, &hw_wqe->cmdq_wqe))
687 * cmdq_init_queue_ctxt - init the queue ctxt of a cmdq
688 * @cmdq_ctxt: cmdq ctxt to initialize
689 * @cmdq: the cmdq
693 struct hinic_cmdq *cmdq,
698 struct hinic_cmdqs *cmdqs = cmdq_to_cmdqs(cmdq);
699 struct hinic_wq *wq = cmdq->wq;
711 HINIC_CMDQ_CTXT_PAGE_INFO_SET(cmdq->wrapped, WRAPPED);
726 cmdq_ctxt->cmdq_type = cmdq->cmdq_type;
730 * init_cmdq - initialize cmdq
731 * @cmdq: the cmdq
732 * @wq: the wq attaced to the cmdq
733 * @q_type: the cmdq type of the cmdq
734 * @db_area: doorbell area for the cmdq
738 static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_wq *wq,
743 cmdq->wq = wq;
744 cmdq->cmdq_type = q_type;
745 cmdq->wrapped = 1;
747 spin_lock_init(&cmdq->cmdq_lock);
749 cmdq->done = vzalloc(array_size(sizeof(*cmdq->done), wq->q_depth));
750 if (!cmdq->done)
753 cmdq->errcode = vzalloc(array_size(sizeof(*cmdq->errcode),
755 if (!cmdq->errcode) {
760 cmdq->db_base = db_area + CMDQ_DB_OFF;
764 vfree(cmdq->done);
769 * free_cmdq - Free cmdq
770 * @cmdq: the cmdq to free
772 static void free_cmdq(struct hinic_cmdq *cmdq)
774 vfree(cmdq->errcode);
775 vfree(cmdq->done);
779 * init_cmdqs_ctxt - write the cmdq ctxt to HW after init all cmdq
805 cmdqs->cmdq[cmdq_type].hwdev = hwdev;
806 err = init_cmdq(&cmdqs->cmdq[cmdq_type],
810 dev_err(&pdev->dev, "Failed to initialize cmdq\n");
815 &cmdqs->cmdq[cmdq_type],
842 free_cmdq(&cmdqs->cmdq[type]);
910 dev_err(&pdev->dev, "Failed to write cmdq ctxt\n");
919 dev_err(&hwif->pdev->dev, "Failed to set cmdq depth\n");
927 free_cmdq(&cmdqs->cmdq[HINIC_CMDQ_SYNC]);
955 free_cmdq(&cmdqs->cmdq[cmdq_type]);