xref: /dpdk/drivers/bus/fslmc/qbman/qbman_debug.c (revision 051f4185f98faa964b6a965b2e8e7b2da68969de)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2015 Freescale Semiconductor, Inc.
3  * Copyright 2018-2020,2022 NXP
4  */
5 
6 #include "compat.h"
7 #include <fsl_qbman_debug.h>
8 #include "qbman_portal.h"
9 
10 /* QBMan portal management command code */
11 #define QBMAN_BP_QUERY            0x32
12 #define QBMAN_FQ_QUERY            0x44
13 #define QBMAN_FQ_QUERY_NP         0x45
14 #define QBMAN_WQ_QUERY            0x47
15 #define QBMAN_CGR_QUERY           0x51
16 #define QBMAN_WRED_QUERY          0x54
17 #define QBMAN_CGR_STAT_QUERY      0x55
18 #define QBMAN_CGR_STAT_QUERY_CLR  0x56
19 
20 struct qbman_bp_query_desc {
21 	uint8_t verb;
22 	uint8_t reserved;
23 	uint16_t bpid;
24 	uint8_t reserved2[60];
25 };
26 
27 #define QB_BP_STATE_SHIFT  24
28 #define QB_BP_VA_SHIFT     1
29 #define QB_BP_VA_MASK      0x2
30 #define QB_BP_WAE_SHIFT    2
31 #define QB_BP_WAE_MASK     0x4
32 #define QB_BP_PL_SHIFT     15
33 #define QB_BP_PL_MASK      0x8000
34 #define QB_BP_ICID_MASK    0x7FFF
35 
36 int qbman_bp_query(struct qbman_swp *s, uint32_t bpid,
37 		   struct qbman_bp_query_rslt *r)
38 {
39 	struct qbman_bp_query_desc *p;
40 	struct qbman_bp_query_rslt *bp_query_rslt;
41 
42 	/* Start the management command */
43 	p = (struct qbman_bp_query_desc *)qbman_swp_mc_start(s);
44 	if (!p)
45 		return -EBUSY;
46 
47 	/* Encode the caller-provided attributes */
48 	p->bpid = bpid;
49 
50 	/* Complete the management command */
51 	bp_query_rslt = (struct qbman_bp_query_rslt *)qbman_swp_mc_complete(s,
52 						p, QBMAN_BP_QUERY);
53 	if (!bp_query_rslt) {
54 		pr_err("qbman: Query BPID %d failed, no response\n",
55 			bpid);
56 		return -EIO;
57 	}
58 
59 	*r = *bp_query_rslt;
60 
61 	/* Decode the outcome */
62 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_BP_QUERY);
63 
64 	/* Determine success or failure */
65 	if (r->rslt != QBMAN_MC_RSLT_OK) {
66 		pr_err("Query of BPID 0x%x failed, code=0x%02x\n", bpid,
67 								r->rslt);
68 		return -EIO;
69 	}
70 
71 	return 0;
72 }
73 
74 int qbman_bp_get_bdi(struct qbman_bp_query_rslt *r)
75 {
76 	return r->bdi & 1;
77 }
78 
79 int qbman_bp_get_va(struct qbman_bp_query_rslt *r)
80 {
81 	return (r->bdi & QB_BP_VA_MASK) >> QB_BP_VA_MASK;
82 }
83 
84 int qbman_bp_get_wae(struct qbman_bp_query_rslt *r)
85 {
86 	return (r->bdi & QB_BP_WAE_MASK) >> QB_BP_WAE_SHIFT;
87 }
88 
89 static uint16_t qbman_bp_thresh_to_value(uint16_t val)
90 {
91 	return (val & 0xff) << ((val & 0xf00) >> 8);
92 }
93 
94 uint16_t qbman_bp_get_swdet(struct qbman_bp_query_rslt  *r)
95 {
96 
97 	return qbman_bp_thresh_to_value(r->swdet);
98 }
99 
100 uint16_t qbman_bp_get_swdxt(struct qbman_bp_query_rslt  *r)
101 {
102 	return qbman_bp_thresh_to_value(r->swdxt);
103 }
104 
105 uint16_t qbman_bp_get_hwdet(struct qbman_bp_query_rslt  *r)
106 {
107 	return qbman_bp_thresh_to_value(r->hwdet);
108 }
109 
110 uint16_t qbman_bp_get_hwdxt(struct qbman_bp_query_rslt  *r)
111 {
112 	return qbman_bp_thresh_to_value(r->hwdxt);
113 }
114 
115 uint16_t qbman_bp_get_swset(struct qbman_bp_query_rslt  *r)
116 {
117 	return qbman_bp_thresh_to_value(r->swset);
118 }
119 
120 uint16_t qbman_bp_get_swsxt(struct qbman_bp_query_rslt  *r)
121 {
122 
123 	return qbman_bp_thresh_to_value(r->swsxt);
124 }
125 
126 uint16_t qbman_bp_get_vbpid(struct qbman_bp_query_rslt  *r)
127 {
128 	return r->vbpid;
129 }
130 
131 uint16_t qbman_bp_get_icid(struct qbman_bp_query_rslt  *r)
132 {
133 	return r->icid & QB_BP_ICID_MASK;
134 }
135 
136 int qbman_bp_get_pl(struct qbman_bp_query_rslt  *r)
137 {
138 	return (r->icid & QB_BP_PL_MASK) >> QB_BP_PL_SHIFT;
139 }
140 
141 uint64_t qbman_bp_get_bpscn_addr(struct qbman_bp_query_rslt  *r)
142 {
143 	return r->bpscn_addr;
144 }
145 
146 uint64_t qbman_bp_get_bpscn_ctx(struct qbman_bp_query_rslt  *r)
147 {
148 	return r->bpscn_ctx;
149 }
150 
151 uint16_t qbman_bp_get_hw_targ(struct qbman_bp_query_rslt  *r)
152 {
153 	return r->hw_targ;
154 }
155 
156 int qbman_bp_has_free_bufs(struct qbman_bp_query_rslt  *r)
157 {
158 	return !(int)(r->state & 0x1);
159 }
160 
161 int qbman_bp_is_depleted(struct qbman_bp_query_rslt  *r)
162 {
163 	return (int)((r->state & 0x2) >> 1);
164 }
165 
166 int qbman_bp_is_surplus(struct qbman_bp_query_rslt  *r)
167 {
168 	return (int)((r->state & 0x4) >> 2);
169 }
170 
171 uint32_t qbman_bp_num_free_bufs(struct qbman_bp_query_rslt  *r)
172 {
173 	return r->fill;
174 }
175 
176 uint32_t qbman_bp_get_hdptr(struct qbman_bp_query_rslt  *r)
177 {
178 	return r->hdptr;
179 }
180 
181 uint32_t qbman_bp_get_sdcnt(struct qbman_bp_query_rslt  *r)
182 {
183 	return r->sdcnt;
184 }
185 
186 uint32_t qbman_bp_get_hdcnt(struct qbman_bp_query_rslt  *r)
187 {
188 	return r->hdcnt;
189 }
190 
191 uint32_t qbman_bp_get_sscnt(struct qbman_bp_query_rslt  *r)
192 {
193 	return r->sscnt;
194 }
195 
196 struct qbman_fq_query_desc {
197 	uint8_t verb;
198 	uint8_t reserved[3];
199 	uint32_t fqid;
200 	uint8_t reserved2[56];
201 };
202 
203 /* FQ query function for programmable fields */
204 int qbman_fq_query(struct qbman_swp *s, uint32_t fqid,
205 		   struct qbman_fq_query_rslt *r)
206 {
207 	struct qbman_fq_query_desc *p;
208 	struct qbman_fq_query_rslt *fq_query_rslt;
209 
210 	p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
211 	if (!p)
212 		return -EBUSY;
213 
214 	p->fqid = fqid;
215 	fq_query_rslt = (struct qbman_fq_query_rslt *)qbman_swp_mc_complete(s,
216 					p, QBMAN_FQ_QUERY);
217 	if (!fq_query_rslt) {
218 		pr_err("qbman: Query FQID %d failed, no response\n",
219 			fqid);
220 		return -EIO;
221 	}
222 
223 	*r = *fq_query_rslt;
224 
225 	/* Decode the outcome */
226 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY);
227 
228 	/* Determine success or failure */
229 	if (r->rslt != QBMAN_MC_RSLT_OK) {
230 		pr_err("Query of FQID 0x%x failed, code=0x%02x\n",
231 		       fqid, r->rslt);
232 		return -EIO;
233 	}
234 
235 	return 0;
236 }
237 
238 uint8_t qbman_fq_attr_get_fqctrl(struct qbman_fq_query_rslt *r)
239 {
240 	return r->fq_ctrl;
241 }
242 
243 uint16_t qbman_fq_attr_get_cgrid(struct qbman_fq_query_rslt *r)
244 {
245 	return r->cgid;
246 }
247 
248 uint16_t qbman_fq_attr_get_destwq(struct qbman_fq_query_rslt *r)
249 {
250 	return r->dest_wq;
251 }
252 
253 static uint16_t qbman_thresh_to_value(uint16_t val)
254 {
255 	return ((val & 0x1FE0) >> 5) << (val & 0x1F);
256 }
257 
258 uint16_t qbman_fq_attr_get_tdthresh(struct qbman_fq_query_rslt *r)
259 {
260 	return qbman_thresh_to_value(r->td_thresh);
261 }
262 
263 int qbman_fq_attr_get_oa_ics(struct qbman_fq_query_rslt *r)
264 {
265 	return (int)(r->oal_oac >> 14) & 0x1;
266 }
267 
268 int qbman_fq_attr_get_oa_cgr(struct qbman_fq_query_rslt *r)
269 {
270 	return (int)(r->oal_oac >> 15);
271 }
272 
273 uint16_t qbman_fq_attr_get_oal(struct qbman_fq_query_rslt *r)
274 {
275 	return (r->oal_oac & 0x0FFF);
276 }
277 
278 int qbman_fq_attr_get_bdi(struct qbman_fq_query_rslt *r)
279 {
280 	return (r->mctl & 0x1);
281 }
282 
283 int qbman_fq_attr_get_ff(struct qbman_fq_query_rslt *r)
284 {
285 	return (r->mctl & 0x2) >> 1;
286 }
287 
288 int qbman_fq_attr_get_va(struct qbman_fq_query_rslt *r)
289 {
290 	return (r->mctl & 0x4) >> 2;
291 }
292 
293 int qbman_fq_attr_get_ps(struct qbman_fq_query_rslt *r)
294 {
295 	return (r->mctl & 0x8) >> 3;
296 }
297 
298 int qbman_fq_attr_get_pps(struct qbman_fq_query_rslt *r)
299 {
300 	return (r->mctl & 0x30) >> 4;
301 }
302 
303 uint16_t qbman_fq_attr_get_icid(struct qbman_fq_query_rslt *r)
304 {
305 	return r->icid & 0x7FFF;
306 }
307 
308 int qbman_fq_attr_get_pl(struct qbman_fq_query_rslt *r)
309 {
310 	return (int)((r->icid & 0x8000) >> 15);
311 }
312 
313 uint32_t qbman_fq_attr_get_vfqid(struct qbman_fq_query_rslt *r)
314 {
315 	return r->vfqid & 0x00FFFFFF;
316 }
317 
318 uint32_t qbman_fq_attr_get_erfqid(struct qbman_fq_query_rslt *r)
319 {
320 	return r->fqid_er & 0x00FFFFFF;
321 }
322 
323 uint16_t qbman_fq_attr_get_opridsz(struct qbman_fq_query_rslt *r)
324 {
325 	return r->opridsz;
326 }
327 
328 int qbman_fq_query_state(struct qbman_swp *s, uint32_t fqid,
329 			 struct qbman_fq_query_np_rslt *r)
330 {
331 	struct qbman_fq_query_desc *p;
332 	struct qbman_fq_query_np_rslt *var;
333 
334 	p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
335 	if (!p)
336 		return -EBUSY;
337 
338 	p->fqid = fqid;
339 	var = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY_NP);
340 	if (!var) {
341 		pr_err("qbman: Query FQID %d NP fields failed, no response\n",
342 		       fqid);
343 		return -EIO;
344 	}
345 	*r = *var;
346 
347 	/* Decode the outcome */
348 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY_NP);
349 
350 	/* Determine success or failure */
351 	if (r->rslt != QBMAN_MC_RSLT_OK) {
352 		pr_err("Query NP fields of FQID 0x%x failed, code=0x%02x\n",
353 		       fqid, r->rslt);
354 		return -EIO;
355 	}
356 
357 	return 0;
358 }
359 
360 uint8_t qbman_fq_state_schedstate(const struct qbman_fq_query_np_rslt *r)
361 {
362 	return r->st1 & 0x7;
363 }
364 
365 int qbman_fq_state_force_eligible(const struct qbman_fq_query_np_rslt *r)
366 {
367 	return (int)((r->st1 & 0x8) >> 3);
368 }
369 
370 int qbman_fq_state_xoff(const struct qbman_fq_query_np_rslt *r)
371 {
372 	return (int)((r->st1 & 0x10) >> 4);
373 }
374 
375 int qbman_fq_state_retirement_pending(const struct qbman_fq_query_np_rslt *r)
376 {
377 	return (int)((r->st1 & 0x20) >> 5);
378 }
379 
380 int qbman_fq_state_overflow_error(const struct qbman_fq_query_np_rslt *r)
381 {
382 	return (int)((r->st1 & 0x40) >> 6);
383 }
384 
385 uint32_t qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r)
386 {
387 	return (r->frm_cnt & 0x00FFFFFF);
388 }
389 
390 uint32_t qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r)
391 {
392 	return r->byte_cnt;
393 }
394 
395 /* Query CGR */
396 struct qbman_cgr_query_desc {
397 	uint8_t verb;
398 	uint8_t reserved;
399 	uint16_t cgid;
400 	uint8_t reserved2[60];
401 };
402 
403 int qbman_cgr_query(struct qbman_swp *s, uint32_t cgid,
404 		    struct qbman_cgr_query_rslt *r)
405 {
406 	struct qbman_cgr_query_desc *p;
407 	struct qbman_cgr_query_rslt *cgr_query_rslt;
408 
409 	p = (struct qbman_cgr_query_desc *)qbman_swp_mc_start(s);
410 	if (!p)
411 		return -EBUSY;
412 
413 	p->cgid = cgid;
414 	cgr_query_rslt = (struct qbman_cgr_query_rslt *)qbman_swp_mc_complete(s,
415 					p, QBMAN_CGR_QUERY);
416 	if (!cgr_query_rslt) {
417 		pr_err("qbman: Query CGID %d failed, no response\n",
418 			cgid);
419 		return -EIO;
420 	}
421 
422 	*r = *cgr_query_rslt;
423 
424 	/* Decode the outcome */
425 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_CGR_QUERY);
426 
427 	/* Determine success or failure */
428 	if (r->rslt != QBMAN_MC_RSLT_OK) {
429 		pr_err("Query CGID 0x%x failed,code=0x%02x\n", cgid, r->rslt);
430 		return -EIO;
431 	}
432 
433 	return 0;
434 }
435 
436 int qbman_cgr_get_cscn_wq_en_enter(struct qbman_cgr_query_rslt *r)
437 {
438 	return (int)(r->ctl1 & 0x1);
439 }
440 
441 int qbman_cgr_get_cscn_wq_en_exit(struct qbman_cgr_query_rslt *r)
442 {
443 	return (int)((r->ctl1 & 0x2) >> 1);
444 }
445 
446 int qbman_cgr_get_cscn_wq_icd(struct qbman_cgr_query_rslt *r)
447 {
448 	return (int)((r->ctl1 & 0x4) >> 2);
449 }
450 
451 uint8_t qbman_cgr_get_mode(struct qbman_cgr_query_rslt *r)
452 {
453 	return r->mode & 0x3;
454 }
455 
456 int qbman_cgr_get_rej_cnt_mode(struct qbman_cgr_query_rslt *r)
457 {
458 	return (int)((r->mode & 0x4) >> 2);
459 }
460 
461 int qbman_cgr_get_cscn_bdi(struct qbman_cgr_query_rslt *r)
462 {
463 	return (int)((r->mode & 0x8) >> 3);
464 }
465 
466 uint16_t qbman_cgr_attr_get_cs_thres(struct qbman_cgr_query_rslt *r)
467 {
468 	return qbman_thresh_to_value(r->cs_thres);
469 }
470 
471 uint16_t qbman_cgr_attr_get_cs_thres_x(struct qbman_cgr_query_rslt *r)
472 {
473 	return qbman_thresh_to_value(r->cs_thres_x);
474 }
475 
476 uint16_t qbman_cgr_attr_get_td_thres(struct qbman_cgr_query_rslt *r)
477 {
478 	return qbman_thresh_to_value(r->td_thres);
479 }
480 
481 int qbman_cgr_wred_query(struct qbman_swp *s, uint32_t cgid,
482 			struct qbman_wred_query_rslt *r)
483 {
484 	struct qbman_cgr_query_desc *p;
485 	struct qbman_wred_query_rslt *wred_query_rslt;
486 
487 	p = (struct qbman_cgr_query_desc *)qbman_swp_mc_start(s);
488 	if (!p)
489 		return -EBUSY;
490 
491 	p->cgid = cgid;
492 	wred_query_rslt = (struct qbman_wred_query_rslt *)qbman_swp_mc_complete(
493 					s, p, QBMAN_WRED_QUERY);
494 	if (!wred_query_rslt) {
495 		pr_err("qbman: Query CGID WRED %d failed, no response\n",
496 			cgid);
497 		return -EIO;
498 	}
499 
500 	*r = *wred_query_rslt;
501 
502 	/* Decode the outcome */
503 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_WRED_QUERY);
504 
505 	/* Determine success or failure */
506 	if (r->rslt != QBMAN_MC_RSLT_OK) {
507 		pr_err("Query CGID WRED 0x%x failed,code=0x%02x\n",
508 							 cgid, r->rslt);
509 		return -EIO;
510 	}
511 
512 	return 0;
513 }
514 
515 int qbman_cgr_attr_wred_get_edp(struct qbman_wred_query_rslt *r, uint32_t idx)
516 {
517 	return (int)(r->edp[idx] & 1);
518 }
519 
520 uint32_t qbman_cgr_attr_wred_get_parm_dp(struct qbman_wred_query_rslt *r,
521 					 uint32_t idx)
522 {
523 	return r->wred_parm_dp[idx];
524 }
525 
526 void qbman_cgr_attr_wred_dp_decompose(uint32_t dp, uint64_t *minth,
527 				      uint64_t *maxth, uint8_t *maxp)
528 {
529 	uint8_t ma, mn, step_i, step_s, pn;
530 
531 	ma = (uint8_t)(dp >> 24);
532 	mn = (uint8_t)(dp >> 19) & 0x1f;
533 	step_i = (uint8_t)(dp >> 11);
534 	step_s = (uint8_t)(dp >> 6) & 0x1f;
535 	pn = (uint8_t)dp & 0x3f;
536 
537 	*maxp = (uint8_t)(((pn<<2) * 100)/256);
538 
539 	if (mn == 0)
540 		*maxth = ma;
541 	else
542 		*maxth = ((uint64_t)(ma+256) * (1<<(mn-1)));
543 
544 	if (step_s == 0)
545 		*minth = *maxth - step_i;
546 	else
547 		*minth = *maxth - (256 + step_i) * (1<<(step_s - 1));
548 }
549 
550 /* Query CGR/CCGR/CQ statistics */
551 struct qbman_cgr_statistics_query_desc {
552 	uint8_t verb;
553 	uint8_t reserved;
554 	uint16_t cgid;
555 	uint8_t reserved1;
556 	uint8_t ct;
557 	uint8_t reserved2[58];
558 };
559 
560 struct qbman_cgr_statistics_query_rslt {
561 	uint8_t verb;
562 	uint8_t rslt;
563 	uint8_t reserved[14];
564 	uint64_t frm_cnt;
565 	uint64_t byte_cnt;
566 	uint32_t reserved2[8];
567 };
568 
569 static int qbman_cgr_statistics_query(struct qbman_swp *s, uint32_t cgid,
570 				      int clear, uint32_t command_type,
571 				      uint64_t *frame_cnt, uint64_t *byte_cnt)
572 {
573 	struct qbman_cgr_statistics_query_desc *p;
574 	struct qbman_cgr_statistics_query_rslt *r;
575 	uint32_t query_verb;
576 
577 	p = (struct qbman_cgr_statistics_query_desc *)qbman_swp_mc_start(s);
578 	if (!p)
579 		return -EBUSY;
580 
581 	p->cgid = cgid;
582 	if (command_type < 2)
583 		p->ct = command_type;
584 	query_verb = clear ?
585 			QBMAN_CGR_STAT_QUERY_CLR : QBMAN_CGR_STAT_QUERY;
586 	r = (struct qbman_cgr_statistics_query_rslt *)qbman_swp_mc_complete(s,
587 							p, query_verb);
588 	if (!r) {
589 		pr_err("qbman: Query CGID %d statistics failed, no response\n",
590 			cgid);
591 		return -EIO;
592 	}
593 
594 	/* Decode the outcome */
595 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != query_verb);
596 
597 	/* Determine success or failure */
598 	if (r->rslt != QBMAN_MC_RSLT_OK) {
599 		pr_err("Query statistics of CGID 0x%x failed, code=0x%02x\n",
600 						cgid, r->rslt);
601 		return -EIO;
602 	}
603 
604 	if (*frame_cnt)
605 		*frame_cnt = r->frm_cnt & 0xFFFFFFFFFFllu;
606 	if (*byte_cnt)
607 		*byte_cnt = r->byte_cnt & 0xFFFFFFFFFFllu;
608 
609 	return 0;
610 }
611 
612 int qbman_cgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
613 				uint64_t *frame_cnt, uint64_t *byte_cnt)
614 {
615 	return qbman_cgr_statistics_query(s, cgid, clear, 0xff,
616 					  frame_cnt, byte_cnt);
617 }
618 
619 int qbman_ccgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
620 				 uint64_t *frame_cnt, uint64_t *byte_cnt)
621 {
622 	return qbman_cgr_statistics_query(s, cgid, clear, 1,
623 					  frame_cnt, byte_cnt);
624 }
625 
626 int qbman_cq_dequeue_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
627 				uint64_t *frame_cnt, uint64_t *byte_cnt)
628 {
629 	return qbman_cgr_statistics_query(s, cgid, clear, 0,
630 					  frame_cnt, byte_cnt);
631 }
632 
633 /* WQ Chan Query */
634 struct qbman_wqchan_query_desc {
635 	uint8_t verb;
636 	uint8_t reserved;
637 	uint16_t chid;
638 	uint8_t reserved2[60];
639 };
640 
641 int qbman_wqchan_query(struct qbman_swp *s, uint16_t chanid,
642 		       struct qbman_wqchan_query_rslt *r)
643 {
644 	struct qbman_wqchan_query_desc *p;
645 	struct qbman_wqchan_query_rslt *wqchan_query_rslt;
646 
647 	/* Start the management command */
648 	p = (struct qbman_wqchan_query_desc *)qbman_swp_mc_start(s);
649 	if (!p)
650 		return -EBUSY;
651 
652 	/* Encode the caller-provided attributes */
653 	p->chid = chanid;
654 
655 	/* Complete the management command */
656 	wqchan_query_rslt = (struct qbman_wqchan_query_rslt *)qbman_swp_mc_complete(
657 						s, p, QBMAN_WQ_QUERY);
658 	if (!wqchan_query_rslt) {
659 		pr_err("qbman: Query WQ Channel %d failed, no response\n",
660 			chanid);
661 		return -EIO;
662 	}
663 
664 	*r = *wqchan_query_rslt;
665 
666 	/* Decode the outcome */
667 	QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_WQ_QUERY);
668 
669 	/* Determine success or failure */
670 	if (r->rslt != QBMAN_MC_RSLT_OK) {
671 		pr_err("Query of WQCHAN 0x%x failed, code=0x%02x\n",
672 		       chanid, r->rslt);
673 		return -EIO;
674 	}
675 
676 	return 0;
677 }
678 
679 uint32_t qbman_wqchan_attr_get_wqlen(struct qbman_wqchan_query_rslt *r, int wq)
680 {
681 	return r->wq_len[wq] & 0x00FFFFFF;
682 }
683 
684 uint64_t qbman_wqchan_attr_get_cdan_ctx(struct qbman_wqchan_query_rslt *r)
685 {
686 	return r->cdan_ctx;
687 }
688 
689 uint16_t qbman_wqchan_attr_get_cdan_wqid(struct qbman_wqchan_query_rslt *r)
690 {
691 	return r->cdan_wqid;
692 }
693 
694 uint8_t qbman_wqchan_attr_get_ctrl(struct qbman_wqchan_query_rslt *r)
695 {
696 	return r->ctrl;
697 }
698 
699 uint16_t qbman_wqchan_attr_get_chanid(struct qbman_wqchan_query_rslt *r)
700 {
701 	return r->chid;
702 }
703