1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name *
4*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name * above copyright notice and this permission notice appear in all
7*5113495bSYour Name * copies.
8*5113495bSYour Name *
9*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name */
18*5113495bSYour Name
19*5113495bSYour Name /**
20*5113495bSYour Name * DOC: qdf_net_dev_stats
21*5113495bSYour Name * QCA driver framework (QDF) network interface stats management APIs
22*5113495bSYour Name */
23*5113495bSYour Name
24*5113495bSYour Name #if !defined(__I_QDF_NET_STATS_H)
25*5113495bSYour Name #define __I_QDF_NET_STATS_H
26*5113495bSYour Name
27*5113495bSYour Name /* Include Files */
28*5113495bSYour Name #include <qdf_types.h>
29*5113495bSYour Name #include <qdf_util.h>
30*5113495bSYour Name #include <linux/netdevice.h>
31*5113495bSYour Name
32*5113495bSYour Name /**
33*5113495bSYour Name * __qdf_net_stats_add_rx_pkts() - Add RX pkts in n/w stats
34*5113495bSYour Name * @stats: Network stats instance
35*5113495bSYour Name * @value: Value to be added
36*5113495bSYour Name *
37*5113495bSYour Name * Return: None.
38*5113495bSYour Name */
39*5113495bSYour Name static inline
__qdf_net_stats_add_rx_pkts(struct net_device_stats * stats,uint32_t value)40*5113495bSYour Name void __qdf_net_stats_add_rx_pkts(struct net_device_stats *stats, uint32_t value)
41*5113495bSYour Name {
42*5113495bSYour Name stats->rx_packets += value;
43*5113495bSYour Name }
44*5113495bSYour Name
45*5113495bSYour Name /**
46*5113495bSYour Name * __qdf_net_stats_get_rx_pkts() - Get RX pkts in net stats
47*5113495bSYour Name * @stats: Network stats instance
48*5113495bSYour Name *
49*5113495bSYour Name * Return: Rx packets received on N/W interface
50*5113495bSYour Name */
51*5113495bSYour Name static inline
__qdf_net_stats_get_rx_pkts(struct net_device_stats * stats)52*5113495bSYour Name unsigned long __qdf_net_stats_get_rx_pkts(struct net_device_stats *stats)
53*5113495bSYour Name {
54*5113495bSYour Name return stats->rx_packets;
55*5113495bSYour Name }
56*5113495bSYour Name
57*5113495bSYour Name /**
58*5113495bSYour Name * __qdf_net_stats_add_rx_bytes() - Add RX bytes in n/w stats
59*5113495bSYour Name * @stats: Network stats instance
60*5113495bSYour Name * @value: Value to be added
61*5113495bSYour Name *
62*5113495bSYour Name * Return: None.
63*5113495bSYour Name */
64*5113495bSYour Name static inline
__qdf_net_stats_add_rx_bytes(struct net_device_stats * stats,uint32_t value)65*5113495bSYour Name void __qdf_net_stats_add_rx_bytes(struct net_device_stats *stats,
66*5113495bSYour Name uint32_t value)
67*5113495bSYour Name {
68*5113495bSYour Name stats->rx_bytes += value;
69*5113495bSYour Name }
70*5113495bSYour Name
71*5113495bSYour Name /**
72*5113495bSYour Name * __qdf_net_stats_get_rx_bytes() - Get RX bytes in net stats
73*5113495bSYour Name * @stats: Network stats instance
74*5113495bSYour Name *
75*5113495bSYour Name * Return: Rx bytes received on N/W interface
76*5113495bSYour Name */
77*5113495bSYour Name static inline
__qdf_net_stats_get_rx_bytes(struct net_device_stats * stats)78*5113495bSYour Name unsigned long __qdf_net_stats_get_rx_bytes(struct net_device_stats *stats)
79*5113495bSYour Name {
80*5113495bSYour Name return stats->rx_bytes;
81*5113495bSYour Name }
82*5113495bSYour Name
83*5113495bSYour Name /**
84*5113495bSYour Name * __qdf_net_stats_inc_rx_errors() - inc RX errors n/w stats
85*5113495bSYour Name * @stats: Network stats instance
86*5113495bSYour Name *
87*5113495bSYour Name * Return: None.
88*5113495bSYour Name */
89*5113495bSYour Name static inline
__qdf_net_stats_inc_rx_errors(struct net_device_stats * stats)90*5113495bSYour Name void __qdf_net_stats_inc_rx_errors(struct net_device_stats *stats)
91*5113495bSYour Name {
92*5113495bSYour Name stats->rx_errors++;
93*5113495bSYour Name }
94*5113495bSYour Name
95*5113495bSYour Name /**
96*5113495bSYour Name * __qdf_net_stats_get_rx_errors() - Get RX errors in net stats
97*5113495bSYour Name * @stats: Network stats instance
98*5113495bSYour Name *
99*5113495bSYour Name * Return: Rx packet errors on N/W interface
100*5113495bSYour Name */
101*5113495bSYour Name static inline
__qdf_net_stats_get_rx_errors(struct net_device_stats * stats)102*5113495bSYour Name unsigned long __qdf_net_stats_get_rx_errors(struct net_device_stats *stats)
103*5113495bSYour Name {
104*5113495bSYour Name return stats->rx_errors;
105*5113495bSYour Name }
106*5113495bSYour Name
107*5113495bSYour Name /**
108*5113495bSYour Name * __qdf_net_stats_inc_rx_dropped() - inc RX dropped n/w stats
109*5113495bSYour Name * @stats: Network stats instance
110*5113495bSYour Name *
111*5113495bSYour Name * Return: None.
112*5113495bSYour Name */
113*5113495bSYour Name static inline
__qdf_net_stats_inc_rx_dropped(struct net_device_stats * stats)114*5113495bSYour Name void __qdf_net_stats_inc_rx_dropped(struct net_device_stats *stats)
115*5113495bSYour Name {
116*5113495bSYour Name stats->rx_dropped++;
117*5113495bSYour Name }
118*5113495bSYour Name
119*5113495bSYour Name /**
120*5113495bSYour Name * __qdf_net_stats_get_rx_dropped() - Get RX dropped in net stats
121*5113495bSYour Name * @stats: Network stats instance
122*5113495bSYour Name *
123*5113495bSYour Name * Return: Rx packet dropped on N/W interface
124*5113495bSYour Name */
125*5113495bSYour Name static inline
__qdf_net_stats_get_rx_dropped(struct net_device_stats * stats)126*5113495bSYour Name unsigned long __qdf_net_stats_get_rx_dropped(struct net_device_stats *stats)
127*5113495bSYour Name {
128*5113495bSYour Name return stats->rx_dropped;
129*5113495bSYour Name }
130*5113495bSYour Name
131*5113495bSYour Name /**
132*5113495bSYour Name * __qdf_net_stats_add_tx_pkts() - Add Tx packets n/w stats
133*5113495bSYour Name * @stats: Network stats instance
134*5113495bSYour Name * @value: Value to be added
135*5113495bSYour Name *
136*5113495bSYour Name * Return: None.
137*5113495bSYour Name */
138*5113495bSYour Name static inline
__qdf_net_stats_add_tx_pkts(struct net_device_stats * stats,uint32_t value)139*5113495bSYour Name void __qdf_net_stats_add_tx_pkts(struct net_device_stats *stats, uint32_t value)
140*5113495bSYour Name {
141*5113495bSYour Name stats->tx_packets += value;
142*5113495bSYour Name }
143*5113495bSYour Name
144*5113495bSYour Name /**
145*5113495bSYour Name * __qdf_net_stats_get_tx_pkts() - Get Tx packets in net stats
146*5113495bSYour Name * @stats: Network stats instance
147*5113495bSYour Name *
148*5113495bSYour Name * Return: Tx packets transmitted on N/W interface
149*5113495bSYour Name */
150*5113495bSYour Name static inline
__qdf_net_stats_get_tx_pkts(struct net_device_stats * stats)151*5113495bSYour Name unsigned long __qdf_net_stats_get_tx_pkts(struct net_device_stats *stats)
152*5113495bSYour Name {
153*5113495bSYour Name return stats->tx_packets;
154*5113495bSYour Name }
155*5113495bSYour Name
156*5113495bSYour Name /**
157*5113495bSYour Name * __qdf_net_stats_add_tx_bytes() - Add Tx bytes n/w stats
158*5113495bSYour Name * @stats: Network stats instance
159*5113495bSYour Name * @value: Value to be added
160*5113495bSYour Name *
161*5113495bSYour Name * Return: None.
162*5113495bSYour Name */
163*5113495bSYour Name static inline
__qdf_net_stats_add_tx_bytes(struct net_device_stats * stats,uint32_t value)164*5113495bSYour Name void __qdf_net_stats_add_tx_bytes(struct net_device_stats *stats,
165*5113495bSYour Name uint32_t value)
166*5113495bSYour Name {
167*5113495bSYour Name stats->tx_bytes += value;
168*5113495bSYour Name }
169*5113495bSYour Name
170*5113495bSYour Name /**
171*5113495bSYour Name * __qdf_net_stats_get_tx_bytes() - Get Tx bytes in net stats
172*5113495bSYour Name * @stats: Network stats instance
173*5113495bSYour Name *
174*5113495bSYour Name * Return: Tx bytes transmitted on N/W interface
175*5113495bSYour Name */
176*5113495bSYour Name static inline
__qdf_net_stats_get_tx_bytes(struct net_device_stats * stats)177*5113495bSYour Name unsigned long __qdf_net_stats_get_tx_bytes(struct net_device_stats *stats)
178*5113495bSYour Name {
179*5113495bSYour Name return stats->tx_bytes;
180*5113495bSYour Name }
181*5113495bSYour Name
182*5113495bSYour Name /**
183*5113495bSYour Name * __qdf_net_stats_inc_tx_errors() - inc Tx errors n/w stats
184*5113495bSYour Name * @stats: Network stats instance
185*5113495bSYour Name *
186*5113495bSYour Name * Return: None.
187*5113495bSYour Name */
188*5113495bSYour Name static inline
__qdf_net_stats_inc_tx_errors(struct net_device_stats * stats)189*5113495bSYour Name void __qdf_net_stats_inc_tx_errors(struct net_device_stats *stats)
190*5113495bSYour Name {
191*5113495bSYour Name stats->tx_errors++;
192*5113495bSYour Name }
193*5113495bSYour Name
194*5113495bSYour Name /**
195*5113495bSYour Name * __qdf_net_stats_get_tx_errors() - Get Tx errors in net stats
196*5113495bSYour Name * @stats: Network stats instance
197*5113495bSYour Name *
198*5113495bSYour Name * Return: Tx errors on N/W interface
199*5113495bSYour Name */
200*5113495bSYour Name static inline
__qdf_net_stats_get_tx_errors(struct net_device_stats * stats)201*5113495bSYour Name unsigned long __qdf_net_stats_get_tx_errors(struct net_device_stats *stats)
202*5113495bSYour Name {
203*5113495bSYour Name return stats->tx_errors;
204*5113495bSYour Name }
205*5113495bSYour Name
206*5113495bSYour Name /**
207*5113495bSYour Name * __qdf_net_stats_inc_tx_dropped() - inc Tx dropped n/w stats
208*5113495bSYour Name * @stats: Network stats instance
209*5113495bSYour Name *
210*5113495bSYour Name * Return: None.
211*5113495bSYour Name */
212*5113495bSYour Name static inline
__qdf_net_stats_inc_tx_dropped(struct net_device_stats * stats)213*5113495bSYour Name void __qdf_net_stats_inc_tx_dropped(struct net_device_stats *stats)
214*5113495bSYour Name {
215*5113495bSYour Name stats->tx_dropped++;
216*5113495bSYour Name }
217*5113495bSYour Name
218*5113495bSYour Name /**
219*5113495bSYour Name * __qdf_net_stats_get_tx_dropped() - Get Tx dropped in net stats
220*5113495bSYour Name * @stats: Network stats instance
221*5113495bSYour Name *
222*5113495bSYour Name * Return: Tx dropped on N/W interface
223*5113495bSYour Name */
224*5113495bSYour Name static inline
__qdf_net_stats_get_tx_dropped(struct net_device_stats * stats)225*5113495bSYour Name unsigned long __qdf_net_stats_get_tx_dropped(struct net_device_stats *stats)
226*5113495bSYour Name {
227*5113495bSYour Name return stats->tx_dropped;
228*5113495bSYour Name }
229*5113495bSYour Name #endif /*__I_QDF_NET_STATS_H*/
230