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