1 /*
2  * Copyright (c) 2012, 2014-2017, 2019 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * @file ol_txrx_status.h
22  * @brief Functions provided for visibility and debugging.
23  * NOTE: This file is used by both kernel driver SW and userspace SW.
24  * Thus, do not reference use any kernel header files or defs in this file!
25  */
26 #ifndef _OL_TXRX_STATS__H_
27 #define _OL_TXRX_STATS__H_
28 
29 #include <athdefs.h>            /* uint64_t */
30 
31 
32 
33 struct ol_txrx_stats_elem {
34 	uint64_t pkts;
35 	uint64_t bytes;
36 };
37 
38 #define NUM_MAX_TSO_SEGS 4
39 #define NUM_MAX_TSO_SEGS_MASK (NUM_MAX_TSO_SEGS - 1)
40 
41 #define NUM_MAX_TSO_MSDUS 32
42 #define NUM_MAX_TSO_MSDUS_MASK (NUM_MAX_TSO_MSDUS - 1)
43 
44 struct ol_txrx_stats_tso_msdu {
45 	struct qdf_tso_seg_t tso_segs[NUM_MAX_TSO_SEGS];
46 	uint8_t num_seg;
47 	uint8_t tso_seg_idx;
48 	uint32_t total_len;
49 	uint32_t gso_size;
50 	uint8_t nr_frags;
51 };
52 
53 struct ol_txrx_stats_tso_info {
54 	struct ol_txrx_stats_tso_msdu tso_msdu_info[NUM_MAX_TSO_MSDUS];
55 	uint32_t tso_msdu_idx;
56 };
57 
58 /**
59  * @brief data stats published by the host txrx layer
60  *
61  * -------------------------
62  *
63  * TX
64  *
65  */
66 struct ol_txrx_stats_tx_dropped {
67 	/* MSDUs that the host did not accept */
68 	struct ol_txrx_stats_elem host_reject;
69 	/* MSDUs which could not be downloaded to the target */
70 	struct ol_txrx_stats_elem download_fail;
71 	/*
72 	 * MSDUs which the target discarded
73 	 * (lack of memory or old age)
74 	 */
75 	struct ol_txrx_stats_elem target_discard;
76 	/*
77 	 * MSDUs which the target sent but
78 	 * couldn't get an ack for
79 	 */
80 	struct ol_txrx_stats_elem no_ack;
81 
82 	/*
83 	 * MSDUs which the target drop
84 	 * (lack of tx descriptor)
85 	 */
86 	struct ol_txrx_stats_elem target_drop;
87 
88 	/* MSDU which were dropped for other reasons */
89 	struct ol_txrx_stats_elem others;
90 };
91 
92 struct ol_txrx_tso_histogram {
93 	uint32_t pkts_1;
94 	uint32_t pkts_2_5;
95 	uint32_t pkts_6_10;
96 	uint32_t pkts_11_15;
97 	uint32_t pkts_16_20;
98 	uint32_t pkts_20_plus;
99 };
100 
101 struct ol_txrx_stats_tx_histogram {
102 	uint32_t pkts_1;
103 	uint32_t pkts_2_10;
104 	uint32_t pkts_11_20;
105 	uint32_t pkts_21_30;
106 	uint32_t pkts_31_40;
107 	uint32_t pkts_41_50;
108 	uint32_t pkts_51_60;
109 	uint32_t pkts_61_plus;
110 };
111 struct ol_txrx_stats_tx_tso {
112 	struct ol_txrx_stats_elem tso_pkts;
113 #if defined(FEATURE_TSO)
114 	struct ol_txrx_stats_tso_info tso_info;
115 	struct ol_txrx_tso_histogram tso_hist;
116 	qdf_spinlock_t tso_stats_lock;
117 #endif
118 };
119 
120 struct ol_txrx_stats_tx {
121 	/* MSDUs given to the txrx layer by the management stack */
122 	struct ol_txrx_stats_elem mgmt;
123 	/* MSDUs received from the stack */
124 	struct ol_txrx_stats_elem from_stack;
125 	/* MSDUs successfully sent across the WLAN */
126 	struct ol_txrx_stats_elem delivered;
127 	struct ol_txrx_stats_tx_dropped dropped;
128 	/* contains information of packets received per tx completion*/
129 	struct ol_txrx_stats_tx_histogram comp_histogram;
130 	/* TSO (TCP segmentation offload) information */
131 	struct ol_txrx_stats_tx_tso tso;
132 };
133 
134 /*
135  * RX
136  */
137 struct ol_txrx_stats_rx_histogram {
138 	uint32_t pkts_1;
139 	uint32_t pkts_2_10;
140 	uint32_t pkts_11_20;
141 	uint32_t pkts_21_30;
142 	uint32_t pkts_31_40;
143 	uint32_t pkts_41_50;
144 	uint32_t pkts_51_60;
145 	uint32_t pkts_61_plus;
146 };
147 struct ol_txrx_stats_rx_ibss_fwd {
148 	/* MSDUs forwarded to network stack */
149 	u_int32_t packets_stack;
150 	/* MSDUs forwarded from the rx path to the tx path */
151 	u_int32_t packets_fwd;
152 	/* MSDUs forwarded to stack and tx path */
153 	u_int32_t packets_stack_n_fwd;
154 };
155 struct ol_txrx_stats_rx {
156 	/* MSDUs given to the OS shim */
157 	struct ol_txrx_stats_elem delivered;
158 	struct ol_txrx_stats_elem dropped_err;
159 	struct ol_txrx_stats_elem dropped_mic_err;
160 	struct ol_txrx_stats_elem dropped_peer_invalid;
161 	struct ol_txrx_stats_rx_ibss_fwd intra_bss_fwd;
162 	struct ol_txrx_stats_rx_histogram rx_ind_histogram;
163 	uint32_t msdus_with_frag_ind;
164 	uint32_t msdus_with_offload_ind;
165 };
166 struct ol_txrx_stats {
167 	struct ol_txrx_stats_tx tx;
168 	struct ol_txrx_stats_rx rx;
169 };
170 
171 /*
172  * Structure to consolidate host stats
173  */
174 struct ieee80211req_ol_ath_host_stats {
175 	struct ol_txrx_stats txrx_stats;
176 	struct {
177 		int pkt_q_fail_count;
178 		int pkt_q_empty_count;
179 		int send_q_empty_count;
180 	} htc;
181 	struct {
182 		int pipe_no_resrc_count;
183 		int ce_ring_delta_fail_count;
184 	} hif;
185 };
186 
187 #endif /* _OL_TXRX_STATS__H_ */
188