blob: e2149be366df9ad8cec08a5d546c2c7b05310d1c [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Anurag Chouhan6d760662016-02-20 16:05:43 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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/**
29 * @file ol_htt_rx_api.h
30 * @brief Specify the rx HTT API functions called by the host data SW.
31 * @details
32 * This file declares the HTT API functions that are specifically
33 * related to receive processing.
34 * In particular, this file specifies methods of the abstract HTT rx
35 * descriptor, and functions to iterate though a series of rx descriptors
36 * and rx MSDU buffers.
37 */
38#ifndef _OL_HTT_RX_API__H_
39#define _OL_HTT_RX_API__H_
40
41/* #include <osapi_linux.h> / * uint16_t, etc. * / */
42#include <osdep.h> /* uint16_t, etc. */
Nirav Shahcbc6d722016-03-01 16:24:53 +053043#include <qdf_nbuf.h> /* qdf_nbuf_t */
Anurag Chouhan6d760662016-02-20 16:05:43 +053044#include <qdf_types.h> /* bool */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045
46#include <htt.h> /* HTT_RX_IND_MPDU_STATUS */
47#include <ol_htt_api.h> /* htt_pdev_handle */
48
49#include <cds_ieee80211_defines.h> /* ieee80211_rx_status */
50#include <ol_vowext_dbg_defs.h>
51
52/*================ constants and types used in the rx API ===================*/
53
54#define HTT_RSSI_INVALID 0x7fff
55
56/**
57 * struct ocb_rx_stats_hdr_t - RX stats header
58 * @version: The version must be 1.
59 * @length: The length of this structure
60 * @channel_freq: The center frequency for the packet
61 * @rssi_cmb: combined RSSI from all chains
62 * @rssi[4]: rssi for chains 0 through 3 (for 20 MHz bandwidth)
63 * @tsf32: timestamp in TSF units
64 * @timestamp_microsec: timestamp in microseconds
65 * @datarate: MCS index
66 * @timestamp_submicrosec: submicrosecond portion of the timestamp
67 * @ext_tid: Extended TID
68 * @reserved: Ensure the size of the structure is a multiple of 4.
69 * Must be 0.
70 *
71 * When receiving an OCB packet, the RX stats is sent to the user application
72 * so that the user application can do processing based on the RX stats.
73 * This structure will be preceded by an ethernet header with
74 * the proto field set to 0x8152. This struct includes various RX
75 * paramaters including RSSI, data rate, and center frequency.
76 */
77PREPACK struct ocb_rx_stats_hdr_t {
78 uint16_t version;
79 uint16_t length;
80 uint16_t channel_freq;
81 int16_t rssi_cmb;
82 int16_t rssi[4];
83 uint32_t tsf32;
84 uint32_t timestamp_microsec;
85 uint8_t datarate;
86 uint8_t timestamp_submicrosec;
87 uint8_t ext_tid;
88 uint8_t reserved;
89};
90
91/*================ rx indication message field access methods ===============*/
92
93/**
94 * @brief Check if a rx indication message has a rx reorder flush command.
95 * @details
96 * Space is reserved in each rx indication message for a rx reorder flush
97 * command, to release specified MPDUs from the rx reorder holding array
98 * before processing the new MPDUs referenced by the rx indication message.
99 * This rx reorder flush command contains a flag to show whether the command
100 * is valid within a given rx indication message.
101 * This function checks the validity flag from the rx indication
102 * flush command IE within the rx indication message.
103 *
104 * @param pdev - the HTT instance the rx data was received on
105 * @param rx_ind_msg - the netbuf containing the rx indication message
106 * @return
107 * 1 - the message's rx flush command is valid and should be processed
108 * before processing new rx MPDUs,
109 * -OR-
110 * 0 - the message's rx flush command is invalid and should be ignored
111 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530112int htt_rx_ind_flush(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113
114/**
115 * @brief Return the sequence number starting the range of MPDUs to flush.
116 * @details
117 * Read the fields of the rx indication message that identify the start
118 * and end of the range of MPDUs to flush from the rx reorder holding array
119 * and send on to subsequent stages of rx processing.
120 * These sequence numbers are the 6 LSBs of the 12-bit 802.11 sequence
121 * number. These sequence numbers are masked with the block ack window size,
122 * rounded up to a power of two (minus one, to create a bitmask) to obtain
123 * the corresponding index into the rx reorder holding array.
124 * The series of MPDUs to flush includes the one specified by the start
125 * sequence number.
126 * The series of MPDUs to flush excludes the one specified by the end
127 * sequence number; the MPDUs up to but not including the end sequence number
128 * are to be flushed.
129 * These start and end seq num fields are only valid if the "flush valid"
130 * flag is set.
131 *
132 * @param pdev - the HTT instance the rx data was received on
133 * @param rx_ind_msg - the netbuf containing the rx indication message
134 * @param seq_num_start - (call-by-reference output) sequence number
135 * for the start of the range of MPDUs to flush
136 * @param seq_num_end - (call-by-reference output) sequence number
137 * for the end of the range of MPDUs to flush
138 */
139void
140htt_rx_ind_flush_seq_num_range(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530141 qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 unsigned *seq_num_start, unsigned *seq_num_end);
143
144/**
145 * @brief Check if a rx indication message has a rx reorder release command.
146 * @details
147 * Space is reserved in each rx indication message for a rx reorder release
148 * command, to release specified MPDUs from the rx reorder holding array
149 * after processing the new MPDUs referenced by the rx indication message.
150 * This rx reorder release command contains a flag to show whether the command
151 * is valid within a given rx indication message.
152 * This function checks the validity flag from the rx indication
153 * release command IE within the rx indication message.
154 *
155 * @param pdev - the HTT instance the rx data was received on
156 * @param rx_ind_msg - the netbuf containing the rx indication message
157 * @return
158 * 1 - the message's rx release command is valid and should be processed
159 * after processing new rx MPDUs,
160 * -OR-
161 * 0 - the message's rx release command is invalid and should be ignored
162 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530163int htt_rx_ind_release(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164
165/**
166 * @brief Return the sequence number starting the range of MPDUs to release.
167 * @details
168 * Read the fields of the rx indication message that identify the start
169 * and end of the range of MPDUs to release from the rx reorder holding
170 * array and send on to subsequent stages of rx processing.
171 * These sequence numbers are the 6 LSBs of the 12-bit 802.11 sequence
172 * number. These sequence numbers are masked with the block ack window size,
173 * rounded up to a power of two (minus one, to create a bitmask) to obtain
174 * the corresponding index into the rx reorder holding array.
175 * The series of MPDUs to release includes the one specified by the start
176 * sequence number.
177 * The series of MPDUs to release excludes the one specified by the end
178 * sequence number; the MPDUs up to but not including the end sequence number
179 * are to be released.
180 * These start and end seq num fields are only valid if the "release valid"
181 * flag is set.
182 *
183 * @param pdev - the HTT instance the rx data was received on
184 * @param rx_ind_msg - the netbuf containing the rx indication message
185 * @param seq_num_start - (call-by-reference output) sequence number
186 * for the start of the range of MPDUs to release
187 * @param seq_num_end - (call-by-reference output) sequence number
188 * for the end of the range of MPDUs to release
189 */
190void
191htt_rx_ind_release_seq_num_range(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530192 qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 unsigned *seq_num_start,
194 unsigned *seq_num_end);
195
196/*
197 * For now, the host HTT -> host data rx status enum
198 * exactly matches the target HTT -> host HTT rx status enum;
199 * no translation is required.
200 * However, the host data SW should only use the htt_rx_status,
201 * so that in the future a translation from target HTT rx status
202 * to host HTT rx status can be added, if the need ever arises.
203 */
204enum htt_rx_status {
205 htt_rx_status_unknown = HTT_RX_IND_MPDU_STATUS_UNKNOWN,
206 htt_rx_status_ok = HTT_RX_IND_MPDU_STATUS_OK,
207 htt_rx_status_err_fcs = HTT_RX_IND_MPDU_STATUS_ERR_FCS,
208 htt_rx_status_err_dup = HTT_RX_IND_MPDU_STATUS_ERR_DUP,
209 htt_rx_status_err_replay = HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
210 htt_rx_status_err_inv_peer = HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
211 htt_rx_status_ctrl_mgmt_null = HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
212 htt_rx_status_tkip_mic_err = HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
213
214 htt_rx_status_err_misc = HTT_RX_IND_MPDU_STATUS_ERR_MISC
215};
216
217/**
218 * @brief Check the status MPDU range referenced by a rx indication message.
219 * @details
220 * Check the status of a range of MPDUs referenced by a rx indication message.
221 * This status determines whether the MPDUs should be processed or discarded.
222 * If the status is OK, then the MPDUs within the range should be processed
223 * as usual.
224 * Otherwise (FCS error, duplicate error, replay error, unknown sender error,
225 * etc.) the MPDUs within the range should be discarded.
226 *
227 * @param pdev - the HTT instance the rx data was received on
228 * @param rx_ind_msg - the netbuf containing the rx indication message
229 * @param mpdu_range_num - which MPDU range within the rx ind msg to check,
230 * starting from 0
231 * @param status - (call-by-reference output) MPDU status
232 * @param mpdu_count - (call-by-reference output) count of MPDUs comprising
233 * the specified MPDU range
234 */
235void
236htt_rx_ind_mpdu_range_info(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530237 qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 int mpdu_range_num,
239 enum htt_rx_status *status, int *mpdu_count);
240
241/**
242 * @brief Return the RSSI provided in a rx indication message.
243 * @details
244 * Return the RSSI from an rx indication message, converted to dBm units.
245 *
246 * @param pdev - the HTT instance the rx data was received on
247 * @param rx_ind_msg - the netbuf containing the rx indication message
248 * @return RSSI in dBm, or HTT_INVALID_RSSI
249 */
250int16_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530251htt_rx_ind_rssi_dbm(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252
253int16_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530254htt_rx_ind_rssi_dbm_chain(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 int8_t chain);
256
257void
Nirav Shahcbc6d722016-03-01 16:24:53 +0530258htt_rx_ind_legacy_rate(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 uint8_t *legacy_rate, uint8_t *legacy_rate_sel);
260
261
262void
Nirav Shahcbc6d722016-03-01 16:24:53 +0530263htt_rx_ind_timestamp(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264 uint32_t *timestamp_microsec,
265 uint8_t *timestamp_submicrosec);
266
267uint32_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530268htt_rx_ind_tsf32(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269
270uint8_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530271htt_rx_ind_ext_tid(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272
273
274/*==================== rx MPDU descriptor access methods ====================*/
275
276/**
277 * @brief Check if the retry bit is set in Rx-descriptor
278 * @details
279 * This function returns the retry bit of the 802.11 header for the
280 * provided rx MPDU descriptor.
281 *
282 * @param pdev - the handle of the physical device the rx data was received on
283 * @param msdu_desc - the abstract descriptor for the MSDU in question
284 * @return boolean -- true if retry is set, false otherwise
285 */
286extern
287bool (*htt_rx_mpdu_desc_retry)(
288 htt_pdev_handle pdev, void *mpdu_desc);
289
290/**
291 * @brief Return a rx MPDU's sequence number.
292 * @details
293 * This function returns the LSBs of the 802.11 sequence number for the
294 * provided rx MPDU descriptor.
295 * Depending on the system, 6-12 LSBs from the 802.11 sequence number are
296 * returned. (Typically, either the 8 or 12 LSBs are returned.)
297 * This sequence number is masked with the block ack window size,
298 * rounded up to a power of two (minus one, to create a bitmask) to obtain
299 * the corresponding index into the rx reorder holding array.
300 *
301 * @param pdev - the HTT instance the rx data was received on
302 * @param mpdu_desc - the abstract descriptor for the MPDU in question
303 * @return the LSBs of the sequence number for the MPDU
304 */
305extern uint16_t
306(*htt_rx_mpdu_desc_seq_num)(htt_pdev_handle pdev, void *mpdu_desc);
307
308/**
309 * @brief Return a rx MPDU's rx reorder array index, based on sequence number.
310 * @details
311 * This function returns a sequence-number based index into the rx
312 * reorder array for the specified MPDU.
313 * In some systems, this rx reorder array is simply the LSBs of the
314 * sequence number, or possibly even the full sequence number.
315 * To support such systems, the returned index has to be masked with
316 * the power-of-two array size before using the value to index the
317 * rx reorder array.
318 * In other systems, this rx reorder array index is
319 * (sequence number) % (block ack window size)
320 *
321 * @param pdev - the HTT instance the rx data was received on
322 * @param mpdu_desc - the abstract descriptor for the MPDU in question
323 * @return the rx reorder array index the MPDU goes into
324 */
325/* use sequence number (or LSBs thereof) as rx reorder array index */
326#define htt_rx_mpdu_desc_reorder_idx htt_rx_mpdu_desc_seq_num
327
328union htt_rx_pn_t {
329 /* WEP: 24-bit PN */
330 uint32_t pn24;
331
332 /* TKIP or CCMP: 48-bit PN */
333 uint64_t pn48;
334
335 /* WAPI: 128-bit PN */
336 uint64_t pn128[2];
337};
338
339/**
340 * @brief Find the packet number (PN) for a MPDU.
341 * @details
342 * This function only applies when the rx PN check is configured to be
343 * performed in the host rather than the target, and on peers using a
344 * security type for which a PN check applies.
345 * The pn_len_bits argument is used to determine which element of the
346 * htt_rx_pn_t union to deposit the PN value read from the MPDU descriptor
347 * into.
348 * A 24-bit PN is deposited into pn->pn24.
349 * A 48-bit PN is deposited into pn->pn48.
350 * A 128-bit PN is deposited in little-endian order into pn->pn128.
351 * Specifically, bits 63:0 of the PN are copied into pn->pn128[0], while
352 * bits 127:64 of the PN are copied into pn->pn128[1].
353 *
354 * @param pdev - the HTT instance the rx data was received on
355 * @param mpdu_desc - the abstract descriptor for the MPDU in question
356 * @param pn - the location to copy the packet number into
357 * @param pn_len_bits - the PN size, in bits
358 */
359extern void (*htt_rx_mpdu_desc_pn)(htt_pdev_handle pdev,
360 void *mpdu_desc,
361 union htt_rx_pn_t *pn, int pn_len_bits);
362
363/**
364 * @brief This function Returns the TID value from the Rx descriptor
365 * for Low Latency driver
366 * @details
367 * This function returns the TID set in the 802.11 QoS Control for the MPDU
368 * in the packet header, by looking at the mpdu_start of the Rx descriptor.
369 * Rx descriptor gets a copy of the TID from the MAC.
370 * @pdev: Handle (pointer) to HTT pdev.
371 * @param mpdu_desc - the abstract descriptor for the MPDU in question
372 * @return: Actual TID set in the packet header.
373 */
374extern
375uint8_t (*htt_rx_mpdu_desc_tid)(
376 htt_pdev_handle pdev, void *mpdu_desc);
377
378/**
379 * @brief Return the TSF timestamp indicating when a MPDU was received.
380 * @details
381 * This function provides the timestamp indicating when the PPDU that
382 * the specified MPDU belongs to was received.
383 *
384 * @param pdev - the HTT instance the rx data was received on
385 * @param mpdu_desc - the abstract descriptor for the MPDU in question
386 * @return 32 LSBs of TSF time at which the MPDU's PPDU was received
387 */
388uint32_t htt_rx_mpdu_desc_tsf32(htt_pdev_handle pdev, void *mpdu_desc);
389
390/**
391 * @brief Return the 802.11 header of the MPDU
392 * @details
393 * This function provides a pointer to the start of the 802.11 header
394 * of the Rx MPDU
395 *
396 * @param pdev - the HTT instance the rx data was received on
397 * @param mpdu_desc - the abstract descriptor for the MPDU in question
398 * @return pointer to 802.11 header of the received MPDU
399 */
400char *htt_rx_mpdu_wifi_hdr_retrieve(htt_pdev_handle pdev, void *mpdu_desc);
401
402/**
403 * @brief Return the RSSI provided in a rx descriptor.
404 * @details
405 * Return the RSSI from a rx descriptor, converted to dBm units.
406 *
407 * @param pdev - the HTT instance the rx data was received on
408 * @param mpdu_desc - the abstract descriptor for the MPDU in question
409 * @return RSSI in dBm, or HTT_INVALID_RSSI
410 */
411int16_t htt_rx_mpdu_desc_rssi_dbm(htt_pdev_handle pdev, void *mpdu_desc);
412
413/*==================== rx MSDU descriptor access methods ====================*/
414
415/**
416 * @brief Check if a MSDU completes a MPDU.
417 * @details
418 * When A-MSDU aggregation is used, a single MPDU will consist of
419 * multiple MSDUs. This function checks a MSDU's rx descriptor to
420 * see whether the MSDU is the final MSDU within a MPDU.
421 *
422 * @param pdev - the handle of the physical device the rx data was received on
423 * @param msdu_desc - the abstract descriptor for the MSDU in question
424 * @return
425 * 0 - there are subsequent MSDUs within the A-MSDU / MPDU
426 * -OR-
427 * 1 - this is the last MSDU within its MPDU
428 */
429extern bool (*htt_rx_msdu_desc_completes_mpdu)(htt_pdev_handle pdev,
430 void *msdu_desc);
431
432/**
433 * @brief Check if a MSDU is first msdu of MPDU.
434 * @details
435 * When A-MSDU aggregation is used, a single MPDU will consist of
436 * multiple MSDUs. This function checks a MSDU's rx descriptor to
437 * see whether the MSDU is the first MSDU within a MPDU.
438 *
439 * @param pdev - the handle of the physical device the rx data was received on
440 * @param msdu_desc - the abstract descriptor for the MSDU in question
441 * @return
442 * 0 - this is interior MSDU in the A-MSDU / MPDU
443 * -OR-
444 * 1 - this is the first MSDU within its MPDU
445 */
446extern bool (*htt_rx_msdu_first_msdu_flag)(htt_pdev_handle pdev,
447 void *msdu_desc);
448
449/**
450 * @brief Retrieve encrypt bit from a mpdu desc.
451 * @details
452 * Fw will pass all the frame to the host whether encrypted or not, and will
453 * indicate the encrypt flag in the desc, this function is to get the info
454 * and used to make a judge whether should make pn check, because
455 * non-encrypted frames always get the same pn number 0.
456 *
457 * @param pdev - the HTT instance the rx data was received on
458 * @param mpdu_desc - the abstract descriptor for the MPDU in question
459 * @return 0 - the frame was not encrypted
460 * 1 - the frame was encrypted
461 */
462extern bool (*htt_rx_mpdu_is_encrypted)(htt_pdev_handle pdev, void *mpdu_desc);
463
464/**
465 * @brief Indicate whether a rx desc has a WLAN unicast vs. mcast/bcast flag.
466 * @details
467 * A flag indicating whether a MPDU was delivered over WLAN as unicast or
468 * multicast/broadcast may be only valid once per MPDU (LL), or within each
469 * rx descriptor for the MSDUs within the MPDU (HL). (In practice, it is
470 * unlikely that A-MSDU aggregation will be used in HL, so typically HL will
471 * only have one MSDU per MPDU anyway.)
472 * This function indicates whether the specified rx descriptor contains
473 * a WLAN ucast vs. mcast/bcast flag.
474 *
475 * @param pdev - the HTT instance the rx data was received on
476 * @param msdu_desc - the abstract descriptor for the MSDU in question
477 * @return
478 * 0 - The rx descriptor does not contain a WLAN ucast vs. mcast flag.
479 * -OR-
480 * 1 - The rx descriptor has a valid WLAN ucast vs. mcast flag.
481 */
482extern int (*htt_rx_msdu_has_wlan_mcast_flag)(htt_pdev_handle pdev,
483 void *msdu_desc);
484
485/**
486 * @brief Indicate whether a MSDU was received as unicast or mcast/bcast
487 * @details
488 * Indicate whether the MPDU that the specified MSDU belonged to was
489 * delivered over the WLAN as unicast, or as multicast/broadcast.
490 * This query can only be performed on rx descriptors for which
491 * htt_rx_msdu_has_wlan_mcast_flag is true.
492 *
493 * @param pdev - the HTT instance the rx data was received on
494 * @param msdu_desc - the abstract descriptor for the MSDU in question
495 * @return
496 * 0 - The MSDU was delivered over the WLAN as unicast.
497 * -OR-
498 * 1 - The MSDU was delivered over the WLAN as broadcast or multicast.
499 */
500extern bool (*htt_rx_msdu_is_wlan_mcast)(htt_pdev_handle pdev, void *msdu_desc);
501
502/**
503 * @brief Indicate whether a MSDU was received as a fragmented frame
504 * @details
505 * This query can only be performed on LL system.
506 *
507 * @param pdev - the HTT instance the rx data was received on
508 * @param msdu_desc - the abstract descriptor for the MSDU in question
509 * @return
510 * 0 - The MSDU was a non-fragmented frame.
511 * -OR-
512 * 1 - The MSDU was fragmented frame.
513 */
514extern int (*htt_rx_msdu_is_frag)(htt_pdev_handle pdev, void *msdu_desc);
515
516/**
517 * @brief Indicate if a MSDU should be delivered to the OS shim or discarded.
518 * @details
519 * Indicate whether a MSDU should be discarded or delivered to the OS shim.
520 *
521 * @param pdev - the HTT instance the rx data was received on
522 * @param msdu_desc - the abstract descriptor for the MSDU in question
523 * @return
524 * 0 - The MSDU should be delivered to the OS
525 * -OR-
526 * non-zero - The MSDU should not be delivered to the OS.
527 * If the "forward" flag is set, it should be forwarded to tx.
528 * Else, it should be discarded.
529 */
530int htt_rx_msdu_discard(htt_pdev_handle pdev, void *msdu_desc);
531
532/**
533 * @brief Indicate whether a MSDU should be forwarded to tx.
534 * @details
535 * Indicate whether a MSDU should be forwarded to tx, e.g. for intra-BSS
536 * STA-to-STA forwarding in an AP, or for multicast echo in an AP.
537 *
538 * @param pdev - the HTT instance the rx data was received on
539 * @param msdu_desc - the abstract descriptor for the MSDU in question
540 * @return
541 * 0 - The MSDU should not be forwarded
542 * -OR-
543 * non-zero - The MSDU should be forwarded.
544 * If the "discard" flag is set, then the original MSDU can be
545 * directly forwarded into the tx path.
546 * Else, a copy (clone?) of the rx MSDU needs to be created to
547 * send to the tx path.
548 */
549int htt_rx_msdu_forward(htt_pdev_handle pdev, void *msdu_desc);
550
551/**
552 * @brief Indicate whether a MSDU's contents need to be inspected.
553 * @details
554 * Indicate whether the host data SW needs to examine the contents of the
555 * received MSDU, and based on the packet type infer what special handling
556 * to provide for the MSDU.
557 *
558 * @param pdev - the HTT instance the rx data was received on
559 * @param msdu_desc - the abstract descriptor for the MSDU in question
560 * @return
561 * 0 - No inspection + special handling is required.
562 * -OR-
563 * non-zero - Inspect the MSDU contents to infer what special handling
564 * to apply to the MSDU.
565 */
566int htt_rx_msdu_inspect(htt_pdev_handle pdev, void *msdu_desc);
567
568/**
569 * @brief Provide all action specifications for a rx MSDU
570 * @details
571 * Provide all action specifications together. This provides the same
572 * information in a single function call as would be provided by calling
573 * the functions htt_rx_msdu_discard, htt_rx_msdu_forward, and
574 * htt_rx_msdu_inspect.
575 *
576 * @param pdev - the HTT instance the rx data was received on
577 * @param msdu_desc - the abstract descriptor for the MSDU in question
578 * @param[out] discard - 1: discard the MSDU, 0: deliver the MSDU to the OS
579 * @param[out] forward - 1: forward the rx MSDU to tx, 0: no rx->tx forward
580 * @param[out] inspect - 1: process according to MSDU contents, 0: no inspect
581 */
582void
583htt_rx_msdu_actions(htt_pdev_handle pdev,
584 void *msdu_desc, int *discard, int *forward, int *inspect);
585
586/**
587 * @brief Get the key id sent in IV of the frame
588 * @details
589 * Provide the key index octet which is taken from IV.
590 * This is valid only for the first MSDU.
591 *
592 * @param pdev - the HTT instance the rx data was received on
593 * @param msdu_desc - the abstract descriptor for the MSDU in question
594 * @key_id - Key id octet
595 * @return indication of whether key id access is successful
596 * true - Success
597 * false - if this is not first msdu
598 */
599extern bool
600(*htt_rx_msdu_desc_key_id)(htt_pdev_handle pdev,
601 void *mpdu_desc, uint8_t *key_id);
602
603extern bool
604(*htt_rx_msdu_chan_info_present)(
605 htt_pdev_handle pdev,
606 void *mpdu_desc);
607
608extern bool
609(*htt_rx_msdu_center_freq)(
610 htt_pdev_handle pdev,
611 struct ol_txrx_peer_t *peer,
612 void *mpdu_desc,
613 uint16_t *primary_chan_center_freq_mhz,
614 uint16_t *contig_chan1_center_freq_mhz,
615 uint16_t *contig_chan2_center_freq_mhz,
616 uint8_t *phy_mode);
617
618/*====================== rx MSDU + descriptor delivery ======================*/
619
620/**
621 * @brief Return a linked-list of network buffer holding the next rx A-MSDU.
622 * @details
623 * In some systems, the rx MSDUs are uploaded along with the rx
624 * indication message, while in other systems the rx MSDUs are uploaded
625 * out of band, via MAC DMA.
626 * This function provides an abstract way to obtain a linked-list of the
627 * next MSDUs, regardless of whether the MSDU was delivered in-band with
628 * the rx indication message, or out of band through MAC DMA.
629 * In a LL system, this function returns a linked list of the one or more
630 * MSDUs that together comprise an A-MSDU.
631 * In a HL system, this function returns a degenerate linked list consisting
632 * of a single MSDU (head_msdu == tail_msdu).
633 * This function also makes sure each MSDU's rx descriptor can be found
634 * through the MSDU's network buffer.
635 * In most systems, this is trivial - a single network buffer stores both
636 * the MSDU rx descriptor and the MSDU payload.
637 * In systems where the rx descriptor is in a separate buffer from the
638 * network buffer holding the MSDU payload, a pointer to the rx descriptor
639 * has to be stored in the network buffer.
640 * After this function call, the descriptor for a given MSDU can be
641 * obtained via the htt_rx_msdu_desc_retrieve function.
642 *
643 * @param pdev - the HTT instance the rx data was received on
644 * @param rx_ind_msg - the netbuf containing the rx indication message
645 * @param head_msdu - call-by-reference network buffer handle, which gets set
646 * in this function to point to the head MSDU of the A-MSDU
647 * @param tail_msdu - call-by-reference network buffer handle, which gets set
648 * in this function to point to the tail MSDU of the A-MSDU, or the
649 * same MSDU that the head_msdu points to if only a single MSDU is
650 * delivered at a time.
651 * @return indication of whether any MSDUs in the AMSDU use chaining:
652 * 0 - no buffer chaining
653 * 1 - buffers are chained
654 */
655extern int
656(*htt_rx_amsdu_pop)(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530657 qdf_nbuf_t rx_ind_msg,
658 qdf_nbuf_t *head_msdu, qdf_nbuf_t *tail_msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659
660extern int
661(*htt_rx_frag_pop)(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530662 qdf_nbuf_t rx_ind_msg,
663 qdf_nbuf_t *head_msdu, qdf_nbuf_t *tail_msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
665/**
666 * @brief Return a linked list of buffers holding one MSDU
667 * In some systems the buffers are delivered along with offload delivery
668 * indication message itself, while in other systems the buffers are uploaded
669 * out of band, via MAC DMA.
670 * @details
671 * This function provides an abstract way to obtain a linked-list of the
672 * buffers corresponding to an msdu, regardless of whether the MSDU was
673 * delivered in-band with the rx indication message, or out of band through
674 * MAC DMA.
675 * In a LL system, this function returns a linked list of one or more
676 * buffers corresponding to an MSDU
677 * In a HL system , TODO
678 *
679 * @param pdev - the HTT instance the rx data was received on
680 * @param offload_deliver_msg - the nebuf containing the offload deliver message
681 * @param head_msdu - call-by-reference network buffer handle, which gets set in this
682 * function to the head buffer of this MSDU
683 * @param tail_msdu - call-by-reference network buffer handle, which gets set in this
684 * function to the tail buffer of this MSDU
685 */
686extern int
687(*htt_rx_offload_msdu_pop)(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530688 qdf_nbuf_t offload_deliver_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 int *vdev_id,
690 int *peer_id,
691 int *tid,
692 uint8_t *fw_desc,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530693 qdf_nbuf_t *head_buf, qdf_nbuf_t *tail_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694
695/**
696 * @brief Return the rx descriptor for the next rx MPDU.
697 * @details
698 * The rx MSDU descriptors may be uploaded as part of the rx indication
699 * message, or delivered separately out of band.
700 * This function provides an abstract way to obtain the next MPDU descriptor,
701 * regardless of whether the MPDU descriptors are delivered in-band with
702 * the rx indication message, or out of band.
703 * This is used to iterate through the series of MPDU descriptors referenced
704 * by a rx indication message.
705 * The htt_rx_amsdu_pop function should be called before this function
706 * (or at least before using the returned rx descriptor handle), so that
707 * the cache location for the rx descriptor will be flushed before the
708 * rx descriptor gets used.
709 *
710 * @param pdev - the HTT instance the rx data was received on
711 * @param rx_ind_msg - the netbuf containing the rx indication message
712 * @return next abstract rx descriptor from the series of MPDUs referenced
713 * by an rx ind msg
714 */
715extern void *
Nirav Shahcbc6d722016-03-01 16:24:53 +0530716(*htt_rx_mpdu_desc_list_next)(htt_pdev_handle pdev, qdf_nbuf_t rx_ind_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717
718/**
719 * @brief Retrieve a previously-stored rx descriptor from a MSDU buffer.
720 * @details
721 * The data SW will call the htt_rx_msdu_desc_link macro/function to
722 * link a MSDU's rx descriptor with the buffer holding the MSDU payload.
723 * This function retrieves the rx MSDU descriptor.
724 *
725 * @param pdev - the HTT instance the rx data was received on
726 * @param msdu - the buffer containing the MSDU payload
727 * @return the corresponding abstract rx MSDU descriptor
728 */
729extern void *
Nirav Shahcbc6d722016-03-01 16:24:53 +0530730(*htt_rx_msdu_desc_retrieve)(htt_pdev_handle pdev, qdf_nbuf_t msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731
732/**
733 * @brief Free both an rx MSDU descriptor and the associated MSDU buffer.
734 * @details
735 * Usually the WLAN driver does not free rx MSDU buffers, but needs to
736 * do so when an invalid frame (e.g. FCS error) was deposited into the
737 * queue of rx buffers.
738 * This function frees both the rx descriptor and the rx frame.
739 * On some systems, the rx descriptor and rx frame are stored in the
740 * same buffer, and thus one free suffices for both objects.
741 * On other systems, the rx descriptor and rx frame are stored
742 * separately, so distinct frees are internally needed.
743 * However, in either case, the rx descriptor has been associated with
744 * the MSDU buffer, and can be retrieved by htt_rx_msdu_desc_retrieve.
745 * Hence, it is only necessary to provide the MSDU buffer; the HTT SW
746 * internally finds the corresponding MSDU rx descriptor.
747 *
748 * @param htt_pdev - the HTT instance the rx data was received on
749 * @param rx_msdu_desc - rx descriptor for the MSDU being freed
750 * @param msdu - rx frame buffer for the MSDU being freed
751 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530752void htt_rx_desc_frame_free(htt_pdev_handle htt_pdev, qdf_nbuf_t msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
754/**
755 * @brief Look up and free the rx descriptor for a MSDU.
756 * @details
757 * When the driver delivers rx frames to the OS, it first needs
758 * to free the associated rx descriptors.
759 * In some systems the rx descriptors are allocated in the same
760 * buffer as the rx frames, so this operation is a no-op.
761 * In other systems, the rx descriptors are stored separately
762 * from the rx frames, so the rx descriptor has to be freed.
763 * The descriptor is located from the MSDU buffer with the
764 * htt_rx_desc_frame_free macro/function.
765 *
766 * @param htt_pdev - the HTT instance the rx data was received on
767 * @param msdu - rx frame buffer for the rx MSDU descriptor being freed
768 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530769void htt_rx_msdu_desc_free(htt_pdev_handle htt_pdev, qdf_nbuf_t msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
771/**
772 * @brief Add new MSDU buffers for the target to fill.
773 * @details
774 * In some systems, the underlying upload mechanism (HIF) allocates new rx
775 * buffers itself. In other systems, the underlying upload mechanism
776 * (MAC DMA) needs to be provided with new rx buffers.
777 * This function is used as an abstract method to indicate to the underlying
778 * data upload mechanism when it is an appropriate time to allocate new rx
779 * buffers.
780 * If the allocation is automatically handled, a la HIF, then this function
781 * call is ignored.
782 * If the allocation has to be done explicitly, a la MAC DMA, then this
783 * function provides the context and timing for such replenishment
784 * allocations.
785 *
786 * @param pdev - the HTT instance the rx data will be received on
787 */
788void htt_rx_msdu_buff_replenish(htt_pdev_handle pdev);
789
790/**
791 * @brief Links list of MSDUs into an single MPDU. Updates RX stats
792 * @details
793 * When HW MSDU splitting is turned on each MSDU in an AMSDU MPDU occupies
794 * a separate wbuf for delivery to the network stack. For delivery to the
795 * monitor mode interface they need to be restitched into an MPDU. This
796 * function does this. Also updates the RX status if the MPDU starts
797 * a new PPDU
798 *
799 * @param pdev - the HTT instance the rx data was received on
800 * @param head_msdu - network buffer handle, which points to the first MSDU
801 * in the list. This is a NULL terminated list
802 * @param rx_staus - pointer to the status associated with this MPDU.
803 * Updated only if there is a new PPDU and new status associated with it
804 * @param clone_not_reqd - If set the MPDU linking destroys the passed in
805 * list, else operates on a cloned nbuf
806 * @return network buffer handle to the MPDU
807 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530808qdf_nbuf_t
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809htt_rx_restitch_mpdu_from_msdus(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530810 qdf_nbuf_t head_msdu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 struct ieee80211_rx_status *rx_status,
812 unsigned clone_not_reqd);
813
814/**
815 * @brief Return the sequence number of MPDUs to flush.
816 * @param pdev - the HTT instance the rx data was received on
817 * @param rx_frag_ind_msg - the netbuf containing the rx fragment indication message
818 * @param seq_num_start - (call-by-reference output) sequence number
819 * for the start of the range of MPDUs to flush
820 * @param seq_num_end - (call-by-reference output) sequence number
821 * for the end of the range of MPDUs to flush
822 */
823void
824htt_rx_frag_ind_flush_seq_num_range(htt_pdev_handle pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530825 qdf_nbuf_t rx_frag_ind_msg,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 int *seq_num_start, int *seq_num_end);
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828/**
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530829 * htt_rx_msdu_rx_desc_size_hl() - Return the HL rx desc size
830 * @pdev: the HTT instance the rx data was received on.
831 * @msdu_desc: the hl rx desc pointer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 *
Siddarth Poddar1df1cd82016-04-27 17:32:21 +0530833 * Return: HL rx desc size
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 */
835uint16_t htt_rx_msdu_rx_desc_size_hl(htt_pdev_handle pdev, void *msdu_desc);
836
837/**
838 * @brief populates vowext stats by processing RX desc.
839 * @param msdu - network buffer handle
840 * @param vowstats - handle to vow ext stats.
841 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530842void htt_rx_get_vowext_stats(qdf_nbuf_t msdu, struct vow_extstats *vowstats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843
844/**
845 * @brief parses the offload message passed by the target.
846 * @param pdev - pdev handle
847 * @param paddr - physical address of the rx buffer
848 * @param vdev_id - reference to vdev id to be filled
849 * @param peer_id - reference to the peer id to be filled
850 * @param tid - reference to the tid to be filled
851 * @param fw_desc - reference to the fw descriptor to be filled
852 * @param peer_id - reference to the peer id to be filled
853 * @param head_buf - reference to the head buffer
854 * @param tail_buf - reference to the tail buffer
855 */
856int
857htt_rx_offload_paddr_msdu_pop_ll(htt_pdev_handle pdev,
858 uint32_t *msg_word,
859 int msdu_iter,
860 int *vdev_id,
861 int *peer_id,
862 int *tid,
863 uint8_t *fw_desc,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530864 qdf_nbuf_t *head_buf, qdf_nbuf_t *tail_buf);
Nirav Shahd59b3b22016-08-01 14:39:23 +0530865
866uint32_t htt_rx_amsdu_rx_in_order_get_pktlog(qdf_nbuf_t rx_ind_msg);
867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868#endif /* _OL_HTT_RX_API__H_ */