1 /*
2  * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 #ifndef _WAL_RX_DESC__H_
29 #define _WAL_RX_DESC__H_
30 
31 
32 #if defined(ATH_TARGET)
33 #include <athdefs.h> /* A_UINT8 */
34 #else
35 #include <a_types.h> /* A_UINT8 */
36 #endif
37 
38 /*
39  * As this header is used by host also,
40  * and host will access target registers by target reg tbl,
41  * so disable direct-reference here for host.
42  *
43  */
44 #if !defined(ATH_PERF_PWR_OFFLOAD)
45 #if defined(CONFIG_AR900B_SUPPORT) || defined(AR900B) //FIXME_WIFI2 beeliner enbled by default (will be removed once we have target aware HTT)
46 #include <hw/interface/rx_location_info.h>
47 #include <hw/interface/rx_pkt_end.h>
48 #include <hw/interface/rx_phy_ppdu_end.h>
49 #include <hw/interface/rx_timing_offset.h>
50 #include <hw/interface/rx_location_info.h>
51 #include <hw/tlv/rx_attention.h>
52 #include <hw/tlv/rx_frag_info.h>
53 #include <hw/tlv/rx_msdu_start.h>
54 #include <hw/tlv/rx_msdu_end.h>
55 #include <hw/tlv/rx_mpdu_start.h>
56 #include <hw/tlv/rx_mpdu_end.h>
57 #include <hw/tlv/rx_ppdu_start.h>
58 #include <hw/tlv/rx_ppdu_end.h>
59 #else
60 /* HW rx descriptor definitions */
61 #include <mac_descriptors/rx_attention.h>
62 #include <mac_descriptors/rx_frag_info.h>
63 #include <mac_descriptors/rx_msdu_start.h>
64 #include <mac_descriptors/rx_msdu_end.h>
65 #include <mac_descriptors/rx_mpdu_start.h>
66 #include <mac_descriptors/rx_mpdu_end.h>
67 #include <mac_descriptors/rx_ppdu_start.h>
68 #include <mac_descriptors/rx_ppdu_end.h>
69 #endif
70 /*
71  * This struct defines the basic descriptor information, which is
72  * written by the 11ac HW MAC into the WAL's rx status descriptor
73  * ring.
74  */
75 struct hw_rx_desc_base {
76     struct rx_attention  attention;
77     struct rx_frag_info  frag_info;
78     struct rx_mpdu_start mpdu_start;
79     struct rx_msdu_start msdu_start;
80     struct rx_msdu_end   msdu_end;
81     struct rx_mpdu_end   mpdu_end;
82     struct rx_ppdu_start ppdu_start;
83     struct rx_ppdu_end   ppdu_end;
84 };
85 #endif
86 
87 /*
88  * This struct defines the basic MSDU rx descriptor created by FW.
89  */
90 struct fw_rx_desc_base {
91     union {
92         struct {
93             A_UINT8 discard  : 1,
94                     forward  : 1,
95                     any_err  : 1,
96                     dup_err  : 1,
97                     ipa_ind  : 1,
98                     inspect  : 1,
99                     extension: 2;
100         }bits;
101         A_UINT8     val;
102     }u;
103 };
104 
105 #define FW_MSDU_INFO_FIRST_WAKEUP_M 0x40
106 #define FW_MSDU_INFO_FIRST_WAKEUP_S 6
107 
108 #define FW_RX_DESC_DISCARD_M 0x1
109 #define FW_RX_DESC_DISCARD_S 0
110 #define FW_RX_DESC_FORWARD_M 0x2
111 #define FW_RX_DESC_FORWARD_S 1
112 #define FW_RX_DESC_ANY_ERR_M 0x4
113 #define FW_RX_DESC_ANY_ERR_S 2
114 #define FW_RX_DESC_DUP_ERR_M 0x8
115 #define FW_RX_DESC_DUP_ERR_S 3
116 #define FW_RX_DESC_INSPECT_M 0x20
117 #define FW_RX_DESC_INSPECT_S 5
118 #define FW_RX_DESC_EXT_M     0xc0
119 #define FW_RX_DESC_EXT_S     6
120 
121 #define FW_RX_DESC_CNT_2_BYTES(_fw_desc_cnt)    (_fw_desc_cnt)
122 
123 enum {
124     FW_RX_DESC_EXT_NONE          = 0,
125     FW_RX_DESC_EXT_LRO_ONLY,
126     FW_RX_DESC_EXT_LRO_AND_OTHER,
127     FW_RX_DESC_EXT_OTHER
128 };
129 
130 #define FW_RX_DESC_DISCARD_GET(_var) \
131     (((_var) & FW_RX_DESC_DISCARD_M) >> FW_RX_DESC_DISCARD_S)
132 #define FW_RX_DESC_DISCARD_SET(_var, _val) \
133     ((_var) |= ((_val) << FW_RX_DESC_DISCARD_S))
134 
135 #define FW_RX_DESC_FORWARD_GET(_var) \
136     (((_var) & FW_RX_DESC_FORWARD_M) >> FW_RX_DESC_FORWARD_S)
137 #define FW_RX_DESC_FORWARD_SET(_var, _val) \
138     ((_var) |= ((_val) << FW_RX_DESC_FORWARD_S))
139 
140 #define FW_RX_DESC_INSPECT_GET(_var) \
141     (((_var) & FW_RX_DESC_INSPECT_M) >> FW_RX_DESC_INSPECT_S)
142 #define FW_RX_DESC_INSPECT_SET(_var, _val) \
143     ((_var) |= ((_val) << FW_RX_DESC_INSPECT_S))
144 
145 #define FW_RX_DESC_EXT_GET(_var) \
146     (((_var) & FW_RX_DESC_EXT_M) >> FW_RX_DESC_EXT_S)
147 #define FW_RX_DESC_EXT_SET(_var, _val) \
148     ((_var) |= ((_val) << FW_RX_DESC_EXT_S))
149 
150 
151 /*
152  * This struct defines TCP_CHKSUM_OFFLOAD bit fields which are needed by host.
153  */
154 struct fw_rx_msdu_info {
155     union {
156         /*
157          * The "bits" struct defines the flags in fw_rx_msdu_info used
158          * during regular operation.
159          */
160         struct {
161             A_UINT8 tcp_udp_chksum_fail : 1, /* for tcp checksum offload use */
162                     ip_chksum_fail      : 1,
163                     ipv6_proto          : 1,
164                     tcp_proto           : 1,
165                     udp_proto           : 1,
166                     ip_frag             : 1,
167                     first_wakeup        : 1,
168                     reserved            : 1;
169         } bits;
170         /*
171          * The "mon" struct defines the flags in fw_rx_msdu_info used
172          * during monitor mode.
173          */
174         struct {
175             A_UINT8 last_frag           : 1,
176                     reserved            : 7;
177         } mon;
178         A_UINT8     val;
179     } u;
180 };
181 
182 /* regular operation flags */
183 
184 #define FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_M 0x1
185 #define FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_S 0
186 #define FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_M      0x2
187 #define FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_S      1
188 #define FW_RX_MSDU_INFO_IPV6_PROTO_M          0x4
189 #define FW_RX_MSDU_INFO_IPV6_PROTO_S          2
190 #define FW_RX_MSDU_INFO_TCP_PROTO_M           0x8
191 #define FW_RX_MSDU_INFO_TCP_PROTO_S           3
192 #define FW_RX_MSDU_INFO_UDP_PROTO_M           0x10
193 #define FW_RX_MSDU_INFO_UDP_PROTO_S           4
194 #define FW_RX_MSDU_INFO_IP_FRAG_M             0x20
195 #define FW_RX_MSDU_INFO_IP_FRAG_S             5
196 #define FW_RX_MSDU_INFO_FIRST_WAKEUP_M        0x40
197 #define FW_RX_MSDU_INFO_FIRST_WAKEUP_S        6
198 
199 #define FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_GET(_var) \
200     (((_var) & FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_M) >> FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_S)
201 #define FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_SET(_var, _val) \
202     ((_var) |= ((_val) << FW_RX_MSDU_INFO_TCP_UDP_CHKSUM_FAIL_S))
203 
204 #define FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_GET(_var) \
205     (((_var) & FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_M) >> FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_S)
206 #define FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_SET(_var, _val) \
207     ((_var) |= ((_val) << FW_RX_MSDU_INFO_IP_CHKSUM_FAIL_S))
208 
209 #define FW_RX_MSDU_INFO_IPV6_PROTO_GET(_var) \
210     (((_var) & FW_RX_MSDU_INFO_IPV6_PROTO_M) >> FW_RX_MSDU_INFO_IPV6_PROTO_S)
211 #define FW_RX_MSDU_INFO_IPV6_PROTO_SET(_var, _val) \
212     ((_var) |= ((_val) << FW_RX_MSDU_INFO_IPV6_PROTO_S))
213 
214 #define FW_RX_MSDU_INFO_TCP_PROTO_GET(_var) \
215     (((_var) & FW_RX_MSDU_INFO_TCP_PROTO_M) >> FW_RX_MSDU_INFO_TCP_PROTO_S)
216 #define FW_RX_MSDU_INFO_TCP_PROTO_SET(_var, _val) \
217     ((_var) |= ((_val) << FW_RX_MSDU_INFO_TCP_PROTO_S))
218 
219 #define FW_RX_MSDU_INFO_UDP_PROTO_GET(_var) \
220     (((_var) & FW_RX_MSDU_INFO_UDP_PROTO_M) >> FW_RX_MSDU_INFO_UDP_PROTO_S)
221 #define FW_RX_MSDU_INFO_UDP_PROTO_SET(_var, _val) \
222     ((_var) |= ((_val) << FW_RX_MSDU_INFO_UDP_PROTO_S))
223 
224 #define FW_RX_MSDU_INFO_IP_FRAG_GET(_var) \
225     (((_var) & FW_RX_MSDU_INFO_IP_FRAG_M) >> FW_RX_MSDU_INFO_IP_FRAG_S)
226 #define FW_RX_MSDU_INFO_IP_FRAG_SET(_var, _val) \
227     ((_var) |= ((_val) << FW_RX_MSDU_INFO_IP_FRAG_S))
228 
229 #define FW_RX_MSDU_INFO_FIRST_WAKEUP_GET(_var) \
230     (((_var) & FW_RX_MSDU_INFO_FIRST_WAKEUP_M) >> FW_RX_MSDU_INFO_FIRST_WAKEUP_S)
231 #define FW_RX_MSDU_INFO_FIRST_WAKEUP_SET(_var, _val) \
232     ((_var) |= ((_val) << FW_RX_MSDU_INFO_FIRST_WAKEUP_S))
233 
234 
235 /* monitor mode flags */
236 
237 #define FW_RX_MSDU_INFO_MON_LAST_FRAG_M       0x1
238 #define FW_RX_MSDU_INFO_MON_LAST_FRAG_S       0
239 
240 
241 #define FW_RX_MSDU_INFO_MON_LAST_FRAG_GET(_var) \
242     (((_var) & FW_RX_MSDU_INFO_MON_LAST_FRAG_M) >> FW_RX_MSDU_INFO_MON_LAST_FRAG_S)
243 #define FW_RX_MSDU_INFO_MON_LAST_FRAG_SET(_var, _val) \
244     ((_var) |= ((_val) << FW_RX_MSDU_INFO_MON_LAST_FRAG_S))
245 
246 
247 #endif /* _WAL_RX_DESC__H_ */
248