]> Pileus Git - ~andy/linux/blob - drivers/staging/csr/csr_wifi_hip_unifi.h
Merge tag 'kvm-3.7-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[~andy/linux] / drivers / staging / csr / csr_wifi_hip_unifi.h
1 /*****************************************************************************
2
3             (c) Cambridge Silicon Radio Limited 2012
4             All rights reserved and confidential information of CSR
5
6             Refer to LICENSE.txt included with this source for details
7             on the license terms.
8
9 *****************************************************************************/
10
11 /*
12  * ---------------------------------------------------------------------------
13  *
14  * FILE : csr_wifi_hip_unifi.h
15  *
16  * PURPOSE : Public API for the UniFi HIP core library.
17  *
18  * ---------------------------------------------------------------------------
19  */
20 #ifndef __CSR_WIFI_HIP_UNIFI_H__
21 #define __CSR_WIFI_HIP_UNIFI_H__ 1
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifndef CSR_WIFI_HIP_TA_DISABLE
28 #include "csr_wifi_router_ctrl_prim.h"
29 #include "csr_wifi_router_prim.h"
30 #else
31 #include "csr_time.h"
32 #endif
33
34 /* SDIO chip ID numbers */
35
36 /* Manufacturer id */
37 #define SDIO_MANF_ID_CSR              0x032a
38
39 /* Device id */
40 #define SDIO_CARD_ID_UNIFI_1          0x0001
41 #define SDIO_CARD_ID_UNIFI_2          0x0002
42 #define SDIO_CARD_ID_UNIFI_3          0x0007
43 #define SDIO_CARD_ID_UNIFI_4          0x0008
44
45 /* Function number for WLAN */
46 #define SDIO_WLAN_FUNC_ID_UNIFI_1          0x0001
47 #define SDIO_WLAN_FUNC_ID_UNIFI_2          0x0001
48 #define SDIO_WLAN_FUNC_ID_UNIFI_3          0x0001
49 #define SDIO_WLAN_FUNC_ID_UNIFI_4          0x0002
50
51 /* Maximum SDIO bus clock supported. */
52 #define UNIFI_SDIO_CLOCK_MAX_HZ    50000000  /* Hz */
53
54 /*
55  * Initialisation SDIO bus clock.
56  *
57  * The initialisation clock speed should be used from when the chip has been
58  * reset until the first MLME-reset has been received (i.e. during firmware
59  * initialisation), unless UNIFI_SDIO_CLOCK_SAFE_HZ applies.
60  */
61 #define UNIFI_SDIO_CLOCK_INIT_HZ    12500000 /* Hz */
62
63 /*
64  * Safe SDIO bus clock.
65  *
66  * The safe speed should be used when the chip is in deep sleep or
67  * it's state is unknown (just after reset / power on).
68  */
69 #define UNIFI_SDIO_CLOCK_SAFE_HZ    1000000  /* Hz */
70
71 /* I/O default block size to use for UniFi. */
72 #define UNIFI_IO_BLOCK_SIZE     64
73
74 #define UNIFI_WOL_OFF   0
75 #define UNIFI_WOL_SDIO  1
76 #define UNIFI_WOL_PIO   2
77
78 /* The number of Tx traffic queues */
79 #define UNIFI_NO_OF_TX_QS              4
80
81 #define CSR_WIFI_HIP_RESERVED_HOST_TAG 0xFFFFFFFF
82
83 /*
84  * The number of slots in the from-host queues.
85  *
86  * UNIFI_SOFT_TRAFFIC_Q_LENGTH is the number of slots in the traffic queues
87  * and there will be UNIFI_NO_OF_TX_QS of them.
88  * Traffic queues are used for data packets.
89  *
90  * UNIFI_SOFT_COMMAND_Q_LENGTH is the number of slots in the command queue.
91  * The command queue is used for MLME management requests.
92  *
93  * Queues are ring buffers and so must always have 1 unused slot.
94  */
95 #define UNIFI_SOFT_TRAFFIC_Q_LENGTH (20 + 1)
96 #define UNIFI_SOFT_COMMAND_Q_LENGTH (16 + 1)
97
98 #include "csr_framework_ext.h"  /* from the synergy porting folder */
99 #include "csr_sdio.h"           /* from the synergy porting folder */
100 #include "csr_macro.h"          /* from the synergy porting folder */
101 #include "csr_wifi_result.h"
102
103 /* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */
104 #define UNIFI_MAC_ADDRESS_COPY(dst, src) \
105     do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; \
106          (dst)[2] = (src)[2]; (dst)[3] = (src)[3]; \
107          (dst)[4] = (src)[4]; (dst)[5] = (src)[5]; \
108     } while (0)
109
110 #define UNIFI_MAC_ADDRESS_CMP(addr1, addr2) \
111     (((addr1)[0] == (addr2)[0]) && ((addr1)[1] == (addr2)[1]) && \
112      ((addr1)[2] == (addr2)[2]) && ((addr1)[3] == (addr2)[3]) && \
113      ((addr1)[4] == (addr2)[4]) && ((addr1)[5] == (addr2)[5]))
114
115 /* Traffic queue ordered according to priority
116  * EAPOL/Uncontrolled port Queue should be the last
117  */
118 typedef enum
119 {
120     UNIFI_TRAFFIC_Q_BK = 0,
121     UNIFI_TRAFFIC_Q_BE,
122     UNIFI_TRAFFIC_Q_VI,
123     UNIFI_TRAFFIC_Q_VO,
124     UNIFI_TRAFFIC_Q_EAPOL,    /* Non existant in HIP */
125     UNIFI_TRAFFIC_Q_MAX,      /* Non existant */
126     UNIFI_TRAFFIC_Q_MLME      /* Non existant */
127 } unifi_TrafficQueue;
128
129 /*
130  * Structure describing a bulk data slot.
131  * This structure is shared between the HIP core library and the OS
132  * layer. See the definition of unifi_net_data_malloc() for more details.
133  *
134  * The data_length field is used to indicate empty/occupied state.
135  * Needs to be defined before #include "unifi_os.h".
136  */
137 typedef struct _bulk_data_desc
138 {
139     const u8 *os_data_ptr;
140     u32       data_length;
141     const void     *os_net_buf_ptr;
142     u32       net_buf_length;
143 } bulk_data_desc_t;
144
145 /* Structure of an entry in the Symbol Look Up Table (SLUT). */
146 typedef struct _symbol
147 {
148     u16 id;
149     u32 obj;
150 } symbol_t;
151
152 /*
153  * Header files need to be included from the current directory,
154  * the SME library, the synergy framework and the OS layer.
155  * A thin OS layer needs to be implemented in the porting exercise.
156  *
157  * Note that unifi_os.h should be included only in unifi.h
158  */
159
160 #include "unifi_os.h"
161
162 /*
163  * Contains the HIP core definitions selected in the porting exercise, such as
164  * UNIFI_PAD_BULK_DATA_TO_BLOCK_SIZE and UNIFI_PAD_SIGNALS_TO_BLOCK_SIZE.
165  * Implemented in the OS layer, as part of the porting exersice.
166  */
167 #include "unifi_config.h"
168
169 #include "csr_wifi_hip_signals.h" /* from this dir */
170
171 /*
172  * The card structure is an opaque pointer that is used to pass context
173  * to the upper-edge API functions.
174  */
175 typedef struct card card_t;
176
177
178 /*
179  * This structure describes all of the bulk data that 'might' be
180  * associated with a signal.
181  */
182 typedef struct _bulk_data_param
183 {
184     bulk_data_desc_t d[UNIFI_MAX_DATA_REFERENCES];
185 } bulk_data_param_t;
186
187
188 /*
189  * This structure describes the chip and HIP core lib
190  * information that exposed to the OS layer.
191  */
192 typedef struct _card_info
193 {
194     u16 chip_id;
195     u16 chip_version;
196     u32 fw_build;
197     u16 fw_hip_version;
198     u32 sdio_block_size;
199 } card_info_t;
200
201
202 /*
203  * Mini-coredump definitions
204  */
205 /* Definition of XAP memory ranges used by the mini-coredump system.
206  * Note that, these values are NOT the same as UNIFI_REGISTERS, etc
207  * in unifihw.h which don't allow selection of register areas for each XAP.
208  */
209 typedef enum unifi_coredump_space
210 {
211     UNIFI_COREDUMP_MAC_REG,
212     UNIFI_COREDUMP_PHY_REG,
213     UNIFI_COREDUMP_SH_DMEM,
214     UNIFI_COREDUMP_MAC_DMEM,
215     UNIFI_COREDUMP_PHY_DMEM,
216     UNIFI_COREDUMP_TRIGGER_MAGIC = 0xFEED
217 } unifi_coredump_space_t;
218
219 /* Structure used to request a register value from a mini-coredump buffer */
220 typedef struct unifi_coredump_req
221 {
222     /* From user */
223     s32               index;       /* 0=newest, -1=oldest */
224     unifi_coredump_space_t space;       /* memory space */
225     u32              offset;      /* register offset in space */
226     /* From driver */
227     u32 drv_build;                /* Driver build id */
228     u32 chip_ver;                 /* Chip version */
229     u32 fw_ver;                   /* Firmware version */
230     s32  requestor;                /* Requestor: 0=auto dump, 1=manual */
231     CsrTime   timestamp;                /* time of capture by driver */
232     u32 serial;                   /* capture serial number */
233     s32  value;                    /* register value */
234 } unifi_coredump_req_t;                 /* mini-coredumped reg value request */
235
236
237 /**
238  * @defgroup upperedge Upper edge API
239  *
240  * The following functions are implemented in the HIP core lib.
241  */
242
243 /**
244  *
245  * Initialise the HIP core lib.
246  * Note that the OS layer must initialise the SDIO glue layer and obtain
247  * an SDIO function context, prior to this call.
248  *
249  * @param sdiopriv the SDIO function context.
250  *
251  * @param ospriv the OS layer context.
252  *
253  * @return \p card_t the HIP core lib API context.
254  *
255  * @ingroup upperedge
256  */
257 card_t* unifi_alloc_card(CsrSdioFunction *sdiopriv, void *ospriv);
258
259
260 /**
261  *
262  * Initialise the UniFi chip.
263  *
264  * @param card the HIP core lib API context.
265  *
266  * @param led_mask the led mask to apply to UniFi.
267  *
268  * @return \b 0 if UniFi is initialized.
269  *
270  * @return \b -CSR_EIO if an I/O error occured while initializing UniFi
271  *
272  * @return \b -CSR_ENODEV if the card is no longer present.
273  *
274  * @ingroup upperedge
275  */
276 CsrResult unifi_init_card(card_t *card, s32 led_mask);
277
278 /**
279  *
280  * De-Initialise the HIP core lib.
281  *
282  * @param card the HIP core lib API context.
283  *
284  * @ingroup upperedge
285  */
286 void unifi_free_card(card_t *card);
287
288 /**
289  *
290  * Cancel all the signals pending in the HIP core lib.
291  * Normally used during a system suspend when the power is retained on UniFi.
292  *
293  * @param card the HIP core lib API context.
294  *
295  * @ingroup upperedge
296  */
297 void unifi_cancel_pending_signals(card_t *card);
298
299 /**
300  *
301  * Send a signal to UniFi.
302  * Normally it is called from unifi_sys_hip_req() and the OS layer
303  * Tx data plane.
304  *
305  * Note that the bulkdata buffers ownership is passed to the HIP core lib.
306  * These buffers must be allocated using unifi_net_data_malloc().
307  *
308  * @param card the HIP core lib API context.
309  *
310  * @param sigptr pointer to the signal.
311  *
312  * @param siglen size of the signal.
313  *
314  * @param bulkdata pointer to the bulk data associated with the signal.
315  *
316  * @return \b 0 signal is sent.
317  *
318  * @return \b -CSR_EIO if an error occured while sending the signal
319  *
320  * @return \b -CSR_ENODEV if the card is no longer present.
321  *
322  * @ingroup upperedge
323  */
324 CsrResult unifi_send_signal(card_t *card, const u8 *sigptr,
325                             u32 siglen,
326                             const bulk_data_param_t *bulkdata);
327
328 /**
329  *
330  * Check if the HIP core lib has resources to send a signal.
331  * Normally there no need to use this function.
332  *
333  * @param card the HIP core lib API context.
334  *
335  * @param sigptr pointer to the signal.
336  *
337  * @return \b 0 if there are resources for the signal.
338  *
339  * @return \b -CSR_ENOSPC if there are not enough resources
340  *
341  * @ingroup upperedge
342  */
343 CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr);
344
345 /**
346  *
347  * Read the UniFi chip and the HIP core lib information.
348  *
349  * @param card the HIP core lib API context.
350  *
351  * @param card_info pointer to save the information.
352  *
353  * @ingroup upperedge
354  */
355 void unifi_card_info(card_t *card, card_info_t *card_info);
356
357 /**
358  *
359  * Print the UniFi I/O and Interrupt status.
360  * Normally it is used for debug purposes only.
361  *
362  * @param card the HIP core lib API context.
363
364  * @param status buffer for the chip status
365  *
366  * @return \b 0 if the check was performed.
367  *
368  * @return \b -CSR_EIO if an error occured while checking the status.
369  *
370  * @return \b -CSR_ENODEV if the card is no longer present.
371  *
372  * @ingroup upperedge
373  */
374 CsrResult unifi_check_io_status(card_t *card, s32 *status);
375
376
377 /**
378  *
379  * Run the HIP core lib Botton-Half.
380  * Whenever the HIP core lib want this function to be called
381  * by the OS layer, it calls unifi_run_bh().
382  *
383  * @param card the HIP core lib API context.
384  *
385  * @param remaining pointer to return the time (in msecs) that this function
386  * should be re-scheduled. A return value of 0 means that no re-scheduling
387  * is required. If unifi_bh() is called before the timeout expires,
388  * the caller must pass in the remaining time.
389  *
390  * @return \b 0 if no error occured.
391  *
392  * @return \b -CSR_ENODEV if the card is no longer present.
393  *
394  * @return \b -CSR_E* if an error occured while running the bottom half.
395  *
396  * @ingroup upperedge
397  */
398 CsrResult unifi_bh(card_t *card, u32 *remaining);
399
400
401 /**
402  * UniFi Low Power Mode (Deep Sleep Signaling)
403  *
404  * unifi_low_power_mode defines the UniFi Deep Sleep Signaling status.
405  * Use with unifi_configure_low_power_mode() to enable/disable
406  * the Deep Sleep Signaling.
407  */
408 enum unifi_low_power_mode
409 {
410     UNIFI_LOW_POWER_DISABLED,
411     UNIFI_LOW_POWER_ENABLED
412 };
413
414 /**
415  * Periodic Wake Host Mode
416  *
417  * unifi_periodic_wake_mode defines the Periodic Wake Host Mode.
418  * It can only be set to UNIFI_PERIODIC_WAKE_HOST_ENABLED if
419  * low_power_mode == UNIFI_LOW_POWER_ENABLED.
420  */
421 enum unifi_periodic_wake_mode
422 {
423     UNIFI_PERIODIC_WAKE_HOST_DISABLED,
424     UNIFI_PERIODIC_WAKE_HOST_ENABLED
425 };
426
427 /**
428  *
429  * Run the HIP core lib Botton-Half.
430  * Whenever the HIP core lib want this function to be called
431  * by the OS layer, it calls unifi_run_bh().
432  *
433  * Typically, the SME is responsible for configuring these parameters,
434  * so unifi_sys_configure_power_mode_req() is usually implemented
435  * as a direct call to unifi_configure_low_power_mode().
436  *
437  * Note: When polling mode is used instead of interrupts,
438  * low_power_mode must never be set to UNIFI_LOW_POWER_ENABLED.
439  *
440  * @param card the HIP core lib API context.
441  *
442  * @param low_power_mode the Low Power Mode.
443  *
444  * @param periodic_wake_mode the Periodic Wake Mode.
445  *
446  * @return \b 0 if no error occured.
447  *
448  * @return \b -CSR_E* if the request failed.
449  *
450  * @ingroup upperedge
451  */
452 CsrResult unifi_configure_low_power_mode(card_t                       *card,
453                                          enum unifi_low_power_mode     low_power_mode,
454                                          enum unifi_periodic_wake_mode periodic_wake_mode);
455
456 /**
457  *
458  * Forces the UniFi chip to enter a Deep Sleep state.
459  * This is normally called by the OS layer when the platform suspends.
460  *
461  * Note that if the UniFi Low Power Mode is disabled this call fails.
462  *
463  * @param card the HIP core lib API context.
464  *
465  * @return \b 0 if no error occured.
466  *
467  * @return \b -CSR_ENODEV if the card is no longer present.
468  *
469  * @return \b -CSR_E* if the request failed.
470  *
471  * @ingroup upperedge
472  */
473 CsrResult unifi_force_low_power_mode(card_t *card);
474
475 #ifndef CSR_WIFI_HIP_TA_DISABLE
476 /**
477  * Configure the Traffic Analysis sampling
478  *
479  * Enable or disable statistics gathering.
480  * Enable or disable particular packet detection.
481  *
482  * @param card the HIP core context
483  * @param config_type the item to configure
484  * @param config pointer to struct containing config info
485  *
486  * @return \b 0 if configuration was successful
487  *
488  * @return \b -CSR_EINVAL if a parameter had an invalid value
489  *
490  * @ingroup upperedge
491  */
492 CsrResult unifi_ta_configure(card_t                               *card,
493                              CsrWifiRouterCtrlTrafficConfigType    config_type,
494                              const CsrWifiRouterCtrlTrafficConfig *config);
495
496 /**
497  * Pass a packet for Traffic Analysis sampling
498  *
499  * @param card the HIP core context
500  * @param direction the direction (Rx or Tx) of the frame.
501  * @param data pointer to bulkdata struct containing the packet
502  * @param saddr the source address of the packet
503  * @param sta_macaddr the MAC address of the UniFi chip
504  * @param timestamp the current time in msecs
505  *
506  * @ingroup upperedge
507  */
508 void unifi_ta_sample(card_t                            *card,
509                      CsrWifiRouterCtrlProtocolDirection direction,
510                      const bulk_data_desc_t            *data,
511                      const u8                    *saddr,
512                      const u8                    *sta_macaddr,
513                      u32                          timestamp,
514                      u16                          rate);
515
516 /**
517  * Notify the HIP core lib for a detected Traffic Classification.
518  * Typically, the SME is responsible for configuring these parameters,
519  * so unifi_sys_traffic_classification_req() is usually implemented
520  * as a direct call to unifi_ta_classification().
521  *
522  * @param card the HIP core context.
523  * @param traffic_type the detected traffic type.
524  * @param period The detected period of the traffic.
525  *
526  * @ingroup upperedge
527  */
528 void unifi_ta_classification(card_t                      *card,
529                              CsrWifiRouterCtrlTrafficType traffic_type,
530                              u16                    period);
531
532 #endif
533 /**
534  * Use software to hard reset the chip.
535  * This is a subset of the unifi_init_card() functionality and should
536  * only be used only to reset a paniced chip before a coredump is taken.
537  *
538  * @param card the HIP core context.
539  *
540  * @ingroup upperedge
541  */
542 CsrResult unifi_card_hard_reset(card_t *card);
543
544
545 CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len);
546 CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata);
547 CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data);
548
549
550 enum unifi_dbg_processors_select
551 {
552     UNIFI_PROC_MAC,
553     UNIFI_PROC_PHY,
554     UNIFI_PROC_BT,
555     UNIFI_PROC_BOTH,
556     UNIFI_PROC_INVALID
557 };
558
559 CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which);
560
561 /**
562  * Call-outs from the HIP core lib to the OS layer.
563  * The following functions need to be implemented during the porting exercise.
564  */
565
566 /**
567  * Selects appropriate queue according to priority
568  * Helps maintain uniformity in queue selection between the HIP
569  * and the OS layers.
570  *
571  * @param priority priority of the packet
572  *
573  * @return \b Traffic queue to which a packet of this priority belongs
574  *
575  * @ingroup upperedge
576  */
577 unifi_TrafficQueue
578 unifi_frame_priority_to_queue(CSR_PRIORITY priority);
579
580 /**
581  * Returns the priority corresponding to a particular Queue when that is used
582  * when downgrading a packet to a lower AC.
583  * Helps maintain uniformity in queue - priority mapping between the HIP
584  * and the OS layers.
585  *
586  * @param queue
587  *
588  * @return \b Highest priority corresponding to this queue
589  *
590  * @ingroup upperedge
591  */
592 CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue);
593
594 /**
595  *
596  * Flow control callbacks.
597  * unifi_pause_xmit() is called when the HIP core lib does not have any
598  * resources to store data packets. The OS layer needs to pause
599  * the Tx data plane until unifi_restart_xmit() is called.
600  *
601  * @param ospriv the OS layer context.
602  *
603  * @ingroup upperedge
604  */
605 void unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue);
606 void unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue);
607
608 /**
609  *
610  * Request to run the Bottom-Half.
611  * The HIP core lib calls this function to request that unifi_bh()
612  * needs to be run by the OS layer. It can be called anytime, i.e.
613  * when the unifi_bh() is running.
614  * Since unifi_bh() is not re-entrant, usually unifi_run_bh() sets
615  * an event to a thread that schedules a call to unifi_bh().
616  *
617  * @param ospriv the OS layer context.
618  *
619  * @ingroup upperedge
620  */
621 CsrResult unifi_run_bh(void *ospriv);
622
623 /**
624  *
625  * Delivers a signal received from UniFi to the OS layer.
626  * Normally, the data signals should be delivered to the data plane
627  * and all the rest to the SME (unifi_sys_hip_ind()).
628  *
629  * Note that the OS layer is responsible for freeing the bulkdata
630  * buffers, using unifi_net_data_free().
631  *
632  * @param ospriv the OS layer context.
633  *
634  * @param sigptr pointer to the signal.
635  *
636  * @param siglen size of the signal.
637  *
638  * @param bulkdata pointer to the bulk data associated with the signal.
639  *
640  * @ingroup upperedge
641  */
642 void unifi_receive_event(void *ospriv,
643                          u8 *sigdata, u32 siglen,
644                          const bulk_data_param_t *bulkdata);
645
646 #ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
647 /**
648  *
649  * Used to reque the failed ma packet request back to hal queues
650  *
651  * @param ospriv the OS layer context.
652  *
653  * @param host_tag host tag for the packet to requeue.
654  *
655  * @param bulkDataDesc pointer to the bulk data.
656  *
657  * @ingroup upperedge
658  */
659 CsrResult unifi_reque_ma_packet_request(void *ospriv, u32 host_tag,
660                                         u16 status,
661                                         bulk_data_desc_t *bulkDataDesc);
662
663 #endif
664 typedef struct
665 {
666     u16 free_fh_sig_queue_slots[UNIFI_NO_OF_TX_QS];
667     u16 free_fh_bulkdata_slots;
668     u16 free_fh_fw_slots;
669 } unifi_HipQosInfo;
670
671 void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo);
672
673
674 /**
675  * Functions that read a portion of a firmware file.
676  *
677  * Note: If the UniFi chip runs the f/w from ROM, the HIP core may never
678  * call these functions. Also, the HIP core may call these functions even if
679  * a f/w file is not available. In this case, it is safe to fail the request.
680  */
681 #define UNIFI_FW_STA    1   /* Identify STA firmware file */
682
683 /**
684  *
685  * Ask the OS layer to initialise a read from a f/w file.
686  *
687  * @param ospriv the OS layer context.
688  *
689  * @param is_fw if 0 the request if for the loader file, if 1 the request
690  * is for a f/w file.
691  *
692  * @param info a card_info_t structure containing versions information.
693  * Note that some members of the structure may not be initialised.
694  *
695  * @return \p NULL if the file is not available, or a pointer which contains
696  * OS specific information for the file (typically the contents of the file)
697  * that the HIP core uses when calling unifi_fw_read() and unifi_fw_read_stop()
698  *
699  * @ingroup upperedge
700  */
701 void* unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info);
702
703 /**
704  *
705  * Ask the OS layer to return a portion from a f/w file.
706  *
707  * @param ospriv the OS layer context.
708  *
709  * @param arg the OS pointer returned by unifi_fw_read_start().
710  *
711  * @param offset the offset in the f/w file to read the read from.
712  *
713  * @param buf the buffer to store the returned data.
714  *
715  * @param len the size in bytes of the requested read.
716  *
717  * @ingroup upperedge
718  */
719 s32 unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len);
720
721 /**
722  *
723  * Ask the OS layer to finish reading from a f/w file.
724  *
725  * @param ospriv the OS layer context.
726  *
727  * @param dlpriv the OS pointer returned by unifi_fw_read_start().
728  *
729  * @ingroup upperedge
730  */
731 void unifi_fw_read_stop(void *ospriv, void *dlpriv);
732
733 /**
734  *
735  * Ask OS layer for a handle to a dynamically allocated firmware buffer
736  * (primarily intended for production test images which may need conversion)
737  *
738  * @param ospriv the OS layer context.
739  *
740  * @param fwbuf pointer to dynamically allocated buffer
741  *
742  * @param len length of provided buffer in bytes
743  *
744  * @ingroup upperedge
745  */
746 void* unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len);
747
748 /**
749  *
750  * Release a handle to a dynamically allocated firmware buffer
751  * (primarily intended for production test images which may need conversion)
752  *
753  * @param ospriv the OS layer context.
754  *
755  * @param fwbuf pointer to dynamically allocated buffer
756  *
757  * @ingroup upperedge
758  */
759 void unifi_fw_close_buffer(void *ospriv, void *fwbuf);
760
761 #ifndef CSR_WIFI_HIP_TA_DISABLE
762 /*
763  * Driver must provide these.
764  *
765  * A simple implementation will just call
766  * unifi_sys_traffic_protocol_ind() or unifi_sys_traffic_classification_ind()
767  * respectively. See sme_csr_userspace/sme_userspace.c.
768  */
769 /**
770  *
771  * Indicates a detected packet of type packet_type.
772  * Typically, this information is processed by the SME so
773  * unifi_ta_indicate_protocol() needs to schedule a call to
774  * unifi_sys_traffic_protocol_ind().
775  *
776  * @param ospriv the OS layer context.
777  *
778  * @param packet_type the detected packet type.
779  *
780  * @param direction the direction of the packet (Rx, Tx).
781  *
782  * @param src_addr the source address of the packet.
783  *
784  * @ingroup upperedge
785  */
786 void unifi_ta_indicate_protocol(void                              *ospriv,
787                                 CsrWifiRouterCtrlTrafficPacketType packet_type,
788                                 CsrWifiRouterCtrlProtocolDirection direction,
789                                 const CsrWifiMacAddress           *src_addr);
790
791 /**
792  *
793  * Indicates statistics for the sample data over a period.
794  * Typically, this information is processed by the SME so
795  * unifi_ta_indicate_sampling() needs to schedule a call to
796  * unifi_sys_traffic_sample_ind().
797  *
798  * @param ospriv the OS layer context.
799  *
800  * @param stats the pointer to the structure that contains the statistics.
801  *
802  * @ingroup upperedge
803  */
804 void unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats);
805 void unifi_ta_indicate_l4stats(void     *ospriv,
806                                u32 rxTcpThroughput,
807                                u32 txTcpThroughput,
808                                u32 rxUdpThroughput,
809                                u32 txUdpThroughput);
810 #endif
811
812 void unifi_rx_queue_flush(void *ospriv);
813
814 /**
815  * Call-out from the SDIO glue layer.
816  *
817  * The glue layer needs to call unifi_sdio_interrupt_handler() every time
818  * an interrupts occurs.
819  *
820  * @param card the HIP core context.
821  *
822  * @ingroup bottomedge
823  */
824 void unifi_sdio_interrupt_handler(card_t *card);
825
826
827 /* HELPER FUNCTIONS */
828
829 /*
830  * unifi_init() and unifi_download() implement a subset of unifi_init_card functionality
831  * that excludes HIP initialization.
832  */
833 CsrResult unifi_init(card_t *card);
834 CsrResult unifi_download(card_t *card, s32 led_mask);
835
836 /*
837  * unifi_start_processors() ensures both on-chip processors are running
838  */
839 CsrResult unifi_start_processors(card_t *card);
840
841 CsrResult unifi_capture_panic(card_t *card);
842
843 /*
844  * Configure HIP interrupt processing mode
845  */
846 #define CSR_WIFI_INTMODE_DEFAULT        0
847 #define CSR_WIFI_INTMODE_RUN_BH_ONCE    1       /* Run BH once per interrupt */
848
849 void unifi_set_interrupt_mode(card_t *card, u32 mode);
850
851 /*
852  * unifi_request_max_clock() requests that max SDIO clock speed is set at the
853  * next suitable opportunity.
854  */
855 void unifi_request_max_sdio_clock(card_t *card);
856
857
858 /* Functions to lookup bulk data command names. */
859 const char* lookup_bulkcmd_name(u16 id);
860
861 /* Function to log HIP's global debug buffer */
862 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
863 void unifi_debug_buf_dump(void);
864 void unifi_debug_log_to_buf(const char *fmt, ...);
865 void unifi_debug_hex_to_buf(const char *buff, u16 length);
866 #endif
867
868 /* Mini-coredump utility functions */
869 CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req);
870 CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req);
871 CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable);
872 CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers);
873 void unifi_coredump_free(card_t *card);
874
875 #ifdef __cplusplus
876 }
877 #endif
878
879 #endif /* __CSR_WIFI_HIP_UNIFI_H__ */