blob: a992691d8b0f97889c15f669d87a1a84a676438c [file] [log] [blame]
Dhanashri Atre5b646482016-03-22 12:22:41 -07001/*
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 * @file cdp_txrx_api_common.h
29 * @brief Define the host data path converged API functions
30 * called by the host control SW and the OS interface module
31 */
32#ifndef _CDP_TXRX_CMN_H_
33#define _CDP_TXRX_CMN_H_
34
35#include "htc_api.h"
36#include "htt.h"
37#include "qdf_types.h"
38#include "qdf_nbuf.h"
39
40/******************************************************************************
41 *
42 * Common Data Path Header File
43 *
44 *****************************************************************************/
45
46/******************************************************************************
47 *
48 * Structure definitions
49 *
50 *****************************************************************************/
51
52 /**
53 * ol_txrx_pdev_handle - opaque handle for txrx physical device
54 * object
55 */
56struct ol_txrx_pdev_t;
57typedef struct ol_txrx_pdev_t *ol_txrx_pdev_handle;
58
59/**
60 * ol_txrx_vdev_handle - opaque handle for txrx virtual device
61 * object
62 */
63struct ol_txrx_vdev_t;
64typedef struct ol_txrx_vdev_t *ol_txrx_vdev_handle;
65
66/**
67 * ol_pdev_handle - opaque handle for the configuration
68 * associated with the physical device
69 */
70struct ol_pdev_t;
71typedef struct ol_pdev_t *ol_pdev_handle;
72
73/**
74 * ol_txrx_peer_handle - opaque handle for txrx peer object
75 */
76struct ol_txrx_peer_t;
77typedef struct ol_txrx_peer_t *ol_txrx_peer_handle;
78
79/**
80 * ol_txrx_vdev_delete_cb - callback registered during vdev
81 * detach
82 */
83typedef void (*ol_txrx_vdev_delete_cb)(void *context);
84
85/**
86 * ol_osif_vdev_handle - paque handle for OS shim virtual device
87 * object
88 */
89struct ol_osif_vdev_t;
90typedef struct ol_osif_vdev_t *ol_osif_vdev_handle;
91
92/**
93 * wlan_op_mode - Virtual device operation mode
94 * @wlan_op_mode_unknown: Unknown mode
95 * @wlan_op_mode_ap: AP mode
96 * @wlan_op_mode_ibss: IBSS mode
97 * @wlan_op_mode_sta: STA (client) mode
98 * @wlan_op_mode_monitor: Monitor mode
99 * @wlan_op_mode_ocb: OCB mode
Deepak Dhamdhere987c1fa2016-05-26 02:23:10 -0700100 * @wlan_op_mode_ndi: NAN datapath mode
Dhanashri Atre5b646482016-03-22 12:22:41 -0700101 */
102enum wlan_op_mode {
103 wlan_op_mode_unknown,
104 wlan_op_mode_ap,
105 wlan_op_mode_ibss,
106 wlan_op_mode_sta,
107 wlan_op_mode_monitor,
108 wlan_op_mode_ocb,
Deepak Dhamdhere987c1fa2016-05-26 02:23:10 -0700109 wlan_op_mode_ndi,
Dhanashri Atre5b646482016-03-22 12:22:41 -0700110};
111
112/**
113 * ol_txrx_tx_fp - top-level transmit function
114 * @data_vdev - handle to the virtual device object
115 * @msdu_list - list of network buffers
116 */
117typedef qdf_nbuf_t (*ol_txrx_tx_fp)(ol_txrx_vdev_handle data_vdev,
118 qdf_nbuf_t msdu_list);
119/**
120 * ol_txrx_tx_flow_control_fp - tx flow control notification
121 * function from txrx to OS shim
122 * @osif_dev - the virtual device's OS shim object
123 * @tx_resume - tx os q should be resumed or not
124 */
125typedef void (*ol_txrx_tx_flow_control_fp)(void *osif_dev,
126 bool tx_resume);
127
128/**
129 * ol_txrx_rx_fp - receive function to hand batches of data
130 * frames from txrx to OS shim
131 * @data_vdev - handle to the OSIF virtual device object
132 * @msdu_list - list of network buffers
133 */
Dhanashri Atre0a485f12016-03-31 11:53:53 -0700134typedef QDF_STATUS (*ol_txrx_rx_fp)(void *osif_dev, qdf_nbuf_t msdu_list);
Dhanashri Atre5b646482016-03-22 12:22:41 -0700135
136/**
137 * ol_txrx_rx_check_wai_fp - OSIF WAPI receive function
138*/
139typedef bool (*ol_txrx_rx_check_wai_fp)(ol_osif_vdev_handle vdev,
140 qdf_nbuf_t mpdu_head,
141 qdf_nbuf_t mpdu_tail);
142/**
143 * ol_txrx_rx_mon_fp - OSIF monitor mode receive function for single
144 * MPDU (802.11 format)
145 */
146typedef void (*ol_txrx_rx_mon_fp)(ol_osif_vdev_handle vdev,
147 qdf_nbuf_t mpdu,
148 void *rx_status);
149
150/**
151 * ol_txrx_proxy_arp_fp - proxy arp function pointer
152*/
153typedef int (*ol_txrx_proxy_arp_fp)(ol_osif_vdev_handle vdev,
154 qdf_nbuf_t netbuf);
155
156/**
157 * ol_txrx_stats_callback - statistics notify callback
158 */
159typedef void (*ol_txrx_stats_callback)(void *ctxt,
160 enum htt_dbg_stats_type type,
161 uint8_t *buf, int bytes);
162
163/**
164 * ol_txrx_ops - (pointers to) the functions used for tx and rx
165 * data xfer
166 *
167 * There are two portions of these txrx operations.
168 * The rx portion is filled in by OSIF SW before calling
169 * ol_txrx_osif_vdev_register; inside the ol_txrx_osif_vdev_register
170 * the txrx SW stores a copy of these rx function pointers, to use
171 * as it delivers rx data frames to the OSIF SW.
172 * The tx portion is filled in by the txrx SW inside
173 * ol_txrx_osif_vdev_register; when the function call returns,
174 * the OSIF SW stores a copy of these tx functions to use as it
175 * delivers tx data frames to the txrx SW.
176 *
177 * @tx.std - the tx function pointer for standard data
178 * frames This function pointer is set by the txrx SW
179 * perform host-side transmit operations based on
180 * whether a HL or LL host/target interface is in use.
181 * @tx.flow_control_cb - the transmit flow control
182 * function that is registered by the
183 * OSIF which is called from txrx to
184 * indicate whether the transmit OS
185 * queues should be paused/resumed
186 * @rx.std - the OS shim rx function to deliver rx data
187 * frames to. This can have different values for
188 * different virtual devices, e.g. so one virtual
189 * device's OS shim directly hands rx frames to the OS,
190 * but another virtual device's OS shim filters out P2P
191 * messages before sending the rx frames to the OS. The
192 * netbufs delivered to the osif_rx function are in the
193 * format specified by the OS to use for tx and rx
194 * frames (either 802.3 or native WiFi)
195 * @rx.wai_check - the tx function pointer for WAPI frames
196 * @rx.mon - the OS shim rx monitor function to deliver
197 * monitor data to Though in practice, it is probable
198 * that the same function will be used for delivering
199 * rx monitor data for all virtual devices, in theory
200 * each different virtual device can have a different
201 * OS shim function for accepting rx monitor data. The
202 * netbufs delivered to the osif_rx_mon function are in
203 * 802.11 format. Each netbuf holds a 802.11 MPDU, not
204 * an 802.11 MSDU. Depending on compile-time
205 * configuration, each netbuf may also have a
206 * monitor-mode encapsulation header such as a radiotap
207 * header added before the MPDU contents.
208 * @proxy_arp - proxy arp function pointer - specified by
209 * OS shim, stored by txrx
210 */
211struct ol_txrx_ops {
212 /* tx function pointers - specified by txrx, stored by OS shim */
213 struct {
214 ol_txrx_tx_fp tx;
215 } tx;
216
217 /* rx function pointers - specified by OS shim, stored by txrx */
218 struct {
219 ol_txrx_rx_fp rx;
220 ol_txrx_rx_check_wai_fp wai_check;
221 ol_txrx_rx_mon_fp mon;
222 } rx;
223
224 /* proxy arp function pointer - specified by OS shim, stored by txrx */
225 ol_txrx_proxy_arp_fp proxy_arp;
226};
227
228/**
229 * ol_txrx_stats_req - specifications of the requested
230 * statistics
231 */
232struct ol_txrx_stats_req {
233 uint32_t stats_type_upload_mask; /* which stats to upload */
234 uint32_t stats_type_reset_mask; /* which stats to reset */
235
236 /* stats will be printed if either print element is set */
237 struct {
238 int verbose; /* verbose stats printout */
239 int concise; /* concise stats printout (takes precedence) */
240 } print; /* print uploaded stats */
241
242 /* stats notify callback will be invoked if fp is non-NULL */
243 struct {
244 ol_txrx_stats_callback fp;
245 void *ctxt;
246 } callback;
247
248 /* stats will be copied into the specified buffer if buf is non-NULL */
249 struct {
250 uint8_t *buf;
251 int byte_limit; /* don't copy more than this */
252 } copy;
253
254 /*
255 * If blocking is true, the caller will take the specified semaphore
256 * to wait for the stats to be uploaded, and the driver will release
257 * the semaphore when the stats are done being uploaded.
258 */
259 struct {
260 int blocking;
261 /*Note: this needs to change to some qdf_* type */
262 qdf_semaphore_t *sem_ptr;
263 } wait;
264};
265
266/******************************************************************************
267 *
268 * Control Interface (A Interface)
269 *
270 *****************************************************************************/
271
272int
273ol_txrx_pdev_attach_target(ol_txrx_pdev_handle pdev);
274
275ol_txrx_vdev_handle
276ol_txrx_vdev_attach(ol_txrx_pdev_handle pdev, uint8_t *vdev_mac_addr,
277 uint8_t vdev_id, enum wlan_op_mode op_mode);
278
279void
280ol_txrx_vdev_detach(ol_txrx_vdev_handle vdev,
281 ol_txrx_vdev_delete_cb callback, void *cb_context);
282
283ol_txrx_pdev_handle
284ol_txrx_pdev_attach(
285 ol_pdev_handle ctrl_pdev,
286 HTC_HANDLE htc_pdev,
287 qdf_device_t osdev);
288
289void
290ol_txrx_pdev_detach(ol_txrx_pdev_handle pdev, int force);
291
292ol_txrx_peer_handle
293ol_txrx_peer_attach(ol_txrx_vdev_handle vdev, uint8_t *peer_mac_addr);
294
295void
296ol_txrx_peer_detach(ol_txrx_peer_handle peer);
297
298int
299ol_txrx_set_monitor_mode(ol_txrx_vdev_handle vdev);
300
301void
302ol_txrx_set_curchan(
303 ol_txrx_pdev_handle pdev,
304 uint32_t chan_mhz);
305
306void
307ol_txrx_set_privacy_filters(ol_txrx_vdev_handle vdev,
308 void *filter, uint32_t num);
309
310/******************************************************************************
311 * Data Interface (B Interface)
312 *****************************************************************************/
313void
314ol_txrx_vdev_register(ol_txrx_vdev_handle vdev,
315 void *osif_vdev, struct ol_txrx_ops *txrx_ops);
316
317int
318ol_txrx_mgmt_send(
319 ol_txrx_vdev_handle vdev,
320 qdf_nbuf_t tx_mgmt_frm,
321 uint8_t type);
322
323int
324ol_txrx_mgmt_send_ext(ol_txrx_vdev_handle vdev,
325 qdf_nbuf_t tx_mgmt_frm,
326 uint8_t type, uint8_t use_6mbps, uint16_t chanfreq);
327
328/**
329 * ol_txrx_mgmt_tx_cb - tx management delivery notification
330 * callback function
331 */
332typedef void
333(*ol_txrx_mgmt_tx_cb)(void *ctxt, qdf_nbuf_t tx_mgmt_frm, int had_error);
334
335void
336ol_txrx_mgmt_tx_cb_set(ol_txrx_pdev_handle pdev,
337 uint8_t type,
338 ol_txrx_mgmt_tx_cb download_cb,
339 ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt);
340
341int ol_txrx_get_tx_pending(ol_txrx_pdev_handle pdev);
342
343/**
344 * ol_txrx_data_tx_cb - Function registered with the data path
345 * that is called when tx frames marked as "no free" are
346 * done being transmitted
347 */
348typedef void
349(*ol_txrx_data_tx_cb)(void *ctxt, qdf_nbuf_t tx_frm, int had_error);
350
351void
352ol_txrx_data_tx_cb_set(ol_txrx_vdev_handle data_vdev,
353 ol_txrx_data_tx_cb callback, void *ctxt);
354
355/******************************************************************************
356 * Statistics and Debugging Interface (C Inteface)
357 *****************************************************************************/
358
359int
360ol_txrx_aggr_cfg(ol_txrx_vdev_handle vdev,
361 int max_subfrms_ampdu,
362 int max_subfrms_amsdu);
363
364int
365ol_txrx_fw_stats_get(
366 ol_txrx_vdev_handle vdev,
367 struct ol_txrx_stats_req *req,
368 bool response_expected);
369
370int
371ol_txrx_debug(ol_txrx_vdev_handle vdev, int debug_specs);
372
373void ol_txrx_fw_stats_cfg(
374 ol_txrx_vdev_handle vdev,
375 uint8_t cfg_stats_type,
376 uint32_t cfg_val);
377
378void ol_txrx_print_level_set(unsigned level);
379
380#define TXRX_FW_STATS_TXSTATS 1
381#define TXRX_FW_STATS_RXSTATS 2
382#define TXRX_FW_STATS_RX_RATE_INFO 3
383#define TXRX_FW_STATS_PHYSTATS 4
384#define TXRX_FW_STATS_PHYSTATS_CONCISE 5
385#define TXRX_FW_STATS_TX_RATE_INFO 6
386#define TXRX_FW_STATS_TID_STATE 7
387#define TXRX_FW_STATS_HOST_STATS 8
388#define TXRX_FW_STATS_CLEAR_HOST_STATS 9
389#define TXRX_FW_STATS_CE_STATS 10
390#define TXRX_FW_STATS_VOW_UMAC_COUNTER 11
391#define TXRX_FW_STATS_ME_STATS 12
392#define TXRX_FW_STATS_TXBF_INFO 13
393#define TXRX_FW_STATS_SND_INFO 14
394#define TXRX_FW_STATS_ERROR_INFO 15
395#define TXRX_FW_STATS_TX_SELFGEN_INFO 16
396#define TXRX_FW_STATS_TX_MU_INFO 17
397#define TXRX_FW_SIFS_RESP_INFO 18
398#define TXRX_FW_RESET_STATS 19
399#define TXRX_FW_MAC_WDOG_STATS 20
400#define TXRX_FW_MAC_DESC_STATS 21
401#define TXRX_FW_MAC_FETCH_MGR_STATS 22
402#define TXRX_FW_MAC_PREFETCH_MGR_STATS 23
403
Manjunathappa Prakash5f45de52016-03-07 11:25:38 -0800404/**
405 * ol_txrx_get_vdev_mac_addr() - Return mac addr of vdev
406 * @vdev: vdev handle
407 *
408 * Return: vdev mac address
409 */
410uint8_t *
411ol_txrx_get_vdev_mac_addr(ol_txrx_vdev_handle vdev);
412
413/**
414 * ol_txrx_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of
415 * vdev
416 * @vdev: vdev handle
417 *
418 * Return: Handle to struct qdf_mac_addr
419 */
420struct qdf_mac_addr *
421ol_txrx_get_vdev_struct_mac_addr(ol_txrx_vdev_handle vdev);
422
423/**
424 * ol_txrx_get_pdev_from_vdev() - Return handle to pdev of vdev
425 * @vdev: vdev handle
426 *
427 * Return: Handle to pdev
428 */
429ol_txrx_pdev_handle ol_txrx_get_pdev_from_vdev(ol_txrx_vdev_handle vdev);
430
431/**
432 * ol_txrx_get_ctrl_pdev_from_vdev() - Return control pdev of vdev
433 * @vdev: vdev handle
434 *
435 * Return: Handle to control pdev
436 */
437ol_pdev_handle
438ol_txrx_get_ctrl_pdev_from_vdev(ol_txrx_vdev_handle vdev);
439
Dhanashri Atre5b646482016-03-22 12:22:41 -0700440#endif /* _CDP_TXRX_CMN_H_ */
441
442