18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Broadcom NetXtreme-E RoCE driver.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2016 - 2017, Broadcom. All rights reserved.  The term
58c2ecf20Sopenharmony_ci * Broadcom refers to Broadcom Limited and/or its subsidiaries.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
88c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
98c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
108c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
118c2ecf20Sopenharmony_ci * BSD license below:
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
148c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
158c2ecf20Sopenharmony_ci * are met:
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
188c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
198c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
208c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
218c2ecf20Sopenharmony_ci *    the documentation and/or other materials provided with the
228c2ecf20Sopenharmony_ci *    distribution.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
258c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
268c2ecf20Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
278c2ecf20Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
288c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
298c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
308c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
318c2ecf20Sopenharmony_ci * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
328c2ecf20Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
338c2ecf20Sopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
348c2ecf20Sopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci * Description: Statistics
378c2ecf20Sopenharmony_ci *
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
418c2ecf20Sopenharmony_ci#include <linux/types.h>
428c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
438c2ecf20Sopenharmony_ci#include <linux/sched.h>
448c2ecf20Sopenharmony_ci#include <linux/slab.h>
458c2ecf20Sopenharmony_ci#include <linux/pci.h>
468c2ecf20Sopenharmony_ci#include <linux/prefetch.h>
478c2ecf20Sopenharmony_ci#include <linux/delay.h>
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#include <rdma/ib_addr.h>
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#include "bnxt_ulp.h"
528c2ecf20Sopenharmony_ci#include "roce_hsi.h"
538c2ecf20Sopenharmony_ci#include "qplib_res.h"
548c2ecf20Sopenharmony_ci#include "qplib_sp.h"
558c2ecf20Sopenharmony_ci#include "qplib_fp.h"
568c2ecf20Sopenharmony_ci#include "qplib_rcfw.h"
578c2ecf20Sopenharmony_ci#include "bnxt_re.h"
588c2ecf20Sopenharmony_ci#include "hw_counters.h"
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistatic const char * const bnxt_re_stat_name[] = {
618c2ecf20Sopenharmony_ci	[BNXT_RE_ACTIVE_QP]		=  "active_qps",
628c2ecf20Sopenharmony_ci	[BNXT_RE_ACTIVE_SRQ]		=  "active_srqs",
638c2ecf20Sopenharmony_ci	[BNXT_RE_ACTIVE_CQ]		=  "active_cqs",
648c2ecf20Sopenharmony_ci	[BNXT_RE_ACTIVE_MR]		=  "active_mrs",
658c2ecf20Sopenharmony_ci	[BNXT_RE_ACTIVE_MW]		=  "active_mws",
668c2ecf20Sopenharmony_ci	[BNXT_RE_RX_PKTS]		=  "rx_pkts",
678c2ecf20Sopenharmony_ci	[BNXT_RE_RX_BYTES]		=  "rx_bytes",
688c2ecf20Sopenharmony_ci	[BNXT_RE_TX_PKTS]		=  "tx_pkts",
698c2ecf20Sopenharmony_ci	[BNXT_RE_TX_BYTES]		=  "tx_bytes",
708c2ecf20Sopenharmony_ci	[BNXT_RE_RECOVERABLE_ERRORS]	=  "recoverable_errors",
718c2ecf20Sopenharmony_ci	[BNXT_RE_RX_DROPS]		=  "rx_roce_drops",
728c2ecf20Sopenharmony_ci	[BNXT_RE_RX_DISCARDS]		=  "rx_roce_discards",
738c2ecf20Sopenharmony_ci	[BNXT_RE_TO_RETRANSMITS]        = "to_retransmits",
748c2ecf20Sopenharmony_ci	[BNXT_RE_SEQ_ERR_NAKS_RCVD]     = "seq_err_naks_rcvd",
758c2ecf20Sopenharmony_ci	[BNXT_RE_MAX_RETRY_EXCEEDED]    = "max_retry_exceeded",
768c2ecf20Sopenharmony_ci	[BNXT_RE_RNR_NAKS_RCVD]         = "rnr_naks_rcvd",
778c2ecf20Sopenharmony_ci	[BNXT_RE_MISSING_RESP]          = "missing_resp",
788c2ecf20Sopenharmony_ci	[BNXT_RE_UNRECOVERABLE_ERR]     = "unrecoverable_err",
798c2ecf20Sopenharmony_ci	[BNXT_RE_BAD_RESP_ERR]          = "bad_resp_err",
808c2ecf20Sopenharmony_ci	[BNXT_RE_LOCAL_QP_OP_ERR]       = "local_qp_op_err",
818c2ecf20Sopenharmony_ci	[BNXT_RE_LOCAL_PROTECTION_ERR]  = "local_protection_err",
828c2ecf20Sopenharmony_ci	[BNXT_RE_MEM_MGMT_OP_ERR]       = "mem_mgmt_op_err",
838c2ecf20Sopenharmony_ci	[BNXT_RE_REMOTE_INVALID_REQ_ERR] = "remote_invalid_req_err",
848c2ecf20Sopenharmony_ci	[BNXT_RE_REMOTE_ACCESS_ERR]     = "remote_access_err",
858c2ecf20Sopenharmony_ci	[BNXT_RE_REMOTE_OP_ERR]         = "remote_op_err",
868c2ecf20Sopenharmony_ci	[BNXT_RE_DUP_REQ]               = "dup_req",
878c2ecf20Sopenharmony_ci	[BNXT_RE_RES_EXCEED_MAX]        = "res_exceed_max",
888c2ecf20Sopenharmony_ci	[BNXT_RE_RES_LENGTH_MISMATCH]   = "res_length_mismatch",
898c2ecf20Sopenharmony_ci	[BNXT_RE_RES_EXCEEDS_WQE]       = "res_exceeds_wqe",
908c2ecf20Sopenharmony_ci	[BNXT_RE_RES_OPCODE_ERR]        = "res_opcode_err",
918c2ecf20Sopenharmony_ci	[BNXT_RE_RES_RX_INVALID_RKEY]   = "res_rx_invalid_rkey",
928c2ecf20Sopenharmony_ci	[BNXT_RE_RES_RX_DOMAIN_ERR]     = "res_rx_domain_err",
938c2ecf20Sopenharmony_ci	[BNXT_RE_RES_RX_NO_PERM]        = "res_rx_no_perm",
948c2ecf20Sopenharmony_ci	[BNXT_RE_RES_RX_RANGE_ERR]      = "res_rx_range_err",
958c2ecf20Sopenharmony_ci	[BNXT_RE_RES_TX_INVALID_RKEY]   = "res_tx_invalid_rkey",
968c2ecf20Sopenharmony_ci	[BNXT_RE_RES_TX_DOMAIN_ERR]     = "res_tx_domain_err",
978c2ecf20Sopenharmony_ci	[BNXT_RE_RES_TX_NO_PERM]        = "res_tx_no_perm",
988c2ecf20Sopenharmony_ci	[BNXT_RE_RES_TX_RANGE_ERR]      = "res_tx_range_err",
998c2ecf20Sopenharmony_ci	[BNXT_RE_RES_IRRQ_OFLOW]        = "res_irrq_oflow",
1008c2ecf20Sopenharmony_ci	[BNXT_RE_RES_UNSUP_OPCODE]      = "res_unsup_opcode",
1018c2ecf20Sopenharmony_ci	[BNXT_RE_RES_UNALIGNED_ATOMIC]  = "res_unaligned_atomic",
1028c2ecf20Sopenharmony_ci	[BNXT_RE_RES_REM_INV_ERR]       = "res_rem_inv_err",
1038c2ecf20Sopenharmony_ci	[BNXT_RE_RES_MEM_ERROR]         = "res_mem_err",
1048c2ecf20Sopenharmony_ci	[BNXT_RE_RES_SRQ_ERR]           = "res_srq_err",
1058c2ecf20Sopenharmony_ci	[BNXT_RE_RES_CMP_ERR]           = "res_cmp_err",
1068c2ecf20Sopenharmony_ci	[BNXT_RE_RES_INVALID_DUP_RKEY]  = "res_invalid_dup_rkey",
1078c2ecf20Sopenharmony_ci	[BNXT_RE_RES_WQE_FORMAT_ERR]    = "res_wqe_format_err",
1088c2ecf20Sopenharmony_ci	[BNXT_RE_RES_CQ_LOAD_ERR]       = "res_cq_load_err",
1098c2ecf20Sopenharmony_ci	[BNXT_RE_RES_SRQ_LOAD_ERR]      = "res_srq_load_err",
1108c2ecf20Sopenharmony_ci	[BNXT_RE_RES_TX_PCI_ERR]        = "res_tx_pci_err",
1118c2ecf20Sopenharmony_ci	[BNXT_RE_RES_RX_PCI_ERR]        = "res_rx_pci_err",
1128c2ecf20Sopenharmony_ci	[BNXT_RE_OUT_OF_SEQ_ERR]        = "oos_drop_count"
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciint bnxt_re_ib_get_hw_stats(struct ib_device *ibdev,
1168c2ecf20Sopenharmony_ci			    struct rdma_hw_stats *stats,
1178c2ecf20Sopenharmony_ci			    u8 port, int index)
1188c2ecf20Sopenharmony_ci{
1198c2ecf20Sopenharmony_ci	struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
1208c2ecf20Sopenharmony_ci	struct ctx_hw_stats *bnxt_re_stats = rdev->qplib_ctx.stats.dma;
1218c2ecf20Sopenharmony_ci	int rc  = 0;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	if (!port || !stats)
1248c2ecf20Sopenharmony_ci		return -EINVAL;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	stats->value[BNXT_RE_ACTIVE_QP] = atomic_read(&rdev->qp_count);
1278c2ecf20Sopenharmony_ci	stats->value[BNXT_RE_ACTIVE_SRQ] = atomic_read(&rdev->srq_count);
1288c2ecf20Sopenharmony_ci	stats->value[BNXT_RE_ACTIVE_CQ] = atomic_read(&rdev->cq_count);
1298c2ecf20Sopenharmony_ci	stats->value[BNXT_RE_ACTIVE_MR] = atomic_read(&rdev->mr_count);
1308c2ecf20Sopenharmony_ci	stats->value[BNXT_RE_ACTIVE_MW] = atomic_read(&rdev->mw_count);
1318c2ecf20Sopenharmony_ci	if (bnxt_re_stats) {
1328c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RECOVERABLE_ERRORS] =
1338c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->tx_bcast_pkts);
1348c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RX_DROPS] =
1358c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->rx_error_pkts);
1368c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RX_DISCARDS] =
1378c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->rx_discard_pkts);
1388c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RX_PKTS] =
1398c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->rx_ucast_pkts);
1408c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RX_BYTES] =
1418c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->rx_ucast_bytes);
1428c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_TX_PKTS] =
1438c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->tx_ucast_pkts);
1448c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_TX_BYTES] =
1458c2ecf20Sopenharmony_ci			le64_to_cpu(bnxt_re_stats->tx_ucast_bytes);
1468c2ecf20Sopenharmony_ci	}
1478c2ecf20Sopenharmony_ci	if (test_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags)) {
1488c2ecf20Sopenharmony_ci		rc = bnxt_qplib_get_roce_stats(&rdev->rcfw, &rdev->stats);
1498c2ecf20Sopenharmony_ci		if (rc)
1508c2ecf20Sopenharmony_ci			clear_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS,
1518c2ecf20Sopenharmony_ci				  &rdev->flags);
1528c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_TO_RETRANSMITS] =
1538c2ecf20Sopenharmony_ci					rdev->stats.to_retransmits;
1548c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_SEQ_ERR_NAKS_RCVD] =
1558c2ecf20Sopenharmony_ci					rdev->stats.seq_err_naks_rcvd;
1568c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_MAX_RETRY_EXCEEDED] =
1578c2ecf20Sopenharmony_ci					rdev->stats.max_retry_exceeded;
1588c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RNR_NAKS_RCVD] =
1598c2ecf20Sopenharmony_ci					rdev->stats.rnr_naks_rcvd;
1608c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_MISSING_RESP] =
1618c2ecf20Sopenharmony_ci					rdev->stats.missing_resp;
1628c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_UNRECOVERABLE_ERR] =
1638c2ecf20Sopenharmony_ci					rdev->stats.unrecoverable_err;
1648c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_BAD_RESP_ERR] =
1658c2ecf20Sopenharmony_ci					rdev->stats.bad_resp_err;
1668c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_LOCAL_QP_OP_ERR]	=
1678c2ecf20Sopenharmony_ci				rdev->stats.local_qp_op_err;
1688c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_LOCAL_PROTECTION_ERR] =
1698c2ecf20Sopenharmony_ci				rdev->stats.local_protection_err;
1708c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_MEM_MGMT_OP_ERR] =
1718c2ecf20Sopenharmony_ci				rdev->stats.mem_mgmt_op_err;
1728c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_REMOTE_INVALID_REQ_ERR] =
1738c2ecf20Sopenharmony_ci				rdev->stats.remote_invalid_req_err;
1748c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_REMOTE_ACCESS_ERR] =
1758c2ecf20Sopenharmony_ci				rdev->stats.remote_access_err;
1768c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_REMOTE_OP_ERR] =
1778c2ecf20Sopenharmony_ci				rdev->stats.remote_op_err;
1788c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_DUP_REQ] =
1798c2ecf20Sopenharmony_ci				rdev->stats.dup_req;
1808c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_EXCEED_MAX] =
1818c2ecf20Sopenharmony_ci				rdev->stats.res_exceed_max;
1828c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_LENGTH_MISMATCH] =
1838c2ecf20Sopenharmony_ci				rdev->stats.res_length_mismatch;
1848c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_EXCEEDS_WQE] =
1858c2ecf20Sopenharmony_ci				rdev->stats.res_exceeds_wqe;
1868c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_OPCODE_ERR] =
1878c2ecf20Sopenharmony_ci				rdev->stats.res_opcode_err;
1888c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_RX_INVALID_RKEY] =
1898c2ecf20Sopenharmony_ci				rdev->stats.res_rx_invalid_rkey;
1908c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_RX_DOMAIN_ERR] =
1918c2ecf20Sopenharmony_ci				rdev->stats.res_rx_domain_err;
1928c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_RX_NO_PERM] =
1938c2ecf20Sopenharmony_ci				rdev->stats.res_rx_no_perm;
1948c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_RX_RANGE_ERR]  =
1958c2ecf20Sopenharmony_ci				rdev->stats.res_rx_range_err;
1968c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_TX_INVALID_RKEY] =
1978c2ecf20Sopenharmony_ci				rdev->stats.res_tx_invalid_rkey;
1988c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_TX_DOMAIN_ERR] =
1998c2ecf20Sopenharmony_ci				rdev->stats.res_tx_domain_err;
2008c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_TX_NO_PERM] =
2018c2ecf20Sopenharmony_ci				rdev->stats.res_tx_no_perm;
2028c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_TX_RANGE_ERR]  =
2038c2ecf20Sopenharmony_ci				rdev->stats.res_tx_range_err;
2048c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_IRRQ_OFLOW] =
2058c2ecf20Sopenharmony_ci				rdev->stats.res_irrq_oflow;
2068c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_UNSUP_OPCODE]  =
2078c2ecf20Sopenharmony_ci				rdev->stats.res_unsup_opcode;
2088c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_UNALIGNED_ATOMIC] =
2098c2ecf20Sopenharmony_ci				rdev->stats.res_unaligned_atomic;
2108c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_REM_INV_ERR]   =
2118c2ecf20Sopenharmony_ci				rdev->stats.res_rem_inv_err;
2128c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_MEM_ERROR] =
2138c2ecf20Sopenharmony_ci				rdev->stats.res_mem_error;
2148c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_SRQ_ERR] =
2158c2ecf20Sopenharmony_ci				rdev->stats.res_srq_err;
2168c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_CMP_ERR] =
2178c2ecf20Sopenharmony_ci				rdev->stats.res_cmp_err;
2188c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_INVALID_DUP_RKEY] =
2198c2ecf20Sopenharmony_ci				rdev->stats.res_invalid_dup_rkey;
2208c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_WQE_FORMAT_ERR] =
2218c2ecf20Sopenharmony_ci				rdev->stats.res_wqe_format_err;
2228c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_CQ_LOAD_ERR]   =
2238c2ecf20Sopenharmony_ci				rdev->stats.res_cq_load_err;
2248c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_SRQ_LOAD_ERR]  =
2258c2ecf20Sopenharmony_ci				rdev->stats.res_srq_load_err;
2268c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_TX_PCI_ERR]    =
2278c2ecf20Sopenharmony_ci				rdev->stats.res_tx_pci_err;
2288c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_RES_RX_PCI_ERR]    =
2298c2ecf20Sopenharmony_ci				rdev->stats.res_rx_pci_err;
2308c2ecf20Sopenharmony_ci		stats->value[BNXT_RE_OUT_OF_SEQ_ERR]    =
2318c2ecf20Sopenharmony_ci				rdev->stats.res_oos_drop_count;
2328c2ecf20Sopenharmony_ci	}
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	return ARRAY_SIZE(bnxt_re_stat_name);
2358c2ecf20Sopenharmony_ci}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_cistruct rdma_hw_stats *bnxt_re_ib_alloc_hw_stats(struct ib_device *ibdev,
2388c2ecf20Sopenharmony_ci						u8 port_num)
2398c2ecf20Sopenharmony_ci{
2408c2ecf20Sopenharmony_ci	BUILD_BUG_ON(ARRAY_SIZE(bnxt_re_stat_name) != BNXT_RE_NUM_COUNTERS);
2418c2ecf20Sopenharmony_ci	/* We support only per port stats */
2428c2ecf20Sopenharmony_ci	if (!port_num)
2438c2ecf20Sopenharmony_ci		return NULL;
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci	return rdma_alloc_hw_stats_struct(bnxt_re_stat_name,
2468c2ecf20Sopenharmony_ci					  ARRAY_SIZE(bnxt_re_stat_name),
2478c2ecf20Sopenharmony_ci					  RDMA_HW_STATS_DEFAULT_LIFESPAN);
2488c2ecf20Sopenharmony_ci}
249