xref: /dpdk/drivers/common/cnxk/roc_cpt_debug.c (revision 02edbfab)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4 
5 #include "roc_api.h"
6 #include "roc_priv.h"
7 
8 static int
9 cpt_af_reg_read(struct roc_cpt *roc_cpt, uint64_t reg, uint64_t *val)
10 {
11 	struct cpt *cpt = roc_cpt_to_cpt_priv(roc_cpt);
12 	struct cpt_rd_wr_reg_msg *msg;
13 	struct dev *dev = &cpt->dev;
14 	int ret;
15 
16 	msg = mbox_alloc_msg_cpt_rd_wr_register(dev->mbox);
17 	if (msg == NULL)
18 		return -EIO;
19 
20 	msg->hdr.pcifunc = dev->pf_func;
21 
22 	msg->is_write = 0;
23 	msg->reg_offset = reg;
24 	msg->ret_val = val;
25 
26 	ret = mbox_process_msg(dev->mbox, (void *)&msg);
27 	if (ret)
28 		return -EIO;
29 
30 	*val = msg->val;
31 
32 	return 0;
33 }
34 
35 static int
36 cpt_sts_print(struct roc_cpt *roc_cpt)
37 {
38 	struct cpt *cpt = roc_cpt_to_cpt_priv(roc_cpt);
39 	struct dev *dev = &cpt->dev;
40 	struct cpt_sts_req *req;
41 	struct cpt_sts_rsp *rsp;
42 	int ret;
43 
44 	req = mbox_alloc_msg_cpt_sts_get(dev->mbox);
45 	if (req == NULL)
46 		return -EIO;
47 
48 	req->blkaddr = 0;
49 	ret = mbox_process_msg(dev->mbox, (void *)&rsp);
50 	if (ret)
51 		return -EIO;
52 
53 	plt_print("    %s:\t0x%016" PRIx64, "inst_req_pc", rsp->inst_req_pc);
54 	plt_print("    %s:\t0x%016" PRIx64, "inst_lat_pc", rsp->inst_lat_pc);
55 	plt_print("    %s:\t\t0x%016" PRIx64, "rd_req_pc", rsp->rd_req_pc);
56 	plt_print("    %s:\t\t0x%016" PRIx64, "rd_lat_pc", rsp->rd_lat_pc);
57 	plt_print("    %s:\t\t0x%016" PRIx64, "rd_uc_pc", rsp->rd_uc_pc);
58 	plt_print("    %s:\t0x%016" PRIx64, "active_cycles_pc",
59 		  rsp->active_cycles_pc);
60 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_mis_pc", rsp->ctx_mis_pc);
61 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_hit_pc", rsp->ctx_hit_pc);
62 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_aop_pc", rsp->ctx_aop_pc);
63 	plt_print("    %s:\t0x%016" PRIx64, "ctx_aop_lat_pc",
64 		  rsp->ctx_aop_lat_pc);
65 	plt_print("    %s:\t0x%016" PRIx64, "ctx_ifetch_pc",
66 		  rsp->ctx_ifetch_pc);
67 	plt_print("    %s:\t0x%016" PRIx64, "ctx_ifetch_lat_pc",
68 		  rsp->ctx_ifetch_lat_pc);
69 	plt_print("    %s:\t0x%016" PRIx64, "ctx_ffetch_pc",
70 		  rsp->ctx_ffetch_pc);
71 	plt_print("    %s:\t0x%016" PRIx64, "ctx_ffetch_lat_pc",
72 		  rsp->ctx_ffetch_lat_pc);
73 	plt_print("    %s:\t0x%016" PRIx64, "ctx_wback_pc", rsp->ctx_wback_pc);
74 	plt_print("    %s:\t0x%016" PRIx64, "ctx_wback_lat_pc",
75 		  rsp->ctx_wback_lat_pc);
76 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_psh_pc", rsp->ctx_psh_pc);
77 	plt_print("    %s:\t0x%016" PRIx64, "ctx_psh_lat_pc",
78 		  rsp->ctx_psh_lat_pc);
79 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_err", rsp->ctx_err);
80 	plt_print("    %s:\t\t0x%016" PRIx64, "ctx_enc_id", rsp->ctx_enc_id);
81 	plt_print("    %s:\t0x%016" PRIx64, "ctx_flush_timer",
82 		  rsp->ctx_flush_timer);
83 	plt_print("    %s:\t\t0x%016" PRIx64, "rxc_time", rsp->rxc_time);
84 	plt_print("    %s:\t0x%016" PRIx64, "rxc_time_cfg", rsp->rxc_time_cfg);
85 	plt_print("    %s:\t0x%016" PRIx64, "rxc_active_sts",
86 		  rsp->rxc_active_sts);
87 	plt_print("    %s:\t0x%016" PRIx64, "rxc_zombie_sts",
88 		  rsp->rxc_zombie_sts);
89 	plt_print("    %s:\t0x%016" PRIx64, "rxc_dfrg", rsp->rxc_dfrg);
90 	plt_print("    %s:\t0x%016" PRIx64, "x2p_link_cfg0",
91 		  rsp->x2p_link_cfg0);
92 	plt_print("    %s:\t0x%016" PRIx64, "x2p_link_cfg1",
93 		  rsp->x2p_link_cfg1);
94 	plt_print("    %s:\t0x%016" PRIx64, "busy_sts_ae", rsp->busy_sts_ae);
95 	plt_print("    %s:\t0x%016" PRIx64, "free_sts_ae", rsp->free_sts_ae);
96 	plt_print("    %s:\t0x%016" PRIx64, "busy_sts_se", rsp->busy_sts_se);
97 	plt_print("    %s:\t0x%016" PRIx64, "free_sts_se", rsp->free_sts_se);
98 	plt_print("    %s:\t0x%016" PRIx64, "busy_sts_ie", rsp->busy_sts_ie);
99 	plt_print("    %s:\t0x%016" PRIx64, "free_sts_ie", rsp->free_sts_ie);
100 	plt_print("    %s:\t0x%016" PRIx64, "exe_err_info", rsp->exe_err_info);
101 	plt_print("    %s:\t\t0x%016" PRIx64, "cptclk_cnt", rsp->cptclk_cnt);
102 	plt_print("    %s:\t\t0x%016" PRIx64, "diag", rsp->diag);
103 
104 	return 0;
105 }
106 
107 int
108 roc_cpt_afs_print(struct roc_cpt *roc_cpt)
109 {
110 	uint64_t reg_val;
111 
112 	plt_print("CPT AF registers:");
113 
114 	if (cpt_af_reg_read(roc_cpt, CPT_AF_LFX_CTL(0), &reg_val))
115 		return -EIO;
116 
117 	plt_print("    CPT_AF_LF0_CTL:\t0x%016" PRIx64, reg_val);
118 
119 	if (cpt_af_reg_read(roc_cpt, CPT_AF_LFX_CTL2(0), &reg_val))
120 		return -EIO;
121 
122 	plt_print("    CPT_AF_LF0_CTL2:\t0x%016" PRIx64, reg_val);
123 
124 	cpt_sts_print(roc_cpt);
125 
126 	return 0;
127 }
128 
129 static void
130 cpt_lf_print(struct roc_cpt_lf *lf)
131 {
132 	uint64_t reg_val;
133 
134 	reg_val = plt_read64(lf->rbase + CPT_LF_CTX_ENC_BYTE_CNT);
135 	plt_print("    Encrypted byte count:\t%" PRIu64, reg_val);
136 
137 	reg_val = plt_read64(lf->rbase + CPT_LF_CTX_ENC_PKT_CNT);
138 	plt_print("    Encrypted packet count:\t%" PRIu64, reg_val);
139 
140 	reg_val = plt_read64(lf->rbase + CPT_LF_CTX_DEC_BYTE_CNT);
141 	plt_print("    Decrypted byte count:\t%" PRIu64, reg_val);
142 
143 	reg_val = plt_read64(lf->rbase + CPT_LF_CTX_ENC_PKT_CNT);
144 	plt_print("    Decrypted packet count:\t%" PRIu64, reg_val);
145 }
146 
147 int
148 roc_cpt_lfs_print(struct roc_cpt *roc_cpt)
149 {
150 	struct cpt *cpt = roc_cpt_to_cpt_priv(roc_cpt);
151 	struct roc_cpt_lf *lf;
152 	int lf_id;
153 
154 	if (cpt == NULL)
155 		return -EINVAL;
156 
157 	for (lf_id = 0; lf_id < roc_cpt->nb_lf; lf_id++) {
158 		lf = roc_cpt->lf[lf_id];
159 		if (lf == NULL)
160 			continue;
161 
162 		plt_print("Count registers for CPT LF%d:", lf_id);
163 		cpt_lf_print(lf);
164 	}
165 
166 	return 0;
167 }
168