• Home
  • Raw
  • Download

Lines Matching full:qm

42 	int (*dump_fn)(struct hisi_qm *qm, char *cmd, char *info_name);
86 /* define the QM's dfx regs region and region length */
122 static void dump_show(struct hisi_qm *qm, void *info, in dump_show() argument
125 struct device *dev = &qm->pdev->dev; in dump_show()
137 static int qm_sqc_dump(struct hisi_qm *qm, char *s, char *name) in qm_sqc_dump() argument
139 struct device *dev = &qm->pdev->dev; in qm_sqc_dump()
149 if (ret || qp_id >= qm->qp_num) { in qm_sqc_dump()
150 dev_err(dev, "Please input qp num (0-%u)", qm->qp_num - 1); in qm_sqc_dump()
154 sqc = hisi_qm_ctx_alloc(qm, sizeof(*sqc), &sqc_dma); in qm_sqc_dump()
158 ret = hisi_qm_mb(qm, QM_MB_CMD_SQC, sqc_dma, qp_id, 1); in qm_sqc_dump()
160 down_read(&qm->qps_lock); in qm_sqc_dump()
161 if (qm->sqc) { in qm_sqc_dump()
162 sqc_curr = qm->sqc + qp_id; in qm_sqc_dump()
164 dump_show(qm, sqc_curr, sizeof(*sqc), "SOFT SQC"); in qm_sqc_dump()
166 up_read(&qm->qps_lock); in qm_sqc_dump()
171 dump_show(qm, sqc, sizeof(*sqc), name); in qm_sqc_dump()
174 hisi_qm_ctx_free(qm, sizeof(*sqc), sqc, &sqc_dma); in qm_sqc_dump()
178 static int qm_cqc_dump(struct hisi_qm *qm, char *s, char *name) in qm_cqc_dump() argument
180 struct device *dev = &qm->pdev->dev; in qm_cqc_dump()
190 if (ret || qp_id >= qm->qp_num) { in qm_cqc_dump()
191 dev_err(dev, "Please input qp num (0-%u)", qm->qp_num - 1); in qm_cqc_dump()
195 cqc = hisi_qm_ctx_alloc(qm, sizeof(*cqc), &cqc_dma); in qm_cqc_dump()
199 ret = hisi_qm_mb(qm, QM_MB_CMD_CQC, cqc_dma, qp_id, 1); in qm_cqc_dump()
201 down_read(&qm->qps_lock); in qm_cqc_dump()
202 if (qm->cqc) { in qm_cqc_dump()
203 cqc_curr = qm->cqc + qp_id; in qm_cqc_dump()
205 dump_show(qm, cqc_curr, sizeof(*cqc), "SOFT CQC"); in qm_cqc_dump()
207 up_read(&qm->qps_lock); in qm_cqc_dump()
212 dump_show(qm, cqc, sizeof(*cqc), name); in qm_cqc_dump()
215 hisi_qm_ctx_free(qm, sizeof(*cqc), cqc, &cqc_dma); in qm_cqc_dump()
219 static int qm_eqc_aeqc_dump(struct hisi_qm *qm, char *s, char *name) in qm_eqc_aeqc_dump() argument
221 struct device *dev = &qm->pdev->dev; in qm_eqc_aeqc_dump()
241 xeqc = hisi_qm_ctx_alloc(qm, size, &xeqc_dma); in qm_eqc_aeqc_dump()
245 ret = hisi_qm_mb(qm, cmd, xeqc_dma, 0, 1); in qm_eqc_aeqc_dump()
249 dump_show(qm, xeqc, size, name); in qm_eqc_aeqc_dump()
252 hisi_qm_ctx_free(qm, size, xeqc, &xeqc_dma); in qm_eqc_aeqc_dump()
256 static int q_dump_param_parse(struct hisi_qm *qm, char *s, in q_dump_param_parse() argument
259 struct device *dev = &qm->pdev->dev; in q_dump_param_parse()
260 unsigned int qp_num = qm->qp_num; in q_dump_param_parse()
296 static int qm_sq_dump(struct hisi_qm *qm, char *s, char *name) in qm_sq_dump() argument
298 u16 sq_depth = qm->qp_array->cq_depth; in qm_sq_dump()
304 ret = q_dump_param_parse(qm, s, &sqe_id, &qp_id, sq_depth); in qm_sq_dump()
308 sqe = kzalloc(qm->sqe_size * sq_depth, GFP_KERNEL); in qm_sq_dump()
312 qp = &qm->qp_array[qp_id]; in qm_sq_dump()
313 memcpy(sqe, qp->sqe, qm->sqe_size * sq_depth); in qm_sq_dump()
314 sqe_curr = sqe + (u32)(sqe_id * qm->sqe_size); in qm_sq_dump()
315 memset(sqe_curr + qm->debug.sqe_mask_offset, QM_SQE_ADDR_MASK, in qm_sq_dump()
316 qm->debug.sqe_mask_len); in qm_sq_dump()
318 dump_show(qm, sqe_curr, qm->sqe_size, name); in qm_sq_dump()
325 static int qm_cq_dump(struct hisi_qm *qm, char *s, char *name) in qm_cq_dump() argument
332 ret = q_dump_param_parse(qm, s, &cqe_id, &qp_id, qm->qp_array->cq_depth); in qm_cq_dump()
336 qp = &qm->qp_array[qp_id]; in qm_cq_dump()
338 dump_show(qm, cqe_curr, sizeof(struct qm_cqe), name); in qm_cq_dump()
343 static int qm_eq_aeq_dump(struct hisi_qm *qm, char *s, char *name) in qm_eq_aeq_dump() argument
345 struct device *dev = &qm->pdev->dev; in qm_eq_aeq_dump()
360 xeq_depth = qm->eq_depth; in qm_eq_aeq_dump()
363 xeq_depth = qm->aeq_depth; in qm_eq_aeq_dump()
372 down_read(&qm->qps_lock); in qm_eq_aeq_dump()
374 if (qm->eqe && !strcmp(name, "EQE")) { in qm_eq_aeq_dump()
375 xeqe = qm->eqe + xeqe_id; in qm_eq_aeq_dump()
376 } else if (qm->aeqe && !strcmp(name, "AEQE")) { in qm_eq_aeq_dump()
377 xeqe = qm->aeqe + xeqe_id; in qm_eq_aeq_dump()
383 dump_show(qm, xeqe, size, name); in qm_eq_aeq_dump()
386 up_read(&qm->qps_lock); in qm_eq_aeq_dump()
390 static int qm_dbg_help(struct hisi_qm *qm, char *s) in qm_dbg_help() argument
392 struct device *dev = &qm->pdev->dev; in qm_dbg_help()
448 static int qm_cmd_write_dump(struct hisi_qm *qm, const char *cmd_buf) in qm_cmd_write_dump() argument
450 struct device *dev = &qm->pdev->dev; in qm_cmd_write_dump()
466 ret = qm_dbg_help(qm, s); in qm_cmd_write_dump()
473 ret = qm_cmd_dump_table[i].dump_fn(qm, s, in qm_cmd_write_dump()
493 struct hisi_qm *qm = filp->private_data; in qm_cmd_write() local
500 ret = hisi_qm_get_dfx_access(qm); in qm_cmd_write()
505 if (unlikely(atomic_read(&qm->status.flags) == QM_STOP)) { in qm_cmd_write()
527 ret = qm_cmd_write_dump(qm, cmd_buf); in qm_cmd_write()
538 hisi_qm_put_dfx_access(qm); in qm_cmd_write()
559 struct hisi_qm *qm = pci_get_drvdata(pdev); in hisi_qm_regs_dump() local
565 ret = hisi_qm_get_dfx_access(qm); in hisi_qm_regs_dump()
574 hisi_qm_put_dfx_access(qm); in hisi_qm_regs_dump()
580 struct hisi_qm *qm = s->private; in qm_regs_show() local
583 if (qm->fun_type == QM_HW_PF) { in qm_regs_show()
591 regset.base = qm->io_base; in qm_regs_show()
592 regset.dev = &qm->pdev->dev; in qm_regs_show()
601 static u32 current_q_read(struct hisi_qm *qm) in current_q_read() argument
603 return readl(qm->io_base + QM_DFX_SQE_CNT_VF_SQN) >> QM_DFX_QN_SHIFT; in current_q_read()
606 static int current_q_write(struct hisi_qm *qm, u32 val) in current_q_write() argument
610 if (val >= qm->debug.curr_qm_qp_num) in current_q_write()
614 (readl(qm->io_base + QM_DFX_SQE_CNT_VF_SQN) & CURRENT_FUN_MASK); in current_q_write()
615 writel(tmp, qm->io_base + QM_DFX_SQE_CNT_VF_SQN); in current_q_write()
618 (readl(qm->io_base + QM_DFX_CQE_CNT_VF_CQN) & CURRENT_FUN_MASK); in current_q_write()
619 writel(tmp, qm->io_base + QM_DFX_CQE_CNT_VF_CQN); in current_q_write()
624 static u32 clear_enable_read(struct hisi_qm *qm) in clear_enable_read() argument
626 return readl(qm->io_base + QM_DFX_CNT_CLR_CE); in clear_enable_read()
630 static int clear_enable_write(struct hisi_qm *qm, u32 rd_clr_ctrl) in clear_enable_write() argument
635 writel(rd_clr_ctrl, qm->io_base + QM_DFX_CNT_CLR_CE); in clear_enable_write()
640 static u32 current_qm_read(struct hisi_qm *qm) in current_qm_read() argument
642 return readl(qm->io_base + QM_DFX_MB_CNT_VF); in current_qm_read()
645 static int qm_get_vf_qp_num(struct hisi_qm *qm, u32 fun_num) in qm_get_vf_qp_num() argument
648 u32 num_vfs = qm->vfs_num; in qm_get_vf_qp_num()
650 vfq_num = (qm->ctrl_qp_num - qm->qp_num) / num_vfs; in qm_get_vf_qp_num()
651 if (vfq_num >= qm->max_qp_num) in qm_get_vf_qp_num()
652 return qm->max_qp_num; in qm_get_vf_qp_num()
654 remain_q_num = (qm->ctrl_qp_num - qm->qp_num) % num_vfs; in qm_get_vf_qp_num()
655 if (vfq_num + remain_q_num <= qm->max_qp_num) in qm_get_vf_qp_num()
665 static int current_qm_write(struct hisi_qm *qm, u32 val) in current_qm_write() argument
669 if (val > qm->vfs_num) in current_qm_write()
674 qm->debug.curr_qm_qp_num = qm->qp_num; in current_qm_write()
676 qm->debug.curr_qm_qp_num = qm_get_vf_qp_num(qm, val); in current_qm_write()
678 writel(val, qm->io_base + QM_DFX_MB_CNT_VF); in current_qm_write()
679 writel(val, qm->io_base + QM_DFX_DB_CNT_VF); in current_qm_write()
682 (readl(qm->io_base + QM_DFX_SQE_CNT_VF_SQN) & CURRENT_Q_MASK); in current_qm_write()
683 writel(tmp, qm->io_base + QM_DFX_SQE_CNT_VF_SQN); in current_qm_write()
686 (readl(qm->io_base + QM_DFX_CQE_CNT_VF_CQN) & CURRENT_Q_MASK); in current_qm_write()
687 writel(tmp, qm->io_base + QM_DFX_CQE_CNT_VF_CQN); in current_qm_write()
697 struct hisi_qm *qm = file_to_qm(file); in qm_debug_read() local
702 ret = hisi_qm_get_dfx_access(qm); in qm_debug_read()
709 val = current_qm_read(qm); in qm_debug_read()
712 val = current_q_read(qm); in qm_debug_read()
715 val = clear_enable_read(qm); in qm_debug_read()
722 hisi_qm_put_dfx_access(qm); in qm_debug_read()
728 hisi_qm_put_dfx_access(qm); in qm_debug_read()
737 struct hisi_qm *qm = file_to_qm(file); in qm_debug_write() local
757 ret = hisi_qm_get_dfx_access(qm); in qm_debug_write()
764 ret = current_qm_write(qm, val); in qm_debug_write()
767 ret = current_q_write(qm, val); in qm_debug_write()
770 ret = clear_enable_write(qm, val); in qm_debug_write()
777 hisi_qm_put_dfx_access(qm); in qm_debug_write()
792 static void dfx_regs_uninit(struct hisi_qm *qm, in dfx_regs_uninit() argument
811 static struct dfx_diff_registers *dfx_regs_init(struct hisi_qm *qm, in dfx_regs_init() argument
836 diff_regs[i].regs[j] = readl(qm->io_base + base_offset); in dfx_regs_init()
851 static int qm_diff_regs_init(struct hisi_qm *qm, in qm_diff_regs_init() argument
856 qm->debug.qm_diff_regs = dfx_regs_init(qm, qm_diff_regs, ARRAY_SIZE(qm_diff_regs)); in qm_diff_regs_init()
857 if (IS_ERR(qm->debug.qm_diff_regs)) { in qm_diff_regs_init()
858 ret = PTR_ERR(qm->debug.qm_diff_regs); in qm_diff_regs_init()
859 qm->debug.qm_diff_regs = NULL; in qm_diff_regs_init()
863 qm->debug.acc_diff_regs = dfx_regs_init(qm, dregs, reg_len); in qm_diff_regs_init()
864 if (IS_ERR(qm->debug.acc_diff_regs)) { in qm_diff_regs_init()
865 dfx_regs_uninit(qm, qm->debug.qm_diff_regs, ARRAY_SIZE(qm_diff_regs)); in qm_diff_regs_init()
866 ret = PTR_ERR(qm->debug.acc_diff_regs); in qm_diff_regs_init()
867 qm->debug.acc_diff_regs = NULL; in qm_diff_regs_init()
874 static void qm_last_regs_uninit(struct hisi_qm *qm) in qm_last_regs_uninit() argument
876 struct qm_debug *debug = &qm->debug; in qm_last_regs_uninit()
878 if (qm->fun_type == QM_HW_VF || !debug->qm_last_words) in qm_last_regs_uninit()
885 static int qm_last_regs_init(struct hisi_qm *qm) in qm_last_regs_init() argument
888 struct qm_debug *debug = &qm->debug; in qm_last_regs_init()
891 if (qm->fun_type == QM_HW_VF) in qm_last_regs_init()
899 debug->qm_last_words[i] = readl_relaxed(qm->io_base + in qm_last_regs_init()
906 static void qm_diff_regs_uninit(struct hisi_qm *qm, u32 reg_len) in qm_diff_regs_uninit() argument
908 dfx_regs_uninit(qm, qm->debug.acc_diff_regs, reg_len); in qm_diff_regs_uninit()
909 qm->debug.acc_diff_regs = NULL; in qm_diff_regs_uninit()
910 dfx_regs_uninit(qm, qm->debug.qm_diff_regs, ARRAY_SIZE(qm_diff_regs)); in qm_diff_regs_uninit()
911 qm->debug.qm_diff_regs = NULL; in qm_diff_regs_uninit()
916 * @qm: device qm handle.
920 int hisi_qm_regs_debugfs_init(struct hisi_qm *qm, in hisi_qm_regs_debugfs_init() argument
925 if (!qm || !dregs) in hisi_qm_regs_debugfs_init()
928 if (qm->fun_type != QM_HW_PF) in hisi_qm_regs_debugfs_init()
931 ret = qm_last_regs_init(qm); in hisi_qm_regs_debugfs_init()
933 dev_info(&qm->pdev->dev, "failed to init qm words memory!\n"); in hisi_qm_regs_debugfs_init()
937 ret = qm_diff_regs_init(qm, dregs, reg_len); in hisi_qm_regs_debugfs_init()
939 qm_last_regs_uninit(qm); in hisi_qm_regs_debugfs_init()
949 * @qm: device qm handle.
952 void hisi_qm_regs_debugfs_uninit(struct hisi_qm *qm, u32 reg_len) in hisi_qm_regs_debugfs_uninit() argument
954 if (!qm || qm->fun_type != QM_HW_PF) in hisi_qm_regs_debugfs_uninit()
957 qm_diff_regs_uninit(qm, reg_len); in hisi_qm_regs_debugfs_uninit()
958 qm_last_regs_uninit(qm); in hisi_qm_regs_debugfs_uninit()
964 * @qm: device qm handle.
969 void hisi_qm_acc_diff_regs_dump(struct hisi_qm *qm, struct seq_file *s, in hisi_qm_acc_diff_regs_dump() argument
975 if (!qm || !s || !dregs) in hisi_qm_acc_diff_regs_dump()
978 ret = hisi_qm_get_dfx_access(qm); in hisi_qm_acc_diff_regs_dump()
982 down_read(&qm->qps_lock); in hisi_qm_acc_diff_regs_dump()
989 val = readl(qm->io_base + base_offset); in hisi_qm_acc_diff_regs_dump()
995 up_read(&qm->qps_lock); in hisi_qm_acc_diff_regs_dump()
997 hisi_qm_put_dfx_access(qm); in hisi_qm_acc_diff_regs_dump()
1001 void hisi_qm_show_last_dfx_regs(struct hisi_qm *qm) in hisi_qm_show_last_dfx_regs() argument
1003 struct qm_debug *debug = &qm->debug; in hisi_qm_show_last_dfx_regs()
1004 struct pci_dev *pdev = qm->pdev; in hisi_qm_show_last_dfx_regs()
1008 if (qm->fun_type == QM_HW_VF || !debug->qm_last_words) in hisi_qm_show_last_dfx_regs()
1012 val = readl_relaxed(qm->io_base + qm_dfx_regs[i].offset); in hisi_qm_show_last_dfx_regs()
1021 struct hisi_qm *qm = s->private; in qm_diff_regs_show() local
1023 hisi_qm_acc_diff_regs_dump(qm, s, qm->debug.qm_diff_regs, in qm_diff_regs_show()
1033 struct hisi_qm *qm = filp->private_data; in qm_status_read() local
1037 val = atomic_read(&qm->status.flags); in qm_status_read()
1049 static void qm_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir, in qm_create_debugfs_file() argument
1052 struct debugfs_file *file = qm->debug.files + index; in qm_create_debugfs_file()
1059 file->debug = &qm->debug; in qm_create_debugfs_file()
1083 * hisi_qm_debug_init() - Initialize qm related debugfs files.
1084 * @qm: The qm for which we want to add debugfs files.
1086 * Create qm related debugfs files.
1088 void hisi_qm_debug_init(struct hisi_qm *qm) in hisi_qm_debug_init() argument
1090 struct dfx_diff_registers *qm_regs = qm->debug.qm_diff_regs; in hisi_qm_debug_init()
1091 struct qm_dfx *dfx = &qm->debug.dfx; in hisi_qm_debug_init()
1096 qm_d = debugfs_create_dir("qm", qm->debug.debug_root); in hisi_qm_debug_init()
1097 qm->debug.qm_d = qm_d; in hisi_qm_debug_init()
1100 if (qm->fun_type == QM_HW_PF) { in hisi_qm_debug_init()
1101 qm_create_debugfs_file(qm, qm->debug.debug_root, CURRENT_QM); in hisi_qm_debug_init()
1103 qm_create_debugfs_file(qm, qm->debug.qm_d, i); in hisi_qm_debug_init()
1107 debugfs_create_file("diff_regs", 0444, qm->debug.qm_d, in hisi_qm_debug_init()
1108 qm, &qm_diff_regs_fops); in hisi_qm_debug_init()
1110 debugfs_create_file("regs", 0444, qm->debug.qm_d, qm, &qm_regs_fops); in hisi_qm_debug_init()
1112 debugfs_create_file("cmd", 0600, qm->debug.qm_d, qm, &qm_cmd_fops); in hisi_qm_debug_init()
1114 debugfs_create_file("status", 0444, qm->debug.qm_d, qm, in hisi_qm_debug_init()
1125 if (test_bit(QM_SUPPORT_FUNC_QOS, &qm->caps)) in hisi_qm_debug_init()
1126 hisi_qm_set_algqos_init(qm); in hisi_qm_debug_init()
1131 * hisi_qm_debug_regs_clear() - clear qm debug related registers.
1132 * @qm: The qm for which we want to clear its debug registers.
1134 void hisi_qm_debug_regs_clear(struct hisi_qm *qm) in hisi_qm_debug_regs_clear() argument
1140 writel(0x0, qm->io_base + QM_DFX_MB_CNT_VF); in hisi_qm_debug_regs_clear()
1141 writel(0x0, qm->io_base + QM_DFX_DB_CNT_VF); in hisi_qm_debug_regs_clear()
1144 writel(0x0, qm->io_base + QM_DFX_SQE_CNT_VF_SQN); in hisi_qm_debug_regs_clear()
1145 writel(0x0, qm->io_base + QM_DFX_CQE_CNT_VF_CQN); in hisi_qm_debug_regs_clear()
1151 writel(0x1, qm->io_base + QM_DFX_CNT_CLR_CE); in hisi_qm_debug_regs_clear()
1155 readl(qm->io_base + regs->offset); in hisi_qm_debug_regs_clear()
1160 writel(0x0, qm->io_base + QM_DFX_CNT_CLR_CE); in hisi_qm_debug_regs_clear()