1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #include "cnxk_telemetry.h"
10 cnxk_tel_npa(struct plt_tel_data *d)
16 lf = idev_npa_obj_get();
18 return NPA_ERR_DEVICE_NOT_BOUNDED;
20 for (i = 0; i < lf->nr_pools; i++) {
21 if (plt_bitmap_get(lf->npa_bmp, i))
26 plt_tel_data_add_dict_ptr(d, "npa", lf);
27 plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
28 plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
29 plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
31 CNXK_TEL_DICT_STR(d, lf->pci_dev, name, pcidev_);
32 CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
33 CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
34 CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
35 CNXK_TEL_DICT_PTR(d, lf, mbox);
36 CNXK_TEL_DICT_PTR(d, lf, base);
37 CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
38 CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
39 CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
40 CNXK_TEL_DICT_INT(d, lf, nr_pools);
41 CNXK_TEL_DICT_INT(d, lf, pf_func);
42 CNXK_TEL_DICT_INT(d, lf, aura_sz);
43 CNXK_TEL_DICT_INT(d, lf, qints);
49 cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
51 __io struct npa_aura_s *aura;
52 struct npa_aq_enq_req *req;
53 struct npa_aq_enq_rsp *rsp;
57 lf = idev_npa_obj_get();
59 return NPA_ERR_DEVICE_NOT_BOUNDED;
61 if (plt_bitmap_get(lf->npa_bmp, aura_id))
64 req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
66 plt_err("Failed to alloc aq enq for npa");
70 req->aura_id = aura_id;
71 req->ctype = NPA_AQ_CTYPE_AURA;
72 req->op = NPA_AQ_INSTOP_READ;
74 rc = mbox_process_msg(lf->mbox, (void *)&rsp);
76 plt_err("Failed to get pool(%d) context", aura_id);
81 CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
82 CNXK_TEL_DICT_INT(d, aura, ena, w1_);
83 CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
84 CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
85 CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
86 CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
87 CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
88 CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
89 CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
90 CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
91 CNXK_TEL_DICT_U64(d, aura, count, w2_);
92 CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
93 CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
94 CNXK_TEL_DICT_U64(d, aura, limit, w3_);
95 CNXK_TEL_DICT_INT(d, aura, bp, w3_);
96 CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
97 CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
98 CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
99 CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
100 CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
101 CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
102 CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
103 CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
104 CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
105 CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
106 CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
107 CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
108 CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
109 CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
110 CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
116 cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
118 __io struct npa_pool_s *pool;
119 struct npa_aq_enq_req *req;
120 struct npa_aq_enq_rsp *rsp;
124 lf = idev_npa_obj_get();
126 return NPA_ERR_DEVICE_NOT_BOUNDED;
128 if (plt_bitmap_get(lf->npa_bmp, pool_id))
131 req = mbox_alloc_msg_npa_aq_enq(lf->mbox);
133 plt_err("Failed to alloc aq enq for npa");
137 req->aura_id = pool_id;
138 req->ctype = NPA_AQ_CTYPE_POOL;
139 req->op = NPA_AQ_INSTOP_READ;
141 rc = mbox_process_msg(lf->mbox, (void *)&rsp);
143 plt_err("Failed to get pool(%d) context", pool_id);
148 CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
149 CNXK_TEL_DICT_INT(d, pool, ena, w1_);
150 CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
151 CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
152 CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
153 CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
154 CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
155 CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
156 CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
157 CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
158 CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
159 CNXK_TEL_DICT_INT(d, pool, shift, w4_);
160 CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
161 CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
162 CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
163 CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
164 CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
165 CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
166 CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
167 CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
168 CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
169 CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
170 CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
171 CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
172 CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
173 CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
174 CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
175 CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
176 CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
182 cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
183 const char *params __plt_unused,
184 struct plt_tel_data *d)
186 plt_tel_data_start_dict(d);
187 return cnxk_tel_npa(d);
191 cnxk_npa_tel_handle_aura_list(const char *cmd __plt_unused,
192 const char *params __plt_unused,
193 struct plt_tel_data *d)
198 lf = idev_npa_obj_get();
200 return NPA_ERR_DEVICE_NOT_BOUNDED;
202 plt_tel_data_start_array(d, PLT_TEL_INT_VAL);
204 for (i = 0; i < (int)lf->nr_pools; i++)
205 if (!plt_bitmap_get(lf->npa_bmp, i))
206 rte_tel_data_add_array_int(d, i);
212 cnxk_npa_tel_handle_pool_list(const char *cmd, const char *params,
213 struct plt_tel_data *d)
215 /* In current implementation, aura and pool ID mapped 1:1 */
216 return cnxk_npa_tel_handle_aura_list(cmd, params, d);
220 cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
221 struct plt_tel_data *d)
225 if (params == NULL || strlen(params) == 0 || !isdigit(*params))
228 id = strtol(params, NULL, 10);
229 plt_tel_data_start_dict(d);
231 if (strstr(cmd, "aura/info"))
232 rc = cnxk_tel_npa_aura(id, d);
234 rc = cnxk_tel_npa_pool(id, d);
239 PLT_INIT(cnxk_telemetry_npa_init)
241 plt_telemetry_register_cmd(
242 "/cnxk/npa/info", cnxk_npa_tel_handle_info,
243 "Returns npa information. Takes no parameters");
245 plt_telemetry_register_cmd(
246 "/cnxk/npa/aura/list", cnxk_npa_tel_handle_aura_list,
247 "Returns list of npa aura id. Takes no parameters");
249 plt_telemetry_register_cmd(
250 "/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
251 "Returns npa aura information. Parameters: aura_id");
253 plt_telemetry_register_cmd(
254 "/cnxk/npa/pool/list", cnxk_npa_tel_handle_pool_list,
255 "Returns list of npa pool id. Takes no parameters");
257 plt_telemetry_register_cmd(
258 "/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
259 "Returns npa pool information. Parameters: pool_id");