]>
git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/bnxt/bnxt_stats.c
4 * Copyright(c) Broadcom Limited.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Broadcom Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <rte_byteorder.h>
40 #include "bnxt_hwrm.h"
42 #include "bnxt_stats.h"
44 #include "hsi_struct_def_dpdk.h"
47 * Statistics functions
50 void bnxt_free_stats(struct bnxt
*bp
)
54 for (i
= 0; i
< (int)bp
->tx_cp_nr_rings
; i
++) {
55 struct bnxt_tx_queue
*txq
= bp
->tx_queues
[i
];
57 bnxt_free_txq_stats(txq
);
59 for (i
= 0; i
< (int)bp
->rx_cp_nr_rings
; i
++) {
60 struct bnxt_rx_queue
*rxq
= bp
->rx_queues
[i
];
62 bnxt_free_rxq_stats(rxq
);
66 void bnxt_stats_get_op(struct rte_eth_dev
*eth_dev
,
67 struct rte_eth_stats
*bnxt_stats
)
70 struct bnxt
*bp
= eth_dev
->data
->dev_private
;
72 memset(bnxt_stats
, 0, sizeof(*bnxt_stats
));
74 for (i
= 0; i
< bp
->rx_cp_nr_rings
; i
++) {
75 struct bnxt_rx_queue
*rxq
= bp
->rx_queues
[i
];
76 struct bnxt_cp_ring_info
*cpr
= rxq
->cp_ring
;
77 struct ctx_hw_stats64
*hw_stats
=
78 (struct ctx_hw_stats64
*)cpr
->hw_stats
;
80 bnxt_stats
->q_ipackets
[i
] +=
81 rte_le_to_cpu_64(hw_stats
->rx_ucast_pkts
);
82 bnxt_stats
->q_ipackets
[i
] +=
83 rte_le_to_cpu_64(hw_stats
->rx_mcast_pkts
);
84 bnxt_stats
->q_ipackets
[i
] +=
85 rte_le_to_cpu_64(hw_stats
->rx_bcast_pkts
);
87 bnxt_stats
->q_ibytes
[i
] +=
88 rte_le_to_cpu_64(hw_stats
->rx_ucast_bytes
);
89 bnxt_stats
->q_ibytes
[i
] +=
90 rte_le_to_cpu_64(hw_stats
->rx_mcast_bytes
);
91 bnxt_stats
->q_ibytes
[i
] +=
92 rte_le_to_cpu_64(hw_stats
->rx_bcast_bytes
);
95 * TBD: No clear mapping to this... we don't seem
96 * to have a stat specifically for dropped due to
99 bnxt_stats
->q_errors
[i
] = 0;
101 /* These get replaced once the *_QSTATS commands work */
102 bnxt_stats
->ipackets
+= bnxt_stats
->q_ipackets
[i
];
103 bnxt_stats
->ibytes
+= bnxt_stats
->q_ibytes
[i
];
104 bnxt_stats
->imissed
+= bnxt_stats
->q_errors
[i
];
105 bnxt_stats
->ierrors
+=
106 rte_le_to_cpu_64(hw_stats
->rx_discard_pkts
);
109 for (i
= 0; i
< bp
->tx_cp_nr_rings
; i
++) {
110 struct bnxt_tx_queue
*txq
= bp
->tx_queues
[i
];
111 struct bnxt_cp_ring_info
*cpr
= txq
->cp_ring
;
112 struct ctx_hw_stats64
*hw_stats
=
113 (struct ctx_hw_stats64
*)cpr
->hw_stats
;
115 bnxt_stats
->q_opackets
[i
] +=
116 rte_le_to_cpu_64(hw_stats
->tx_ucast_pkts
);
117 bnxt_stats
->q_opackets
[i
] +=
118 rte_le_to_cpu_64(hw_stats
->tx_mcast_pkts
);
119 bnxt_stats
->q_opackets
[i
] +=
120 rte_le_to_cpu_64(hw_stats
->tx_bcast_pkts
);
122 bnxt_stats
->q_obytes
[i
] +=
123 rte_le_to_cpu_64(hw_stats
->tx_ucast_bytes
);
124 bnxt_stats
->q_obytes
[i
] +=
125 rte_le_to_cpu_64(hw_stats
->tx_mcast_bytes
);
126 bnxt_stats
->q_obytes
[i
] +=
127 rte_le_to_cpu_64(hw_stats
->tx_bcast_bytes
);
129 /* These get replaced once the *_QSTATS commands work */
130 bnxt_stats
->opackets
+= bnxt_stats
->q_opackets
[i
];
131 bnxt_stats
->obytes
+= bnxt_stats
->q_obytes
[i
];
132 bnxt_stats
->oerrors
+= rte_le_to_cpu_64(hw_stats
->tx_drop_pkts
);
133 bnxt_stats
->oerrors
+= rte_le_to_cpu_64(hw_stats
->tx_discard_pkts
);
137 void bnxt_stats_reset_op(struct rte_eth_dev
*eth_dev
)
139 struct bnxt
*bp
= (struct bnxt
*)eth_dev
->data
->dev_private
;
141 bnxt_clear_all_hwrm_stat_ctxs(bp
);