162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Broadcom NetXtreme-E RoCE driver.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright (c) 2016 - 2017, Broadcom. All rights reserved.  The term
562306a36Sopenharmony_ci * Broadcom refers to Broadcom Limited and/or its subsidiaries.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * This software is available to you under a choice of one of two
862306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
962306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
1062306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
1162306a36Sopenharmony_ci * BSD license below:
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
1462306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
1562306a36Sopenharmony_ci * are met:
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
1862306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
1962306a36Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
2062306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
2162306a36Sopenharmony_ci *    the documentation and/or other materials provided with the
2262306a36Sopenharmony_ci *    distribution.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
2562306a36Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2662306a36Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2762306a36Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
2862306a36Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2962306a36Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3062306a36Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
3162306a36Sopenharmony_ci * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
3262306a36Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
3362306a36Sopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
3462306a36Sopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3562306a36Sopenharmony_ci *
3662306a36Sopenharmony_ci * Description: Statistics (header)
3762306a36Sopenharmony_ci *
3862306a36Sopenharmony_ci */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#ifndef __BNXT_RE_HW_STATS_H__
4162306a36Sopenharmony_ci#define __BNXT_RE_HW_STATS_H__
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cienum bnxt_re_hw_stats {
4462306a36Sopenharmony_ci	BNXT_RE_ACTIVE_PD,
4562306a36Sopenharmony_ci	BNXT_RE_ACTIVE_AH,
4662306a36Sopenharmony_ci	BNXT_RE_ACTIVE_QP,
4762306a36Sopenharmony_ci	BNXT_RE_ACTIVE_RC_QP,
4862306a36Sopenharmony_ci	BNXT_RE_ACTIVE_UD_QP,
4962306a36Sopenharmony_ci	BNXT_RE_ACTIVE_SRQ,
5062306a36Sopenharmony_ci	BNXT_RE_ACTIVE_CQ,
5162306a36Sopenharmony_ci	BNXT_RE_ACTIVE_MR,
5262306a36Sopenharmony_ci	BNXT_RE_ACTIVE_MW,
5362306a36Sopenharmony_ci	BNXT_RE_WATERMARK_PD,
5462306a36Sopenharmony_ci	BNXT_RE_WATERMARK_AH,
5562306a36Sopenharmony_ci	BNXT_RE_WATERMARK_QP,
5662306a36Sopenharmony_ci	BNXT_RE_WATERMARK_RC_QP,
5762306a36Sopenharmony_ci	BNXT_RE_WATERMARK_UD_QP,
5862306a36Sopenharmony_ci	BNXT_RE_WATERMARK_SRQ,
5962306a36Sopenharmony_ci	BNXT_RE_WATERMARK_CQ,
6062306a36Sopenharmony_ci	BNXT_RE_WATERMARK_MR,
6162306a36Sopenharmony_ci	BNXT_RE_WATERMARK_MW,
6262306a36Sopenharmony_ci	BNXT_RE_RESIZE_CQ_CNT,
6362306a36Sopenharmony_ci	BNXT_RE_RX_PKTS,
6462306a36Sopenharmony_ci	BNXT_RE_RX_BYTES,
6562306a36Sopenharmony_ci	BNXT_RE_TX_PKTS,
6662306a36Sopenharmony_ci	BNXT_RE_TX_BYTES,
6762306a36Sopenharmony_ci	BNXT_RE_RECOVERABLE_ERRORS,
6862306a36Sopenharmony_ci	BNXT_RE_TX_ERRORS,
6962306a36Sopenharmony_ci	BNXT_RE_TX_DISCARDS,
7062306a36Sopenharmony_ci	BNXT_RE_RX_ERRORS,
7162306a36Sopenharmony_ci	BNXT_RE_RX_DISCARDS,
7262306a36Sopenharmony_ci	BNXT_RE_TO_RETRANSMITS,
7362306a36Sopenharmony_ci	BNXT_RE_SEQ_ERR_NAKS_RCVD,
7462306a36Sopenharmony_ci	BNXT_RE_MAX_RETRY_EXCEEDED,
7562306a36Sopenharmony_ci	BNXT_RE_RNR_NAKS_RCVD,
7662306a36Sopenharmony_ci	BNXT_RE_MISSING_RESP,
7762306a36Sopenharmony_ci	BNXT_RE_UNRECOVERABLE_ERR,
7862306a36Sopenharmony_ci	BNXT_RE_BAD_RESP_ERR,
7962306a36Sopenharmony_ci	BNXT_RE_LOCAL_QP_OP_ERR,
8062306a36Sopenharmony_ci	BNXT_RE_LOCAL_PROTECTION_ERR,
8162306a36Sopenharmony_ci	BNXT_RE_MEM_MGMT_OP_ERR,
8262306a36Sopenharmony_ci	BNXT_RE_REMOTE_INVALID_REQ_ERR,
8362306a36Sopenharmony_ci	BNXT_RE_REMOTE_ACCESS_ERR,
8462306a36Sopenharmony_ci	BNXT_RE_REMOTE_OP_ERR,
8562306a36Sopenharmony_ci	BNXT_RE_DUP_REQ,
8662306a36Sopenharmony_ci	BNXT_RE_RES_EXCEED_MAX,
8762306a36Sopenharmony_ci	BNXT_RE_RES_LENGTH_MISMATCH,
8862306a36Sopenharmony_ci	BNXT_RE_RES_EXCEEDS_WQE,
8962306a36Sopenharmony_ci	BNXT_RE_RES_OPCODE_ERR,
9062306a36Sopenharmony_ci	BNXT_RE_RES_RX_INVALID_RKEY,
9162306a36Sopenharmony_ci	BNXT_RE_RES_RX_DOMAIN_ERR,
9262306a36Sopenharmony_ci	BNXT_RE_RES_RX_NO_PERM,
9362306a36Sopenharmony_ci	BNXT_RE_RES_RX_RANGE_ERR,
9462306a36Sopenharmony_ci	BNXT_RE_RES_TX_INVALID_RKEY,
9562306a36Sopenharmony_ci	BNXT_RE_RES_TX_DOMAIN_ERR,
9662306a36Sopenharmony_ci	BNXT_RE_RES_TX_NO_PERM,
9762306a36Sopenharmony_ci	BNXT_RE_RES_TX_RANGE_ERR,
9862306a36Sopenharmony_ci	BNXT_RE_RES_IRRQ_OFLOW,
9962306a36Sopenharmony_ci	BNXT_RE_RES_UNSUP_OPCODE,
10062306a36Sopenharmony_ci	BNXT_RE_RES_UNALIGNED_ATOMIC,
10162306a36Sopenharmony_ci	BNXT_RE_RES_REM_INV_ERR,
10262306a36Sopenharmony_ci	BNXT_RE_RES_MEM_ERROR,
10362306a36Sopenharmony_ci	BNXT_RE_RES_SRQ_ERR,
10462306a36Sopenharmony_ci	BNXT_RE_RES_CMP_ERR,
10562306a36Sopenharmony_ci	BNXT_RE_RES_INVALID_DUP_RKEY,
10662306a36Sopenharmony_ci	BNXT_RE_RES_WQE_FORMAT_ERR,
10762306a36Sopenharmony_ci	BNXT_RE_RES_CQ_LOAD_ERR,
10862306a36Sopenharmony_ci	BNXT_RE_RES_SRQ_LOAD_ERR,
10962306a36Sopenharmony_ci	BNXT_RE_RES_TX_PCI_ERR,
11062306a36Sopenharmony_ci	BNXT_RE_RES_RX_PCI_ERR,
11162306a36Sopenharmony_ci	BNXT_RE_OUT_OF_SEQ_ERR,
11262306a36Sopenharmony_ci	BNXT_RE_TX_ATOMIC_REQ,
11362306a36Sopenharmony_ci	BNXT_RE_TX_READ_REQ,
11462306a36Sopenharmony_ci	BNXT_RE_TX_READ_RES,
11562306a36Sopenharmony_ci	BNXT_RE_TX_WRITE_REQ,
11662306a36Sopenharmony_ci	BNXT_RE_TX_SEND_REQ,
11762306a36Sopenharmony_ci	BNXT_RE_TX_ROCE_PKTS,
11862306a36Sopenharmony_ci	BNXT_RE_TX_ROCE_BYTES,
11962306a36Sopenharmony_ci	BNXT_RE_RX_ATOMIC_REQ,
12062306a36Sopenharmony_ci	BNXT_RE_RX_READ_REQ,
12162306a36Sopenharmony_ci	BNXT_RE_RX_READ_RESP,
12262306a36Sopenharmony_ci	BNXT_RE_RX_WRITE_REQ,
12362306a36Sopenharmony_ci	BNXT_RE_RX_SEND_REQ,
12462306a36Sopenharmony_ci	BNXT_RE_RX_ROCE_PKTS,
12562306a36Sopenharmony_ci	BNXT_RE_RX_ROCE_BYTES,
12662306a36Sopenharmony_ci	BNXT_RE_RX_ROCE_GOOD_PKTS,
12762306a36Sopenharmony_ci	BNXT_RE_RX_ROCE_GOOD_BYTES,
12862306a36Sopenharmony_ci	BNXT_RE_OOB,
12962306a36Sopenharmony_ci	BNXT_RE_TX_CNP,
13062306a36Sopenharmony_ci	BNXT_RE_RX_CNP,
13162306a36Sopenharmony_ci	BNXT_RE_RX_ECN,
13262306a36Sopenharmony_ci	BNXT_RE_PACING_RESCHED,
13362306a36Sopenharmony_ci	BNXT_RE_PACING_CMPL,
13462306a36Sopenharmony_ci	BNXT_RE_PACING_ALERT,
13562306a36Sopenharmony_ci	BNXT_RE_DB_FIFO_REG,
13662306a36Sopenharmony_ci	BNXT_RE_NUM_EXT_COUNTERS
13762306a36Sopenharmony_ci};
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define BNXT_RE_NUM_STD_COUNTERS (BNXT_RE_OUT_OF_SEQ_ERR + 1)
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_cistruct bnxt_re_db_pacing_stats {
14262306a36Sopenharmony_ci	u64 resched;
14362306a36Sopenharmony_ci	u64 complete;
14462306a36Sopenharmony_ci	u64 alerts;
14562306a36Sopenharmony_ci};
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_cistruct bnxt_re_res_cntrs {
14862306a36Sopenharmony_ci	atomic_t qp_count;
14962306a36Sopenharmony_ci	atomic_t rc_qp_count;
15062306a36Sopenharmony_ci	atomic_t ud_qp_count;
15162306a36Sopenharmony_ci	atomic_t cq_count;
15262306a36Sopenharmony_ci	atomic_t srq_count;
15362306a36Sopenharmony_ci	atomic_t mr_count;
15462306a36Sopenharmony_ci	atomic_t mw_count;
15562306a36Sopenharmony_ci	atomic_t ah_count;
15662306a36Sopenharmony_ci	atomic_t pd_count;
15762306a36Sopenharmony_ci	atomic_t resize_count;
15862306a36Sopenharmony_ci	u64 qp_watermark;
15962306a36Sopenharmony_ci	u64 rc_qp_watermark;
16062306a36Sopenharmony_ci	u64 ud_qp_watermark;
16162306a36Sopenharmony_ci	u64 cq_watermark;
16262306a36Sopenharmony_ci	u64 srq_watermark;
16362306a36Sopenharmony_ci	u64 mr_watermark;
16462306a36Sopenharmony_ci	u64 mw_watermark;
16562306a36Sopenharmony_ci	u64 ah_watermark;
16662306a36Sopenharmony_ci	u64 pd_watermark;
16762306a36Sopenharmony_ci};
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_cistruct bnxt_re_rstat {
17062306a36Sopenharmony_ci	struct bnxt_qplib_roce_stats    errs;
17162306a36Sopenharmony_ci	struct bnxt_qplib_ext_stat      ext_stat;
17262306a36Sopenharmony_ci};
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cistruct bnxt_re_stats {
17562306a36Sopenharmony_ci	struct bnxt_re_rstat            rstat;
17662306a36Sopenharmony_ci	struct bnxt_re_res_cntrs        res;
17762306a36Sopenharmony_ci	struct bnxt_re_db_pacing_stats  pacing;
17862306a36Sopenharmony_ci};
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_cistruct rdma_hw_stats *bnxt_re_ib_alloc_hw_port_stats(struct ib_device *ibdev,
18162306a36Sopenharmony_ci						     u32 port_num);
18262306a36Sopenharmony_ciint bnxt_re_ib_get_hw_stats(struct ib_device *ibdev,
18362306a36Sopenharmony_ci			    struct rdma_hw_stats *stats,
18462306a36Sopenharmony_ci			    u32 port, int index);
18562306a36Sopenharmony_ci#endif /* __BNXT_RE_HW_STATS_H__ */
186