]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/bus/fslmc/qbman/qbman_debug.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / bus / fslmc / qbman / qbman_debug.c
1 /* Copyright (C) 2015 Freescale Semiconductor, Inc.
2 *
3 * SPDX-License-Identifier: BSD-3-Clause
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_fq_query_desc {
21 uint8_t verb;
22 uint8_t reserved[3];
23 uint32_t fqid;
24 uint8_t reserved2[57];
25 };
26
27 int qbman_fq_query_state(struct qbman_swp *s, uint32_t fqid,
28 struct qbman_fq_query_np_rslt *r)
29 {
30 struct qbman_fq_query_desc *p;
31
32 p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s);
33 if (!p)
34 return -EBUSY;
35
36 p->fqid = fqid;
37 *r = *(struct qbman_fq_query_np_rslt *)qbman_swp_mc_complete(s, p,
38 QBMAN_FQ_QUERY_NP);
39 if (!r) {
40 pr_err("qbman: Query FQID %d NP fields failed, no response\n",
41 fqid);
42 return -EIO;
43 }
44
45 /* Decode the outcome */
46 QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY_NP);
47
48 /* Determine success or failure */
49 if (r->rslt != QBMAN_MC_RSLT_OK) {
50 pr_err("Query NP fields of FQID 0x%x failed, code=0x%02x\n",
51 fqid, r->rslt);
52 return -EIO;
53 }
54
55 return 0;
56 }
57
58 uint32_t qbman_fq_state_frame_count(const struct qbman_fq_query_np_rslt *r)
59 {
60 return (r->frm_cnt & 0x00FFFFFF);
61 }
62
63 uint32_t qbman_fq_state_byte_count(const struct qbman_fq_query_np_rslt *r)
64 {
65 return r->byte_cnt;
66 }