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