History

staging: csr: remove driver

This driver is not being updated as the specifications are not able to be gotten from CSR or anyone else. Without those, getting this driver into proper mergable shape is going to be impossible. So remove the driver from the tree. If the specifications ever become available, this patch can be reverted and the driver fixed up properly.

Greg Kroah-Hartman committed 13 years ago

Commit ade76151 parent ad81f05146 files · +0 −91599Browse files

Unified · Split

146 files
  1. drivers/staging/Kconfig +0 −2
  2. drivers/staging/Makefile +0 −1
  3. drivers/staging/csr/Kconfig +0 −9
  4. drivers/staging/csr/LICENSE.txt +0 −39
  5. drivers/staging/csr/Makefile +0 −73
  6. drivers/staging/csr/bh.c +0 −404
  7. drivers/staging/csr/csr_framework_ext.c +0 −40
  8. drivers/staging/csr/csr_framework_ext.h +0 −35
  9. drivers/staging/csr/csr_framework_ext_types.h +0 −30
  10. drivers/staging/csr/csr_log.h +0 −223
  11. drivers/staging/csr/csr_log_configure.h +0 −39
  12. drivers/staging/csr/csr_log_text.h +0 −124
  13. drivers/staging/csr/csr_macro.h +0 −39
  14. drivers/staging/csr/csr_msg_transport.h +0 −17
  15. drivers/staging/csr/csr_msgconv.c +0 −291
  16. drivers/staging/csr/csr_msgconv.h +0 −78
  17. drivers/staging/csr/csr_prim_defs.h +0 −55
  18. drivers/staging/csr/csr_result.h +0 −17
  19. drivers/staging/csr/csr_sched.h +0 −85
  20. drivers/staging/csr/csr_sdio.h +0 −723
  21. drivers/staging/csr/csr_serialize_primitive_types.c +0 −100
  22. drivers/staging/csr/csr_time.c +0 −33
  23. drivers/staging/csr/csr_time.h +0 −76
  24. drivers/staging/csr/csr_util.c +0 −15
  25. drivers/staging/csr/csr_wifi_common.h +0 −101
  26. drivers/staging/csr/csr_wifi_fsm.h +0 −240
  27. drivers/staging/csr/csr_wifi_fsm_event.h +0 −42
  28. drivers/staging/csr/csr_wifi_fsm_types.h +0 −430
  29. drivers/staging/csr/csr_wifi_hip_card.h +0 −114
  30. drivers/staging/csr/csr_wifi_hip_card_sdio.c +0 −4001
  31. drivers/staging/csr/csr_wifi_hip_card_sdio.h +0 −694
  32. drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c +0 −2595
  33. drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c +0 −1713
  34. drivers/staging/csr/csr_wifi_hip_chiphelper.c +0 −793
  35. drivers/staging/csr/csr_wifi_hip_chiphelper.h +0 −407
  36. drivers/staging/csr/csr_wifi_hip_chiphelper_private.h +0 −200
  37. drivers/staging/csr/csr_wifi_hip_conversions.h +0 −73
  38. drivers/staging/csr/csr_wifi_hip_download.c +0 −819
  39. drivers/staging/csr/csr_wifi_hip_dump.c +0 −837
  40. drivers/staging/csr/csr_wifi_hip_packing.c +0 −4804
  41. drivers/staging/csr/csr_wifi_hip_send.c +0 −415
  42. drivers/staging/csr/csr_wifi_hip_signals.c +0 −1313
  43. drivers/staging/csr/csr_wifi_hip_signals.h +0 −128
  44. drivers/staging/csr/csr_wifi_hip_sigs.h +0 −1417
  45. drivers/staging/csr/csr_wifi_hip_ta_sampling.c +0 −541
  46. drivers/staging/csr/csr_wifi_hip_ta_sampling.h +0 −66
  47. drivers/staging/csr/csr_wifi_hip_udi.c +0 −173
  48. drivers/staging/csr/csr_wifi_hip_unifi.h +0 −871
  49. drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c +0 −41
  50. drivers/staging/csr/csr_wifi_hip_unifi_udi.h +0 −52
  51. drivers/staging/csr/csr_wifi_hip_unifihw.h +0 −59
  52. drivers/staging/csr/csr_wifi_hip_unifiversion.h +0 −30
  53. drivers/staging/csr/csr_wifi_hip_xbv.c +0 −1076
  54. drivers/staging/csr/csr_wifi_hip_xbv.h +0 −119
  55. drivers/staging/csr/csr_wifi_hostio_prim.h +0 −18
  56. drivers/staging/csr/csr_wifi_lib.h +0 −103
  57. drivers/staging/csr/csr_wifi_msgconv.h +0 −49
  58. drivers/staging/csr/csr_wifi_nme_ap_converter_init.c +0 −90
  59. drivers/staging/csr/csr_wifi_nme_ap_converter_init.h +0 −41
  60. drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c +0 −84
  61. drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c +0 −39
  62. drivers/staging/csr/csr_wifi_nme_ap_lib.h +0 −495
  63. drivers/staging/csr/csr_wifi_nme_ap_prim.h +0 −494
  64. drivers/staging/csr/csr_wifi_nme_ap_sef.c +0 −30
  65. drivers/staging/csr/csr_wifi_nme_ap_sef.h +0 −21
  66. drivers/staging/csr/csr_wifi_nme_ap_serialize.c +0 −909
  67. drivers/staging/csr/csr_wifi_nme_ap_serialize.h +0 −94
  68. drivers/staging/csr/csr_wifi_nme_converter_init.h +0 −38
  69. drivers/staging/csr/csr_wifi_nme_lib.h +0 −991
  70. drivers/staging/csr/csr_wifi_nme_prim.h +0 −1657
  71. drivers/staging/csr/csr_wifi_nme_serialize.h +0 −166
  72. drivers/staging/csr/csr_wifi_nme_task.h +0 −27
  73. drivers/staging/csr/csr_wifi_private_common.h +0 −81
  74. drivers/staging/csr/csr_wifi_result.h +0 −27
  75. drivers/staging/csr/csr_wifi_router_converter_init.c +0 −82
  76. drivers/staging/csr/csr_wifi_router_converter_init.h +0 −34
  77. drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c +0 −134
  78. drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h +0 −34
  79. drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c +0 −108
  80. drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c +0 −87
  81. drivers/staging/csr/csr_wifi_router_ctrl_lib.h +0 −2082
  82. drivers/staging/csr/csr_wifi_router_ctrl_prim.h +0 −2113
  83. drivers/staging/csr/csr_wifi_router_ctrl_sef.c +0 −46
  84. drivers/staging/csr/csr_wifi_router_ctrl_sef.h +0 −51
  85. drivers/staging/csr/csr_wifi_router_ctrl_serialize.c +0 −2591
  86. drivers/staging/csr/csr_wifi_router_ctrl_serialize.h +0 −333
  87. drivers/staging/csr/csr_wifi_router_free_downstream_contents.c +0 −53
  88. drivers/staging/csr/csr_wifi_router_free_upstream_contents.c +0 −47
  89. drivers/staging/csr/csr_wifi_router_lib.h +0 −417
  90. drivers/staging/csr/csr_wifi_router_prim.h +0 −421
  91. drivers/staging/csr/csr_wifi_router_sef.c +0 −19
  92. drivers/staging/csr/csr_wifi_router_sef.h +0 −25
  93. drivers/staging/csr/csr_wifi_router_serialize.c +0 −418
  94. drivers/staging/csr/csr_wifi_router_serialize.h +0 −67
  95. drivers/staging/csr/csr_wifi_router_task.h +0 −25
  96. drivers/staging/csr/csr_wifi_router_transport.c +0 −199
  97. drivers/staging/csr/csr_wifi_serialize_primitive_types.c +0 −256
  98. drivers/staging/csr/csr_wifi_sme_ap_lib.h +0 −774
  99. drivers/staging/csr/csr_wifi_sme_ap_prim.h +0 −1030
  100. drivers/staging/csr/csr_wifi_sme_converter_init.c +0 −201
  101. drivers/staging/csr/csr_wifi_sme_converter_init.h +0 −34
  102. drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c +0 −187
  103. drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c +0 −275
  104. drivers/staging/csr/csr_wifi_sme_lib.h +0 −4303
  105. drivers/staging/csr/csr_wifi_sme_prim.h +0 −6510
  106. drivers/staging/csr/csr_wifi_sme_sef.c +0 −85
  107. drivers/staging/csr/csr_wifi_sme_sef.h +0 −142
  108. drivers/staging/csr/csr_wifi_sme_serialize.c +0 −5809
  109. drivers/staging/csr/csr_wifi_sme_serialize.h +0 −666
  110. drivers/staging/csr/csr_wifi_sme_task.h +0 −25
  111. drivers/staging/csr/csr_wifi_vif_utils.h +0 −27
  112. drivers/staging/csr/data_tx.c +0 −54
  113. drivers/staging/csr/drv.c +0 −2193
  114. drivers/staging/csr/firmware.c +0 −396
  115. drivers/staging/csr/inet.c +0 −104
  116. drivers/staging/csr/init_hw.c +0 −108
  117. drivers/staging/csr/io.c +0 −1098
  118. drivers/staging/csr/mlme.c +0 −433
  119. drivers/staging/csr/monitor.c +0 −384
  120. drivers/staging/csr/netdev.c +0 −3307
  121. drivers/staging/csr/os.c +0 −477
  122. drivers/staging/csr/putest.c +0 −685
  123. drivers/staging/csr/sdio_events.c +0 −134
  124. drivers/staging/csr/sdio_mmc.c +0 −1288
  125. drivers/staging/csr/sdio_stubs.c +0 −82
  126. drivers/staging/csr/sme_blocking.c +0 −1466
  127. drivers/staging/csr/sme_mgt.c +0 −1012
  128. drivers/staging/csr/sme_native.c +0 −566
  129. drivers/staging/csr/sme_sys.c +0 −3260
  130. drivers/staging/csr/sme_userspace.c +0 −315
  131. drivers/staging/csr/sme_userspace.h +0 −38
  132. drivers/staging/csr/sme_wext.c +0 −3327
  133. drivers/staging/csr/ul_int.c +0 −528
  134. drivers/staging/csr/unifi_clients.h +0 −129
  135. drivers/staging/csr/unifi_config.h +0 −34
  136. drivers/staging/csr/unifi_dbg.c +0 −110
  137. drivers/staging/csr/unifi_event.c +0 −692
  138. drivers/staging/csr/unifi_native.h +0 −257
  139. drivers/staging/csr/unifi_os.h +0 −122
  140. drivers/staging/csr/unifi_pdu_processing.c +0 −3729
  141. drivers/staging/csr/unifi_priv.h +0 −1136
  142. drivers/staging/csr/unifi_sme.c +0 −1225
  143. drivers/staging/csr/unifi_sme.h +0 −245
  144. drivers/staging/csr/unifi_wext.h +0 −108
  145. drivers/staging/csr/unifiio.h +0 −398
  146. drivers/staging/csr/wext_events.c +0 −283
drivers/staging/Kconfig+0−2
@@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig" · 117 unmodified lines
118 118
119source "drivers/staging/gdm72xx/Kconfig"119source "drivers/staging/gdm72xx/Kconfig"
120 120
121source "drivers/staging/csr/Kconfig"
122
123source "drivers/staging/silicom/Kconfig"121source "drivers/staging/silicom/Kconfig"
124 122
125source "drivers/staging/ced1401/Kconfig"123source "drivers/staging/ced1401/Kconfig"
drivers/staging/Makefile+0−1
@@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/ · 51 unmodified lines
52obj-$(CONFIG_ANDROID) += android/52obj-$(CONFIG_ANDROID) += android/
53obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/53obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
54obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/54obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
55obj-$(CONFIG_CSR_WIFI) += csr/
56obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/55obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/
57obj-$(CONFIG_CED1401) += ced1401/56obj-$(CONFIG_CED1401) += ced1401/
58obj-$(CONFIG_DRM_IMX) += imx-drm/57obj-$(CONFIG_DRM_IMX) += imx-drm/
drivers/staging/csr/Kconfig+0−9
@@ -1,9 +0,0 @@
1config CSR_WIFI
2 tristate "CSR wireless driver"
3 depends on MMC && CFG80211_WEXT && INET
4 select WIRELESS_EXT
5 select WEXT_PRIV
6 help
7 Driver for the CSR wireless SDIO device.
8
9 If unsure, select N.
drivers/staging/csr/LICENSE.txt+0−39
@@ -1,39 +0,0 @@
1Permission is hereby granted, free of charge, to any person obtaining
2a copy of this software and associated documentation files (the
3"Software"), to deal in the Software without restriction, including
4without limitation the rights to use, copy, modify, merge, publish,
5distribute, sublicense, and/or sell copies of the Software, and to
6permit persons to whom the Software is furnished to do so, subject to
7the following conditions:
8
9The above copyright notice and this permission notice shall be
10included in all copies or substantial portions of the Software.
11
12Except as contained in this notice, the names of above-listed
13copyright holders and the names of any contributors shall not be used
14in advertising or otherwise to promote the sale, use or other dealings
15in this Software without prior written authorization.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
23OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25
26Alternatively, this software may be distributed under the terms of the
27GNU General Public License ("GPL") version 2 as published
28by the Free Software Foundation.
29
30As a special exception, if other files instantiate templates or use
31macros or inline functions from this file, or you compile this file
32and link it with other works to produce a work based on this file,
33this file does not by itself cause the resulting work to be covered by
34the GNU General Public License. However the source code for this file
35must still be made available in accordance with section (3) of the GNU
36General Public License.
37
38This exception does not invalidate any other reasons why a work based
39on this file might be covered by the GNU General Public License.
drivers/staging/csr/Makefile+0−73
@@ -1,73 +0,0 @@
1ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
2ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
3ccflags-y += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL
4
5obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
6obj-$(CONFIG_CSR_WIFI) += csr_helper.o
7
8csr_wifi-y := bh.o \
9 data_tx.o \
10 drv.o \
11 firmware.o \
12 inet.o \
13 init_hw.o \
14 io.o \
15 monitor.o \
16 netdev.o \
17 os.o \
18 putest.o \
19 sdio_events.o \
20 sdio_mmc.o \
21 sdio_stubs.o \
22 sme_blocking.o \
23 ul_int.o \
24 unifi_dbg.o \
25 unifi_event.o \
26 unifi_pdu_processing.o \
27 unifi_sme.o \
28 csr_wifi_hip_card_sdio.o \
29 csr_wifi_hip_card_sdio_intr.o \
30 csr_wifi_hip_card_sdio_mem.o \
31 csr_wifi_hip_chiphelper.o \
32 csr_wifi_hip_download.o \
33 csr_wifi_hip_dump.o \
34 csr_wifi_hip_packing.o \
35 csr_wifi_hip_send.o \
36 csr_wifi_hip_signals.o \
37 csr_wifi_hip_ta_sampling.o \
38 csr_wifi_hip_udi.o \
39 csr_wifi_hip_unifi_signal_names.o \
40 csr_wifi_hip_xbv.o \
41 csr_wifi_nme_ap_converter_init.o \
42 csr_wifi_nme_ap_free_downstream_contents.o \
43 csr_wifi_nme_ap_free_upstream_contents.o \
44 csr_wifi_nme_ap_serialize.o \
45 csr_wifi_nme_ap_sef.o \
46 csr_wifi_router_ctrl_sef.o \
47 csr_wifi_router_sef.o \
48 csr_wifi_router_transport.o \
49 csr_wifi_sme_sef.o \
50 csr_wifi_sme_converter_init.o \
51 csr_wifi_sme_free_downstream_contents.o \
52 csr_wifi_sme_free_upstream_contents.o \
53 csr_wifi_sme_serialize.o \
54 csr_wifi_router_ctrl_converter_init.o \
55 csr_wifi_router_ctrl_free_downstream_contents.o \
56 csr_wifi_router_ctrl_free_upstream_contents.o \
57 csr_wifi_router_ctrl_serialize.o \
58 csr_wifi_router_converter_init.o \
59 csr_wifi_router_free_downstream_contents.o \
60 csr_wifi_router_free_upstream_contents.o \
61 csr_wifi_router_serialize.o \
62 sme_mgt.o \
63 sme_sys.o \
64 sme_userspace.o \
65 sme_wext.o \
66 wext_events.o
67
68csr_helper-y := csr_time.o \
69 csr_util.o \
70 csr_framework_ext.o \
71 csr_wifi_serialize_primitive_types.o \
72 csr_serialize_primitive_types.o \
73 csr_msgconv.o
drivers/staging/csr/bh.c+0−404
@@ -1,404 +0,0 @@
1/*
2 * ---------------------------------------------------------------------------
3 * FILE: bh.c
4 *
5 * PURPOSE:
6 * Provides an implementation for the driver bottom-half.
7 * It is part of the porting exercise in Linux.
8 *
9 * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
10 *
11 * Refer to LICENSE.txt included with this source code for details on
12 * the license terms.
13 *
14 * ---------------------------------------------------------------------------
15 */
16#include "csr_wifi_hip_unifi.h"
17#include "unifi_priv.h"
18#include <linux/sched/rt.h>
19
20/*
21 * ---------------------------------------------------------------------------
22 * uf_start_thread
23 *
24 * Helper function to start a new thread.
25 *
26 * Arguments:
27 * priv Pointer to OS driver structure for the device.
28 * thread Pointer to the thread object
29 * func The thread function
30 *
31 * Returns:
32 * 0 on success or else a Linux error code.
33 * ---------------------------------------------------------------------------
34 */
35int uf_start_thread(unifi_priv_t *priv,
36 struct uf_thread *thread, int (*func)(void *))
37{
38 if (thread->thread_task != NULL) {
39 unifi_error(priv, "%s thread already started\n", thread->name);
40 return 0;
41 }
42
43 /* Start the kernel thread that handles all h/w accesses. */
44 thread->thread_task = kthread_run(func, priv, "%s", thread->name);
45 if (IS_ERR(thread->thread_task))
46 return PTR_ERR(thread->thread_task);
47
48 /* Module parameter overides the thread priority */
49 if (bh_priority != -1) {
50 if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
51 struct sched_param param;
52 priv->bh_thread.prio = bh_priority;
53 unifi_trace(priv, UDBG1,
54 "%s thread (RT) priority = %d\n",
55 thread->name, bh_priority);
56 param.sched_priority = bh_priority;
57 sched_setscheduler(thread->thread_task,
58 SCHED_FIFO, &param);
59 } else if (bh_priority > MAX_RT_PRIO &&
60 bh_priority <= MAX_PRIO) {
61 priv->bh_thread.prio = bh_priority;
62 unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
63 thread->name,
64 PRIO_TO_NICE(bh_priority));
65 set_user_nice(thread->thread_task,
66 PRIO_TO_NICE(bh_priority));
67 } else {
68 priv->bh_thread.prio = DEFAULT_PRIO;
69 unifi_warning(priv,
70 "%s thread unsupported (%d) priority\n",
71 thread->name, bh_priority);
72 }
73 } else
74 priv->bh_thread.prio = DEFAULT_PRIO;
75 unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
76
77 return 0;
78} /* uf_start_thread() */
79
80
81/*
82 * ---------------------------------------------------------------------------
83 * uf_stop_thread
84 *
85 * Helper function to stop a thread.
86 *
87 * Arguments:
88 * priv Pointer to OS driver structure for the device.
89 * thread Pointer to the thread object
90 *
91 * Returns:
92 *
93 * ---------------------------------------------------------------------------
94 */
95void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
96{
97 if (!thread->thread_task) {
98 unifi_notice(priv, "%s thread is already stopped\n",
99 thread->name);
100 return;
101 }
102
103 unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
104
105 kthread_stop(thread->thread_task);
106 thread->thread_task = NULL;
107
108} /* uf_stop_thread() */
109
110
111
112/*
113 * ---------------------------------------------------------------------------
114 * uf_wait_for_thread_to_stop
115 *
116 * Helper function to wait until a thread is stopped.
117 *
118 * Arguments:
119 * priv Pointer to OS driver structure for the device.
120 *
121 * Returns:
122 *
123 * ---------------------------------------------------------------------------
124 */
125void
126uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
127{
128 /*
129 * kthread_stop() cannot handle the thread exiting while
130 * kthread_should_stop() is false, so sleep until kthread_stop()
131 * wakes us up
132 */
133 unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n",
134 thread->name);
135 set_current_state(TASK_INTERRUPTIBLE);
136 if (!kthread_should_stop()) {
137 unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
138 schedule();
139 }
140
141 thread->thread_task = NULL;
142 unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
143} /* uf_wait_for_thread_to_stop() */
144
145
146/*
147 * ---------------------------------------------------------------------------
148 * handle_bh_error
149 *
150 * This function reports an error returned from the HIP core bottom-half.
151 * Normally, implemented during the porting exercise, passing the error
152 * to the SME using unifi_sys_wifi_off_ind().
153 * The SME will try to reset the device and go through
154 * the initialisation of the UniFi.
155 *
156 * Arguments:
157 * priv Pointer to OS driver structure for the device.
158 *
159 * Returns:
160 * None.
161 * ---------------------------------------------------------------------------
162 */
163static void
164handle_bh_error(unifi_priv_t *priv)
165{
166 netInterface_priv_t *interfacePriv;
167 u8 conf_param = CONFIG_IND_ERROR;
168 u8 interfaceTag;
169
170
171 /* Block unifi_run_bh() until the error has been handled. */
172 priv->bh_thread.block_thread = 1;
173
174 /* Consider UniFi to be uninitialised */
175 priv->init_progress = UNIFI_INIT_NONE;
176
177 /* Stop the network traffic */
178 for (interfaceTag = 0;
179 interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) {
180 interfacePriv = priv->interfacePriv[interfaceTag];
181 if (interfacePriv->netdev_registered)
182 netif_carrier_off(priv->netdev[interfaceTag]);
183 }
184
185#ifdef CSR_NATIVE_LINUX
186 /* Force any client waiting on an mlme_wait_for_reply() to abort. */
187 uf_abort_mlme(priv);
188
189 /* Cancel any pending workqueue tasks */
190 flush_workqueue(priv->unifi_workqueue);
191
192#endif /* CSR_NATIVE_LINUX */
193
194 unifi_error(priv,
195 "handle_bh_error: fatal error is reported to the SME.\n");
196 /* Notify the clients (SME or unifi_manager) for the error. */
197 ul_log_config_ind(priv, &conf_param, sizeof(u8));
198
199} /* handle_bh_error() */
200
201
202
203/*
204 * ---------------------------------------------------------------------------
205 * bh_thread_function
206 *
207 * All hardware access happens in this thread.
208 * This means there is no need for locks on the hardware and we don't need
209 * to worry about reentrancy with the SDIO library.
210 * Provides and example implementation on how to call unifi_bh(), which
211 * is part of the HIP core API.
212 *
213 * It processes the events generated by unifi_run_bh() to serialise calls
214 * to unifi_bh(). It also demonstrates how the timeout parameter passed in
215 * and returned from unifi_bh() needs to be handled.
216 *
217 * Arguments:
218 * arg Pointer to OS driver structure for the device.
219 *
220 * Returns:
221 * None.
222 *
223 * Notes:
224 * When the bottom half of the driver needs to process signals, events,
225 * or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
226 * Since we need all SDIO transaction to be in a single thread, the
227 * unifi_run_bh() will wake up this thread to process it.
228 *
229 * ---------------------------------------------------------------------------
230 */
231static int bh_thread_function(void *arg)
232{
233 unifi_priv_t *priv = (unifi_priv_t *)arg;
234 CsrResult csrResult;
235 long ret;
236 u32 timeout, t;
237 struct uf_thread *this_thread;
238
239 unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
240
241 this_thread = &priv->bh_thread;
242
243 t = timeout = 0;
244 while (!kthread_should_stop()) {
245 /*
246 * wait until an error occurs,
247 * or we need to process something.
248 */
249 unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
250
251 if (timeout > 0) {
252 /* Convert t in ms to jiffies */
253 t = msecs_to_jiffies(timeout);
254 ret = wait_event_interruptible_timeout(
255 this_thread->wakeup_q,
256 (this_thread->wakeup_flag && !this_thread->block_thread) ||
257 kthread_should_stop(),
258 t);
259 timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
260 } else {
261 ret = wait_event_interruptible(this_thread->wakeup_q,
262 (this_thread->wakeup_flag && !this_thread->block_thread) ||
263 kthread_should_stop());
264 }
265
266 if (kthread_should_stop()) {
267 unifi_trace(priv, UDBG2,
268 "bh_thread: signalled to exit\n");
269 break;
270 }
271
272 if (ret < 0) {
273 unifi_notice(priv,
274 "bh_thread: wait_event returned %d, thread will exit\n",
275 ret);
276 uf_wait_for_thread_to_stop(priv, this_thread);
277 break;
278 }
279
280 this_thread->wakeup_flag = 0;
281
282 unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
283
284 CsrSdioClaim(priv->sdio);
285 csrResult = unifi_bh(priv->card, &timeout);
286 if (csrResult != CSR_RESULT_SUCCESS) {
287 if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
288 CsrSdioRelease(priv->sdio);
289 uf_wait_for_thread_to_stop(priv, this_thread);
290 break;
291 }
292 /* Errors must be delivered to the error task */
293 handle_bh_error(priv);
294 }
295 CsrSdioRelease(priv->sdio);
296 }
297
298 /*
299 * I would normally try to call csr_sdio_remove_irq() here to make sure
300 * that we do not get any interrupts while this thread is not running.
301 * However, the MMC/SDIO driver tries to kill its' interrupt thread.
302 * The kernel threads implementation does not allow to kill threads
303 * from a signalled to stop thread.
304 * So, instead call csr_sdio_linux_remove_irq() always after calling
305 * uf_stop_thread() to kill this thread.
306 */
307
308 unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
309 return 0;
310} /* bh_thread_function() */
311
312
313/*
314 * ---------------------------------------------------------------------------
315 * uf_init_bh
316 *
317 * Helper function to start the bottom half of the driver.
318 * All we need to do here is start the I/O bh thread.
319 *
320 * Arguments:
321 * priv Pointer to OS driver structure for the device.
322 *
323 * Returns:
324 * 0 on success or else a Linux error code.
325 * ---------------------------------------------------------------------------
326 */
327int
328uf_init_bh(unifi_priv_t *priv)
329{
330 int r;
331
332 /* Enable mlme interface. */
333 priv->io_aborted = 0;
334
335
336 /* Start the BH thread */
337 r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
338 if (r) {
339 unifi_error(priv,
340 "uf_init_bh: failed to start the BH thread.\n");
341 return r;
342 }
343
344 /* Allow interrupts */
345 r = csr_sdio_linux_install_irq(priv->sdio);
346 if (r) {
347 unifi_error(priv,
348 "uf_init_bh: failed to install the IRQ.\n");
349
350 uf_stop_thread(priv, &priv->bh_thread);
351 }
352
353 return r;
354} /* uf_init_bh() */
355
356
357/*
358 * ---------------------------------------------------------------------------
359 * unifi_run_bh
360 *
361 * Part of the HIP core lib API, implemented in the porting exercise.
362 * The bottom half of the driver calls this function when
363 * it wants to process anything that requires access to unifi.
364 * We need to call unifi_bh() which in this implementation is done
365 * by waking up the I/O thread.
366 *
367 * Arguments:
368 * ospriv Pointer to OS driver structure for the device.
369 *
370 * Returns:
371 * 0 on success or else a Linux error code.
372 *
373 * Notes:
374 * ---------------------------------------------------------------------------
375 */
376CsrResult unifi_run_bh(void *ospriv)
377{
378 unifi_priv_t *priv = ospriv;
379
380 /*
381 * If an error has occurred, we discard silently all messages from the bh
382 * until the error has been processed and the unifi has been
383 * reinitialised.
384 */
385 if (priv->bh_thread.block_thread == 1) {
386 unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
387 /*
388 * Do not try to acknowledge a pending interrupt here.
389 * This function is called by unifi_send_signal()
390 * which in turn can be running in an atomic or 'disabled irq'
391 * level if a signal is sent from a workqueue task
392 * (i.e multicass addresses set). We can not hold the SDIO lock
393 * because it might sleep.
394 */
395 return CSR_RESULT_FAILURE;
396 }
397
398 priv->bh_thread.wakeup_flag = 1;
399 /* wake up I/O thread */
400 wake_up_interruptible(&priv->bh_thread.wakeup_q);
401
402 return CSR_RESULT_SUCCESS;
403} /* unifi_run_bh() */
404
drivers/staging/csr/csr_framework_ext.c+0−40
@@ -1,40 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
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#include <linux/kernel.h>
12#include <linux/kthread.h>
13#include <linux/module.h>
14#include <linux/freezer.h>
15#include <linux/semaphore.h>
16#include <linux/slab.h>
17#include <linux/bitops.h>
18
19#include "csr_framework_ext.h"
20
21/*----------------------------------------------------------------------------*
22 * NAME
23 * CsrThreadSleep
24 *
25 * DESCRIPTION
26 * Sleep for a given period.
27 *
28 * RETURNS
29 * void
30 *
31 *----------------------------------------------------------------------------*/
32void CsrThreadSleep(u16 sleepTimeInMs)
33{
34 unsigned long t;
35
36 /* Convert t in ms to jiffies and round up */
37 t = ((sleepTimeInMs * HZ) + 999) / 1000;
38 schedule_timeout_uninterruptible(t);
39}
40EXPORT_SYMBOL_GPL(CsrThreadSleep);
drivers/staging/csr/csr_framework_ext.h+0−35
@@ -1,35 +0,0 @@
1#ifndef CSR_FRAMEWORK_EXT_H__
2#define CSR_FRAMEWORK_EXT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14#include "csr_framework_ext_types.h"
15
16/* Result codes */
17#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
18#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
19#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
20#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
21#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
22#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
23
24/* Thread priorities */
25#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
26#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
27#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
28#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
29#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
30
31#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
32
33void CsrThreadSleep(u16 sleepTimeInMs);
34
35#endif
drivers/staging/csr/csr_framework_ext_types.h+0−30
@@ -1,30 +0,0 @@
1#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
2#define CSR_FRAMEWORK_EXT_TYPES_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#ifdef __KERNEL__
14#include <linux/kthread.h>
15#include <linux/semaphore.h>
16#else
17#include <pthread.h>
18#endif
19
20#ifdef __KERNEL__
21
22typedef struct semaphore CsrMutexHandle;
23
24#else /* __KERNEL __ */
25
26typedef pthread_mutex_t CsrMutexHandle;
27
28#endif /* __KERNEL__ */
29
30#endif
drivers/staging/csr/csr_log.h+0−223
@@ -1,223 +0,0 @@
1#ifndef CSR_LOG_H__
2#define CSR_LOG_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_sched.h"
14#include "csr_prim_defs.h"
15#include "csr_msgconv.h"
16
17/*
18 * Log filtering
19 */
20
21/*----------------------------------------------------*/
22/* Filtering on environment specific log levels */
23/*----------------------------------------------------*/
24typedef u32 CsrLogLevelEnvironment;
25#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
26#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
27#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
28#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
29#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
30#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
31#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
32#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
33#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
34#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
35#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
36#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
37#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
38/* The bit masks between here are reserved for future usage */
39#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
40
41/*----------------------------------------------------*/
42/* Filtering on task specific log levels */
43/*----------------------------------------------------*/
44typedef u32 CsrLogLevelTask;
45#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
46#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
47#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
48#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
49#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
50#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
51#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
52#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
53#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
54#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
55#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
56#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
57#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
58#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
59#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
60#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
61#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
62#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
63#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
64#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
65/* The bit masks between here are reserved for future usage */
66#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
67
68u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
69CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
70u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
71
72/*
73 * Logging stuff
74 */
75#define CSR_LOG_STRINGIFY_REAL(a) (#a)
76#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
77
78typedef struct {
79 u16 primitiveType;
80 const char *primitiveName;
81 CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
82} CsrLogPrimitiveInformation;
83
84typedef struct {
85 const char *techVer;
86 u32 primitiveInfoCount;
87 CsrLogPrimitiveInformation *primitiveInfo;
88} CsrLogTechInformation;
89
90/*---------------------------------*/
91/* Tech logging */
92/*---------------------------------*/
93typedef u8 bitmask8_t;
94typedef u16 bitmask16_t;
95typedef u32 bitmask32_t;
96
97#ifdef CSR_LOG_ENABLE
98#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
99/* DEPRECATED - replaced by csr_log_text.h */
100#define CSR_LOG_TEXT(text) \
101 do { \
102 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
103 CsrLogTaskText(text, __LINE__, __FILE__); \
104 } \
105 } while (0)
106#else
107/* DEPRECATED - replaced by csr_log_text.h */
108#define CSR_LOG_TEXT(text) \
109 do { \
110 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
111 CsrLogTaskText(text, 0, NULL); \
112 } \
113 } while (0)
114#endif
115#else
116#define CSR_LOG_TEXT(text)
117#endif
118
119/* DEPRECATED - replaced by csr_log_text.h */
120void CsrLogTaskText(const char *text,
121 u32 line,
122 const char *file);
123
124#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
125#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
126#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
127#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
128#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
129#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
130#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
131
132/* DEPRECATED - replaced by csr_log_text.h */
133void CsrLogStateTransition(bitmask16_t mask,
134 u32 identifier,
135 const char *fsm_name,
136 u32 prev_state,
137 const char *prev_state_str,
138 u32 in_event,
139 const char *in_event_str,
140 u32 next_state,
141 const char *next_state_str,
142 u32 line,
143 const char *file);
144
145/*---------------------------------*/
146/* BSP logging */
147/*---------------------------------*/
148void CsrLogSchedInit(u8 thread_id);
149void CsrLogSchedDeinit(u8 thread_id);
150
151void CsrLogSchedStart(u8 thread_id);
152void CsrLogSchedStop(u8 thread_id);
153
154void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
155void CsrLogDeinitTask(u16 task_id);
156
157void CsrLogActivate(CsrSchedQid tskid);
158void CsrLogDeactivate(CsrSchedQid tskid);
159
160#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
161#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
162
163void CsrLogMessagePut(u32 line,
164 const char *file,
165 CsrSchedQid src_task_id,
166 CsrSchedQid dst_taskid,
167 CsrSchedMsgId msg_id,
168 u16 prim_type,
169 const void *msg);
170
171void CsrLogMessageGet(CsrSchedQid src_task_id,
172 CsrSchedQid dst_taskid,
173 u8 get_res,
174 CsrSchedMsgId msg_id,
175 u16 prim_type,
176 const void *msg);
177
178void CsrLogTimedEventIn(u32 line,
179 const char *file,
180 CsrSchedQid task_id,
181 CsrSchedTid tid,
182 u32 requested_delay,
183 u16 fniarg,
184 const void *fnvarg);
185
186void CsrLogTimedEventFire(CsrSchedQid task_id,
187 CsrSchedTid tid);
188
189void CsrLogTimedEventDone(CsrSchedQid task_id,
190 CsrSchedTid tid);
191
192void CsrLogTimedEventCancel(u32 line,
193 const char *file,
194 CsrSchedQid task_id,
195 CsrSchedTid tid,
196 u8 cancel_res);
197
198void CsrLogBgintRegister(u8 thread_id,
199 CsrSchedBgint irq,
200 const char *callback,
201 const void *ptr);
202void CsrLogBgintUnregister(CsrSchedBgint irq);
203void CsrLogBgintSet(CsrSchedBgint irq);
204void CsrLogBgintServiceStart(CsrSchedBgint irq);
205void CsrLogBgintServiceDone(CsrSchedBgint irq);
206
207void CsrLogExceptionStateEvent(u16 prim_type,
208 CsrPrim msg_type,
209 u16 state,
210 u32 line,
211 const char *file);
212void CsrLogExceptionGeneral(u16 prim_type,
213 u16 state,
214 const char *text,
215 u32 line,
216 const char *file);
217void CsrLogExceptionWarning(u16 prim_type,
218 u16 state,
219 const char *text,
220 u32 line,
221 const char *file);
222
223#endif
drivers/staging/csr/csr_log_configure.h+0−39
@@ -1,39 +0,0 @@
1#ifndef CSR_LOG_CONFIGURE_H__
2#define CSR_LOG_CONFIGURE_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11 *****************************************************************************/
12
13#include "csr_log.h"
14
15/*--------------------------------------------*/
16/* Filtering on log text warning levels */
17/*--------------------------------------------*/
18typedef u32 CsrLogLevelText;
19#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000)
20
21#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001)
22#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002)
23#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004)
24#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008)
25#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010)
26
27#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF)
28
29/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
30 * Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower
31 * 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
32 * by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
33 * scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
34 * clashes the technologies are only allowed to assign values within the same restrictive range as allies to
35 * primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
36 * taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
37typedef u32 CsrLogTextTaskId;
38
39#endif
drivers/staging/csr/csr_log_text.h+0−124
@@ -1,124 +0,0 @@
1#ifndef CSR_LOG_TEXT_H__
2#define CSR_LOG_TEXT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_log_configure.h"
14
15typedef struct CsrLogSubOrigin
16{
17 u16 subOriginNumber; /* Id of the given SubOrigin */
18 const char *subOriginName; /* Prefix Text for this SubOrigin */
19} CsrLogSubOrigin;
20
21/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
22#ifdef CSR_LOG_ENABLE
23void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
24#else
25#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
26#endif
27
28/* CRITICAL: Conditions that are threatening to the integrity/stability of the
29 system as a whole. */
30#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
31void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
32void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
33#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
34#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
35#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
36#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
37#else
38#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
39#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
40#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
41#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
42#endif
43
44/* ERROR: Malfunction of a component rendering it unable to operate correctly,
45 causing lack of functionality but not loss of system integrity/stability. */
46#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
47void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
48void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
49#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
50#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
51#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
52#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
53#else
54#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
55#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
56#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
57#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
58#endif
59
60/* WARNING: Conditions that are unexpected and indicative of possible problems
61 or violations of specifications, where the result of such deviations does not
62 lead to malfunction of the component. */
63#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
64void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
65void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
66#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
67#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
68#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
69#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
70#else
71#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
72#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
73#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
74#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
75#endif
76
77/* INFO: Important events that may aid in determining the conditions under which
78 the more severe conditions are encountered. */
79#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
80void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
81void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
82#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
83#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
84#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
85#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
86#else
87#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
88#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
89#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
90#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
91#endif
92
93/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
94#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
95void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
96void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
97#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
98#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
99#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
100#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
101#else
102#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
103#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
104#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
105#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
106#endif
107
108/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
109#ifdef CSR_LOG_ENABLE
110#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
111 {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
112#else
113#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
114#endif
115
116/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
117#ifdef CSR_LOG_ENABLE
118#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
119 CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
120#else
121#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
122#endif
123
124#endif
drivers/staging/csr/csr_macro.h+0−39
@@ -1,39 +0,0 @@
1#ifndef CSR_MACRO_H__
2#define CSR_MACRO_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include <linux/types.h>
14
15#define FALSE (0)
16#define TRUE (1)
17
18/*------------------------------------------------------------------*/
19/* Endian conversion */
20/*------------------------------------------------------------------*/
21#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
22#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
23 ((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
24#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
25 ((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
26#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
27 ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
28 ((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
29 ((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
30
31/*------------------------------------------------------------------*/
32/* Misc */
33/*------------------------------------------------------------------*/
34/* Use this macro on unused local variables that cannot be removed (such as
35 unused function parameters). This will quell warnings from certain compilers
36 and static code analysis tools like Lint and Valgrind. */
37#define CSR_UNUSED(x) ((void) (x))
38
39#endif
drivers/staging/csr/csr_msg_transport.h+0−17
@@ -1,17 +0,0 @@
1#ifndef CSR_MSG_TRANSPORT_H__
2#define CSR_MSG_TRANSPORT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#ifndef CsrMsgTransport
14#define CsrMsgTransport CsrSchedMessagePut
15#endif
16
17#endif /* CSR_MSG_TRANSPORT */
drivers/staging/csr/csr_msgconv.c+0−291
@@ -1,291 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
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#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/slab.h>
14#include "csr_sched.h"
15#include "csr_msgconv.h"
16#include "csr_macro.h"
17
18static CsrMsgConvEntry *converter;
19
20CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType)
21{
22 CsrMsgConvPrimEntry *ptr = NULL;
23
24 if (converter)
25 {
26 ptr = converter->profile_converters;
27 while (ptr)
28 {
29 if (ptr->primType == primType)
30 {
31 break;
32 }
33 else
34 {
35 ptr = ptr->next;
36 }
37 }
38 }
39
40 return ptr;
41}
42
43static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType)
44{
45 const CsrMsgConvMsgEntry *cv = ptr->conv;
46 if (ptr->lookupFunc)
47 {
48 return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
49 }
50
51 while (cv)
52 {
53 if (cv->serFunc == NULL)
54 {
55 /* We've reached the end of the chain */
56 cv = NULL;
57 break;
58 }
59
60 if (cv->msgType == msgType)
61 {
62 break;
63 }
64 else
65 {
66 cv++;
67 }
68 }
69
70 return cv;
71}
72
73static void *deserialize_data(u16 primType,
74 size_t length,
75 u8 *data)
76{
77 CsrMsgConvPrimEntry *ptr;
78 u8 *ret;
79
80 ptr = CsrMsgConvFind(primType);
81
82 if (ptr)
83 {
84 const CsrMsgConvMsgEntry *cv;
85 u16 msgId = 0;
86 size_t offset = 0;
87 CsrUint16Des(&msgId, data, &offset);
88
89 cv = find_msg_converter(ptr, msgId);
90 if (cv)
91 {
92 ret = cv->deserFunc(data, length);
93 }
94 else
95 {
96 ret = NULL;
97 }
98 }
99 else
100 {
101 ret = NULL;
102 }
103
104 return ret;
105}
106
107static size_t sizeof_message(u16 primType, void *msg)
108{
109 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
110 size_t ret;
111
112 if (ptr)
113 {
114 const CsrMsgConvMsgEntry *cv;
115 u16 msgId = *(u16 *) msg;
116
117 cv = find_msg_converter(ptr, msgId);
118 if (cv)
119 {
120 ret = cv->sizeofFunc(msg);
121 }
122 else
123 {
124 ret = 0;
125 }
126 }
127 else
128 {
129 ret = 0;
130 }
131
132 return ret;
133}
134
135static u8 free_message(u16 primType, u8 *data)
136{
137 CsrMsgConvPrimEntry *ptr;
138 u8 ret;
139
140 ptr = CsrMsgConvFind(primType);
141
142 if (ptr)
143 {
144 const CsrMsgConvMsgEntry *cv;
145 u16 msgId = *(u16 *) data;
146
147 cv = find_msg_converter(ptr, msgId);
148 if (cv)
149 {
150 cv->freeFunc(data);
151 ret = TRUE;
152 }
153 else
154 {
155 ret = FALSE;
156 }
157 }
158 else
159 {
160 ret = FALSE;
161 }
162
163 return ret;
164}
165
166static u8 *serialize_message(u16 primType,
167 void *msg,
168 size_t *length,
169 u8 *buffer)
170{
171 CsrMsgConvPrimEntry *ptr;
172 u8 *ret;
173
174 ptr = CsrMsgConvFind(primType);
175
176 *length = 0;
177
178 if (ptr)
179 {
180 const CsrMsgConvMsgEntry *cv;
181
182 cv = find_msg_converter(ptr, *(u16 *) msg);
183 if (cv)
184 {
185 ret = cv->serFunc(buffer, length, msg);
186 }
187 else
188 {
189 ret = NULL;
190 }
191 }
192 else
193 {
194 ret = NULL;
195 }
196
197 return ret;
198}
199
200size_t CsrMsgConvSizeof(u16 primType, void *msg)
201{
202 return sizeof_message(primType, msg);
203}
204
205u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
206{
207 if (converter)
208 {
209 size_t serializedLength;
210 u8 *bufSerialized;
211 u8 *bufOffset = &buffer[*offset];
212 bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
213 *offset += serializedLength;
214 return bufSerialized;
215 }
216 else
217 {
218 return NULL;
219 }
220}
221
222/* Insert profile converter at head of converter list. */
223void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
224{
225 CsrMsgConvPrimEntry *pc;
226 pc = CsrMsgConvFind(primType);
227
228 if (pc)
229 {
230 /* Already registered. Do nothing */
231 }
232 else
233 {
234 pc = kmalloc(sizeof(*pc), GFP_KERNEL);
235 pc->primType = primType;
236 pc->conv = ce;
237 pc->lookupFunc = NULL;
238 pc->next = converter->profile_converters;
239 converter->profile_converters = pc;
240 }
241}
242EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
243
244CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
245{
246 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
247 if (ptr)
248 {
249 return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
250 }
251 return NULL;
252}
253EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
254
255CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
256{
257 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
258 if (ptr && msg)
259 {
260 u16 msgType = *((u16 *) msg);
261 return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
262 }
263 return NULL;
264}
265
266void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
267{
268 CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
269 if (ptr)
270 {
271 ptr->lookupFunc = lookupFunc;
272 }
273}
274EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
275
276CsrMsgConvEntry *CsrMsgConvInit(void)
277{
278 if (!converter)
279 {
280 converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
281
282 converter->profile_converters = NULL;
283 converter->free_message = free_message;
284 converter->sizeof_message = sizeof_message;
285 converter->serialize_message = serialize_message;
286 converter->deserialize_data = deserialize_data;
287 }
288
289 return converter;
290}
291EXPORT_SYMBOL_GPL(CsrMsgConvInit);
drivers/staging/csr/csr_msgconv.h+0−78
@@ -1,78 +0,0 @@
1#ifndef CSR_MSGCONV_H__
2#define CSR_MSGCONV_H__
3
4/*****************************************************************************
5
6 (c) Cambridge Silicon Radio Limited 2010
7 All rights reserved and confidential information of CSR
8
9 Refer to LICENSE.txt included with this source for details
10 on the license terms.
11
12*****************************************************************************/
13
14#include <linux/types.h>
15#include "csr_prim_defs.h"
16#include "csr_sched.h"
17
18typedef size_t (CsrMsgSizeofFunc)(void *msg);
19typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
20typedef void (CsrMsgFreeFunc)(void *msg);
21typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
22
23/* Converter entry for one message type */
24typedef struct CsrMsgConvMsgEntry
25{
26 u16 msgType;
27 CsrMsgSizeofFunc *sizeofFunc;
28 CsrMsgSerializeFunc *serFunc;
29 CsrMsgDeserializeFunc *deserFunc;
30 CsrMsgFreeFunc *freeFunc;
31} CsrMsgConvMsgEntry;
32
33/* Optional lookup function */
34typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
35
36/* All converter entries for one specific primitive */
37typedef struct CsrMsgConvPrimEntry
38{
39 u16 primType;
40 const CsrMsgConvMsgEntry *conv;
41 CsrMsgCustomLookupFunc *lookupFunc;
42 struct CsrMsgConvPrimEntry *next;
43} CsrMsgConvPrimEntry;
44
45typedef struct
46{
47 CsrMsgConvPrimEntry *profile_converters;
48 void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
49 u8 (*free_message)(u16 primType, u8 *data);
50 size_t (*sizeof_message)(u16 primType, void *msg);
51 u8 *(*serialize_message)(u16 primType, void *msg,
52 size_t * length,
53 u8 * buffer);
54} CsrMsgConvEntry;
55
56size_t CsrMsgConvSizeof(u16 primType, void *msg);
57u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
58void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
59void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
60CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
61CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
62CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
63CsrMsgConvEntry *CsrMsgConvInit(void);
64
65/* Prototypes for primitive type serializers */
66void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
67void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
68void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
69void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
70void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
71
72void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
73void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
74void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
75void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
76void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
77
78#endif
drivers/staging/csr/csr_prim_defs.h+0−55
@@ -1,55 +0,0 @@
1#ifndef CSR_PRIM_DEFS_H__
2#define CSR_PRIM_DEFS_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13/************************************************************************************
14 * Segmentation of primitives in upstream and downstream segment
15 ************************************************************************************/
16typedef u16 CsrPrim;
17#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000))
18
19/************************************************************************************
20 * Primitive definitions for Synergy framework
21 ************************************************************************************/
22#define CSR_SYNERGY_EVENT_CLASS_BASE ((u16) (0x0600))
23
24#define CSR_HCI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
25#define CSR_BCCMD_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
26#define CSR_HQ_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
27#define CSR_VM_PRIM ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
28#define CSR_TM_BLUECORE_PRIM ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
29#define CSR_FP_PRIM ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
30#define CSR_IP_SOCKET_PRIM ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
31#define CSR_IP_ETHER_PRIM ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
32#define CSR_IP_IFCONFIG_PRIM ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
33#define CSR_IP_INTERNAL_PRIM ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
34#define CSR_FSAL_PRIM ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
35#define CSR_DATA_STORE_PRIM ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
36#define CSR_AM_PRIM ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
37#define CSR_TLS_PRIM ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
38#define CSR_DHCP_SERVER_PRIM ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
39#define CSR_TFTP_PRIM ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
40#define CSR_DSPM_PRIM ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
41#define CSR_TLS_INTERNAL_PRIM ((u16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE))
42
43#define NUMBER_OF_CSR_FW_EVENTS (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1)
44
45#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE ((u16) (0x06A0))
46
47#define CSR_UI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
48#define CSR_APP_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
49#define CSR_SDIO_PROBE_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
50
51#define NUMBER_OF_CSR_FW_MISC_EVENTS (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1)
52
53#define CSR_ENV_PRIM ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
54
55#endif /* CSR_PRIM_DEFS_H__ */
drivers/staging/csr/csr_result.h+0−17
@@ -1,17 +0,0 @@
1#ifndef CSR_RESULT_H__
2#define CSR_RESULT_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13typedef u16 CsrResult;
14#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
15#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
16
17#endif
drivers/staging/csr/csr_sched.h+0−85
@@ -1,85 +0,0 @@
1#ifndef CSR_SCHED_H__
2#define CSR_SCHED_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12#include <linux/types.h>
13#include "csr_time.h"
14
15/* An identifier issued by the scheduler. */
16typedef u32 CsrSchedIdentifier;
17
18/* A task identifier */
19typedef u16 CsrSchedTaskId;
20
21/* A queue identifier */
22typedef u16 CsrSchedQid;
23
24/* A message identifier */
25typedef CsrSchedIdentifier CsrSchedMsgId;
26
27/* A timer event identifier */
28typedef CsrSchedIdentifier CsrSchedTid;
29#define CSR_SCHED_TID_INVALID ((CsrSchedTid) 0)
30
31/* Time constants. */
32#define CSR_SCHED_TIME_MAX (0xFFFFFFFF)
33#define CSR_SCHED_MILLISECOND (1000)
34#define CSR_SCHED_SECOND (1000 * CSR_SCHED_MILLISECOND)
35#define CSR_SCHED_MINUTE (60 * CSR_SCHED_SECOND)
36
37/* Queue and primitive that identifies the environment */
38#define CSR_SCHED_TASK_ID 0xFFFF
39#define CSR_SCHED_PRIM (CSR_SCHED_TASK_ID)
40#define CSR_SCHED_EXCLUDED_MODULE_QUEUE 0xFFFF
41
42/*
43 * Background interrupt definitions
44 */
45typedef u16 CsrSchedBgint;
46#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF)
47
48/*----------------------------------------------------------------------------*
49 * NAME
50 * CsrSchedMessagePut
51 *
52 * DESCRIPTION
53 * Sends a message consisting of the integer "mi" and the void * pointer
54 * "mv" to the message queue "q".
55 *
56 * "mi" and "mv" are neither inspected nor changed by the scheduler - the
57 * task that owns "q" is expected to make sense of the values. "mv" may
58 * be null.
59 *
60 * NOTE
61 * If "mv" is not null then it will typically be a chunk of kmalloc()ed
62 * memory, though there is no need for it to be so. Tasks should normally
63 * obey the convention that when a message built with kmalloc()ed memory
64 * is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
65 * scheduler - and eventually to the recipient task. I.e., the receiver of
66 * the message will be expected to kfree() the message storage.
67 *
68 * RETURNS
69 * void.
70 *
71 *----------------------------------------------------------------------------*/
72#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
73void CsrSchedMessagePutStringLog(CsrSchedQid q,
74 u16 mi,
75 void *mv,
76 u32 line,
77 const char *file);
78#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__)
79#else
80void CsrSchedMessagePut(CsrSchedQid q,
81 u16 mi,
82 void *mv);
83#endif
84
85#endif
drivers/staging/csr/csr_sdio.h+0−723
@@ -1,723 +0,0 @@
1#ifndef CSR_SDIO_H__
2#define CSR_SDIO_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_result.h"
14
15/* Result Codes */
16#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
17#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
18#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
19#define CSR_SDIO_RESULT_TIMEOUT ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */
20#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
21
22/* Features (for use in features member of CsrSdioFunction) */
23#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
24#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
25
26/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
27#define CSR_SDIO_ANY_MANF_ID 0xFFFF
28#define CSR_SDIO_ANY_CARD_ID 0xFFFF
29#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
30#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
31
32/*----------------------------------------------------------------------------*
33 * NAME
34 * CsrSdioFunctionId
35 *
36 * DESCRIPTION
37 * This structure describes one or more functions of a device, based on
38 * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
39 * used for making the CsrSdioFunctionId match more than one function.
40 *
41 * MEMBERS
42 * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
43 * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
44 * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
45 * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
46 *
47 *----------------------------------------------------------------------------*/
48typedef struct
49{
50 u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
51 u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
52 u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
53 u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
54} CsrSdioFunctionId;
55
56/*----------------------------------------------------------------------------*
57 * NAME
58 * CsrSdioFunction
59 *
60 * DESCRIPTION
61 * This structure represents a single function on a device.
62 *
63 * MEMBERS
64 * sdioId - A CsrSdioFunctionId describing this particular function. The
65 * subfield shall not contain any CsrSdioFunctionId wildcards. The
66 * subfields shall describe the specific single function
67 * represented by this structure.
68 * blockSize - Actual configured block size, or 0 if unconfigured.
69 * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
70 * device - Handle of device containing the function. If two functions have
71 * the same device handle, they reside on the same device.
72 * driverData - For use by the Function Driver. The SDIO Driver shall not
73 * attempt to dereference the pointer.
74 * priv - For use by the SDIO Driver. The Function Driver shall not attempt
75 * to dereference the pointer.
76 *
77 *
78 *----------------------------------------------------------------------------*/
79typedef struct
80{
81 CsrSdioFunctionId sdioId;
82 u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
83 u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
84 void *device; /* Handle of device containing the function */
85 void *driverData; /* For use by the Function Driver */
86 void *priv; /* For use by the SDIO Driver */
87} CsrSdioFunction;
88
89/*----------------------------------------------------------------------------*
90 * NAME
91 * CsrSdioInsertedCallback, CsrSdioRemovedCallback
92 *
93 * DESCRIPTION
94 * CsrSdioInsertedCallback is called when a function becomes available to
95 * a registered Function Driver that supports the function.
96 * CsrSdioRemovedCallback is called when a function is no longer available
97 * to a Function Driver, either because the device has been removed, or the
98 * Function Driver has been unregistered.
99 *
100 * NOTE: These functions are implemented by the Function Driver, and are
101 * passed as function pointers in the CsrSdioFunctionDriver struct.
102 *
103 * PARAMETERS
104 * function - Pointer to struct representing the function.
105 *
106 *----------------------------------------------------------------------------*/
107typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
108typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
109
110/*----------------------------------------------------------------------------*
111 * NAME
112 * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
113 *
114 * DESCRIPTION
115 * CsrSdioInterruptCallback is called when an interrupt occurs on the
116 * the device associated with the specified function.
117 *
118 * NOTE: These functions are implemented by the Function Driver, and are
119 * passed as function pointers in the CsrSdioFunctionDriver struct.
120 *
121 * PARAMETERS
122 * function - Pointer to struct representing the function.
123 *
124 * RETURNS (only CsrSdioInterruptCallback)
125 * A pointer to a CsrSdioInterruptDsrCallback function.
126 *
127 *----------------------------------------------------------------------------*/
128typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
129typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
130
131/*----------------------------------------------------------------------------*
132 * NAME
133 * CsrSdioSuspendCallback, CsrSdioResumeCallback
134 *
135 * DESCRIPTION
136 * CsrSdioSuspendCallback is called when the system is preparing to go
137 * into a suspended state. CsrSdioResumeCallback is called when the system
138 * has entered an active state again.
139 *
140 * NOTE: These functions are implemented by the Function Driver, and are
141 * passed as function pointers in the CsrSdioFunctionDriver struct.
142 *
143 * PARAMETERS
144 * function - Pointer to struct representing the function.
145 *
146 *----------------------------------------------------------------------------*/
147typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
148typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
149
150/*----------------------------------------------------------------------------*
151 * NAME
152 * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
153 *
154 * DESCRIPTION
155 * CsrSdioAsyncCallback is called when an asynchronous operation completes.
156 *
157 * NOTE: These functions are implemented by the Function Driver, and are
158 * passed as function pointers in the function calls that initiate
159 * the operation.
160 *
161 * PARAMETERS
162 * function - Pointer to struct representing the function.
163 * result - The result of the operation that completed. See the description
164 * of the initiating function for possible result values.
165 *
166 * RETURNS (only CsrSdioAsyncCallback)
167 * A pointer to a CsrSdioAsyncDsrCallback function.
168 *
169 *----------------------------------------------------------------------------*/
170typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
171typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
172
173/*----------------------------------------------------------------------------*
174 * NAME
175 * CsrSdioFunctionDriver
176 *
177 * DESCRIPTION
178 * Structure representing a Function Driver.
179 *
180 * MEMBERS
181 * inserted - Callback, see description of CsrSdioInsertedCallback.
182 * removed - Callback, see description of CsrSdioRemovedCallback.
183 * intr - Callback, see description of CsrSdioInterruptCallback.
184 * suspend - Callback, see description of CsrSdioSuspendCallback.
185 * resume - Callback, see description of CsrSdioResumeCallback.
186 * ids - Array of CsrSdioFunctionId describing one or more functions that
187 * are supported by the Function Driver.
188 * idsCount - Length of the ids array.
189 * priv - For use by the SDIO Driver. The Function Driver may initialise
190 * it to NULL, but shall otherwise not access the pointer or attempt
191 * to dereference it.
192 *
193 *----------------------------------------------------------------------------*/
194typedef struct
195{
196 CsrSdioInsertedCallback inserted;
197 CsrSdioRemovedCallback removed;
198 CsrSdioInterruptCallback intr;
199 CsrSdioSuspendCallback suspend;
200 CsrSdioResumeCallback resume;
201 CsrSdioFunctionId *ids;
202 u8 idsCount;
203 void *priv; /* For use by the SDIO Driver */
204} CsrSdioFunctionDriver;
205
206/*----------------------------------------------------------------------------*
207 * NAME
208 * CsrSdioFunctionDriverRegister
209 *
210 * DESCRIPTION
211 * Register a Function Driver.
212 *
213 * PARAMETERS
214 * functionDriver - Pointer to struct describing the Function Driver.
215 *
216 * RETURNS
217 * CSR_RESULT_SUCCESS - The Function Driver was successfully
218 * registered.
219 * CSR_RESULT_FAILURE - Unable to register the function driver,
220 * because of an unspecified/unknown error. The
221 * Function Driver has not been registered.
222 * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
223 * does not point at a valid Function
224 * Driver structure, or some of the members
225 * contain invalid entries.
226 *
227 *----------------------------------------------------------------------------*/
228CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
229
230/*----------------------------------------------------------------------------*
231 * NAME
232 * CsrSdioFunctionDriverUnregister
233 *
234 * DESCRIPTION
235 * Unregister a previously registered Function Driver.
236 *
237 * PARAMETERS
238 * functionDriver - pointer to struct describing the Function Driver.
239 *
240 *----------------------------------------------------------------------------*/
241void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
242
243/*----------------------------------------------------------------------------*
244 * NAME
245 * CsrSdioFunctionEnable, CsrSdioFunctionDisable
246 *
247 * DESCRIPTION
248 * Enable/disable the specified function by setting/clearing the
249 * corresponding bit in the I/O Enable register in function 0, and then
250 * periodically reading the related bit in the I/O Ready register until it
251 * is set/clear, limited by an implementation defined timeout.
252 *
253 * PARAMETERS
254 * function - Pointer to struct representing the function.
255 *
256 * RETURNS
257 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
258 * CSR_RESULT_FAILURE - Unspecified/unknown error.
259 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
260 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
261 * related bit in the I/O Enable register is
262 * undefined.
263 * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
264 * bit in the I/O ready register was not
265 * set/cleared within the timeout period.
266 *
267 * NOTE: If the SDIO R5 response is available, and either of the
268 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
269 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
270 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
271 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
272 * COM_CRC_ERROR bits shall be ignored.
273 *
274 * If the CSPI response is available, and any of the
275 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
276 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
277 *
278 *----------------------------------------------------------------------------*/
279CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
280CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
281
282/*----------------------------------------------------------------------------*
283 * NAME
284 * CsrSdioInterruptEnable, CsrSdioInterruptDisable
285 *
286 * DESCRIPTION
287 * Enable/disable the interrupt for the specified function by
288 * setting/clearing the corresponding bit in the INT Enable register in
289 * function 0.
290 *
291 * PARAMETERS
292 * function - Pointer to struct representing the function.
293 *
294 * RETURNS
295 * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
296 * CSR_RESULT_FAILURE - Unspecified/unknown error.
297 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
298 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The state of the
299 * related bit in the INT Enable register is
300 * unchanged.
301 * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
302 * enabled/disabled, because it either
303 * does not exist or it is not possible to
304 * individually enable/disable functions.
305 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
306 *
307 * NOTE: If the SDIO R5 response is available, and either of the
308 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
309 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
310 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
311 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
312 * COM_CRC_ERROR bits shall be ignored.
313 *
314 * If the CSPI response is available, and any of the
315 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
316 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
317 *
318 *----------------------------------------------------------------------------*/
319CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
320CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
321
322/*----------------------------------------------------------------------------*
323 * NAME
324 * CsrSdioInterruptAcknowledge
325 *
326 * DESCRIPTION
327 * Acknowledge that a signalled interrupt has been handled. Shall only
328 * be called once, and exactly once for each signalled interrupt to the
329 * corresponding function.
330 *
331 * PARAMETERS
332 * function - Pointer to struct representing the function to which the
333 * event was signalled.
334 *
335 *----------------------------------------------------------------------------*/
336void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
337
338/*----------------------------------------------------------------------------*
339 * NAME
340 * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
341 *
342 * DESCRIPTION
343 * Acknowledge that a signalled inserted/removed event has been handled.
344 * Shall only be called once, and exactly once for each signalled event to
345 * the corresponding function.
346 *
347 * PARAMETERS
348 * function - Pointer to struct representing the function to which the
349 * inserted was signalled.
350 * result (CsrSdioInsertedAcknowledge only)
351 * CSR_RESULT_SUCCESS - The Function Driver has accepted the
352 * function, and the function is attached to
353 * the Function Driver until the
354 * CsrSdioRemovedCallback is called and
355 * acknowledged.
356 * CSR_RESULT_FAILURE - Unable to accept the function. The
357 * function is not attached to the Function
358 * Driver, and it may be passed to another
359 * Function Driver which supports the
360 * function.
361 *
362 *----------------------------------------------------------------------------*/
363void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
364void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
365
366/*----------------------------------------------------------------------------*
367 * NAME
368 * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
369 *
370 * DESCRIPTION
371 * Acknowledge that a signalled suspend event has been handled. Shall only
372 * be called once, and exactly once for each signalled event to the
373 * corresponding function.
374 *
375 * PARAMETERS
376 * function - Pointer to struct representing the function to which the
377 * event was signalled.
378 * result
379 * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
380 * CSR_RESULT_FAILURE - Unspecified/unknown error.
381 *
382 *----------------------------------------------------------------------------*/
383void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
384void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
385
386/*----------------------------------------------------------------------------*
387 * NAME
388 * CsrSdioBlockSizeSet
389 *
390 * DESCRIPTION
391 * Set the block size to use for the function. The actual configured block
392 * size shall be the minimum of:
393 * 1) Maximum block size supported by the function.
394 * 2) Maximum block size supported by the host controller.
395 * 3) The block size specified by the blockSize argument.
396 *
397 * When this function returns, the actual configured block size is
398 * available in the blockSize member of the function struct.
399 *
400 * PARAMETERS
401 * function - Pointer to struct representing the function.
402 * blockSize - Block size to use for the function. Valid range is 1 to
403 * 2048.
404 *
405 * RETURNS
406 * CSR_RESULT_SUCCESS - The block size register on the chip
407 * was updated.
408 * CSR_RESULT_FAILURE - Unspecified/unknown error.
409 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
410 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
411 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. The configured block
412 * size is undefined.
413 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
414 *
415 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
416 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
417 * If the ERROR bit is set (but not FUNCTION_NUMBER),
418 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
419 * COM_CRC_ERROR bits shall be ignored.
420 *
421 * If the CSPI response is available, and any of the
422 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
423 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
424 *
425 * NOTE: Setting the block size requires two individual operations. The
426 * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
427 * response for the first operation, as the partially configured
428 * block size may be out of range, even if the final block size
429 * (after the second operation) is in the valid range.
430 *
431 *----------------------------------------------------------------------------*/
432CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
433
434/*----------------------------------------------------------------------------*
435 * NAME
436 * CsrSdioMaxBusClockFrequencySet
437 *
438 * DESCRIPTION
439 * Set the maximum clock frequency to use for the device associated with
440 * the specified function. The actual configured clock frequency for the
441 * device shall be the minimum of:
442 * 1) Maximum clock frequency supported by the device.
443 * 2) Maximum clock frequency supported by the host controller.
444 * 3) Maximum clock frequency specified for any function on the same
445 * device.
446 *
447 * If the clock frequency exceeds 25MHz, it is the responsibility of the
448 * SDIO driver to enable high speed mode on the device, using the standard
449 * defined procedure, before increasing the frequency beyond the limit.
450 *
451 * Note that the clock frequency configured affects all functions on the
452 * same device.
453 *
454 * PARAMETERS
455 * function - Pointer to struct representing the function.
456 * maxFrequency - The maximum clock frequency for the function in Hertz.
457 *
458 * RETURNS
459 * CSR_RESULT_SUCCESS - The maximum clock frequency was successfully
460 * set for the function.
461 * CSR_RESULT_FAILURE - Unspecified/unknown error.
462 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
463 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
464 *
465 * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
466 * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
467 * If the ERROR bit is set (but not FUNCTION_NUMBER),
468 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
469 * COM_CRC_ERROR bits shall be ignored.
470 *
471 * If the CSPI response is available, and any of the
472 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
473 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
474 *
475 *
476 *----------------------------------------------------------------------------*/
477CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
478
479/*----------------------------------------------------------------------------*
480 * NAME
481 * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
482 *
483 * DESCRIPTION
484 * Read/write an 8bit value from/to the specified register address.
485 *
486 * PARAMETERS
487 * function - Pointer to struct representing the function.
488 * address - Register address within the function.
489 * data - The data to read/write.
490 * callback - The function to call on operation completion.
491 *
492 * RETURNS
493 * CSR_RESULT_SUCCESS - The data was successfully read/written.
494 * CSR_RESULT_FAILURE - Unspecified/unknown error.
495 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
496 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
497 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
498 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
499 *
500 * NOTE: If the SDIO R5 response is available, and either of the
501 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
502 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
503 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
504 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
505 * COM_CRC_ERROR bits shall be ignored.
506 *
507 * If the CSPI response is available, and any of the
508 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
509 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
510 *
511 * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
512 * immediately, and the supplied callback function is called when the
513 * operation is complete. The result value is given as an argument to
514 * the callback function.
515 *
516 *----------------------------------------------------------------------------*/
517CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
518CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
519void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
520void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
521
522/*----------------------------------------------------------------------------*
523 * NAME
524 * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
525 *
526 * DESCRIPTION
527 * Read/write a 16bit value from/to the specified register address.
528 *
529 * PARAMETERS
530 * function - Pointer to struct representing the function.
531 * address - Register address within the function.
532 * data - The data to read/write.
533 * callback - The function to call on operation completion.
534 *
535 * RETURNS
536 * CSR_RESULT_SUCCESS - The data was successfully read/written.
537 * CSR_RESULT_FAILURE - Unspecified/unknown error.
538 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
539 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
540 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
541 * partially read/written.
542 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
543 *
544 * NOTE: If the SDIO R5 response is available, and either of the
545 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
546 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
547 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
548 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
549 * COM_CRC_ERROR bits shall be ignored.
550 *
551 * If the CSPI response is available, and any of the
552 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
553 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
554 *
555 * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
556 * immediately, and the supplied callback function is called when the
557 * operation is complete. The result value is given as an argument to
558 * the callback function.
559 *
560 *----------------------------------------------------------------------------*/
561CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
562CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
563void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
564void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
565
566/*----------------------------------------------------------------------------*
567 * NAME
568 * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
569 * CsrSdioF0Write8Async
570 *
571 * DESCRIPTION
572 * Read/write an 8bit value from/to the specified register address in
573 * function 0.
574 *
575 * PARAMETERS
576 * function - Pointer to struct representing the function.
577 * address - Register address within the function.
578 * data - The data to read/write.
579 * callback - The function to call on operation completion.
580 *
581 * RETURNS
582 * CSR_RESULT_SUCCESS - The data was successfully read/written.
583 * CSR_RESULT_FAILURE - Unspecified/unknown error.
584 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
585 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
586 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. No data read/written.
587 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
588 *
589 * NOTE: If the SDIO R5 response is available, and either of the
590 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
591 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
592 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
593 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
594 * COM_CRC_ERROR bits shall be ignored.
595 *
596 * If the CSPI response is available, and any of the
597 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
598 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
599 *
600 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
601 * immediately, and the supplied callback function is called when the
602 * operation is complete. The result value is given as an argument to
603 * the callback function.
604 *
605 *----------------------------------------------------------------------------*/
606CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
607CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
608void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
609void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
610
611/*----------------------------------------------------------------------------*
612 * NAME
613 * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
614 *
615 * DESCRIPTION
616 * Read/write a specified number of bytes from/to the specified register
617 * address.
618 *
619 * PARAMETERS
620 * function - Pointer to struct representing the function.
621 * address - Register address within the function.
622 * data - The data to read/write.
623 * length - Number of byte to read/write.
624 * callback - The function to call on operation completion.
625 *
626 * RETURNS
627 * CSR_RESULT_SUCCESS - The data was successfully read/written.
628 * CSR_RESULT_FAILURE - Unspecified/unknown error.
629 * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
630 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
631 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred. Data may have been
632 * partially read/written.
633 * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
634 *
635 * NOTE: If the SDIO R5 response is available, and either of the
636 * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
637 * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
638 * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
639 * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
640 * COM_CRC_ERROR bits shall be ignored.
641 *
642 * If the CSPI response is available, and any of the
643 * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
644 * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
645 *
646 * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
647 * immediately, and the supplied callback function is called when the
648 * operation is complete. The result value is given as an argument to
649 * the callback function.
650 *
651 *----------------------------------------------------------------------------*/
652CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
653CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
654void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
655void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
656
657/*----------------------------------------------------------------------------*
658 * NAME
659 * CsrSdioPowerOn, CsrSdioPowerOff
660 *
661 * DESCRIPTION
662 * Power on/off the device.
663 *
664 * PARAMETERS
665 * function - Pointer to struct representing the function that resides on
666 * the device to power on/off.
667 *
668 * RETURNS (only CsrSdioPowerOn)
669 * CSR_RESULT_SUCCESS - Power was successfully reapplied and the device
670 * has been reinitialised.
671 * CSR_RESULT_FAILURE - Unspecified/unknown error.
672 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
673 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
674 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
675 * reinitialisation.
676 * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
677 * CsrSdioPowerOff call. The state of the
678 * device is unchanged.
679 *
680 *----------------------------------------------------------------------------*/
681CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
682void CsrSdioPowerOff(CsrSdioFunction *function);
683
684/*----------------------------------------------------------------------------*
685 * NAME
686 * CsrSdioHardReset
687 *
688 * DESCRIPTION
689 * Perform a hardware reset of the device.
690 *
691 * PARAMETERS
692 * function - Pointer to struct representing the function that resides on
693 * the device to hard reset.
694 *
695 * RETURNS
696 * CSR_RESULT_SUCCESS - Reset was successfully performed and the device
697 * has been reinitialised.
698 * CSR_RESULT_FAILURE - Unspecified/unknown error.
699 * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
700 * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occurred during reinitialisation.
701 * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
702 * reinitialisation.
703 * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
704 * supported. The state of the device is
705 * unchanged.
706 *
707 *----------------------------------------------------------------------------*/
708CsrResult CsrSdioHardReset(CsrSdioFunction *function);
709
710/*----------------------------------------------------------------------------*
711 * NAME
712 * CsrSdioFunctionActive, CsrSdioFunctionIdle
713 *
714 * DESCRIPTION
715 *
716 * PARAMETERS
717 * function - Pointer to struct representing the function.
718 *
719 *----------------------------------------------------------------------------*/
720void CsrSdioFunctionActive(CsrSdioFunction *function);
721void CsrSdioFunctionIdle(CsrSdioFunction *function);
722
723#endif
drivers/staging/csr/csr_serialize_primitive_types.c+0−100
@@ -1,100 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
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#include <linux/module.h>
12#include <linux/slab.h>
13#include "csr_prim_defs.h"
14#include "csr_msgconv.h"
15#include "csr_macro.h"
16
17void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
18{
19 *value = buffer[*offset];
20 *offset += sizeof(*value);
21}
22EXPORT_SYMBOL_GPL(CsrUint8Des);
23
24void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset)
25{
26 *value = (buffer[*offset + 0] << 0) |
27 (buffer[*offset + 1] << 8);
28 *offset += sizeof(*value);
29}
30EXPORT_SYMBOL_GPL(CsrUint16Des);
31
32void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset)
33{
34 *value = (buffer[*offset + 0] << 0) |
35 (buffer[*offset + 1] << 8) |
36 (buffer[*offset + 2] << 16) |
37 (buffer[*offset + 3] << 24);
38 *offset += sizeof(*value);
39}
40EXPORT_SYMBOL_GPL(CsrUint32Des);
41
42void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length)
43{
44 memcpy(value, &buffer[*offset], length);
45 *offset += length;
46}
47EXPORT_SYMBOL_GPL(CsrMemCpyDes);
48
49void CsrCharStringDes(char **value, u8 *buffer, size_t *offset)
50{
51 *value = kstrdup((char *) &buffer[*offset], GFP_KERNEL);
52 *offset += strlen(*value) + 1;
53}
54EXPORT_SYMBOL_GPL(CsrCharStringDes);
55
56void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value)
57{
58 buffer[*offset] = value;
59 *offset += sizeof(value);
60}
61EXPORT_SYMBOL_GPL(CsrUint8Ser);
62
63void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value)
64{
65 buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
66 buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
67 *offset += sizeof(value);
68}
69EXPORT_SYMBOL_GPL(CsrUint16Ser);
70
71void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value)
72{
73 buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
74 buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
75 buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF);
76 buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF);
77 *offset += sizeof(value);
78}
79EXPORT_SYMBOL_GPL(CsrUint32Ser);
80
81void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length)
82{
83 memcpy(&buffer[*offset], value, length);
84 *offset += length;
85}
86EXPORT_SYMBOL_GPL(CsrMemCpySer);
87
88void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value)
89{
90 if (value)
91 {
92 strcpy(((char *) &buffer[*offset]), value);
93 *offset += strlen(value) + 1;
94 }
95 else
96 {
97 CsrUint8Ser(buffer, offset, 0);
98 }
99}
100EXPORT_SYMBOL_GPL(CsrCharStringSer);
drivers/staging/csr/csr_time.c+0−33
@@ -1,33 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
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#include <linux/kernel.h>
12#include <linux/time.h>
13#include <linux/module.h>
14
15#include "csr_time.h"
16
17u32 CsrTimeGet(u32 *high)
18{
19 struct timespec ts;
20 u64 time;
21 u32 low;
22
23 ts = current_kernel_time();
24 time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
25
26 if (high != NULL)
27 *high = (u32) ((time >> 32) & 0xFFFFFFFF);
28
29 low = (u32) (time & 0xFFFFFFFF);
30
31 return low;
32}
33EXPORT_SYMBOL_GPL(CsrTimeGet);
drivers/staging/csr/csr_time.h+0−76
@@ -1,76 +0,0 @@
1#ifndef CSR_TIME_H__
2#define CSR_TIME_H__
3/*****************************************************************************
4
5(c) Cambridge Silicon Radio Limited 2010
6All rights reserved and confidential information of CSR
7
8Refer to LICENSE.txt included with this source for details
9on the license terms.
10
11*****************************************************************************/
12
13#include <linux/types.h>
14
15/*******************************************************************************
16
17NAME
18 CsrTimeGet
19
20DESCRIPTION
21 Returns the current system time in a low and a high part. The low part
22 is expressed in microseconds. The high part is incremented when the low
23 part wraps to provide an extended range.
24
25 The caller may provide a NULL pointer as the high parameter.
26 In this case the function just returns the low part and ignores the
27 high parameter.
28
29 Although the time is expressed in microseconds the actual resolution is
30 platform dependent and can be less. It is recommended that the
31 resolution is at least 10 milliseconds.
32
33PARAMETERS
34 high - Pointer to variable that will receive the high part of the
35 current system time. Passing NULL is valid.
36
37RETURNS
38 Low part of current system time in microseconds.
39
40*******************************************************************************/
41u32 CsrTimeGet(u32 *high);
42
43
44/*------------------------------------------------------------------*/
45/* CsrTime Macros */
46/*------------------------------------------------------------------*/
47
48/*----------------------------------------------------------------------------*
49 * NAME
50 * CsrTimeAdd
51 *
52 * DESCRIPTION
53 * Add two time values. Adding the numbers can overflow the range of a
54 * CsrTime, so the user must be cautious.
55 *
56 * RETURNS
57 * CsrTime - the sum of "t1" and "t2".
58 *
59 *----------------------------------------------------------------------------*/
60#define CsrTimeAdd(t1, t2) ((t1) + (t2))
61
62/*----------------------------------------------------------------------------*
63 * NAME
64 * CsrTimeSub
65 *
66 * DESCRIPTION
67 * Subtract two time values. Subtracting the numbers can provoke an
68 * underflow, so the user must be cautious.
69 *
70 * RETURNS
71 * CsrTime - "t1" - "t2".
72 *
73 *----------------------------------------------------------------------------*/
74#define CsrTimeSub(t1, t2) ((s32) (t1) - (s32) (t2))
75
76#endif
drivers/staging/csr/csr_util.c+0−15
@@ -1,15 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2010
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#include <linux/module.h>
12
13MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
14MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
15MODULE_LICENSE("GPL and additional rights");
drivers/staging/csr/csr_wifi_common.h+0−101
@@ -1,101 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_COMMON_H__
12#define CSR_WIFI_COMMON_H__
13
14#include <linux/types.h>
15#include "csr_result.h"
16
17/* MAC address */
18typedef struct
19{
20 u8 a[6];
21} CsrWifiMacAddress;
22
23/* IPv4 address */
24typedef struct
25{
26 u8 a[4];
27} CsrWifiIp4Address;
28
29/* IPv6 address */
30typedef struct
31{
32 u8 a[16];
33} CsrWifiIp6Address;
34
35typedef struct
36{
37 u8 ssid[32];
38 u8 length;
39} CsrWifiSsid;
40
41/*******************************************************************************
42
43 DESCRIPTION
44 Result values used on the Wifi Interfaces
45
46 VALUES
47 CSR_RESULT_SUCCESS
48 - The request/procedure succeeded
49 CSR_RESULT_FAILURE
50 - The request/procedure did not succeed because of an error
51 CSR_WIFI_RESULT_NOT_FOUND
52 - The request did not succeed because some resource was not
53 found.
54 CSR_WIFI_RESULT_TIMED_OUT
55 - The request/procedure did not succeed because of a time out
56 CSR_WIFI_RESULT_CANCELLED
57 - The request was canceled due to another conflicting
58 request that was issued before this one was completed
59 CSR_WIFI_RESULT_INVALID_PARAMETER
60 - The request/procedure did not succeed because it had an
61 invalid parameter
62 CSR_WIFI_RESULT_NO_ROOM
63 - The request did not succeed due to a lack of resources,
64 e.g. out of memory problem.
65 CSR_WIFI_RESULT_UNSUPPORTED
66 - The request/procedure did not succeed because the feature
67 is not supported yet
68 CSR_WIFI_RESULT_UNAVAILABLE
69 - The request cannot be processed at this time
70 CSR_WIFI_RESULT_WIFI_OFF
71 - The requested action is not available because Wi-Fi is
72 currently off
73 CSR_WIFI_RESULT_SECURITY_ERROR
74 - The request/procedure did not succeed because of a security
75 error
76 CSR_WIFI_RESULT_MIB_SET_FAILURE
77 - MIB Set Failure: either the MIB OID to be written to does
78 not exist or the MIB Value is invalid.
79 CSR_WIFI_RESULT_INVALID_INTERFACE_TAG
80 - The supplied Interface Tag is not valid.
81 CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT
82 - The new NOA configuration conflicts with the existing NOA configuration
83 hence not accepted"
84*******************************************************************************/
85#define CSR_WIFI_RESULT_NOT_FOUND ((CsrResult) 0x0001)
86#define CSR_WIFI_RESULT_TIMED_OUT ((CsrResult) 0x0002)
87#define CSR_WIFI_RESULT_CANCELLED ((CsrResult) 0x0003)
88#define CSR_WIFI_RESULT_INVALID_PARAMETER ((CsrResult) 0x0004)
89#define CSR_WIFI_RESULT_NO_ROOM ((CsrResult) 0x0005)
90#define CSR_WIFI_RESULT_UNSUPPORTED ((CsrResult) 0x0006)
91#define CSR_WIFI_RESULT_UNAVAILABLE ((CsrResult) 0x0007)
92#define CSR_WIFI_RESULT_WIFI_OFF ((CsrResult) 0x0008)
93#define CSR_WIFI_RESULT_SECURITY_ERROR ((CsrResult) 0x0009)
94#define CSR_WIFI_RESULT_MIB_SET_FAILURE ((CsrResult) 0x000A)
95#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG ((CsrResult) 0x000B)
96#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT ((CsrResult) 0x000C)
97
98#define CSR_WIFI_VERSION "5.1.0.0"
99
100#endif
101
drivers/staging/csr/csr_wifi_fsm.h+0−240
@@ -1,240 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_FSM_H
12#define CSR_WIFI_FSM_H
13
14#include "csr_prim_defs.h"
15#include "csr_log_text.h"
16#include "csr_wifi_fsm_event.h"
17
18/* including this file for CsrWifiInterfaceMode*/
19#include "csr_wifi_common.h"
20
21#define CSR_WIFI_FSM_ENV (0xFFFF)
22
23/**
24 * @brief
25 * Toplevel FSM context data
26 *
27 * @par Description
28 * Holds ALL FSM static and dynamic data for a FSM
29 */
30typedef struct CsrWifiFsmContext CsrWifiFsmContext;
31
32/**
33 * @brief
34 * FSM External Wakeup CallbackFunction Pointer
35 *
36 * @par Description
37 * Defines the external wakeup function for the FSM
38 * to call when an external event is injected into the systen
39 *
40 * @param[in] context : External context
41 *
42 * @return
43 * void
44 */
45typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context);
46
47/**
48 * @brief
49 * Initialises a top level FSM context
50 *
51 * @par Description
52 * Initialises the FSM Context to an initial state and allocates
53 * space for "maxProcesses" number of instances
54 *
55 * @param[in] osaContext : OSA context
56 * @param[in] applicationContext : Internal fsm application context
57 * @param[in] externalContext : External context
58 * @param[in] maxProcesses : Max processes to allocate room for
59 *
60 * @return
61 * CsrWifiFsmContext* fsm context
62 */
63extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId);
64
65/**
66 * @brief
67 * Resets the FSM's back to first conditions
68 *
69 * @par Description
70 * This function is used to free any dynamic resources allocated for the
71 * given context by CsrWifiFsmInit().
72 * The FSM's reset function is called to cleanup any fsm specific memory
73 * The reset function does NOT need to free the fsm data pointer as
74 * CsrWifiFsmShutdown() will do it.
75 * the FSM's init function is call again to reinitialise the FSM context.
76 * CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
77 *
78 * @param[in] context : FSM context
79 *
80 * @return
81 * void
82 */
83extern void CsrWifiFsmReset(CsrWifiFsmContext *context);
84
85/**
86 * @brief
87 * Frees resources allocated by CsrWifiFsmInit
88 *
89 * @par Description
90 * This function is used to free any dynamic resources allocated for the
91 * given context by CsrWifiFsmInit(), prior to complete termination of
92 * the program.
93 * The FSM's reset function is called to cleanup any fsm specific memory.
94 * The reset function does NOT need to free the fsm data pointer as
95 * CsrWifiFsmShutdown() will do it.
96 * CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
97 *
98 * @param[in] context : FSM context
99 *
100 * @return
101 * void
102 */
103extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context);
104
105/**
106 * @brief
107 * Executes the fsm context
108 *
109 * @par Description
110 * Executes the FSM context and runs until ALL events in the context are processed.
111 * When no more events are left to process then CsrWifiFsmExecute() returns to a time
112 * specifying when to next call the CsrWifiFsmExecute()
113 * Scheduling, threading, blocking and external event notification are outside
114 * the scope of the FSM and CsrWifiFsmExecute().
115 *
116 * @param[in] context : FSM context
117 *
118 * @return
119 * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
120 */
121extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context);
122
123/**
124 * @brief
125 * Adds an event to the FSM context's external event queue for processing
126 *
127 * @par Description
128 * Adds an event to the contexts external queue
129 * This is thread safe and adds an event to the fsm's external event queue.
130 *
131 * @param[in] context : FSM context
132 * @param[in] event : event to add to the event queue
133 * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
134 * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
135 * @param[in] id : event id
136 *
137 * @return
138 * void
139 */
140extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id);
141
142/**
143 * @brief
144 * Adds an Alien event to the FSM context's external event queue for processing
145 *
146 * @par Description
147 * Adds an event to the contexts external queue
148 * This is thread safe and adds an event to the fsm's external event queue.
149 *
150 * @param[in] context : FSM context
151 * @param[in] event : event to add to the event queue
152 * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
153 * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
154 * @param[in] id : event id
155 */
156#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \
157 { \
158 CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \
159 _evt->alienEvent = _alienEvent; \
160 CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
161 }
162
163
164/**
165 * @brief
166 * Current time of day in ms
167 *
168 * @param[in] context : FSM context
169 *
170 * @return
171 * u32 32 bit ms tick
172 */
173extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context);
174
175/**
176 * @brief
177 * Gets the time until the next FSM timer expiry
178 *
179 * @par Description
180 * Returns the next timeout time or 0 if no timers are set.
181 *
182 * @param[in] context : FSM context
183 *
184 * @return
185 * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
186 */
187extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context);
188
189/**
190 * @brief
191 * Fast forwards the fsm timers by ms Milliseconds
192 *
193 * @param[in] context : FSM context
194 * @param[in] ms : Milliseconds to fast forward by
195 *
196 * @return
197 * void
198 */
199extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms);
200
201/**
202 * @brief
203 * shift the current time of day by ms amount
204 *
205 * @par Description
206 * useful to speed up tests where time needs to pass
207 *
208 * @param[in] context : FSM context
209 * @param[in] ms : ms to adjust time by
210 *
211 * @return
212 * void
213 */
214extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms);
215
216/**
217 * @brief
218 * Check if the fsm has events to process
219 *
220 * @param[in] context : FSM context
221 *
222 * @return
223 * u8 returns TRUE if there are events for the FSM to process
224 */
225extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context);
226
227/**
228 * @brief
229 * function that installs the contexts wakeup function
230 *
231 * @param[in] context : FSM context
232 * @param[in] callback : Callback function pointer
233 *
234 * @return
235 * void
236 */
237extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback);
238
239#endif /* CSR_WIFI_FSM_H */
240
drivers/staging/csr/csr_wifi_fsm_event.h+0−42
@@ -1,42 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_FSM_EVENT_H
12#define CSR_WIFI_FSM_EVENT_H
13
14#include "csr_prim_defs.h"
15#include "csr_sched.h"
16
17/**
18 * @brief
19 * FSM event header.
20 *
21 * @par Description
22 * All events MUST have this struct as the FIRST member.
23 * The next member is used internally for linked lists
24 */
25typedef struct CsrWifiFsmEvent
26{
27 CsrPrim type;
28 u16 primtype;
29 CsrSchedQid destination;
30 CsrSchedQid source;
31
32 /* Private pointer to allow an optimal Event list */
33 /* NOTE: Ignore this pointer.
34 * Do not waste code initializing OR freeing it.
35 * The pointer is used internally in the CsrWifiFsm code
36 * to avoid a second malloc when queuing events.
37 */
38 struct CsrWifiFsmEvent *next;
39} CsrWifiFsmEvent;
40
41#endif /* CSR_WIFI_FSM_EVENT_H */
42
drivers/staging/csr/csr_wifi_fsm_types.h+0−430
@@ -1,430 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_FSM_TYPES_H
12#define CSR_WIFI_FSM_TYPES_H
13
14#include <linux/types.h>
15#include "csr_macro.h"
16#include "csr_sched.h"
17
18#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
19#include "csr_framework_ext.h"
20#endif
21
22#include "csr_wifi_fsm.h"
23
24#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
25
26/**
27 * @brief
28 * FSM event list header.
29 *
30 * @par Description
31 * Singly linked list of events.
32 */
33typedef struct CsrWifiFsmEventList
34{
35 CsrWifiFsmEvent *first;
36 CsrWifiFsmEvent *last;
37} CsrWifiFsmEventList;
38
39
40/**
41 * @brief
42 * FSM timer id.
43 *
44 * @par Description
45 * Composite Id made up of the type, dest and a unique id so
46 * CsrWifiFsmRemoveTimer knows where to look when removing the timer
47 */
48typedef struct CsrWifiFsmTimerId
49{
50 CsrPrim type;
51 u16 primtype;
52 CsrSchedQid destination;
53 u16 uniqueid;
54} CsrWifiFsmTimerId;
55
56/**
57 * @brief
58 * FSM timer header.
59 *
60 * @par Description
61 * All timer MUST have this struct as the FIRST member.
62 * The first members of the structure MUST remain compatable
63 * with the CsrWifiFsmEvent so that timers are just specialised events
64 */
65typedef struct CsrWifiFsmTimer
66{
67 CsrPrim type;
68 u16 primtype;
69 CsrSchedQid destination;
70 CsrSchedQid source;
71
72 /* Private pointer to allow an optimal Event list */
73 struct CsrWifiFsmTimer *next;
74
75 CsrWifiFsmTimerId timerid;
76 u32 timeoutTimeMs;
77} CsrWifiFsmTimer;
78
79
80/**
81 * @brief
82 * Fsm Alien Event
83 *
84 * @par Description
85 * Allows the wrapping of alien events that do not use CsrWifiFsmEvent
86 * as the first member of the Event struct
87 */
88typedef struct
89{
90 CsrWifiFsmEvent event;
91 void *alienEvent;
92} CsrWifiFsmAlienEvent;
93
94
95/**
96 * @brief
97 * FSM timer list header.
98 *
99 * @par Description
100 * Singly linked list of timers.
101 */
102typedef struct CsrWifiFsmTimerList
103{
104 CsrWifiFsmTimer *first;
105 CsrWifiFsmTimer *last;
106 u16 nexttimerid;
107} CsrWifiFsmTimerList;
108
109/**
110 * @brief
111 * Process Entry Function Pointer
112 *
113 * @par Description
114 * Defines the entry function for a processes.
115 * Called at process initialisation.
116 *
117 * @param[in] context : FSM context
118 *
119 * @return
120 * void
121 */
122typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context);
123
124/**
125 * @brief
126 * Process Transition Function Pointer
127 *
128 * @par Description
129 * Defines a transition function for a processes.
130 * Called when an event causes a transition on a process
131 *
132 * @param[in] CsrWifiFsmContext* : FSM context
133 * @param[in] void* : FSM data (can be NULL)
134 * @param[in] const CsrWifiFsmEvent* : event to process
135 *
136 * @return
137 * void
138 */
139typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event);
140
141/**
142 * @brief
143 * Process reset/shutdown Function Pointer
144 *
145 * @par Description
146 * Defines the reset/shutdown function for a processes.
147 * Called to reset or shutdown an fsm.
148 *
149 * @param[in] context : FSM context
150 *
151 * @return
152 * void
153 */
154typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context);
155
156/**
157 * @brief
158 * FSM Default Destination CallbackFunction Pointer
159 *
160 * @par Description
161 * Defines the default destination function for the FSM
162 * to call when an event does not have a valid destination.
163 * This
164 *
165 * @param[in] context : External context
166 *
167 * @return
168 * u16 a valid destination OR CSR_WIFI_FSM_ENV
169 */
170typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event);
171
172
173#ifdef CSR_WIFI_FSM_DUMP_ENABLE
174/**
175 * @brief
176 * Trace Dump Function Pointer
177 *
178 * @par Description
179 * Called when we want to trace the FSM
180 *
181 * @param[in] context : FSM context
182 * @param[in] id : fsm id
183 *
184 * @return
185 * void
186 */
187typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
188#endif
189
190/**
191 * @brief
192 * Event ID to transition function entry
193 *
194 * @par Description
195 * Event ID to Transition Entry in a state table.
196 */
197typedef struct
198{
199 u32 eventid;
200 CsrWifiFsmTransitionFnPtr transition;
201#ifdef CSR_LOG_ENABLE
202 const char *transitionName;
203#endif
204} CsrWifiFsmEventEntry;
205
206/**
207 * @brief
208 * Single State's Transition Table
209 *
210 * @par Description
211 * Stores Data for a single State's event to
212 * transition functions mapping
213 */
214typedef struct
215{
216 const u8 numEntries;
217 const u8 saveAll;
218 const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
219#ifdef CSR_LOG_ENABLE
220 u16 stateNumber;
221 const char *stateName;
222#endif
223} CsrWifiFsmTableEntry;
224
225/**
226 * @brief
227 * Process State Transtion table
228 *
229 * @par Description
230 * Stores Data for a processes State to transition table
231 */
232typedef struct
233{
234 u16 numStates; /* number of states */
235 const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */
236} CsrWifiFsmTransitionFunctionTable;
237
238/**
239 * @brief
240 * Const Process definition
241 *
242 * @par Description
243 * Constant process specification.
244 * This is ALL the non dynamic data that defines
245 * a process.
246 */
247typedef struct
248{
249 const char *processName;
250 const u32 processId;
251 const CsrWifiFsmTransitionFunctionTable transitionTable;
252 const CsrWifiFsmTableEntry unhandledTransitions;
253 const CsrWifiFsmTableEntry ignoreFunctions;
254 const CsrWifiFsmProcEntryFnPtr entryFn;
255 const CsrWifiFsmProcResetFnPtr resetFn;
256#ifdef CSR_WIFI_FSM_DUMP_ENABLE
257 const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */
258#endif
259} CsrWifiFsmProcessStateMachine;
260
261#ifdef CSR_WIFI_FSM_DUMP_ENABLE
262/**
263 * @brief
264 * Storage for state transition info
265 */
266typedef struct
267{
268 u16 transitionNumber;
269 CsrWifiFsmEvent event;
270 u16 fromState;
271 u16 toState;
272 CsrWifiFsmTransitionFnPtr transitionFn;
273 u16 transitionCount; /* number consecutive of times this transition was seen */
274#ifdef CSR_LOG_ENABLE
275 const char *transitionName;
276#endif
277} CsrWifiFsmTransitionRecord;
278
279/**
280 * @brief
281 * Storage for the last state X transitions
282 */
283typedef struct
284{
285 u16 numTransitions;
286 CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
287} CsrWifiFsmTransitionRecords;
288#endif
289
290/**
291 * @brief
292 * Dynamic Process data
293 *
294 * @par Description
295 * Dynamic process data that is used to keep track of the
296 * state and data for a process instance
297 */
298typedef struct
299{
300 const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */
301 u16 instanceId; /* Runtime process id */
302 u16 state; /* Current state */
303 void *params; /* Instance user data */
304 CsrWifiFsmEventList savedEventQueue; /* The saved event queue */
305 struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */
306 struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/
307#ifdef CSR_WIFI_FSM_DUMP_ENABLE
308 CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */
309#endif
310} CsrWifiFsmInstanceEntry;
311
312/**
313 * @brief
314 * OnCreate Callback Function Pointer
315 *
316 * @par Description
317 * Called when an fsm is created.
318 *
319 * @param[in] extContext : External context
320 * @param[in] instance : FSM instance
321 *
322 * @return
323 * void
324 */
325typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
326
327/**
328 * @brief
329 * OnTransition Callback Function Pointer
330 *
331 * @par Description
332 * Called when an event is processed by a fsm
333 *
334 * @param[in] extContext : External context
335 * @param[in] eventEntryArray : Entry data
336 * @param[in] event : Event
337 *
338 * @return
339 * void
340 */
341typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
342
343/**
344 * @brief
345 * OnStateChange Callback Function Pointer
346 *
347 * @par Description
348 * Called when CsrWifiFsmNextState is called
349 *
350 * @param[in] extContext : External context
351 *
352 * @return
353 * void
354 */
355typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
356
357/**
358 * @brief
359 * OnIgnore,OnError or OnInvalid Callback Function Pointer
360 *
361 * @par Description
362 * Called when an event is processed by a fsm
363 *
364 * @param[in] extContext : External context
365 * @param[in] event : Event
366 *
367 * @return
368 * void
369 */
370typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
371
372/**
373 * @brief
374 * Toplevel FSM context data
375 *
376 * @par Description
377 * Holds ALL FSM static and dynamic data for a FSM
378 */
379struct CsrWifiFsmContext
380{
381 CsrWifiFsmEventList eventQueue; /* The internal event queue */
382 CsrWifiFsmEventList externalEventQueue; /* The external event queue */
383#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
384 CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */
385#endif
386 u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */
387 CsrWifiFsmTimerList timerQueue; /* The internal timer queue */
388 u8 useTempSaveList; /* Should the temp save list be used */
389 CsrWifiFsmEventList tempSaveList; /* The temp save event queue */
390 CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */
391 u16 maxProcesses; /* Size of instanceArray */
392 u16 numProcesses; /* Current number allocated in instanceArray */
393 CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */
394 CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */
395 CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */
396 CsrWifiFsmExternalWakupCallbackPtr externalEventFn; /* External event Callback */
397 CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */
398 CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/
399
400 void *applicationContext; /* Internal fsm application context */
401 void *externalContext; /* External context (set by the user of the fsm)*/
402 CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */
403
404#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
405 CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */
406 u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */
407#endif
408
409#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
410#ifdef CSR_WIFI_FSM_TRANSITION_LOCK
411 CsrMutexHandle transitionLock; /* Lock when calling transition functions */
412#endif
413#endif
414
415#ifdef CSR_LOG_ENABLE
416 CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */
417 CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */
418 CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */
419 CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */
420 CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */
421 CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */
422 CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */
423 CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */
424#endif
425#ifdef CSR_WIFI_FSM_DUMP_ENABLE
426 u16 masterTransitionNumber; /* Increments on every transition */
427#endif
428};
429
430#endif /* CSR_WIFI_FSM_TYPES_H */
drivers/staging/csr/csr_wifi_hip_card.h+0−114
@@ -1,114 +0,0 @@
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 * FILE : csr_wifi_hip_card.h
14 *
15 * PURPOSE : Defines abstract interface for hardware specific functions.
16 * Note, this is a different file from one of the same name in the
17 * Windows driver.
18 *
19 *****************************************************************************
20 */
21#ifndef __CARD_H__
22#define __CARD_H__
23
24#include "csr_wifi_hip_card_sdio.h"
25#include "csr_wifi_hip_signals.h"
26#include "csr_wifi_hip_unifi_udi.h"
27
28
29/*****************************************************************************
30 * CardEnableInt -
31 */
32CsrResult CardEnableInt(card_t *card);
33
34/*****************************************************************************
35 * CardGenInt -
36 */
37CsrResult CardGenInt(card_t *card);
38
39/*****************************************************************************
40 * CardPendingInt -
41 */
42CsrResult CardPendingInt(card_t *card, u8 *pintr);
43
44/*****************************************************************************
45 * CardDisableInt -
46 */
47CsrResult CardDisableInt(card_t *card);
48
49/*****************************************************************************
50 * CardClearInt -
51 */
52CsrResult CardClearInt(card_t *card);
53
54/*****************************************************************************
55 * CardDisable -
56 */
57void CardDisable(card_t *card);
58
59/*****************************************************************************
60 * CardIntEnabled -
61 */
62CsrResult CardIntEnabled(card_t *card, u8 *enabled);
63
64/*****************************************************************************
65 * CardGetDataSlotSize
66 */
67u16 CardGetDataSlotSize(card_t *card);
68
69/*****************************************************************************
70 * CardWriteBulkData -
71 */
72CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue);
73
74
75/*****************************************************************************
76 * CardClearFromHostDataSlot -
77 */
78void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum);
79
80#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
81/*****************************************************************************
82 * CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot
83 * without freeing the bulk data
84 */
85
86void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum);
87#endif
88
89/*****************************************************************************
90 * CardGetFreeFromHostDataSlots -
91 */
92u16 CardGetFreeFromHostDataSlots(card_t *card);
93
94u16 CardAreAllFromHostDataSlotsEmpty(card_t *card);
95
96CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which);
97
98CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr);
99
100CsrResult unifi_dl_firmware(card_t *card, void *arg);
101CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl);
102CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode);
103void* unifi_dl_fw_read_start(card_t *card, s8 is_fw);
104
105CsrResult unifi_coredump_handle_request(card_t *card);
106
107CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult);
108#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
109void unifi_debug_log_to_buf(const char *fmt, ...);
110void unifi_debug_string_to_buf(const char *str);
111void unifi_debug_hex_to_buf(const char *buff, u16 length);
112#endif
113
114#endif /* __CARD_H__ */
drivers/staging/csr/csr_wifi_hip_card_sdio.c+0−4001
@@ -1,4001 +0,0 @@
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 * FILE: csr_wifi_hip_card_sdio.c
14 *
15 * PURPOSE: Implementation of the Card API for SDIO.
16 *
17 * NOTES:
18 * CardInit() is called from the SDIO probe callback when a card is
19 * inserted. This performs the basic SDIO initialisation, enabling i/o
20 * etc.
21 *
22 * ---------------------------------------------------------------------------
23 */
24#include <linux/slab.h>
25#include "csr_wifi_hip_unifi.h"
26#include "csr_wifi_hip_conversions.h"
27#include "csr_wifi_hip_unifiversion.h"
28#include "csr_wifi_hip_card.h"
29#include "csr_wifi_hip_card_sdio.h"
30#include "csr_wifi_hip_chiphelper.h"
31
32
33/* Time to wait between attempts to read MAILBOX0 */
34#define MAILBOX1_TIMEOUT 10 /* in millisecs */
35#define MAILBOX1_ATTEMPTS 200 /* 2 seconds */
36
37#define MAILBOX2_TIMEOUT 5 /* in millisecs */
38#define MAILBOX2_ATTEMPTS 10 /* 50ms */
39
40#define RESET_SETTLE_DELAY 25 /* in millisecs */
41
42static CsrResult card_init_slots(card_t *card);
43static CsrResult card_hw_init(card_t *card);
44static CsrResult firmware_present_in_flash(card_t *card);
45static void bootstrap_chip_hw(card_t *card);
46static CsrResult unifi_reset_hardware(card_t *card);
47static CsrResult unifi_hip_init(card_t *card);
48static CsrResult card_access_panic(card_t *card);
49static CsrResult unifi_read_chip_version(card_t *card);
50
51/*
52 * ---------------------------------------------------------------------------
53 * unifi_alloc_card
54 *
55 * Allocate and initialise the card context structure.
56 *
57 * Arguments:
58 * sdio Pointer to SDIO context pointer to pass to low
59 * level i/o functions.
60 * ospriv Pointer to O/S private struct to pass when calling
61 * callbacks to the higher level system.
62 *
63 * Returns:
64 * Pointer to card struct, which represents the driver context or
65 * NULL if the allocation failed.
66 * ---------------------------------------------------------------------------
67 */
68card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv)
69{
70 card_t *card;
71 u32 i;
72
73
74 card = kzalloc(sizeof(card_t), GFP_KERNEL);
75 if (card == NULL)
76 {
77 return NULL;
78 }
79
80 card->sdio_if = sdio;
81 card->ospriv = ospriv;
82
83 card->unifi_interrupt_seq = 1;
84
85 /* Make these invalid. */
86 card->proc_select = (u32)(-1);
87 card->dmem_page = (u32)(-1);
88 card->pmem_page = (u32)(-1);
89
90 card->bh_reason_host = 0;
91 card->bh_reason_unifi = 0;
92
93 for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
94 {
95 card->tx_q_paused_flag[i] = 0;
96 }
97 card->memory_resources_allocated = 0;
98
99 card->low_power_mode = UNIFI_LOW_POWER_DISABLED;
100 card->periodic_wake_mode = UNIFI_PERIODIC_WAKE_HOST_DISABLED;
101
102 card->host_state = UNIFI_HOST_STATE_AWAKE;
103 card->intmode = CSR_WIFI_INTMODE_DEFAULT;
104
105 /*
106 * Memory resources for buffers are allocated when the chip is initialised
107 * because we need configuration information from the firmware.
108 */
109
110 /*
111 * Initialise wait queues and lists
112 */
113 card->fh_command_queue.q_body = card->fh_command_q_body;
114 card->fh_command_queue.q_length = UNIFI_SOFT_COMMAND_Q_LENGTH;
115
116 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
117 {
118 card->fh_traffic_queue[i].q_body = card->fh_traffic_q_body[i];
119 card->fh_traffic_queue[i].q_length = UNIFI_SOFT_TRAFFIC_Q_LENGTH;
120 }
121
122
123 /* Initialise mini-coredump pointers in case no coredump buffers
124 * are requested by the OS layer.
125 */
126 card->request_coredump_on_reset = 0;
127 card->dump_next_write = NULL;
128 card->dump_cur_read = NULL;
129 card->dump_buf = NULL;
130
131#ifdef UNIFI_DEBUG
132 /* Determine offset of LSB in pointer for later alignment sanity check.
133 * Synergy integer types have specific widths, which cause compiler
134 * warnings when casting pointer types, e.g. on 64-bit systems.
135 */
136 {
137 u32 val = 0x01234567;
138
139 if (*((u8 *)&val) == 0x01)
140 {
141 card->lsb = sizeof(void *) - 1; /* BE */
142 }
143 else
144 {
145 card->lsb = 0; /* LE */
146 }
147 }
148#endif
149 return card;
150} /* unifi_alloc_card() */
151
152
153/*
154 * ---------------------------------------------------------------------------
155 * unifi_init_card
156 *
157 * Reset the hardware and perform HIP initialization
158 *
159 * Arguments:
160 * card Pointer to card struct
161 *
162 * Returns:
163 * CsrResult code
164 * CSR_RESULT_SUCCESS if successful
165 * ---------------------------------------------------------------------------
166 */
167CsrResult unifi_init_card(card_t *card, s32 led_mask)
168{
169 CsrResult r;
170
171
172 if (card == NULL)
173 {
174 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
175 }
176
177 r = unifi_init(card);
178 if (r != CSR_RESULT_SUCCESS)
179 {
180 return r;
181 }
182
183 r = unifi_hip_init(card);
184 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
185 {
186 return r;
187 }
188 if (r != CSR_RESULT_SUCCESS)
189 {
190 unifi_error(card->ospriv, "Failed to start host protocol.\n");
191 return r;
192 }
193
194 return CSR_RESULT_SUCCESS;
195}
196
197
198/*
199 * ---------------------------------------------------------------------------
200 * unifi_init
201 *
202 * Init the hardware.
203 *
204 * Arguments:
205 * card Pointer to card struct
206 *
207 * Returns:
208 * CsrResult code
209 * CSR_RESULT_SUCCESS if successful
210 * ---------------------------------------------------------------------------
211 */
212CsrResult unifi_init(card_t *card)
213{
214 CsrResult r;
215 CsrResult csrResult;
216
217 if (card == NULL)
218 {
219 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
220 }
221
222 /*
223 * Disable the SDIO interrupts while initialising UniFi.
224 * Re-enable them when f/w is running.
225 */
226 csrResult = CsrSdioInterruptDisable(card->sdio_if);
227 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
228 {
229 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
230 }
231
232 /*
233 * UniFi's PLL may start with a slow clock (~ 1 MHz) so initially
234 * set the SDIO bus clock to a similar value or SDIO accesses may
235 * fail.
236 */
237 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
238 if (csrResult != CSR_RESULT_SUCCESS)
239 {
240 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
241 return r;
242 }
243 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
244
245 /*
246 * Reset UniFi. Note, this only resets the WLAN function part of the chip,
247 * the SDIO interface is not reset.
248 */
249 unifi_trace(card->ospriv, UDBG1, "Resetting UniFi\n");
250 r = unifi_reset_hardware(card);
251 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
252 {
253 return r;
254 }
255 if (r != CSR_RESULT_SUCCESS)
256 {
257 unifi_error(card->ospriv, "Failed to reset UniFi\n");
258 return r;
259 }
260
261 /* Reset the power save mode, to be active until the MLME-reset is complete */
262 r = unifi_configure_low_power_mode(card,
263 UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED);
264 if (r != CSR_RESULT_SUCCESS)
265 {
266 unifi_error(card->ospriv, "Failed to set power save mode\n");
267 return r;
268 }
269
270 /*
271 * Set initial value of page registers.
272 * The page registers will be maintained by unifi_read...() and
273 * unifi_write...().
274 */
275 card->proc_select = (u32)(-1);
276 card->dmem_page = (u32)(-1);
277 card->pmem_page = (u32)(-1);
278 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, 0);
279 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
280 {
281 return r;
282 }
283 if (r != CSR_RESULT_SUCCESS)
284 {
285 unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
286 return r;
287 }
288 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, 0);
289 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
290 {
291 return r;
292 }
293 if (r != CSR_RESULT_SUCCESS)
294 {
295 unifi_error(card->ospriv, "Failed to write PROG_MEM2_PAGE\n");
296 return r;
297 }
298
299 /*
300 * If the driver has reset UniFi due to previous SDIO failure, this may
301 * have been due to a chip watchdog reset. In this case, the driver may
302 * have requested a mini-coredump which needs to be captured now the
303 * SDIO interface is alive.
304 */
305 (void)unifi_coredump_handle_request(card);
306
307 /*
308 * Probe to see if the UniFi has ROM/flash to boot from. CSR6xxx should do.
309 */
310 r = firmware_present_in_flash(card);
311 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
312 {
313 return r;
314 }
315 if (r == CSR_WIFI_HIP_RESULT_NOT_FOUND)
316 {
317 unifi_error(card->ospriv, "No firmware found\n");
318 }
319 else if (r != CSR_RESULT_SUCCESS)
320 {
321 unifi_error(card->ospriv, "Probe for Flash failed\n");
322 }
323
324 return r;
325} /* unifi_init() */
326
327
328/*
329 * ---------------------------------------------------------------------------
330 * unifi_download
331 *
332 * Load the firmware.
333 *
334 * Arguments:
335 * card Pointer to card struct
336 * led_mask Loader LED mask
337 *
338 * Returns:
339 * CSR_RESULT_SUCCESS on success
340 * CsrResult error code on failure.
341 * ---------------------------------------------------------------------------
342 */
343CsrResult unifi_download(card_t *card, s32 led_mask)
344{
345 CsrResult r;
346 void *dlpriv;
347
348 if (card == NULL)
349 {
350 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
351 }
352
353 /* Set the loader led mask */
354 card->loader_led_mask = led_mask;
355
356 /* Get the firmware file information */
357 unifi_trace(card->ospriv, UDBG1, "downloading firmware...\n");
358
359 dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
360 if (dlpriv == NULL)
361 {
362 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
363 }
364
365 /* Download the firmware. */
366 r = unifi_dl_firmware(card, dlpriv);
367 if (r != CSR_RESULT_SUCCESS)
368 {
369 unifi_error(card->ospriv, "Failed to download firmware\n");
370 return r;
371 }
372
373 /* Free the firmware file information. */
374 unifi_fw_read_stop(card->ospriv, dlpriv);
375
376 return CSR_RESULT_SUCCESS;
377} /* unifi_download() */
378
379
380/*
381 * ---------------------------------------------------------------------------
382 * unifi_hip_init
383 *
384 * This function performs the f/w initialisation sequence as described
385 * in the Unifi Host Interface Protocol Specification.
386 * It allocates memory for host-side slot data and signal queues.
387 *
388 * Arguments:
389 * card Pointer to card struct
390 *
391 * Returns:
392 * CSR_RESULT_SUCCESS on success or else a CSR error code
393 *
394 * Notes:
395 * The firmware must have been downloaded.
396 * ---------------------------------------------------------------------------
397 */
398static CsrResult unifi_hip_init(card_t *card)
399{
400 CsrResult r;
401 CsrResult csrResult;
402
403 r = card_hw_init(card);
404 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
405 {
406 return r;
407 }
408 if (r != CSR_RESULT_SUCCESS)
409 {
410 unifi_error(card->ospriv, "Failed to establish communication with UniFi\n");
411 return r;
412 }
413#ifdef CSR_PRE_ALLOC_NET_DATA
414 /* if there is any preallocated netdata left from the prev session free it now */
415 prealloc_netdata_free(card);
416#endif
417 /*
418 * Allocate memory for host-side slot data and signal queues.
419 * We need the config info read from the firmware to know how much
420 * memory to allocate.
421 */
422 r = card_init_slots(card);
423 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
424 {
425 return r;
426 }
427 if (r != CSR_RESULT_SUCCESS)
428 {
429 unifi_error(card->ospriv, "Init slots failed: %d\n", r);
430 return r;
431 }
432
433 unifi_trace(card->ospriv, UDBG2, "Sending first UniFi interrupt\n");
434
435 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
436 if (r != CSR_RESULT_SUCCESS)
437 {
438 return r;
439 }
440
441 /* Enable the SDIO interrupts now that the f/w is running. */
442 csrResult = CsrSdioInterruptEnable(card->sdio_if);
443 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
444 {
445 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
446 }
447
448 /* Signal the UniFi to start handling messages */
449 r = CardGenInt(card);
450 if (r != CSR_RESULT_SUCCESS)
451 {
452 return r;
453 }
454
455 return CSR_RESULT_SUCCESS;
456} /* unifi_hip_init() */
457
458
459/*
460 * ---------------------------------------------------------------------------
461 * _build_sdio_config_data
462 *
463 * Unpack the SDIO configuration information from a buffer read from
464 * UniFi into a host structure.
465 * The data is byte-swapped for a big-endian host if necessary by the
466 * UNPACK... macros.
467 *
468 * Arguments:
469 * card Pointer to card struct
470 * cfg_data Destination structure to unpack into.
471 * cfg_data_buf Source buffer to read from. This should be the raw
472 * data read from UniFi.
473 *
474 * Returns:
475 * None.
476 * ---------------------------------------------------------------------------
477 */
478static void _build_sdio_config_data(sdio_config_data_t *cfg_data,
479 const u8 *cfg_data_buf)
480{
481 s16 offset = 0;
482
483 cfg_data->version = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
484 offset += SIZEOF_UINT16;
485
486 cfg_data->sdio_ctrl_offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
487 offset += SIZEOF_UINT16;
488
489 cfg_data->fromhost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
490 offset += SIZEOF_UINT16;
491
492 cfg_data->tohost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
493 offset += SIZEOF_UINT16;
494
495 cfg_data->num_fromhost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
496 offset += SIZEOF_UINT16;
497
498 cfg_data->num_tohost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
499 offset += SIZEOF_UINT16;
500
501 cfg_data->num_fromhost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
502 offset += SIZEOF_UINT16;
503
504 cfg_data->num_tohost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
505 offset += SIZEOF_UINT16;
506
507 cfg_data->data_slot_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
508 offset += SIZEOF_UINT16;
509
510 cfg_data->initialised = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
511 offset += SIZEOF_UINT16;
512
513 cfg_data->overlay_size = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
514 offset += SIZEOF_UINT32;
515
516 cfg_data->data_slot_round = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
517 offset += SIZEOF_UINT16;
518
519 cfg_data->sig_frag_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
520 offset += SIZEOF_UINT16;
521
522 cfg_data->tohost_signal_padding = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
523} /* _build_sdio_config_data() */
524
525
526/*
527 * - Function ----------------------------------------------------------------
528 * card_hw_init()
529 *
530 * Perform the initialisation procedure described in the UniFi Host
531 * Interface Protocol document (section 3.3.8) and read the run-time
532 * configuration information from the UniFi. This is stuff like number
533 * of bulk data slots etc.
534 *
535 * The card enumeration and SD initialisation has already been done by
536 * the SDIO library, see card_sdio_init().
537 *
538 * The initialisation is done when firmware is ready, i.e. this may need
539 * to be called after a f/w download operation.
540 *
541 * The initialisation procedure goes like this:
542 * - Wait for UniFi to start-up by polling SHARED_MAILBOX1
543 * - Find the symbol table and look up SLT_SDIO_SLOT_CONFIG
544 * - Read the config structure
545 * - Check the "SDIO initialised" flag, if not zero do a h/w reset and
546 * start again
547 * - Decide the number of bulk data slots to allocate, allocate them and
548 * set "SDIO initialised" flag (and generate an interrupt) to say so.
549 *
550 * Arguments:
551 * card Pointer to card struct
552 *
553 * Returns:
554 * CSR_RESULT_SUCEESS on success,
555 * a CSR error code on failure
556 *
557 * Notes:
558 * All data in the f/w is stored in a little endian format, without any
559 * padding bytes. Every read from this memory has to be transformed in
560 * host (cpu specific) format, before it is stored in driver's parameters
561 * or/and structures. Athough unifi_card_read16() and unifi_read32() do perform
562 * the conversion internally, unifi_readn() does not.
563 * ---------------------------------------------------------------------------
564 */
565static CsrResult card_hw_init(card_t *card)
566{
567 u32 slut_address;
568 u16 initialised;
569 u16 finger_print;
570 symbol_t slut;
571 sdio_config_data_t *cfg_data;
572 u8 cfg_data_buf[SDIO_CONFIG_DATA_SIZE];
573 CsrResult r;
574 void *dlpriv;
575 s16 major, minor;
576 s16 search_4slut_again;
577 CsrResult csrResult;
578
579 /*
580 * The device revision from the TPLMID_MANF and TPLMID_CARD fields
581 * of the CIS are available as
582 * card->sdio_if->pDevice->ManfID
583 * card->sdio_if->pDevice->AppID
584 */
585
586 /*
587 * Run in a loop so we can patch.
588 */
589 do
590 {
591 /* Reset these each time around the loop. */
592 search_4slut_again = 0;
593 cfg_data = NULL;
594
595 r = card_wait_for_firmware_to_start(card, &slut_address);
596 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
597 {
598 return r;
599 }
600 if (r != CSR_RESULT_SUCCESS)
601 {
602 unifi_error(card->ospriv, "Firmware hasn't started\n");
603 return r;
604 }
605 unifi_trace(card->ospriv, UDBG4, "SLUT addr 0x%lX\n", slut_address);
606
607 /*
608 * Firmware has started, but doesn't know full clock configuration yet
609 * as some of the information may be in the MIB. Therefore we set an
610 * initial SDIO clock speed, faster than UNIFI_SDIO_CLOCK_SAFE_HZ, for
611 * the patch download and subsequent firmware initialisation, and
612 * full speed UNIFI_SDIO_CLOCK_MAX_HZ will be set once the f/w tells us
613 * that it is ready.
614 */
615 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
616 if (csrResult != CSR_RESULT_SUCCESS)
617 {
618 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
619 return r;
620 }
621 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
622
623 /*
624 * Check the SLUT fingerprint.
625 * The slut_address is a generic pointer so we must use unifi_card_read16().
626 */
627 unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
628 finger_print = 0;
629 r = unifi_card_read16(card, slut_address, &finger_print);
630 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
631 {
632 return r;
633 }
634 if (r != CSR_RESULT_SUCCESS)
635 {
636 unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
637 return r;
638 }
639
640 if (finger_print != SLUT_FINGERPRINT)
641 {
642 unifi_error(card->ospriv, "Failed to find Symbol lookup table fingerprint\n");
643 return CSR_RESULT_FAILURE;
644 }
645
646 /* Symbol table starts imedately after the fingerprint */
647 slut_address += 2;
648
649 /* Search the table until either the end marker is found, or the
650 * loading of patch firmware invalidates the current table.
651 */
652 while (!search_4slut_again)
653 {
654 u16 s;
655 u32 l;
656
657 r = unifi_card_read16(card, slut_address, &s);
658 if (r != CSR_RESULT_SUCCESS)
659 {
660 return r;
661 }
662 slut_address += 2;
663
664 if (s == CSR_SLT_END)
665 {
666 unifi_trace(card->ospriv, UDBG3, " found CSR_SLT_END\n");
667 break;
668 }
669
670 r = unifi_read32(card, slut_address, &l);
671 if (r != CSR_RESULT_SUCCESS)
672 {
673 return r;
674 }
675 slut_address += 4;
676
677 slut.id = s;
678 slut.obj = l;
679
680 unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", slut.id, slut.obj);
681 switch (slut.id)
682 {
683 case CSR_SLT_SDIO_SLOT_CONFIG:
684 cfg_data = &card->config_data;
685 /*
686 * unifi_card_readn reads n bytes from the card, where data is stored
687 * in a little endian format, without any padding bytes. So, we
688 * can not just pass the cfg_data pointer or use the
689 * sizeof(sdio_config_data_t) since the structure in the host can
690 * be big endian formatted or have padding bytes for alignment.
691 * We use a char buffer to read the data from the card.
692 */
693 r = unifi_card_readn(card, slut.obj, cfg_data_buf, SDIO_CONFIG_DATA_SIZE);
694 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
695 {
696 return r;
697 }
698 if (r != CSR_RESULT_SUCCESS)
699 {
700 unifi_error(card->ospriv, "Failed to read config data\n");
701 return r;
702 }
703 /* .. and then we copy the data to the host structure */
704 _build_sdio_config_data(cfg_data, cfg_data_buf);
705
706 /* Make sure the from host data slots are what we expect
707 we reserve 2 for commands and there should be at least
708 1 left for each access category */
709 if ((cfg_data->num_fromhost_data_slots < UNIFI_RESERVED_COMMAND_SLOTS)
710 || (cfg_data->num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS) / UNIFI_NO_OF_TX_QS == 0)
711 {
712 unifi_error(card->ospriv, "From host data slots %d\n", cfg_data->num_fromhost_data_slots);
713 unifi_error(card->ospriv, "need to be (queues * x + 2) (UNIFI_RESERVED_COMMAND_SLOTS for commands)\n");
714 return CSR_RESULT_FAILURE;
715 }
716
717 /* Configure SDIO to-block-size padding */
718 if (card->sdio_io_block_pad)
719 {
720 /*
721 * Firmware limits the maximum padding size via data_slot_round.
722 * Therefore when padding to whole block sizes, the block size
723 * must be configured correctly by adjusting CSR_WIFI_HIP_SDIO_BLOCK_SIZE.
724 */
725 if (cfg_data->data_slot_round < card->sdio_io_block_size)
726 {
727 unifi_error(card->ospriv,
728 "Configuration error: Block size of %d exceeds f/w data_slot_round of %d\n",
729 card->sdio_io_block_size, cfg_data->data_slot_round);
730 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
731 }
732
733 /*
734 * To force the To-Host signals to be rounded up to the SDIO block
735 * size, we need to write the To-Host Signal Padding Fragments
736 * field of the SDIO configuration in UniFi.
737 */
738 if ((card->sdio_io_block_size % cfg_data->sig_frag_size) != 0)
739 {
740 unifi_error(card->ospriv, "Configuration error: Can not pad to-host signals.\n");
741 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
742 }
743 cfg_data->tohost_signal_padding = (u16) (card->sdio_io_block_size / cfg_data->sig_frag_size);
744 unifi_info(card->ospriv, "SDIO block size %d requires %d padding chunks\n",
745 card->sdio_io_block_size, cfg_data->tohost_signal_padding);
746 r = unifi_card_write16(card, slut.obj + SDIO_TO_HOST_SIG_PADDING_OFFSET, cfg_data->tohost_signal_padding);
747 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
748 {
749 return r;
750 }
751 if (r != CSR_RESULT_SUCCESS)
752 {
753 unifi_error(card->ospriv, "Failed to write To-Host Signal Padding Fragments\n");
754 return r;
755 }
756 }
757
758 /* Reconstruct the Generic Pointer address of the
759 * SDIO Control Data Struct.
760 */
761 card->sdio_ctrl_addr = cfg_data->sdio_ctrl_offset | (UNIFI_SH_DMEM << 24);
762 card->init_flag_addr = slut.obj + SDIO_INIT_FLAG_OFFSET;
763 break;
764
765 case CSR_SLT_BUILD_ID_NUMBER:
766 {
767 u32 n;
768 r = unifi_read32(card, slut.obj, &n);
769 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
770 {
771 return r;
772 }
773 if (r != CSR_RESULT_SUCCESS)
774 {
775 unifi_error(card->ospriv, "Failed to read build id\n");
776 return r;
777 }
778 card->build_id = n;
779 }
780 break;
781
782 case CSR_SLT_BUILD_ID_STRING:
783 r = unifi_readnz(card, slut.obj, card->build_id_string,
784 sizeof(card->build_id_string));
785 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
786 {
787 return r;
788 }
789 if (r != CSR_RESULT_SUCCESS)
790 {
791 unifi_error(card->ospriv, "Failed to read build string\n");
792 return r;
793 }
794 break;
795
796 case CSR_SLT_PERSISTENT_STORE_DB:
797 break;
798
799 case CSR_SLT_BOOT_LOADER_CONTROL:
800
801 /* This command copies most of the station firmware
802 * image from ROM into program RAM. It also clears
803 * out the zerod data and sets up the initialised
804 * data. */
805 r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_LOAD_STA);
806 if (r != CSR_RESULT_SUCCESS)
807 {
808 unifi_error(card->ospriv, "Failed to write loader load image command\n");
809 return r;
810 }
811
812 dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
813
814 /* dlpriv might be NULL, we still need to do the do_loader_op step. */
815 if (dlpriv != NULL)
816 {
817 /* Download the firmware. */
818 r = unifi_dl_patch(card, dlpriv, slut.obj);
819
820 /* Free the firmware file information. */
821 unifi_fw_read_stop(card->ospriv, dlpriv);
822
823 if (r != CSR_RESULT_SUCCESS)
824 {
825 unifi_error(card->ospriv, "Failed to patch firmware\n");
826 return r;
827 }
828 }
829
830 /* This command starts the firmware image that we want (the
831 * station by default) with any patches required applied. */
832 r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_RESTART);
833 if (r != CSR_RESULT_SUCCESS)
834 {
835 unifi_error(card->ospriv, "Failed to write loader restart command\n");
836 return r;
837 }
838
839 /* The now running patch f/w defines a new SLUT data structure -
840 * the current one is no longer valid. We must drop out of the
841 * processing loop and enumerate the new SLUT (which may appear
842 * at a different offset).
843 */
844 search_4slut_again = 1;
845 break;
846
847 case CSR_SLT_PANIC_DATA_PHY:
848 card->panic_data_phy_addr = slut.obj;
849 break;
850
851 case CSR_SLT_PANIC_DATA_MAC:
852 card->panic_data_mac_addr = slut.obj;
853 break;
854
855 default:
856 /* do nothing */
857 break;
858 }
859 } /* while */
860 } while (search_4slut_again);
861
862 /* Did we find the Config Data ? */
863 if (cfg_data == NULL)
864 {
865 unifi_error(card->ospriv, "Failed to find SDIO_SLOT_CONFIG Symbol\n");
866 return CSR_RESULT_FAILURE;
867 }
868
869 /*
870 * Has ths card already been initialised?
871 * If so, return an error so we do a h/w reset and start again.
872 */
873 r = unifi_card_read16(card, card->init_flag_addr, &initialised);
874 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
875 {
876 return r;
877 }
878 if (r != CSR_RESULT_SUCCESS)
879 {
880 unifi_error(card->ospriv, "Failed to read init flag at %08lx\n",
881 card->init_flag_addr);
882 return r;
883 }
884 if (initialised != 0)
885 {
886 return CSR_RESULT_FAILURE;
887 }
888
889
890 /*
891 * Now check the UniFi firmware version
892 */
893 major = (cfg_data->version >> 8) & 0xFF;
894 minor = cfg_data->version & 0xFF;
895 unifi_info(card->ospriv, "UniFi f/w protocol version %d.%d (driver %d.%d)\n",
896 major, minor,
897 UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
898
899 unifi_info(card->ospriv, "Firmware build %u: %s\n",
900 card->build_id, card->build_id_string);
901
902 if (major != UNIFI_HIP_MAJOR_VERSION)
903 {
904 unifi_error(card->ospriv, "UniFi f/w protocol major version (%d) is different from driver (v%d.%d)\n",
905 major, UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
906#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
907 return CSR_RESULT_FAILURE;
908#endif
909 }
910 if (minor < UNIFI_HIP_MINOR_VERSION)
911 {
912 unifi_error(card->ospriv, "UniFi f/w protocol version (v%d.%d) is older than minimum required by driver (v%d.%d).\n",
913 major, minor,
914 UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
915#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
916 return CSR_RESULT_FAILURE;
917#endif
918 }
919
920 /* Read panic codes from a previous firmware panic. If the firmware has
921 * not panicked since power was applied (e.g. power-off hard reset)
922 * the stored panic codes will not be updated.
923 */
924 unifi_read_panic(card);
925
926 return CSR_RESULT_SUCCESS;
927} /* card_hw_init() */
928
929
930/*
931 * ---------------------------------------------------------------------------
932 * card_wait_for_unifi_to_reset
933 *
934 * Waits for a reset to complete by polling the WLAN function enable
935 * bit (which is cleared on reset).
936 *
937 * Arguments:
938 * card Pointer to card struct
939 *
940 * Returns:
941 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
942 * ---------------------------------------------------------------------------
943 */
944static CsrResult card_wait_for_unifi_to_reset(card_t *card)
945{
946 s16 i;
947 CsrResult r;
948 u8 io_enable;
949 CsrResult csrResult;
950
951 r = CSR_RESULT_SUCCESS;
952 for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
953 {
954 unifi_trace(card->ospriv, UDBG1, "waiting for reset to complete, attempt %d\n", i);
955 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
956 {
957 /* It's quite likely that this read will timeout for the
958 * first few tries - especially if we have reset via
959 * DBG_RESET.
960 */
961#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
962 unifi_debug_log_to_buf("m0@%02X=", SDIO_IO_READY);
963#endif
964 csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
965#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
966 if (csrResult != CSR_RESULT_SUCCESS)
967 {
968 unifi_debug_log_to_buf("error=%X\n", csrResult);
969 }
970 else
971 {
972 unifi_debug_log_to_buf("%X\n", io_enable);
973 }
974#endif
975 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
976 {
977 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
978 }
979 r = CSR_RESULT_SUCCESS;
980 if (csrResult != CSR_RESULT_SUCCESS)
981 {
982 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
983 }
984 }
985 else
986 {
987 r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_enable);
988 }
989 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
990 {
991 return r;
992 }
993 if (r == CSR_RESULT_SUCCESS)
994 {
995 u16 mbox2;
996 s16 enabled = io_enable & (1 << card->function);
997
998 if (!enabled)
999 {
1000 unifi_trace(card->ospriv, UDBG1,
1001 "Reset complete (function %d is disabled) in ~ %u msecs\n",
1002 card->function, i * MAILBOX2_TIMEOUT);
1003
1004 /* Enable WLAN function and verify MAILBOX2 is zero'd */
1005 csrResult = CsrSdioFunctionEnable(card->sdio_if);
1006 if (csrResult != CSR_RESULT_SUCCESS)
1007 {
1008 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
1009 unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d\n", r);
1010 break;
1011 }
1012 }
1013
1014 r = unifi_read_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, &mbox2);
1015 if (r != CSR_RESULT_SUCCESS)
1016 {
1017 unifi_error(card->ospriv, "read HIP_HANDSHAKE failed %d\n", r);
1018 break;
1019 }
1020 if (mbox2 != 0)
1021 {
1022 unifi_error(card->ospriv, "MAILBOX2 non-zero after reset (mbox2 = %04x)\n", mbox2);
1023 r = CSR_RESULT_FAILURE;
1024 }
1025 break;
1026 }
1027 else
1028 {
1029 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
1030 {
1031 /* We ignore read failures for the first few reads,
1032 * they are probably benign. */
1033 if (i > MAILBOX2_ATTEMPTS / 4)
1034 {
1035 unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Ready register while polling for reset\n");
1036 }
1037 }
1038 else
1039 {
1040 unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Enable register while polling for reset\n");
1041 }
1042 }
1043 CsrThreadSleep(MAILBOX2_TIMEOUT);
1044 }
1045
1046 if (r == CSR_RESULT_SUCCESS && i == MAILBOX2_ATTEMPTS)
1047 {
1048 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete reset\n");
1049 r = CSR_RESULT_FAILURE;
1050 }
1051
1052 return r;
1053} /* card_wait_for_unifi_to_reset() */
1054
1055
1056/*
1057 * ---------------------------------------------------------------------------
1058 * card_wait_for_unifi_to_disable
1059 *
1060 * Waits for the function to become disabled by polling the
1061 * IO_READY bit.
1062 *
1063 * Arguments:
1064 * card Pointer to card struct
1065 *
1066 * Returns:
1067 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1068 *
1069 * Notes: This function can only be used with
1070 * card->chip_id > SDIO_CARD_ID_UNIFI_2
1071 * ---------------------------------------------------------------------------
1072 */
1073static CsrResult card_wait_for_unifi_to_disable(card_t *card)
1074{
1075 s16 i;
1076 CsrResult r;
1077 u8 io_enable;
1078 CsrResult csrResult;
1079
1080 if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
1081 {
1082 unifi_error(card->ospriv,
1083 "Function reset method not supported for chip_id=%d\n",
1084 card->chip_id);
1085 return CSR_RESULT_FAILURE;
1086 }
1087
1088 r = CSR_RESULT_SUCCESS;
1089 for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
1090 {
1091 unifi_trace(card->ospriv, UDBG1, "waiting for disable to complete, attempt %d\n", i);
1092
1093 /*
1094 * It's quite likely that this read will timeout for the
1095 * first few tries - especially if we have reset via
1096 * DBG_RESET.
1097 */
1098#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1099 unifi_debug_log_to_buf("r0@%02X=", SDIO_IO_READY);
1100#endif
1101 csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
1102#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1103 if (csrResult != CSR_RESULT_SUCCESS)
1104 {
1105 unifi_debug_log_to_buf("error=%X\n", csrResult);
1106 }
1107 else
1108 {
1109 unifi_debug_log_to_buf("%X\n", io_enable);
1110 }
1111#endif
1112 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
1113 {
1114 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
1115 }
1116 if (csrResult == CSR_RESULT_SUCCESS)
1117 {
1118 s16 enabled = io_enable & (1 << card->function);
1119 r = CSR_RESULT_SUCCESS;
1120 if (!enabled)
1121 {
1122 unifi_trace(card->ospriv, UDBG1,
1123 "Disable complete (function %d is disabled) in ~ %u msecs\n",
1124 card->function, i * MAILBOX2_TIMEOUT);
1125
1126 break;
1127 }
1128 }
1129 else
1130 {
1131 /*
1132 * We ignore read failures for the first few reads,
1133 * they are probably benign.
1134 */
1135 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
1136 if (i > (MAILBOX2_ATTEMPTS / 4))
1137 {
1138 unifi_trace(card->ospriv, UDBG1,
1139 "Failed to read CCCR IO Ready register while polling for disable\n");
1140 }
1141 }
1142 CsrThreadSleep(MAILBOX2_TIMEOUT);
1143 }
1144
1145 if ((r == CSR_RESULT_SUCCESS) && (i == MAILBOX2_ATTEMPTS))
1146 {
1147 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete disable\n");
1148 r = CSR_RESULT_FAILURE;
1149 }
1150
1151 return r;
1152} /* card_wait_for_unifi_to_reset() */
1153
1154
1155/*
1156 * ---------------------------------------------------------------------------
1157 * card_wait_for_firmware_to_start
1158 *
1159 * Polls the MAILBOX1 register for a non-zero value.
1160 * Then reads MAILBOX0 and forms the two values into a 32-bit address
1161 * which is returned to the caller.
1162 *
1163 * Arguments:
1164 * card Pointer to card struct
1165 * paddr Pointer to receive the UniFi address formed
1166 * by concatenating MAILBOX1 and MAILBOX0.
1167 *
1168 * Returns:
1169 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1170 * ---------------------------------------------------------------------------
1171 */
1172CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr)
1173{
1174 s32 i;
1175 u16 mbox0, mbox1;
1176 CsrResult r;
1177
1178 /*
1179 * Wait for UniFi to initialise its data structures by polling
1180 * the SHARED_MAILBOX1 register.
1181 * Experience shows this is typically 120ms.
1182 */
1183 CsrThreadSleep(MAILBOX1_TIMEOUT);
1184
1185 mbox1 = 0;
1186 unifi_trace(card->ospriv, UDBG1, "waiting for MAILBOX1 to be non-zero...\n");
1187 for (i = 0; i < MAILBOX1_ATTEMPTS; i++)
1188 {
1189 r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
1190 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1191 {
1192 return r;
1193 }
1194 if (r != CSR_RESULT_SUCCESS)
1195 {
1196 /* These reads can fail if UniFi isn't up yet, so try again */
1197 unifi_warning(card->ospriv, "Failed to read UniFi Mailbox1 register\n");
1198 }
1199
1200 if ((r == CSR_RESULT_SUCCESS) && (mbox1 != 0))
1201 {
1202 unifi_trace(card->ospriv, UDBG1, "MAILBOX1 ready (0x%04X) in %u millisecs\n",
1203 mbox1, i * MAILBOX1_TIMEOUT);
1204
1205 /* Read the MAILBOX1 again in case we caught the value as it
1206 * changed. */
1207 r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
1208 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1209 {
1210 return r;
1211 }
1212 if (r != CSR_RESULT_SUCCESS)
1213 {
1214 unifi_error(card->ospriv, "Failed to read UniFi Mailbox1 register for second time\n");
1215 return r;
1216 }
1217 unifi_trace(card->ospriv, UDBG1, "MAILBOX1 value=0x%04X\n", mbox1);
1218
1219 break;
1220 }
1221
1222 CsrThreadSleep(MAILBOX1_TIMEOUT);
1223 if ((i % 100) == 99)
1224 {
1225 unifi_trace(card->ospriv, UDBG2, "MAILBOX1 not ready (0x%X), still trying...\n", mbox1);
1226 }
1227 }
1228
1229 if ((r == CSR_RESULT_SUCCESS) && (mbox1 == 0))
1230 {
1231 unifi_trace(card->ospriv, UDBG1, "Timeout waiting for firmware to start, Mailbox1 still 0 after %d ms\n",
1232 MAILBOX1_ATTEMPTS * MAILBOX1_TIMEOUT);
1233 return CSR_RESULT_FAILURE;
1234 }
1235
1236
1237 /*
1238 * Complete the reset handshake by setting MAILBOX2 to 0xFFFF
1239 */
1240 r = unifi_write_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, 0xFFFF);
1241 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1242 {
1243 return r;
1244 }
1245 if (r != CSR_RESULT_SUCCESS)
1246 {
1247 unifi_error(card->ospriv, "Failed to write f/w startup handshake to MAILBOX2\n");
1248 return r;
1249 }
1250
1251
1252 /*
1253 * Read the Symbol Look Up Table (SLUT) offset.
1254 * Top 16 bits are in mbox1, read the lower 16 bits from mbox0.
1255 */
1256 mbox0 = 0;
1257 r = unifi_read_direct16(card, ChipHelper_MAILBOX0(card->helper) * 2, &mbox0);
1258 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1259 {
1260 return r;
1261 }
1262 if (r != CSR_RESULT_SUCCESS)
1263 {
1264 unifi_error(card->ospriv, "Failed to read UniFi Mailbox0 register\n");
1265 return r;
1266 }
1267
1268 *paddr = (((u32)mbox1 << 16) | mbox0);
1269
1270 return CSR_RESULT_SUCCESS;
1271} /* card_wait_for_firmware_to_start() */
1272
1273
1274/*
1275 * ---------------------------------------------------------------------------
1276 * unifi_capture_panic
1277 *
1278 * Attempt to capture panic codes from the firmware. This may involve
1279 * warm reset of the chip to regain access following a watchdog reset.
1280 *
1281 * Arguments:
1282 * card Pointer to card struct
1283 *
1284 * Returns:
1285 * CSR_RESULT_SUCCESS if panic codes were captured, or none available
1286 * CSR_RESULT_FAILURE if the driver could not access function 1
1287 * ---------------------------------------------------------------------------
1288 */
1289CsrResult unifi_capture_panic(card_t *card)
1290{
1291
1292 /* The firmware must have previously initialised to read the panic addresses
1293 * from the SLUT
1294 */
1295 if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
1296 {
1297 return CSR_RESULT_SUCCESS;
1298 }
1299
1300 /* Ensure we can access function 1 following a panic/watchdog reset */
1301 if (card_access_panic(card) == CSR_RESULT_SUCCESS)
1302 {
1303 /* Read the panic codes */
1304 unifi_read_panic(card);
1305 }
1306 else
1307 {
1308 unifi_info(card->ospriv, "Unable to read panic codes");
1309 }
1310
1311 return CSR_RESULT_SUCCESS;
1312}
1313
1314
1315/*
1316 * ---------------------------------------------------------------------------
1317 * card_access_panic
1318 * Attempt to read the WLAN SDIO function in order to read panic codes
1319 * and perform various reset steps to regain access if the read fails.
1320 *
1321 * Arguments:
1322 * card Pointer to card struct
1323 *
1324 * Returns:
1325 * CSR_RESULT_SUCCESS if panic codes can be read
1326 * CSR error code if panic codes can not be read
1327 * ---------------------------------------------------------------------------
1328 */
1329static CsrResult card_access_panic(card_t *card)
1330{
1331 u16 data_u16 = 0;
1332 s32 i;
1333 CsrResult r, sr;
1334
1335 /* A chip version of zero means that the version never got successfully read
1336 * during reset. In this case give up because it will not be possible to
1337 * verify the chip version.
1338 */
1339 if (!card->chip_version)
1340 {
1341 unifi_info(card->ospriv, "Unknown chip version\n");
1342 return CSR_RESULT_FAILURE;
1343 }
1344
1345 /* Ensure chip is awake or access to function 1 will fail */
1346 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1347 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1348 {
1349 return r;
1350 }
1351 if (r != CSR_RESULT_SUCCESS)
1352 {
1353 unifi_error(card->ospriv, "unifi_set_host_state() failed %d\n", r);
1354 return CSR_RESULT_FAILURE; /* Card is probably unpowered */
1355 }
1356 CsrThreadSleep(20);
1357
1358 for (i = 0; i < 3; i++)
1359 {
1360 sr = CsrSdioRead16(card->sdio_if, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION * 2, &data_u16);
1361 if (sr != CSR_RESULT_SUCCESS || data_u16 != card->chip_version)
1362 {
1363 unifi_info(card->ospriv, "Failed to read valid chip version sr=%d (0x%04x want 0x%04x) try %d\n",
1364 sr, data_u16, card->chip_version, i);
1365
1366 /* Set clock speed low */
1367 sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
1368 if (sr != CSR_RESULT_SUCCESS)
1369 {
1370 unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed1 %d\n", sr);
1371 r = ConvertCsrSdioToCsrHipResult(card, sr);
1372 }
1373 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
1374
1375 /* First try re-enabling function in case a f/w watchdog reset disabled it */
1376 if (i == 0)
1377 {
1378 unifi_info(card->ospriv, "Try function enable\n");
1379 sr = CsrSdioFunctionEnable(card->sdio_if);
1380 if (sr != CSR_RESULT_SUCCESS)
1381 {
1382 r = ConvertCsrSdioToCsrHipResult(card, sr);
1383 unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d (HIP %d)\n", sr, r);
1384 }
1385 continue;
1386 }
1387
1388 /* Second try, set awake */
1389 unifi_info(card->ospriv, "Try set awake\n");
1390
1391 /* Ensure chip is awake */
1392 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1393 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1394 {
1395 return r;
1396 }
1397 if (r != CSR_RESULT_SUCCESS)
1398 {
1399 unifi_error(card->ospriv, "unifi_set_host_state() failed2 %d\n", r);
1400 }
1401
1402 /* Set clock speed low in case setting the host state raised it, which
1403 * would only happen if host state was previously TORPID
1404 */
1405 sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
1406 if (sr != CSR_RESULT_SUCCESS)
1407 {
1408 unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed2 %d\n", sr);
1409 }
1410 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
1411
1412 if (i == 1)
1413 {
1414 continue;
1415 }
1416
1417 /* Perform a s/w reset to preserve as much as the card state as possible,
1418 * (mainly the preserve RAM). The context will be lost for coredump - but as we
1419 * were unable to access the WLAN function for panic, the coredump would have
1420 * also failed without a reset.
1421 */
1422 unifi_info(card->ospriv, "Try s/w reset\n");
1423
1424 r = unifi_card_hard_reset(card);
1425 if (r != CSR_RESULT_SUCCESS)
1426 {
1427 unifi_error(card->ospriv, "unifi_card_hard_reset() failed %d\n", r);
1428 }
1429 }
1430 else
1431 {
1432 if (i > 0)
1433 {
1434 unifi_info(card->ospriv, "Read chip version 0x%x after %d retries\n", data_u16, i);
1435 }
1436 break;
1437 }
1438 }
1439
1440 r = ConvertCsrSdioToCsrHipResult(card, sr);
1441 return r;
1442}
1443
1444
1445/*
1446 * ---------------------------------------------------------------------------
1447 * unifi_read_panic
1448 * Reads, saves and prints panic codes stored by the firmware in UniFi's
1449 * preserve RAM by the last panic that occurred since chip was powered.
1450 * Nothing is saved if the panic codes are read as zero.
1451 *
1452 * Arguments:
1453 * card Pointer to card struct
1454 *
1455 * Returns:
1456 * ---------------------------------------------------------------------------
1457 */
1458void unifi_read_panic(card_t *card)
1459{
1460 CsrResult r;
1461 u16 p_code, p_arg;
1462
1463 /* The firmware must have previously initialised to read the panic addresses
1464 * from the SLUT
1465 */
1466 if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
1467 {
1468 return;
1469 }
1470
1471 /* Get the panic data from PHY */
1472 r = unifi_card_read16(card, card->panic_data_phy_addr, &p_code);
1473 if (r != CSR_RESULT_SUCCESS)
1474 {
1475 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr, r);
1476 p_code = 0;
1477 }
1478 if (p_code)
1479 {
1480 r = unifi_card_read16(card, card->panic_data_phy_addr + 2, &p_arg);
1481 if (r != CSR_RESULT_SUCCESS)
1482 {
1483 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr + 2, r);
1484 }
1485 unifi_error(card->ospriv, "Last UniFi PHY PANIC %04x arg %04x\n", p_code, p_arg);
1486 card->last_phy_panic_code = p_code;
1487 card->last_phy_panic_arg = p_arg;
1488 }
1489
1490 /* Get the panic data from MAC */
1491 r = unifi_card_read16(card, card->panic_data_mac_addr, &p_code);
1492 if (r != CSR_RESULT_SUCCESS)
1493 {
1494 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr, r);
1495 p_code = 0;
1496 }
1497 if (p_code)
1498 {
1499 r = unifi_card_read16(card, card->panic_data_mac_addr + 2, &p_arg);
1500 if (r != CSR_RESULT_SUCCESS)
1501 {
1502 unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr + 2, r);
1503 }
1504 unifi_error(card->ospriv, "Last UniFi MAC PANIC %04x arg %04x\n", p_code, p_arg);
1505 card->last_mac_panic_code = p_code;
1506 card->last_mac_panic_arg = p_arg;
1507 }
1508
1509}
1510
1511
1512/*
1513 * ---------------------------------------------------------------------------
1514 * card_allocate_memory_resources
1515 *
1516 * Allocates memory for the from-host, to-host bulk data slots,
1517 * soft queue buffers and bulk data buffers.
1518 *
1519 * Arguments:
1520 * card Pointer to card struct
1521 *
1522 * Returns:
1523 * CSR_RESULT_SUCCESS on success, CSR error code on failure.
1524 * ---------------------------------------------------------------------------
1525 */
1526static CsrResult card_allocate_memory_resources(card_t *card)
1527{
1528 s16 n, i, k, r;
1529 sdio_config_data_t *cfg_data;
1530
1531 /* Reset any state carried forward from a previous life */
1532 card->fh_command_queue.q_rd_ptr = 0;
1533 card->fh_command_queue.q_wr_ptr = 0;
1534 (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
1535 "fh_cmd_q");
1536 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1537 {
1538 card->fh_traffic_queue[i].q_rd_ptr = 0;
1539 card->fh_traffic_queue[i].q_wr_ptr = 0;
1540 (void)scnprintf(card->fh_traffic_queue[i].name,
1541 UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
1542 }
1543#ifndef CSR_WIFI_HIP_TA_DISABLE
1544 unifi_ta_sampling_init(card);
1545#endif
1546 /* Convenience short-cut */
1547 cfg_data = &card->config_data;
1548
1549 /*
1550 * Allocate memory for the from-host and to-host signal buffers.
1551 */
1552 card->fh_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
1553 if (card->fh_buffer.buf == NULL)
1554 {
1555 unifi_error(card->ospriv, "Failed to allocate memory for F-H signals\n");
1556 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1557 }
1558 card->fh_buffer.bufsize = UNIFI_FH_BUF_SIZE;
1559 card->fh_buffer.ptr = card->fh_buffer.buf;
1560 card->fh_buffer.count = 0;
1561
1562 card->th_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
1563 if (card->th_buffer.buf == NULL)
1564 {
1565 unifi_error(card->ospriv, "Failed to allocate memory for T-H signals\n");
1566 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1567 }
1568 card->th_buffer.bufsize = UNIFI_FH_BUF_SIZE;
1569 card->th_buffer.ptr = card->th_buffer.buf;
1570 card->th_buffer.count = 0;
1571
1572
1573 /*
1574 * Allocate memory for the from-host and to-host bulk data slots.
1575 * This is done as separate kmallocs because lots of smaller
1576 * allocations are more likely to succeed than one huge one.
1577 */
1578
1579 /* Allocate memory for the array of pointers */
1580 n = cfg_data->num_fromhost_data_slots;
1581
1582 unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n);
1583 card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL);
1584 if (card->from_host_data == NULL)
1585 {
1586 unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n");
1587 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1588 }
1589
1590 /* Initialise from-host bulk data slots */
1591 for (i = 0; i < n; i++)
1592 {
1593 UNIFI_INIT_BULK_DATA(&card->from_host_data[i].bd);
1594 }
1595
1596 /* Allocate memory for the array used for slot host tag mapping */
1597 card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL);
1598
1599 if (card->fh_slot_host_tag_record == NULL)
1600 {
1601 unifi_error(card->ospriv, "Failed to allocate memory for F-H slot host tag mapping array\n");
1602 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1603 }
1604
1605 /* Initialise host tag entries for from-host bulk data slots */
1606 for (i = 0; i < n; i++)
1607 {
1608 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1609 }
1610
1611
1612 /* Allocate memory for the array of pointers */
1613 n = cfg_data->num_tohost_data_slots;
1614
1615 unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n);
1616 card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL);
1617 if (card->to_host_data == NULL)
1618 {
1619 unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n");
1620 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
1621 }
1622
1623 /* Initialise to-host bulk data slots */
1624 for (i = 0; i < n; i++)
1625 {
1626 UNIFI_INIT_BULK_DATA(&card->to_host_data[i]);
1627 }
1628
1629 /*
1630 * Initialise buffers for soft Q
1631 */
1632 for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
1633 {
1634 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1635 {
1636 UNIFI_INIT_BULK_DATA(&card->fh_command_q_body[i].bulkdata[r]);
1637 }
1638 }
1639
1640 for (k = 0; k < UNIFI_NO_OF_TX_QS; k++)
1641 {
1642 for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
1643 {
1644 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1645 {
1646 UNIFI_INIT_BULK_DATA(&card->fh_traffic_q_body[k][i].bulkdata[r]);
1647 }
1648 }
1649 }
1650
1651 card->memory_resources_allocated = 1;
1652
1653 return CSR_RESULT_SUCCESS;
1654} /* card_allocate_memory_resources() */
1655
1656
1657/*
1658 * ---------------------------------------------------------------------------
1659 * unifi_free_bulk_data
1660 *
1661 * Free the data associated to a bulk data structure.
1662 *
1663 * Arguments:
1664 * card Pointer to card struct
1665 * bulk_data_slot Pointer to bulk data structure
1666 *
1667 * Returns:
1668 * None.
1669 *
1670 * ---------------------------------------------------------------------------
1671 */
1672static void unifi_free_bulk_data(card_t *card, bulk_data_desc_t *bulk_data_slot)
1673{
1674 if (bulk_data_slot->data_length != 0)
1675 {
1676 unifi_net_data_free(card->ospriv, bulk_data_slot);
1677 }
1678} /* unifi_free_bulk_data() */
1679
1680
1681/*
1682 * ---------------------------------------------------------------------------
1683 * card_free_memory_resources
1684 *
1685 * Frees memory allocated for the from-host, to-host bulk data slots,
1686 * soft queue buffers and bulk data buffers.
1687 *
1688 * Arguments:
1689 * card Pointer to card struct
1690 *
1691 * Returns:
1692 * None.
1693 * ---------------------------------------------------------------------------
1694 */
1695static void card_free_memory_resources(card_t *card)
1696{
1697
1698 unifi_trace(card->ospriv, UDBG1, "Freeing card memory resources.\n");
1699
1700 /* Clear our internal queues */
1701 unifi_cancel_pending_signals(card);
1702
1703
1704 kfree(card->to_host_data);
1705 card->to_host_data = NULL;
1706
1707 kfree(card->from_host_data);
1708 card->from_host_data = NULL;
1709
1710 /* free the memory for slot host tag mapping array */
1711 kfree(card->fh_slot_host_tag_record);
1712 card->fh_slot_host_tag_record = NULL;
1713
1714 kfree(card->fh_buffer.buf);
1715 card->fh_buffer.ptr = card->fh_buffer.buf = NULL;
1716 card->fh_buffer.bufsize = 0;
1717 card->fh_buffer.count = 0;
1718
1719 kfree(card->th_buffer.buf);
1720 card->th_buffer.ptr = card->th_buffer.buf = NULL;
1721 card->th_buffer.bufsize = 0;
1722 card->th_buffer.count = 0;
1723
1724
1725 card->memory_resources_allocated = 0;
1726
1727} /* card_free_memory_resources() */
1728
1729
1730static void card_init_soft_queues(card_t *card)
1731{
1732 s16 i;
1733
1734 unifi_trace(card->ospriv, UDBG1, "Initialising internal signal queues.\n");
1735 /* Reset any state carried forward from a previous life */
1736 card->fh_command_queue.q_rd_ptr = 0;
1737 card->fh_command_queue.q_wr_ptr = 0;
1738 (void)scnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
1739 "fh_cmd_q");
1740 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1741 {
1742 card->fh_traffic_queue[i].q_rd_ptr = 0;
1743 card->fh_traffic_queue[i].q_wr_ptr = 0;
1744 (void)scnprintf(card->fh_traffic_queue[i].name,
1745 UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
1746 }
1747#ifndef CSR_WIFI_HIP_TA_DISABLE
1748 unifi_ta_sampling_init(card);
1749#endif
1750}
1751
1752
1753/*
1754 * ---------------------------------------------------------------------------
1755 * unifi_cancel_pending_signals
1756 *
1757 * Free the signals and associated bulk data, pending in the core.
1758 *
1759 * Arguments:
1760 * card Pointer to card struct
1761 *
1762 * Returns:
1763 * None.
1764 * ---------------------------------------------------------------------------
1765 */
1766void unifi_cancel_pending_signals(card_t *card)
1767{
1768 s16 i, n, r;
1769
1770 unifi_trace(card->ospriv, UDBG1, "Canceling pending signals.\n");
1771
1772 if (card->to_host_data)
1773 {
1774 /*
1775 * Free any bulk data buffers allocated for the t-h slots
1776 * This will clear all buffers that did not make it to
1777 * unifi_receive_event() before cancel was request.
1778 */
1779 n = card->config_data.num_tohost_data_slots;
1780 unifi_trace(card->ospriv, UDBG3, "Freeing to-host resources, %d slots.\n", n);
1781 for (i = 0; i < n; i++)
1782 {
1783 unifi_free_bulk_data(card, &card->to_host_data[i]);
1784 }
1785 }
1786
1787 /*
1788 * If any of the from-host bulk data has reached the card->from_host_data
1789 * but not UniFi, we need to free the buffers here.
1790 */
1791 if (card->from_host_data)
1792 {
1793 /* Free any bulk data buffers allocated for the f-h slots */
1794 n = card->config_data.num_fromhost_data_slots;
1795 unifi_trace(card->ospriv, UDBG3, "Freeing from-host resources, %d slots.\n", n);
1796 for (i = 0; i < n; i++)
1797 {
1798 unifi_free_bulk_data(card, &card->from_host_data[i].bd);
1799 }
1800
1801 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1802 {
1803 card->dynamic_slot_data.from_host_used_slots[i] = 0;
1804 card->dynamic_slot_data.from_host_max_slots[i] = 0;
1805 card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
1806 }
1807 }
1808
1809 /*
1810 * Free any bulk data buffers allocated in the soft queues.
1811 * This covers the case where a bulk data pointer has reached the soft queue
1812 * but not the card->from_host_data.
1813 */
1814 unifi_trace(card->ospriv, UDBG3, "Freeing cmd q resources.\n");
1815 for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
1816 {
1817 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1818 {
1819 unifi_free_bulk_data(card, &card->fh_command_q_body[i].bulkdata[r]);
1820 }
1821 }
1822
1823 unifi_trace(card->ospriv, UDBG3, "Freeing traffic q resources.\n");
1824 for (n = 0; n < UNIFI_NO_OF_TX_QS; n++)
1825 {
1826 for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
1827 {
1828 for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
1829 {
1830 unifi_free_bulk_data(card, &card->fh_traffic_q_body[n][i].bulkdata[r]);
1831 }
1832 }
1833 }
1834
1835 card_init_soft_queues(card);
1836
1837} /* unifi_cancel_pending_signals() */
1838
1839
1840/*
1841 * ---------------------------------------------------------------------------
1842 * unifi_free_card
1843 *
1844 * Free the memory allocated for the card structure and buffers.
1845 *
1846 * Notes:
1847 * The porting layer is responsible for freeing any mini-coredump buffers
1848 * allocated when it called unifi_coredump_init(), by calling
1849 * unifi_coredump_free() before calling this function.
1850 *
1851 * Arguments:
1852 * card Pointer to card struct
1853 *
1854 * Returns:
1855 * None.
1856 * ---------------------------------------------------------------------------
1857 */
1858void unifi_free_card(card_t *card)
1859{
1860#ifdef CSR_PRE_ALLOC_NET_DATA
1861 prealloc_netdata_free(card);
1862#endif
1863 /* Free any memory allocated. */
1864 card_free_memory_resources(card);
1865
1866 /* Warn if caller didn't free coredump buffers */
1867 if (card->dump_buf)
1868 {
1869 unifi_error(card->ospriv, "Caller should call unifi_coredump_free()\n");
1870 unifi_coredump_free(card); /* free anyway to prevent memory leak */
1871 }
1872
1873 kfree(card);
1874
1875} /* unifi_free_card() */
1876
1877
1878/*
1879 * ---------------------------------------------------------------------------
1880 * card_init_slots
1881 *
1882 * Allocate memory for host-side slot data and signal queues.
1883 *
1884 * Arguments:
1885 * card Pointer to card object
1886 *
1887 * Returns:
1888 * CSR error code.
1889 * ---------------------------------------------------------------------------
1890 */
1891static CsrResult card_init_slots(card_t *card)
1892{
1893 CsrResult r;
1894 u8 i;
1895
1896 /* Allocate the buffers we need, only once. */
1897 if (card->memory_resources_allocated == 1)
1898 {
1899 card_free_memory_resources(card);
1900 }
1901 else
1902 {
1903 /* Initialise our internal command and traffic queues */
1904 card_init_soft_queues(card);
1905 }
1906
1907 r = card_allocate_memory_resources(card);
1908 if (r != CSR_RESULT_SUCCESS)
1909 {
1910 unifi_error(card->ospriv, "Failed to allocate card memory resources.\n");
1911 card_free_memory_resources(card);
1912 return r;
1913 }
1914
1915 if (card->sdio_ctrl_addr == 0)
1916 {
1917 unifi_error(card->ospriv, "Failed to find config struct!\n");
1918 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1919 }
1920
1921 /*
1922 * Set initial counts.
1923 */
1924
1925 card->from_host_data_head = 0;
1926
1927 /* Get initial signal counts from UniFi, in case it has not been reset. */
1928 {
1929 u16 s;
1930
1931 /* Get the from-host-signals-written count */
1932 r = unifi_card_read16(card, card->sdio_ctrl_addr + 0, &s);
1933 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1934 {
1935 return r;
1936 }
1937 if (r != CSR_RESULT_SUCCESS)
1938 {
1939 unifi_error(card->ospriv, "Failed to read from-host sig written count\n");
1940 return r;
1941 }
1942 card->from_host_signals_w = (s16)s;
1943
1944 /* Get the to-host-signals-written count */
1945 r = unifi_card_read16(card, card->sdio_ctrl_addr + 6, &s);
1946 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1947 {
1948 return r;
1949 }
1950 if (r != CSR_RESULT_SUCCESS)
1951 {
1952 unifi_error(card->ospriv, "Failed to read to-host sig read count\n");
1953 return r;
1954 }
1955 card->to_host_signals_r = (s16)s;
1956 }
1957
1958 /* Set Initialised flag. */
1959 r = unifi_card_write16(card, card->init_flag_addr, 0x0001);
1960 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1961 {
1962 return r;
1963 }
1964 if (r != CSR_RESULT_SUCCESS)
1965 {
1966 unifi_error(card->ospriv, "Failed to write initialised flag\n");
1967 return r;
1968 }
1969
1970 /* Dynamic queue reservation */
1971 memset(&card->dynamic_slot_data, 0, sizeof(card_dynamic_slot_t));
1972
1973 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
1974 {
1975 card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
1976 UNIFI_RESERVED_COMMAND_SLOTS;
1977 card->dynamic_slot_data.queue_stable[i] = FALSE;
1978 }
1979
1980 card->dynamic_slot_data.packets_interval = UNIFI_PACKETS_INTERVAL;
1981
1982 return CSR_RESULT_SUCCESS;
1983} /* card_init_slots() */
1984
1985
1986/*
1987 * ---------------------------------------------------------------------------
1988 * unifi_set_udi_hook
1989 *
1990 * Registers the udi hook that reports the sent signals to the core.
1991 *
1992 * Arguments:
1993 * card Pointer to the card context struct
1994 * udi_fn Pointer to the callback function.
1995 *
1996 * Returns:
1997 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
1998 * CSR_RESULT_SUCCESS on success.
1999 * ---------------------------------------------------------------------------
2000 */
2001CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn)
2002{
2003 if (card == NULL)
2004 {
2005 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2006 }
2007
2008 if (card->udi_hook == NULL)
2009 {
2010 card->udi_hook = udi_fn;
2011 }
2012
2013 return CSR_RESULT_SUCCESS;
2014} /* unifi_set_udi_hook() */
2015
2016
2017/*
2018 * ---------------------------------------------------------------------------
2019 * unifi_remove_udi_hook
2020 *
2021 * Removes the udi hook that reports the sent signals from the core.
2022 *
2023 * Arguments:
2024 * card Pointer to the card context struct
2025 * udi_fn Pointer to the callback function.
2026 *
2027 * Returns:
2028 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
2029 * CSR_RESULT_SUCCESS on success.
2030 * ---------------------------------------------------------------------------
2031 */
2032CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn)
2033{
2034 if (card == NULL)
2035 {
2036 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2037 }
2038
2039 if (card->udi_hook == udi_fn)
2040 {
2041 card->udi_hook = NULL;
2042 }
2043
2044 return CSR_RESULT_SUCCESS;
2045} /* unifi_remove_udi_hook() */
2046
2047
2048static void CardReassignDynamicReservation(card_t *card)
2049{
2050 u8 i;
2051
2052 unifi_trace(card->ospriv, UDBG5, "Packets Txed %d %d %d %d\n",
2053 card->dynamic_slot_data.packets_txed[0],
2054 card->dynamic_slot_data.packets_txed[1],
2055 card->dynamic_slot_data.packets_txed[2],
2056 card->dynamic_slot_data.packets_txed[3]);
2057
2058 /* Clear reservation and recalculate max slots */
2059 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2060 {
2061 card->dynamic_slot_data.queue_stable[i] = FALSE;
2062 card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
2063 card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
2064 UNIFI_RESERVED_COMMAND_SLOTS;
2065 card->dynamic_slot_data.packets_txed[i] = 0;
2066
2067 unifi_trace(card->ospriv, UDBG5, "CardReassignDynamicReservation: queue %d reserved %d Max %d\n", i,
2068 card->dynamic_slot_data.from_host_reserved_slots[i],
2069 card->dynamic_slot_data.from_host_max_slots[i]);
2070 }
2071
2072 card->dynamic_slot_data.total_packets_txed = 0;
2073}
2074
2075
2076/* Algorithm to dynamically reserve slots. The logic is based mainly on the outstanding queue
2077 * length. Slots are reserved for particular queues during an interval and cleared after the interval.
2078 * Each queue has three associated variables.. a) used slots - the number of slots currently occupied
2079 * by the queue b) reserved slots - number of slots reserved specifically for the queue c) max slots - total
2080 * slots that this queue can actually use (may be higher than reserved slots and is dependent on reserved slots
2081 * for other queues).
2082 * This function is called when there are no slots available for a queue. It checks to see if there are enough
2083 * unreserved slots sufficient for this request. If available these slots are reserved for the queue.
2084 * If there are not enough unreserved slots, a fair share for each queue is calculated based on the total slots
2085 * and the number of active queues (any queue with existing reservation is considered active). Queues needing
2086 * less than their fair share are allowed to have the previously reserved slots. The remaining slots are
2087 * distributed evenly among queues that need more than the fair share
2088 *
2089 * A better scheme would take current bandwidth per AC into consideration when reserving slots. An
2090 * implementation scheme could consider the relative time/service period for slots in an AC. If the firmware
2091 * services other ACs faster than a particular AC (packets wait in the slots longer) then it is fair to reserve
2092 * less slots for the AC
2093 */
2094static void CardCheckDynamicReservation(card_t *card, unifi_TrafficQueue queue)
2095{
2096 u16 q_len, active_queues = 0, excess_queue_slots, div_extra_slots,
2097 queue_fair_share, reserved_slots = 0, q, excess_need_queues = 0, unmovable_slots = 0;
2098 s32 i;
2099 q_t *sigq;
2100 u16 num_data_slots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
2101
2102 /* Calculate the pending queue length */
2103 sigq = &card->fh_traffic_queue[queue];
2104 q_len = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
2105
2106 if (q_len <= card->dynamic_slot_data.from_host_reserved_slots[queue])
2107 {
2108 unifi_trace(card->ospriv, UDBG5, "queue %d q_len %d already has that many reserved slots, exiting\n", queue, q_len);
2109 return;
2110 }
2111
2112 /* Upper limit */
2113 if (q_len > num_data_slots)
2114 {
2115 q_len = num_data_slots;
2116 }
2117
2118 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2119 {
2120 if (i != (s32)queue)
2121 {
2122 reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
2123 }
2124 if ((i == (s32)queue) || (card->dynamic_slot_data.from_host_reserved_slots[i] > 0))
2125 {
2126 active_queues++;
2127 }
2128 }
2129
2130 unifi_trace(card->ospriv, UDBG5, "CardCheckDynamicReservation: queue %d q_len %d\n", queue, q_len);
2131 unifi_trace(card->ospriv, UDBG5, "Active queues %d reserved slots on other queues %d\n",
2132 active_queues, reserved_slots);
2133
2134 if (reserved_slots + q_len <= num_data_slots)
2135 {
2136 card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
2137 if (q_len == num_data_slots)
2138 {
2139 /* This is the common case when just 1 stream is going */
2140 card->dynamic_slot_data.queue_stable[queue] = TRUE;
2141 }
2142 }
2143 else
2144 {
2145 queue_fair_share = num_data_slots / active_queues;
2146 unifi_trace(card->ospriv, UDBG5, "queue fair share %d\n", queue_fair_share);
2147
2148 /* Evenly distribute slots among active queues */
2149 /* Find out the queues that need excess of fair share. Also find slots allocated
2150 * to queues less than their fair share, these slots cannot be reallocated (unmovable slots) */
2151
2152 card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
2153
2154 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2155 {
2156 if (card->dynamic_slot_data.from_host_reserved_slots[i] > queue_fair_share)
2157 {
2158 excess_need_queues++;
2159 }
2160 else
2161 {
2162 unmovable_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
2163 }
2164 }
2165
2166 unifi_trace(card->ospriv, UDBG5, "Excess need queues %d\n", excess_need_queues);
2167
2168 /* Now find the slots per excess demand queue */
2169 excess_queue_slots = (num_data_slots - unmovable_slots) / excess_need_queues;
2170 div_extra_slots = (num_data_slots - unmovable_slots) - excess_queue_slots * excess_need_queues;
2171 for (i = UNIFI_NO_OF_TX_QS - 1; i >= 0; i--)
2172 {
2173 if (card->dynamic_slot_data.from_host_reserved_slots[i] > excess_queue_slots)
2174 {
2175 card->dynamic_slot_data.from_host_reserved_slots[i] = excess_queue_slots;
2176 if (div_extra_slots > 0)
2177 {
2178 card->dynamic_slot_data.from_host_reserved_slots[i]++;
2179 div_extra_slots--;
2180 }
2181 /* No more slots will be allocated to this queue during the current interval */
2182 card->dynamic_slot_data.queue_stable[i] = TRUE;
2183 unifi_trace(card->ospriv, UDBG5, "queue stable %d\n", i);
2184 }
2185 }
2186 }
2187
2188 /* Redistribute max slots */
2189 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
2190 {
2191 reserved_slots = 0;
2192 for (q = 0; q < UNIFI_NO_OF_TX_QS; q++)
2193 {
2194 if (i != q)
2195 {
2196 reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[q];
2197 }
2198 }
2199
2200 card->dynamic_slot_data.from_host_max_slots[i] = num_data_slots - reserved_slots;
2201 unifi_trace(card->ospriv, UDBG5, "queue %d reserved %d Max %d\n", i,
2202 card->dynamic_slot_data.from_host_reserved_slots[i],
2203 card->dynamic_slot_data.from_host_max_slots[i]);
2204 }
2205
2206}
2207
2208
2209/*
2210 * ---------------------------------------------------------------------------
2211 * CardClearFromHostDataSlot
2212 *
2213 * Clear a the given data slot, making it available again.
2214 *
2215 * Arguments:
2216 * card Pointer to Card object
2217 * slot Index of the signal slot to clear.
2218 *
2219 * Returns:
2220 * None.
2221 * ---------------------------------------------------------------------------
2222 */
2223void CardClearFromHostDataSlot(card_t *card, const s16 slot)
2224{
2225 u8 queue = card->from_host_data[slot].queue;
2226 const void *os_data_ptr = card->from_host_data[slot].bd.os_data_ptr;
2227
2228 if (card->from_host_data[slot].bd.data_length == 0)
2229 {
2230 unifi_warning(card->ospriv,
2231 "Surprise: request to clear an already free FH data slot: %d\n",
2232 slot);
2233 return;
2234 }
2235
2236 if (os_data_ptr == NULL)
2237 {
2238 unifi_warning(card->ospriv,
2239 "Clearing FH data slot %d: has null payload, len=%d\n",
2240 slot, card->from_host_data[slot].bd.data_length);
2241 }
2242
2243 /* Free card->from_host_data[slot].bd.os_net_ptr here. */
2244 /* Mark slot as free by setting length to 0. */
2245 unifi_free_bulk_data(card, &card->from_host_data[slot].bd);
2246 if (queue < UNIFI_NO_OF_TX_QS)
2247 {
2248 if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
2249 {
2250 unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
2251 queue,
2252 card->dynamic_slot_data.from_host_used_slots[queue]);
2253 }
2254 else
2255 {
2256 card->dynamic_slot_data.from_host_used_slots[queue]--;
2257 }
2258 card->dynamic_slot_data.packets_txed[queue]++;
2259 card->dynamic_slot_data.total_packets_txed++;
2260 if (card->dynamic_slot_data.total_packets_txed >= card->dynamic_slot_data.packets_interval)
2261 {
2262 CardReassignDynamicReservation(card);
2263 }
2264 }
2265
2266 unifi_trace(card->ospriv, UDBG4, "CardClearFromHostDataSlot: slot %d recycled %p\n", slot, os_data_ptr);
2267
2268} /* CardClearFromHostDataSlot() */
2269
2270
2271#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
2272/*
2273 * ---------------------------------------------------------------------------
2274 * CardClearFromHostDataSlotWithoutFreeingBulkData
2275 *
2276 * Clear the given data slot with out freeing the bulk data.
2277 *
2278 * Arguments:
2279 * card Pointer to Card object
2280 * slot Index of the signal slot to clear.
2281 *
2282 * Returns:
2283 * None.
2284 * ---------------------------------------------------------------------------
2285 */
2286void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 slot)
2287{
2288 u8 queue = card->from_host_data[slot].queue;
2289
2290 /* Initialise the from_host data slot so it can be re-used,
2291 * Set length field in from_host_data array to 0.
2292 */
2293 UNIFI_INIT_BULK_DATA(&card->from_host_data[slot].bd);
2294
2295 queue = card->from_host_data[slot].queue;
2296
2297 if (queue < UNIFI_NO_OF_TX_QS)
2298 {
2299 if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
2300 {
2301 unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
2302 queue,
2303 card->dynamic_slot_data.from_host_used_slots[queue]);
2304 }
2305 else
2306 {
2307 card->dynamic_slot_data.from_host_used_slots[queue]--;
2308 }
2309 card->dynamic_slot_data.packets_txed[queue]++;
2310 card->dynamic_slot_data.total_packets_txed++;
2311 if (card->dynamic_slot_data.total_packets_txed >=
2312 card->dynamic_slot_data.packets_interval)
2313 {
2314 CardReassignDynamicReservation(card);
2315 }
2316 }
2317} /* CardClearFromHostDataSlotWithoutFreeingBulkData() */
2318
2319
2320#endif
2321
2322u16 CardGetDataSlotSize(card_t *card)
2323{
2324 return card->config_data.data_slot_size;
2325} /* CardGetDataSlotSize() */
2326
2327
2328/*
2329 * ---------------------------------------------------------------------------
2330 * CardGetFreeFromHostDataSlots
2331 *
2332 * Retrieve the number of from-host bulk data slots available.
2333 *
2334 * Arguments:
2335 * card Pointer to the card context struct
2336 *
2337 * Returns:
2338 * Number of free from-host bulk data slots.
2339 * ---------------------------------------------------------------------------
2340 */
2341u16 CardGetFreeFromHostDataSlots(card_t *card)
2342{
2343 u16 i, n = 0;
2344
2345 /* First two slots reserved for MLME */
2346 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
2347 {
2348 if (card->from_host_data[i].bd.data_length == 0)
2349 {
2350 /* Free slot */
2351 n++;
2352 }
2353 }
2354
2355 return n;
2356} /* CardGetFreeFromHostDataSlots() */
2357
2358
2359/*
2360 * ---------------------------------------------------------------------------
2361 * CardAreAllFromHostDataSlotsEmpty
2362 *
2363 * Returns the state of from-host bulk data slots.
2364 *
2365 * Arguments:
2366 * card Pointer to the card context struct
2367 *
2368 * Returns:
2369 * 1 The from-host bulk data slots are all empty (available).
2370 * 0 Some or all the from-host bulk data slots are in use.
2371 * ---------------------------------------------------------------------------
2372 */
2373u16 CardAreAllFromHostDataSlotsEmpty(card_t *card)
2374{
2375 u16 i;
2376
2377 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
2378 {
2379 if (card->from_host_data[i].bd.data_length != 0)
2380 {
2381 return 0;
2382 }
2383 }
2384
2385 return 1;
2386} /* CardGetFreeFromHostDataSlots() */
2387
2388
2389static CsrResult unifi_identify_hw(card_t *card)
2390{
2391
2392 card->chip_id = card->sdio_if->sdioId.cardId;
2393 card->function = card->sdio_if->sdioId.sdioFunction;
2394 card->sdio_io_block_size = card->sdio_if->blockSize;
2395
2396 /* If SDIO controller doesn't support byte mode CMD53, pad transfers to block sizes */
2397 card->sdio_io_block_pad = (card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)?FALSE : TRUE;
2398
2399 /*
2400 * Setup the chip helper so that we can access the registers (and
2401 * also tell what sub-type of HIP we should use).
2402 */
2403 card->helper = ChipHelper_GetVersionSdio((u8)card->chip_id);
2404 if (!card->helper)
2405 {
2406 unifi_error(card->ospriv, "Null ChipHelper\n");
2407 }
2408
2409 unifi_info(card->ospriv, "Chip ID 0x%02X Function %u Block Size %u Name %s(%s)\n",
2410 card->chip_id, card->function, card->sdio_io_block_size,
2411 ChipHelper_MarketingName(card->helper),
2412 ChipHelper_FriendlyName(card->helper));
2413
2414 return CSR_RESULT_SUCCESS;
2415} /* unifi_identify_hw() */
2416
2417
2418static CsrResult unifi_prepare_hw(card_t *card)
2419{
2420 CsrResult r;
2421 CsrResult csrResult;
2422 enum unifi_host_state old_state = card->host_state;
2423
2424 r = unifi_identify_hw(card);
2425 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2426 {
2427 return r;
2428 }
2429 if (r != CSR_RESULT_SUCCESS)
2430 {
2431 unifi_error(card->ospriv, "Failed to identify hw\n");
2432 return r;
2433 }
2434
2435 unifi_trace(card->ospriv, UDBG1,
2436 "%s mode SDIO\n", card->sdio_io_block_pad?"Block" : "Byte");
2437 /*
2438 * Chip must be a awake or blocks that are asleep may not get
2439 * reset. We can only do this after we have read the chip_id.
2440 */
2441 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
2442 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2443 {
2444 return r;
2445 }
2446
2447 if (old_state == UNIFI_HOST_STATE_TORPID)
2448 {
2449 /* Ensure the initial clock rate is set; if a reset occurred when the chip was
2450 * TORPID, unifi_set_host_state() may have raised it to MAX.
2451 */
2452 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
2453 if (csrResult != CSR_RESULT_SUCCESS)
2454 {
2455 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2456 return r;
2457 }
2458 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
2459 }
2460
2461 /*
2462 * The WLAN function must be enabled to access MAILBOX2 and DEBUG_RST
2463 * registers.
2464 */
2465 csrResult = CsrSdioFunctionEnable(card->sdio_if);
2466 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2467 {
2468 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2469 }
2470 if (csrResult != CSR_RESULT_SUCCESS)
2471 {
2472 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2473 /* Can't enable WLAN function. Try resetting the SDIO block. */
2474 unifi_error(card->ospriv, "Failed to re-enable function %d.\n", card->function);
2475 return r;
2476 }
2477
2478 /*
2479 * Poke some registers to make sure the PLL has started,
2480 * otherwise memory accesses are likely to fail.
2481 */
2482 bootstrap_chip_hw(card);
2483
2484 /* Try to read the chip version from register. */
2485 r = unifi_read_chip_version(card);
2486 if (r != CSR_RESULT_SUCCESS)
2487 {
2488 return r;
2489 }
2490
2491 return CSR_RESULT_SUCCESS;
2492} /* unifi_prepare_hw() */
2493
2494
2495static CsrResult unifi_read_chip_version(card_t *card)
2496{
2497 u32 gbl_chip_version;
2498 CsrResult r;
2499 u16 ver;
2500
2501 gbl_chip_version = ChipHelper_GBL_CHIP_VERSION(card->helper);
2502
2503 /* Try to read the chip version from register. */
2504 if (gbl_chip_version != 0)
2505 {
2506 r = unifi_read_direct16(card, gbl_chip_version * 2, &ver);
2507 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2508 {
2509 return r;
2510 }
2511 if (r != CSR_RESULT_SUCCESS)
2512 {
2513 unifi_error(card->ospriv, "Failed to read GBL_CHIP_VERSION\n");
2514 return r;
2515 }
2516 card->chip_version = ver;
2517 }
2518 else
2519 {
2520 unifi_info(card->ospriv, "Unknown Chip ID, cannot locate GBL_CHIP_VERSION\n");
2521 r = CSR_RESULT_FAILURE;
2522 }
2523
2524 unifi_info(card->ospriv, "Chip Version 0x%04X\n", card->chip_version);
2525
2526 return r;
2527} /* unifi_read_chip_version() */
2528
2529
2530/*
2531 * ---------------------------------------------------------------------------
2532 * unifi_reset_hardware
2533 *
2534 * Execute the UniFi reset sequence.
2535 *
2536 * Note: This may fail if the chip is going TORPID so retry at
2537 * least once.
2538 *
2539 * Arguments:
2540 * card - pointer to card context structure
2541 *
2542 * Returns:
2543 * CSR_RESULT_SUCCESS on success, CSR error otherwise.
2544 *
2545 * Notes:
2546 * Some platforms (e.g. Windows Vista) do not allow access to registers
2547 * that are necessary for a software soft reset.
2548 * ---------------------------------------------------------------------------
2549 */
2550static CsrResult unifi_reset_hardware(card_t *card)
2551{
2552 CsrResult r;
2553 u16 new_block_size = UNIFI_IO_BLOCK_SIZE;
2554 CsrResult csrResult;
2555
2556 /* Errors returned by unifi_prepare_hw() are not critical at this point */
2557 r = unifi_prepare_hw(card);
2558 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2559 {
2560 return r;
2561 }
2562
2563 /* First try SDIO controller reset, which may power cycle the UniFi, assert
2564 * its reset line, or not be implemented depending on the platform.
2565 */
2566 unifi_info(card->ospriv, "Calling CsrSdioHardReset\n");
2567 csrResult = CsrSdioHardReset(card->sdio_if);
2568 if (csrResult == CSR_RESULT_SUCCESS)
2569 {
2570 unifi_info(card->ospriv, "CsrSdioHardReset succeeded on resetting UniFi\n");
2571 r = unifi_prepare_hw(card);
2572 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2573 {
2574 return r;
2575 }
2576 if (r != CSR_RESULT_SUCCESS)
2577 {
2578 unifi_error(card->ospriv, "unifi_prepare_hw failed after hard reset\n");
2579 return r;
2580 }
2581 }
2582 else if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2583 {
2584 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2585 }
2586 else
2587 {
2588 /* Falling back to software hard reset methods */
2589 unifi_info(card->ospriv, "Falling back to software hard reset\n");
2590 r = unifi_card_hard_reset(card);
2591 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2592 {
2593 return r;
2594 }
2595 if (r != CSR_RESULT_SUCCESS)
2596 {
2597 unifi_error(card->ospriv, "software hard reset failed\n");
2598 return r;
2599 }
2600
2601 /* If we fell back to unifi_card_hard_reset() methods, chip version may
2602 * not have been read. (Note in the unlikely event that it is zero,
2603 * it will be harmlessly read again)
2604 */
2605 if (card->chip_version == 0)
2606 {
2607 r = unifi_read_chip_version(card);
2608 if (r != CSR_RESULT_SUCCESS)
2609 {
2610 return r;
2611 }
2612 }
2613 }
2614
2615#ifdef CSR_WIFI_HIP_SDIO_BLOCK_SIZE
2616 new_block_size = CSR_WIFI_HIP_SDIO_BLOCK_SIZE;
2617#endif
2618
2619 /* After hard reset, we need to restore the SDIO block size */
2620 csrResult = CsrSdioBlockSizeSet(card->sdio_if, new_block_size);
2621 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2622
2623 /* Warn if a different block size was achieved by the transport */
2624 if (card->sdio_if->blockSize != new_block_size)
2625 {
2626 unifi_info(card->ospriv,
2627 "Actually got block size %d\n", card->sdio_if->blockSize);
2628 }
2629
2630 /* sdio_io_block_size always needs be updated from the achieved block size,
2631 * as it is used by the OS layer to allocate memory in unifi_net_malloc().
2632 * Controllers which don't support block mode (e.g. CSPI) will report a
2633 * block size of zero.
2634 */
2635 if (card->sdio_if->blockSize == 0)
2636 {
2637 unifi_info(card->ospriv, "Block size 0, block mode not available\n");
2638
2639 /* Set sdio_io_block_size to 1 so that unifi_net_data_malloc() has a
2640 * sensible rounding value. Elsewhere padding will already be
2641 * disabled because the controller supports byte mode.
2642 */
2643 card->sdio_io_block_size = 1;
2644
2645 /* Controller features must declare support for byte mode */
2646 if (!(card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE))
2647 {
2648 unifi_error(card->ospriv, "Requires byte mode\n");
2649 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2650 }
2651 }
2652 else
2653 {
2654 /* Padding will be enabled if CSR_SDIO_FEATURE_BYTE_MODE isn't set */
2655 card->sdio_io_block_size = card->sdio_if->blockSize;
2656 }
2657
2658
2659 return r;
2660} /* unifi_reset_hardware() */
2661
2662
2663/*
2664 * ---------------------------------------------------------------------------
2665 * card_reset_method_io_enable
2666 *
2667 * Issue a hard reset to the hw writing the IO_ENABLE.
2668 *
2669 * Arguments:
2670 * card Pointer to Card object
2671 *
2672 * Returns:
2673 * 0 on success,
2674 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2675 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2676 * was not seen in the expected time
2677 * ---------------------------------------------------------------------------
2678 */
2679static CsrResult card_reset_method_io_enable(card_t *card)
2680{
2681 CsrResult r;
2682 CsrResult csrResult;
2683
2684 /*
2685 * This resets only function 1, so should be used in
2686 * preference to the method below (CSR_FUNC_EN)
2687 */
2688 unifi_trace(card->ospriv, UDBG1, "Hard reset (IO_ENABLE)\n");
2689
2690 csrResult = CsrSdioFunctionDisable(card->sdio_if);
2691 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
2692 {
2693 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
2694 }
2695 if (csrResult != CSR_RESULT_SUCCESS)
2696 {
2697 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
2698 unifi_warning(card->ospriv, "SDIO error writing IO_ENABLE: %d\n", r);
2699 }
2700 else
2701 {
2702 /* Delay here to let the reset take affect. */
2703 CsrThreadSleep(RESET_SETTLE_DELAY);
2704
2705 r = card_wait_for_unifi_to_disable(card);
2706 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2707 {
2708 return r;
2709 }
2710
2711 if (r == CSR_RESULT_SUCCESS)
2712 {
2713 r = card_wait_for_unifi_to_reset(card);
2714 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2715 {
2716 return r;
2717 }
2718 }
2719 }
2720
2721 if (r != CSR_RESULT_SUCCESS)
2722 {
2723 unifi_trace(card->ospriv, UDBG1, "Hard reset (CSR_FUNC_EN)\n");
2724
2725 r = sdio_write_f0(card, SDIO_CSR_FUNC_EN, 0);
2726 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2727 {
2728 return r;
2729 }
2730 if (r != CSR_RESULT_SUCCESS)
2731 {
2732 unifi_warning(card->ospriv, "SDIO error writing SDIO_CSR_FUNC_EN: %d\n", r);
2733 return r;
2734 }
2735 else
2736 {
2737 /* Delay here to let the reset take affect. */
2738 CsrThreadSleep(RESET_SETTLE_DELAY);
2739
2740 r = card_wait_for_unifi_to_reset(card);
2741 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2742 {
2743 return r;
2744 }
2745 }
2746 }
2747
2748 if (r != CSR_RESULT_SUCCESS)
2749 {
2750 unifi_warning(card->ospriv, "card_reset_method_io_enable failed to reset UniFi\n");
2751 }
2752
2753 return r;
2754} /* card_reset_method_io_enable() */
2755
2756
2757/*
2758 * ---------------------------------------------------------------------------
2759 * card_reset_method_dbg_reset
2760 *
2761 * Issue a hard reset to the hw writing the DBG_RESET.
2762 *
2763 * Arguments:
2764 * card Pointer to Card object
2765 *
2766 * Returns:
2767 * CSR_RESULT_SUCCESS on success,
2768 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2769 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2770 * was not seen in the expected time
2771 * ---------------------------------------------------------------------------
2772 */
2773static CsrResult card_reset_method_dbg_reset(card_t *card)
2774{
2775 CsrResult r;
2776
2777 /*
2778 * Prepare UniFi for h/w reset
2779 */
2780 if (card->host_state == UNIFI_HOST_STATE_TORPID)
2781 {
2782 r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
2783 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2784 {
2785 return r;
2786 }
2787 if (r != CSR_RESULT_SUCCESS)
2788 {
2789 unifi_error(card->ospriv, "Failed to set UNIFI_HOST_STATE_DROWSY\n");
2790 return r;
2791 }
2792 CsrThreadSleep(5);
2793 }
2794
2795 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
2796 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2797 {
2798 return r;
2799 }
2800 if (r != CSR_RESULT_SUCCESS)
2801 {
2802 unifi_error(card->ospriv, "Can't stop processors\n");
2803 return r;
2804 }
2805
2806 unifi_trace(card->ospriv, UDBG1, "Hard reset (DBG_RESET)\n");
2807
2808 /*
2809 * This register write may fail. The debug reset resets
2810 * parts of the Function 0 sections of the chip, and
2811 * therefore the response cannot be sent back to the host.
2812 */
2813 r = unifi_write_direct_8_or_16(card, ChipHelper_DBG_RESET(card->helper) * 2, 1);
2814 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2815 {
2816 return r;
2817 }
2818 if (r != CSR_RESULT_SUCCESS)
2819 {
2820 unifi_warning(card->ospriv, "SDIO error writing DBG_RESET: %d\n", r);
2821 return r;
2822 }
2823
2824 /* Delay here to let the reset take affect. */
2825 CsrThreadSleep(RESET_SETTLE_DELAY);
2826
2827 r = card_wait_for_unifi_to_reset(card);
2828 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2829 {
2830 return r;
2831 }
2832 if (r != CSR_RESULT_SUCCESS)
2833 {
2834 unifi_warning(card->ospriv, "card_reset_method_dbg_reset failed to reset UniFi\n");
2835 }
2836
2837 return r;
2838} /* card_reset_method_dbg_reset() */
2839
2840
2841/*
2842 * ---------------------------------------------------------------------------
2843 * unifi_card_hard_reset
2844 *
2845 * Issue reset to hardware, by writing to registers on the card.
2846 * Power to the card is preserved.
2847 *
2848 * Arguments:
2849 * card Pointer to Card object
2850 *
2851 * Returns:
2852 * CSR_RESULT_SUCCESS on success,
2853 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2854 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2855 * was not seen in the expected time
2856 * ---------------------------------------------------------------------------
2857 */
2858CsrResult unifi_card_hard_reset(card_t *card)
2859{
2860 CsrResult r;
2861 const struct chip_helper_reset_values *init_data;
2862 u32 chunks;
2863
2864 /* Clear cache of page registers */
2865 card->proc_select = (u32)(-1);
2866 card->dmem_page = (u32)(-1);
2867 card->pmem_page = (u32)(-1);
2868
2869 /*
2870 * We need to have a valid card->helper before we use software hard reset.
2871 * If unifi_identify_hw() fails to get the card ID, it probably means
2872 * that there is no way to talk to the h/w.
2873 */
2874 r = unifi_identify_hw(card);
2875 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2876 {
2877 return r;
2878 }
2879 if (r != CSR_RESULT_SUCCESS)
2880 {
2881 unifi_error(card->ospriv, "unifi_card_hard_reset failed to identify h/w\n");
2882 return r;
2883 }
2884
2885 /* Search for some reset code. */
2886 chunks = ChipHelper_HostResetSequence(card->helper, &init_data);
2887 if (chunks != 0)
2888 {
2889 unifi_error(card->ospriv,
2890 "Hard reset (Code download) is unsupported\n");
2891
2892 return CSR_RESULT_FAILURE;
2893 }
2894
2895 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
2896 {
2897 /* The HIP spec considers this a bus-specific reset.
2898 * This resets only function 1, so should be used in
2899 * preference to the method below (CSR_FUNC_EN)
2900 * If this method fails, it means that the f/w is probably
2901 * not running. In this case, try the DBG_RESET method.
2902 */
2903 r = card_reset_method_io_enable(card);
2904 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2905 {
2906 return r;
2907 }
2908 if (r == CSR_RESULT_SUCCESS)
2909 {
2910 return r;
2911 }
2912 }
2913
2914 /* Software hard reset */
2915 r = card_reset_method_dbg_reset(card);
2916
2917 return r;
2918} /* unifi_card_hard_reset() */
2919
2920
2921/*
2922 * ---------------------------------------------------------------------------
2923 *
2924 * CardGenInt
2925 *
2926 * Prod the card.
2927 * This function causes an internal interrupt to be raised in the
2928 * UniFi chip. It is used to signal the firmware that some action has
2929 * been completed.
2930 * The UniFi Host Interface asks that the value used increments for
2931 * debugging purposes.
2932 *
2933 * Arguments:
2934 * card Pointer to Card object
2935 *
2936 * Returns:
2937 * CSR_RESULT_SUCCESS on success,
2938 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2939 * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
2940 * was not seen in the expected time
2941 * ---------------------------------------------------------------------------
2942 */
2943CsrResult CardGenInt(card_t *card)
2944{
2945 CsrResult r;
2946
2947 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
2948 {
2949 r = sdio_write_f0(card, SDIO_CSR_FROM_HOST_SCRATCH0,
2950 (u8)card->unifi_interrupt_seq);
2951 }
2952 else
2953 {
2954 r = unifi_write_direct_8_or_16(card,
2955 ChipHelper_SHARED_IO_INTERRUPT(card->helper) * 2,
2956 (u8)card->unifi_interrupt_seq);
2957 }
2958 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2959 {
2960 return r;
2961 }
2962 if (r != CSR_RESULT_SUCCESS)
2963 {
2964 unifi_error(card->ospriv, "SDIO error writing UNIFI_SHARED_IO_INTERRUPT: %d\n", r);
2965 return r;
2966 }
2967
2968 card->unifi_interrupt_seq++;
2969
2970 return CSR_RESULT_SUCCESS;
2971} /* CardGenInt() */
2972
2973
2974/*
2975 * ---------------------------------------------------------------------------
2976 * CardEnableInt
2977 *
2978 * Enable the outgoing SDIO interrupt from UniFi to the host.
2979 *
2980 * Arguments:
2981 * card Pointer to Card object
2982 *
2983 * Returns:
2984 * CSR_RESULT_SUCCESS on success,
2985 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
2986 * CSR_RESULT_FAILURE if an SDIO error occurred,
2987 * ---------------------------------------------------------------------------
2988 */
2989CsrResult CardEnableInt(card_t *card)
2990{
2991 CsrResult r;
2992 u8 int_enable;
2993
2994 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
2995 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2996 {
2997 return r;
2998 }
2999 if (r != CSR_RESULT_SUCCESS)
3000 {
3001 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3002 return r;
3003 }
3004
3005 int_enable |= (1 << card->function) | UNIFI_SD_INT_ENABLE_IENM;
3006
3007 r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
3008 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3009 {
3010 return r;
3011 }
3012 if (r != CSR_RESULT_SUCCESS)
3013 {
3014 unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
3015 return r;
3016 }
3017
3018 return CSR_RESULT_SUCCESS;
3019} /* CardEnableInt() */
3020
3021
3022/*
3023 * ---------------------------------------------------------------------------
3024 * CardDisableInt
3025 *
3026 * Disable the outgoing SDIO interrupt from UniFi to the host.
3027 *
3028 * Arguments:
3029 * card Pointer to Card object
3030 *
3031 * Returns:
3032 * CSR_RESULT_SUCCESS on success,
3033 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3034 * CSR_RESULT_FAILURE if an SDIO error occurred,
3035 * ---------------------------------------------------------------------------
3036 */
3037CsrResult CardDisableInt(card_t *card)
3038{
3039 CsrResult r;
3040 u8 int_enable;
3041
3042 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
3043 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3044 {
3045 return r;
3046 }
3047 if (r != CSR_RESULT_SUCCESS)
3048 {
3049 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3050 return r;
3051 }
3052
3053 int_enable &= ~(1 << card->function);
3054
3055 r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
3056 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3057 {
3058 return r;
3059 }
3060 if (r != CSR_RESULT_SUCCESS)
3061 {
3062 unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
3063 return r;
3064 }
3065
3066 return CSR_RESULT_SUCCESS;
3067} /* CardDisableInt() */
3068
3069
3070/*
3071 * ---------------------------------------------------------------------------
3072 * CardPendingInt
3073 *
3074 * Determine whether UniFi is currently asserting the SDIO interrupt
3075 * request.
3076 *
3077 * Arguments:
3078 * card Pointer to Card object
3079 * pintr Pointer to location to write interrupt status,
3080 * TRUE if interrupt pending,
3081 * FALSE if no interrupt pending.
3082 * Returns:
3083 * CSR_RESULT_SUCCESS interrupt status read successfully
3084 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3085 * CSR_RESULT_FAILURE if an SDIO error occurred,
3086 * ---------------------------------------------------------------------------
3087 */
3088CsrResult CardPendingInt(card_t *card, u8 *pintr)
3089{
3090 CsrResult r;
3091 u8 pending;
3092
3093 *pintr = FALSE;
3094
3095 r = sdio_read_f0(card, SDIO_INT_PENDING, &pending);
3096 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3097 {
3098 return r;
3099 }
3100 if (r != CSR_RESULT_SUCCESS)
3101 {
3102 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_PENDING\n");
3103 return r;
3104 }
3105
3106 *pintr = (pending & (1 << card->function))?TRUE : FALSE;
3107
3108 return CSR_RESULT_SUCCESS;
3109} /* CardPendingInt() */
3110
3111
3112/*
3113 * ---------------------------------------------------------------------------
3114 * CardClearInt
3115 *
3116 * Clear the UniFi SDIO interrupt request.
3117 *
3118 * Arguments:
3119 * card Pointer to Card object
3120 *
3121 * Returns:
3122 * CSR_RESULT_SUCCESS if pending interrupt was cleared, or no pending interrupt.
3123 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3124 * CSR_RESULT_FAILURE if an SDIO error occurred,
3125 * ---------------------------------------------------------------------------
3126 */
3127CsrResult CardClearInt(card_t *card)
3128{
3129 CsrResult r;
3130 u8 intr;
3131
3132 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
3133 {
3134 /* CardPendingInt() sets intr, if there is a pending interrupt */
3135 r = CardPendingInt(card, &intr);
3136 if (intr == FALSE)
3137 {
3138 return r;
3139 }
3140
3141 r = sdio_write_f0(card, SDIO_CSR_HOST_INT_CLEAR, 1);
3142 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3143 {
3144 return r;
3145 }
3146 if (r != CSR_RESULT_SUCCESS)
3147 {
3148 unifi_error(card->ospriv, "SDIO error writing SDIO_CSR_HOST_INT_CLEAR\n");
3149 }
3150 }
3151 else
3152 {
3153 r = unifi_write_direct_8_or_16(card,
3154 ChipHelper_SDIO_HOST_INT(card->helper) * 2,
3155 0);
3156 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3157 {
3158 return r;
3159 }
3160 if (r != CSR_RESULT_SUCCESS)
3161 {
3162 unifi_error(card->ospriv, "SDIO error writing UNIFI_SDIO_HOST_INT\n");
3163 }
3164 }
3165
3166 return r;
3167} /* CardClearInt() */
3168
3169
3170/*
3171 * ---------------------------------------------------------------------------
3172 * CardIntEnabled
3173 *
3174 * Determine whether UniFi is currently asserting the SDIO interrupt
3175 * request.
3176 *
3177 * Arguments:
3178 * card Pointer to Card object
3179 * enabled Pointer to location to write interrupt enable status,
3180 * TRUE if interrupts enabled,
3181 * FALSE if interupts disabled.
3182 *
3183 * Returns:
3184 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3185 * CSR_RESULT_FAILURE if an SDIO error occurred,
3186 * ---------------------------------------------------------------------------
3187 */
3188CsrResult CardIntEnabled(card_t *card, u8 *enabled)
3189{
3190 CsrResult r;
3191 u8 int_enable;
3192
3193 r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
3194 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3195 {
3196 return r;
3197 }
3198 if (r != CSR_RESULT_SUCCESS)
3199 {
3200 unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
3201 return r;
3202 }
3203
3204 *enabled = (int_enable & (1 << card->function))?TRUE : FALSE;
3205
3206 return CSR_RESULT_SUCCESS;
3207} /* CardIntEnabled() */
3208
3209
3210/*
3211 * ---------------------------------------------------------------------------
3212 * CardWriteBulkData
3213 * Allocate slot in the pending bulkdata arrays and assign it to a signal's
3214 * bulkdata reference. The slot is then ready for UniFi's bulkdata commands
3215 * to transfer the data to/from the host.
3216 *
3217 * Arguments:
3218 * card Pointer to Card object
3219 * csptr Pending signal pointer, including bulkdata ref
3220 * queue Traffic queue that this signal is using
3221 *
3222 * Returns:
3223 * CSR_RESULT_SUCCESS if a free slot was assigned
3224 * CSR_RESULT_FAILURE if no slot was available
3225 * ---------------------------------------------------------------------------
3226 */
3227CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue)
3228{
3229 u16 i, slots[UNIFI_MAX_DATA_REFERENCES], j = 0;
3230 u8 *packed_sigptr, num_slots_required = 0;
3231 bulk_data_desc_t *bulkdata = csptr->bulkdata;
3232 s16 h, nslots;
3233
3234 /* Count the number of slots required */
3235 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
3236 {
3237 if (bulkdata[i].data_length != 0)
3238 {
3239 num_slots_required++;
3240 }
3241 }
3242
3243 /* Get the slot numbers */
3244 if (num_slots_required != 0)
3245 {
3246 /* Last 2 slots for MLME */
3247 if (queue == UNIFI_TRAFFIC_Q_MLME)
3248 {
3249 h = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
3250 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
3251 {
3252 if (card->from_host_data[h].bd.data_length == 0)
3253 {
3254 /* Free data slot, claim it */
3255 slots[j++] = h;
3256 if (j == num_slots_required)
3257 {
3258 break;
3259 }
3260 }
3261
3262 if (++h >= card->config_data.num_fromhost_data_slots)
3263 {
3264 h = 0;
3265 }
3266 }
3267 }
3268 else
3269 {
3270 if (card->dynamic_slot_data.from_host_used_slots[queue]
3271 < card->dynamic_slot_data.from_host_max_slots[queue])
3272 {
3273 /* Data commands get a free slot only after a few checks */
3274 nslots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
3275
3276 h = card->from_host_data_head;
3277
3278 for (i = 0; i < nslots; i++)
3279 {
3280 if (card->from_host_data[h].bd.data_length == 0)
3281 {
3282 /* Free data slot, claim it */
3283 slots[j++] = h;
3284 if (j == num_slots_required)
3285 {
3286 break;
3287 }
3288 }
3289
3290 if (++h >= nslots)
3291 {
3292 h = 0;
3293 }
3294 }
3295 card->from_host_data_head = h;
3296 }
3297 }
3298
3299 /* Required number of slots are not available, bail out */
3300 if (j != num_slots_required)
3301 {
3302 unifi_trace(card->ospriv, UDBG5, "CardWriteBulkData: didn't find free slot/s\n");
3303
3304 /* If we haven't already reached the stable state we can ask for reservation */
3305 if ((queue != UNIFI_TRAFFIC_Q_MLME) && (card->dynamic_slot_data.queue_stable[queue] == FALSE))
3306 {
3307 CardCheckDynamicReservation(card, queue);
3308 }
3309
3310 for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
3311 {
3312 unifi_trace(card->ospriv, UDBG5, "fh data slot %d: %d\n", i, card->from_host_data[i].bd.data_length);
3313 }
3314 return CSR_RESULT_FAILURE;
3315 }
3316 }
3317
3318 packed_sigptr = csptr->sigbuf;
3319
3320 /* Fill in the slots with data */
3321 j = 0;
3322 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
3323 {
3324 if (bulkdata[i].data_length == 0)
3325 {
3326 /* Zero-out the DATAREF in the signal */
3327 SET_PACKED_DATAREF_SLOT(packed_sigptr, i, 0);
3328 SET_PACKED_DATAREF_LEN(packed_sigptr, i, 0);
3329 }
3330 else
3331 {
3332 /*
3333 * Fill in the slot number in the SIGNAL structure but
3334 * preserve the offset already in there
3335 */
3336 SET_PACKED_DATAREF_SLOT(packed_sigptr, i, slots[j] | (((u16)packed_sigptr[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1]) << 8));
3337 SET_PACKED_DATAREF_LEN(packed_sigptr, i, bulkdata[i].data_length);
3338
3339 /* Do not copy the data, just store the information to them */
3340 card->from_host_data[slots[j]].bd.os_data_ptr = bulkdata[i].os_data_ptr;
3341 card->from_host_data[slots[j]].bd.os_net_buf_ptr = bulkdata[i].os_net_buf_ptr;
3342 card->from_host_data[slots[j]].bd.data_length = bulkdata[i].data_length;
3343 card->from_host_data[slots[j]].bd.net_buf_length = bulkdata[i].net_buf_length;
3344 card->from_host_data[slots[j]].queue = queue;
3345
3346 unifi_trace(card->ospriv, UDBG4, "CardWriteBulkData sig=0x%x, fh slot %d = %p\n",
3347 GET_SIGNAL_ID(packed_sigptr), i, bulkdata[i].os_data_ptr);
3348
3349 /* Sanity-check that the bulk data desc being assigned to the slot
3350 * actually has a payload.
3351 */
3352 if (!bulkdata[i].os_data_ptr)
3353 {
3354 unifi_error(card->ospriv, "Assign null os_data_ptr (len=%d) fh slot %d, i=%d, q=%d, sig=0x%x",
3355 bulkdata[i].data_length, slots[j], i, queue, GET_SIGNAL_ID(packed_sigptr));
3356 }
3357
3358 j++;
3359 if (queue < UNIFI_NO_OF_TX_QS)
3360 {
3361 card->dynamic_slot_data.from_host_used_slots[queue]++;
3362 }
3363 }
3364 }
3365
3366 return CSR_RESULT_SUCCESS;
3367} /* CardWriteBulkData() */
3368
3369
3370/*
3371 * ---------------------------------------------------------------------------
3372 * card_find_data_slot
3373 *
3374 * Dereference references to bulk data slots into pointers to real data.
3375 *
3376 * Arguments:
3377 * card Pointer to the card struct.
3378 * slot Slot number from a signal structure
3379 *
3380 * Returns:
3381 * Pointer to entry in bulk_data_slot array.
3382 * ---------------------------------------------------------------------------
3383 */
3384bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot)
3385{
3386 s16 sn;
3387 bulk_data_desc_t *bd;
3388
3389 sn = slot & 0x7FFF;
3390
3391 /* ?? check sanity of slot number ?? */
3392
3393 if (slot & SLOT_DIR_TO_HOST)
3394 {
3395 bd = &card->to_host_data[sn];
3396 }
3397 else
3398 {
3399 bd = &card->from_host_data[sn].bd;
3400 }
3401
3402 return bd;
3403} /* card_find_data_slot() */
3404
3405
3406/*
3407 * ---------------------------------------------------------------------------
3408 * firmware_present_in_flash
3409 *
3410 * Probe for external Flash that looks like it might contain firmware.
3411 *
3412 * If Flash is not present, reads always return 0x0008.
3413 * If Flash is present, but empty, reads return 0xFFFF.
3414 * Anything else is considered to be firmware.
3415 *
3416 * Arguments:
3417 * card Pointer to card struct
3418 *
3419 * Returns:
3420 * CSR_RESULT_SUCCESS firmware is present in ROM or flash
3421 * CSR_WIFI_HIP_RESULT_NOT_FOUND firmware is not present in ROM or flash
3422 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3423 * CSR_RESULT_FAILURE if an SDIO error occurred
3424 * ---------------------------------------------------------------------------
3425 */
3426static CsrResult firmware_present_in_flash(card_t *card)
3427{
3428 CsrResult r;
3429 u16 m1, m5;
3430
3431 if (ChipHelper_HasRom(card->helper))
3432 {
3433 return CSR_RESULT_SUCCESS;
3434 }
3435 if (!ChipHelper_HasFlash(card->helper))
3436 {
3437 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
3438 }
3439
3440 /*
3441 * Examine the Flash locations that are the power-on default reset
3442 * vectors of the XAP processors.
3443 * These are words 1 and 5 in Flash.
3444 */
3445 r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 2), &m1);
3446 if (r != CSR_RESULT_SUCCESS)
3447 {
3448 return r;
3449 }
3450
3451 r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 10), &m5);
3452 if (r != CSR_RESULT_SUCCESS)
3453 {
3454 return r;
3455 }
3456
3457 /* Check for uninitialised/missing flash */
3458 if ((m1 == 0x0008) || (m1 == 0xFFFF) ||
3459 (m1 == 0x0004) || (m5 == 0x0004) ||
3460 (m5 == 0x0008) || (m5 == 0xFFFF))
3461 {
3462 return CSR_WIFI_HIP_RESULT_NOT_FOUND;
3463 }
3464
3465 return CSR_RESULT_SUCCESS;
3466} /* firmware_present_in_flash() */
3467
3468
3469/*
3470 * ---------------------------------------------------------------------------
3471 * bootstrap_chip_hw
3472 *
3473 * Perform chip specific magic to "Get It Working" TM. This will
3474 * increase speed of PLLs in analogue and maybe enable some
3475 * on-chip regulators.
3476 *
3477 * Arguments:
3478 * card Pointer to card struct
3479 *
3480 * Returns:
3481 * None.
3482 * ---------------------------------------------------------------------------
3483 */
3484static void bootstrap_chip_hw(card_t *card)
3485{
3486 const struct chip_helper_init_values *vals;
3487 u32 i, len;
3488 void *sdio = card->sdio_if;
3489 CsrResult csrResult;
3490
3491 len = ChipHelper_ClockStartupSequence(card->helper, &vals);
3492 if (len != 0)
3493 {
3494 for (i = 0; i < len; i++)
3495 {
3496 csrResult = CsrSdioWrite16(sdio, vals[i].addr * 2, vals[i].value);
3497 if (csrResult != CSR_RESULT_SUCCESS)
3498 {
3499 unifi_warning(card->ospriv, "Failed to write bootstrap value %d\n", i);
3500 /* Might not be fatal */
3501 }
3502
3503 CsrThreadSleep(1);
3504 }
3505 }
3506} /* bootstrap_chip_hw() */
3507
3508
3509/*
3510 * ---------------------------------------------------------------------------
3511 * unifi_card_stop_processor
3512 *
3513 * Stop the UniFi XAP processors.
3514 *
3515 * Arguments:
3516 * card Pointer to card struct
3517 * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
3518 *
3519 * Returns:
3520 * CSR_RESULT_SUCCESS if successful, or CSR error code
3521 * ---------------------------------------------------------------------------
3522 */
3523CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which)
3524{
3525 CsrResult r = CSR_RESULT_SUCCESS;
3526 u8 status;
3527 s16 retry = 100;
3528
3529 while (retry--)
3530 {
3531 /* Select both XAPs */
3532 r = unifi_set_proc_select(card, which);
3533 if (r != CSR_RESULT_SUCCESS)
3534 {
3535 break;
3536 }
3537
3538 /* Stop processors */
3539 r = unifi_write_direct16(card, ChipHelper_DBG_EMU_CMD(card->helper) * 2, 2);
3540 if (r != CSR_RESULT_SUCCESS)
3541 {
3542 break;
3543 }
3544
3545 /* Read status */
3546 r = unifi_read_direct_8_or_16(card,
3547 ChipHelper_DBG_HOST_STOP_STATUS(card->helper) * 2,
3548 &status);
3549 if (r != CSR_RESULT_SUCCESS)
3550 {
3551 break;
3552 }
3553
3554 if ((status & 1) == 1)
3555 {
3556 /* Success! */
3557 return CSR_RESULT_SUCCESS;
3558 }
3559
3560 /* Processors didn't stop, try again */
3561 }
3562
3563 if (r != CSR_RESULT_SUCCESS)
3564 {
3565 /* An SDIO error occurred */
3566 unifi_error(card->ospriv, "Failed to stop processors: SDIO error\n");
3567 }
3568 else
3569 {
3570 /* If we reach here, we didn't the status in time. */
3571 unifi_error(card->ospriv, "Failed to stop processors: timeout waiting for stopped status\n");
3572 r = CSR_RESULT_FAILURE;
3573 }
3574
3575 return r;
3576} /* unifi_card_stop_processor() */
3577
3578
3579/*
3580 * ---------------------------------------------------------------------------
3581 * card_start_processor
3582 *
3583 * Start the UniFi XAP processors.
3584 *
3585 * Arguments:
3586 * card Pointer to card struct
3587 * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
3588 *
3589 * Returns:
3590 * CSR_RESULT_SUCCESS or CSR error code
3591 * ---------------------------------------------------------------------------
3592 */
3593CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which)
3594{
3595 CsrResult r;
3596
3597 /* Select both XAPs */
3598 r = unifi_set_proc_select(card, which);
3599 if (r != CSR_RESULT_SUCCESS)
3600 {
3601 unifi_error(card->ospriv, "unifi_set_proc_select failed: %d.\n", r);
3602 return r;
3603 }
3604
3605
3606 r = unifi_write_direct_8_or_16(card,
3607 ChipHelper_DBG_EMU_CMD(card->helper) * 2, 8);
3608 if (r != CSR_RESULT_SUCCESS)
3609 {
3610 return r;
3611 }
3612
3613 r = unifi_write_direct_8_or_16(card,
3614 ChipHelper_DBG_EMU_CMD(card->helper) * 2, 0);
3615 if (r != CSR_RESULT_SUCCESS)
3616 {
3617 return r;
3618 }
3619
3620 return CSR_RESULT_SUCCESS;
3621} /* card_start_processor() */
3622
3623
3624/*
3625 * ---------------------------------------------------------------------------
3626 * unifi_set_interrupt_mode
3627 *
3628 * Configure the interrupt processing mode used by the HIP
3629 *
3630 * Arguments:
3631 * card Pointer to card struct
3632 * mode Interrupt mode to apply
3633 *
3634 * Returns:
3635 * None
3636 * ---------------------------------------------------------------------------
3637 */
3638void unifi_set_interrupt_mode(card_t *card, u32 mode)
3639{
3640 if (mode == CSR_WIFI_INTMODE_RUN_BH_ONCE)
3641 {
3642 unifi_info(card->ospriv, "Scheduled interrupt mode");
3643 }
3644 card->intmode = mode;
3645} /* unifi_set_interrupt_mode() */
3646
3647
3648/*
3649 * ---------------------------------------------------------------------------
3650 * unifi_start_processors
3651 *
3652 * Start all UniFi XAP processors.
3653 *
3654 * Arguments:
3655 * card Pointer to card struct
3656 *
3657 * Returns:
3658 * CSR_RESULT_SUCCESS on success, CSR error code on error
3659 * ---------------------------------------------------------------------------
3660 */
3661CsrResult unifi_start_processors(card_t *card)
3662{
3663 return card_start_processor(card, UNIFI_PROC_BOTH);
3664} /* unifi_start_processors() */
3665
3666
3667/*
3668 * ---------------------------------------------------------------------------
3669 * unifi_request_max_sdio_clock
3670 *
3671 * Requests that the maximum SDIO clock rate is set at the next suitable
3672 * opportunity (e.g. when the BH next runs, so as not to interfere with
3673 * any current operation).
3674 *
3675 * Arguments:
3676 * card Pointer to card struct
3677 *
3678 * Returns:
3679 * None
3680 * ---------------------------------------------------------------------------
3681 */
3682void unifi_request_max_sdio_clock(card_t *card)
3683{
3684 card->request_max_clock = 1;
3685} /* unifi_request_max_sdio_clock() */
3686
3687
3688/*
3689 * ---------------------------------------------------------------------------
3690 * unifi_set_host_state
3691 *
3692 * Set the host deep-sleep state.
3693 *
3694 * If transitioning to TORPID, the SDIO driver will be notified
3695 * that the SD bus will be unused (idle) and conversely, when
3696 * transitioning from TORPID that the bus will be used (active).
3697 *
3698 * Arguments:
3699 * card Pointer to card struct
3700 * state New deep-sleep state.
3701 *
3702 * Returns:
3703 * CSR_RESULT_SUCCESS on success
3704 * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
3705 * CSR_RESULT_FAILURE if an SDIO error occurred
3706 *
3707 * Notes:
3708 * We need to reduce the SDIO clock speed before trying to wake up the
3709 * chip. Actually, in the implementation below we reduce the clock speed
3710 * not just before we try to wake up the chip, but when we put the chip to
3711 * deep sleep. This means that if the f/w wakes up on its' own, we waste
3712 * a reduce/increace cycle. However, trying to eliminate this overhead is
3713 * proved difficult, as the current state machine in the HIP lib does at
3714 * least a CMD52 to disable the interrupts before we configure the host
3715 * state.
3716 * ---------------------------------------------------------------------------
3717 */
3718CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state)
3719{
3720 CsrResult r = CSR_RESULT_SUCCESS;
3721 CsrResult csrResult;
3722 static const char *const states[] = {
3723 "AWAKE", "DROWSY", "TORPID"
3724 };
3725 static const u8 state_csr_host_wakeup[] = {
3726 1, 3, 0
3727 };
3728 static const u8 state_io_abort[] = {
3729 0, 2, 3
3730 };
3731
3732 unifi_trace(card->ospriv, UDBG4, "State %s to %s\n",
3733 states[card->host_state], states[state]);
3734
3735 if (card->host_state == UNIFI_HOST_STATE_TORPID)
3736 {
3737 CsrSdioFunctionActive(card->sdio_if);
3738 }
3739
3740 /* Write the new state to UniFi. */
3741 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
3742 {
3743 r = sdio_write_f0(card, SDIO_CSR_HOST_WAKEUP,
3744 (u8)((card->function << 4) | state_csr_host_wakeup[state]));
3745 }
3746 else
3747 {
3748 r = sdio_write_f0(card, SDIO_IO_ABORT, state_io_abort[state]);
3749 }
3750
3751 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3752 {
3753 return r;
3754 }
3755 if (r != CSR_RESULT_SUCCESS)
3756 {
3757 unifi_error(card->ospriv, "Failed to write UniFi deep sleep state\n");
3758 }
3759 else
3760 {
3761 /*
3762 * If the chip was in state TORPID then we can now increase
3763 * the maximum bus clock speed.
3764 */
3765 if (card->host_state == UNIFI_HOST_STATE_TORPID)
3766 {
3767 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
3768 UNIFI_SDIO_CLOCK_MAX_HZ);
3769 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
3770 /* Non-fatal error */
3771 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
3772 {
3773 unifi_warning(card->ospriv,
3774 "Failed to increase the SDIO clock speed\n");
3775 }
3776 else
3777 {
3778 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ;
3779 }
3780 }
3781
3782 /*
3783 * Cache the current state in the card structure to avoid
3784 * unnecessary SDIO reads.
3785 */
3786 card->host_state = state;
3787
3788 if (state == UNIFI_HOST_STATE_TORPID)
3789 {
3790 /*
3791 * If the chip is now in state TORPID then we must now decrease
3792 * the maximum bus clock speed.
3793 */
3794 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
3795 UNIFI_SDIO_CLOCK_SAFE_HZ);
3796 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
3797 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
3798 {
3799 unifi_warning(card->ospriv,
3800 "Failed to decrease the SDIO clock speed\n");
3801 }
3802 else
3803 {
3804 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
3805 }
3806 CsrSdioFunctionIdle(card->sdio_if);
3807 }
3808 }
3809
3810 return r;
3811} /* unifi_set_host_state() */
3812
3813
3814/*
3815 * ---------------------------------------------------------------------------
3816 * unifi_card_info
3817 *
3818 * Update the card information data structure
3819 *
3820 * Arguments:
3821 * card Pointer to card struct
3822 * card_info Pointer to info structure to update
3823 *
3824 * Returns:
3825 * None
3826 * ---------------------------------------------------------------------------
3827 */
3828void unifi_card_info(card_t *card, card_info_t *card_info)
3829{
3830 card_info->chip_id = card->chip_id;
3831 card_info->chip_version = card->chip_version;
3832 card_info->fw_build = card->build_id;
3833 card_info->fw_hip_version = card->config_data.version;
3834 card_info->sdio_block_size = card->sdio_io_block_size;
3835} /* unifi_card_info() */
3836
3837
3838/*
3839 * ---------------------------------------------------------------------------
3840 * unifi_check_io_status
3841 *
3842 * Check UniFi for spontaneous reset and pending interrupt.
3843 *
3844 * Arguments:
3845 * card Pointer to card struct
3846 * status Pointer to location to write chip status:
3847 * 0 if UniFi is running, and no interrupt pending
3848 * 1 if UniFi has spontaneously reset
3849 * 2 if there is a pending interrupt
3850 * Returns:
3851 * CSR_RESULT_SUCCESS if OK, or CSR error
3852 * ---------------------------------------------------------------------------
3853 */
3854CsrResult unifi_check_io_status(card_t *card, s32 *status)
3855{
3856 u8 io_en;
3857 CsrResult r;
3858 u8 pending;
3859
3860 *status = 0;
3861
3862 r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_en);
3863 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
3864 {
3865 return r;
3866 }
3867 if (r != CSR_RESULT_SUCCESS)
3868 {
3869 unifi_error(card->ospriv, "Failed to read SDIO_IO_ENABLE to check for spontaneous reset\n");
3870 return r;
3871 }
3872
3873 if ((io_en & (1 << card->function)) == 0)
3874 {
3875 s32 fw_count;
3876 *status = 1;
3877 unifi_error(card->ospriv, "UniFi has spontaneously reset.\n");
3878
3879 /*
3880 * These reads are very likely to fail. We want to know if the function is really
3881 * disabled or the SDIO driver just returns rubbish.
3882 */
3883 fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
3884 if (fw_count < 0)
3885 {
3886 unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
3887 }
3888 else
3889 {
3890 unifi_error(card->ospriv, "thsw: %u (driver thinks is %u)\n",
3891 fw_count, card->to_host_signals_w);
3892 }
3893 fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
3894 if (fw_count < 0)
3895 {
3896 unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
3897 }
3898 else
3899 {
3900 unifi_error(card->ospriv, "fhsr: %u (driver thinks is %u)\n",
3901 fw_count, card->from_host_signals_r);
3902 }
3903
3904 return r;
3905 }
3906
3907 unifi_info(card->ospriv, "UniFi function %d is enabled.\n", card->function);
3908
3909 /* See if we missed an SDIO interrupt */
3910 r = CardPendingInt(card, &pending);
3911 if (pending)
3912 {
3913 unifi_error(card->ospriv, "There is an unhandled pending interrupt.\n");
3914 *status = 2;
3915 return r;
3916 }
3917
3918 return r;
3919} /* unifi_check_io_status() */
3920
3921
3922void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo)
3923{
3924 s32 count_fhr;
3925 s16 t;
3926 u32 occupied_fh;
3927
3928 q_t *sigq;
3929 u16 nslots, i;
3930
3931 memset(hipqosinfo, 0, sizeof(unifi_HipQosInfo));
3932
3933 nslots = card->config_data.num_fromhost_data_slots;
3934
3935 for (i = 0; i < nslots; i++)
3936 {
3937 if (card->from_host_data[i].bd.data_length == 0)
3938 {
3939 hipqosinfo->free_fh_bulkdata_slots++;
3940 }
3941 }
3942
3943 for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
3944 {
3945 sigq = &card->fh_traffic_queue[i];
3946 t = sigq->q_wr_ptr - sigq->q_rd_ptr;
3947 if (t < 0)
3948 {
3949 t += sigq->q_length;
3950 }
3951 hipqosinfo->free_fh_sig_queue_slots[i] = (sigq->q_length - t) - 1;
3952 }
3953
3954 count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
3955 if (count_fhr < 0)
3956 {
3957 unifi_error(card->ospriv, "Failed to read from-host sig read count - %d\n", count_fhr);
3958 hipqosinfo->free_fh_fw_slots = 0xfa;
3959 return;
3960 }
3961
3962 occupied_fh = (card->from_host_signals_w - count_fhr) % 128;
3963
3964 hipqosinfo->free_fh_fw_slots = (u16)(card->config_data.num_fromhost_sig_frags - occupied_fh);
3965}
3966
3967
3968
3969CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult)
3970{
3971 CsrResult r = CSR_RESULT_FAILURE;
3972
3973 switch (csrResult)
3974 {
3975 case CSR_RESULT_SUCCESS:
3976 r = CSR_RESULT_SUCCESS;
3977 break;
3978 /* Timeout errors */
3979 case CSR_SDIO_RESULT_TIMEOUT:
3980 /* Integrity errors */
3981 case CSR_SDIO_RESULT_CRC_ERROR:
3982 r = CSR_RESULT_FAILURE;
3983 break;
3984 case CSR_SDIO_RESULT_NO_DEVICE:
3985 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
3986 break;
3987 case CSR_SDIO_RESULT_INVALID_VALUE:
3988 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
3989 break;
3990 case CSR_RESULT_FAILURE:
3991 r = CSR_RESULT_FAILURE;
3992 break;
3993 default:
3994 unifi_warning(card->ospriv, "Unrecognised csrResult error code: %d\n", csrResult);
3995 break;
3996 }
3997
3998 return r;
3999} /* ConvertCsrSdioToCsrHipResult() */
4000
4001
drivers/staging/csr/csr_wifi_hip_card_sdio.h+0−694
@@ -1,694 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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_card_sdio.h
15 *
16 * PURPOSE:
17 * Internal header for Card API for SDIO.
18 * ---------------------------------------------------------------------------
19 */
20#ifndef __CARD_SDIO_H__
21#define __CARD_SDIO_H__
22
23#include "csr_wifi_hip_unifi.h"
24#include "csr_wifi_hip_unifi_udi.h"
25#include "csr_wifi_hip_unifihw.h"
26#include "csr_wifi_hip_unifiversion.h"
27#ifndef CSR_WIFI_HIP_TA_DISABLE
28#include "csr_wifi_hip_ta_sampling.h"
29#endif
30#include "csr_wifi_hip_xbv.h"
31#include "csr_wifi_hip_chiphelper.h"
32
33
34/*
35 *
36 * Configuration items.
37 * Which of these should go in a platform unifi_config.h file?
38 *
39 */
40
41/*
42 * When the traffic queues contain more signals than there is space for on
43 * UniFi, a limiting algorithm comes into play.
44 * If a traffic queue has enough slots free to buffer more traffic from the
45 * network stack, then the following check is applied. The number of free
46 * slots is RESUME_XMIT_THRESHOLD.
47 */
48#define RESUME_XMIT_THRESHOLD 4
49
50
51/*
52 * When reading signals from UniFi, the host processes pending all signals
53 * and then acknowledges them together in a single write to update the
54 * to-host-chunks-read location.
55 * When there is more than one bulk data transfer (e.g. one received data
56 * packet and a request for the payload data of a transmitted packet), the
57 * update can be delayed significantly. This ties up resources on chip.
58 *
59 * To remedy this problem, to-host-chunks-read is updated after processing
60 * a signal if TO_HOST_FLUSH_THRESHOLD bytes of bulk data have been
61 * transferred since the last update.
62 */
63#define TO_HOST_FLUSH_THRESHOLD (500 * 5)
64
65
66/* SDIO Card Common Control Registers */
67#define SDIO_CCCR_SDIO_REVISION (0x00)
68#define SDIO_SD_SPEC_REVISION (0x01)
69#define SDIO_IO_ENABLE (0x02)
70#define SDIO_IO_READY (0x03)
71#define SDIO_INT_ENABLE (0x04)
72#define SDIO_INT_PENDING (0x05)
73#define SDIO_IO_ABORT (0x06)
74#define SDIO_BUS_IFACE_CONTROL (0x07)
75#define SDIO_CARD_CAPABILOTY (0x08)
76#define SDIO_COMMON_CIS_POINTER (0x09)
77#define SDIO_BUS_SUSPEND (0x0C)
78#define SDIO_FUNCTION_SELECT (0x0D)
79#define SDIO_EXEC_FLAGS (0x0E)
80#define SDIO_READY_FLAGS (0x0F)
81#define SDIO_FN0_BLOCK_SIZE (0x10)
82#define SDIO_POWER_CONTROL (0x12)
83#define SDIO_VENDOR_START (0xF0)
84
85#define SDIO_CSR_HOST_WAKEUP (0xf0)
86#define SDIO_CSR_HOST_INT_CLEAR (0xf1)
87#define SDIO_CSR_FROM_HOST_SCRATCH0 (0xf2)
88#define SDIO_CSR_FROM_HOST_SCRATCH1 (0xf3)
89#define SDIO_CSR_TO_HOST_SCRATCH0 (0xf4)
90#define SDIO_CSR_TO_HOST_SCRATCH1 (0xf5)
91#define SDIO_CSR_FUNC_EN (0xf6)
92#define SDIO_CSR_CSPI_MODE (0xf7)
93#define SDIO_CSR_CSPI_STATUS (0xf8)
94#define SDIO_CSR_CSPI_PADDING (0xf9)
95
96
97#define UNIFI_SD_INT_ENABLE_IENM 0x0001 /* Master INT Enable */
98
99#ifdef CSR_PRE_ALLOC_NET_DATA
100#define BULK_DATA_PRE_ALLOC_NUM 16
101#endif
102
103/*
104 * Structure to hold configuration information read from UniFi.
105 */
106typedef struct
107{
108 /*
109 * The version of the SDIO signal queues and bulk data pools
110 * configuration structure. The MSB is the major version number, used to
111 * indicate incompatible changes. The LSB gives the minor revision number,
112 * used to indicate changes that maintain backwards compatibility.
113 */
114 u16 version;
115
116 /*
117 * offset from the start of the shared data memory to the SD IO
118 * control structure.
119 */
120 u16 sdio_ctrl_offset;
121
122 /* Buffer handle of the from-host signal queue */
123 u16 fromhost_sigbuf_handle;
124
125 /* Buffer handle of the to-host signal queue */
126 u16 tohost_sigbuf_handle;
127
128 /*
129 * Maximum number of signal primitive or bulk data command fragments that may be
130 * pending in the to-hw signal queue.
131 */
132 u16 num_fromhost_sig_frags;
133
134 /*
135 * Number of signal primitive or bulk data command fragments that must be pending
136 * in the to-host signal queue before the host will generate an interrupt
137 * to indicate that it has read a signal. This will usually be the total
138 * capacity of the to-host signal buffer less the size of the largest signal
139 * primitive divided by the signal primitive fragment size, but may be set
140 * to 1 to request interrupts every time that the host read a signal.
141 * Note that the hw may place more signals in the to-host signal queue
142 * than indicated by this field.
143 */
144 u16 num_tohost_sig_frags;
145
146 /*
147 * Number of to-hw bulk data slots. Slots are numbered from 0 (zero) to
148 * one less than the value in this field
149 */
150 u16 num_fromhost_data_slots;
151
152 /*
153 * Number of frm-hw bulk data slots. Slots are numbered from 0 (zero) to
154 * one less than the value in this field
155 */
156 u16 num_tohost_data_slots;
157
158 /*
159 * Size of the bulk data slots (2 octets)
160 * The size of the bulk data slots in octets. This will usually be
161 * the size of the largest MSDU. The value should always be even.
162 */
163 u16 data_slot_size;
164
165 /*
166 * Indicates that the host has finished the initialisation sequence.
167 * Initialised to 0x0000 by the firmware, and set to 0x0001 by us.
168 */
169 u16 initialised;
170
171 /* Added by protocol version 0x0001 */
172 u32 overlay_size;
173
174 /* Added by protocol version 0x0300 */
175 u16 data_slot_round;
176 u16 sig_frag_size;
177
178 /* Added by protocol version 0x0500 */
179 u16 tohost_signal_padding;
180} sdio_config_data_t;
181
182/*
183 * These values may change with versions of the Host Interface Protocol.
184 */
185/*
186 * Size of config info block pointed to by the CSR_SLT_SDIO_SLOT_CONFIG
187 * entry in the f/w symbol table
188 */
189#define SDIO_CONFIG_DATA_SIZE 30
190
191/* Offset of the INIT flag in the config info block. */
192#define SDIO_INIT_FLAG_OFFSET 0x12
193#define SDIO_TO_HOST_SIG_PADDING_OFFSET 0x1C
194
195
196/* Structure for a bulk data transfer command */
197typedef struct
198{
199 u16 cmd_and_len; /* bits 12-15 cmd, bits 0-11 len */
200 u16 data_slot; /* slot number, perhaps OR'd with SLOT_DIR_TO_HOST */
201 u16 offset;
202 u16 buffer_handle;
203} bulk_data_cmd_t;
204
205
206/* Bulk Data signal command values */
207#define SDIO_CMD_SIGNAL 0x00
208#define SDIO_CMD_TO_HOST_TRANSFER 0x01
209#define SDIO_CMD_TO_HOST_TRANSFER_ACK 0x02 /*deprecated*/
210#define SDIO_CMD_FROM_HOST_TRANSFER 0x03
211#define SDIO_CMD_FROM_HOST_TRANSFER_ACK 0x04 /*deprecated*/
212#define SDIO_CMD_CLEAR_SLOT 0x05
213#define SDIO_CMD_OVERLAY_TRANSFER 0x06
214#define SDIO_CMD_OVERLAY_TRANSFER_ACK 0x07 /*deprecated*/
215#define SDIO_CMD_FROM_HOST_AND_CLEAR 0x08
216#define SDIO_CMD_PADDING 0x0f
217
218#define SLOT_DIR_TO_HOST 0x8000
219
220
221/* Initialise bulkdata slot
222 * params:
223 * bulk_data_desc_t *bulk_data_slot
224 */
225#define UNIFI_INIT_BULK_DATA(bulk_data_slot) \
226 { \
227 (bulk_data_slot)->os_data_ptr = NULL; \
228 (bulk_data_slot)->data_length = 0; \
229 (bulk_data_slot)->os_net_buf_ptr = NULL; \
230 (bulk_data_slot)->net_buf_length = 0; \
231 }
232
233/*
234 * Structure to contain a SIGNAL datagram.
235 * This is used to build signal queues between the main driver and the
236 * i/o thread.
237 * The fields are:
238 * sigbuf Contains the HIP signal is wire-format (i.e. packed,
239 * little-endian)
240 * bulkdata Contains a copy of any associated bulk data
241 * signal_length The size of the signal in the sigbuf
242 */
243typedef struct card_signal
244{
245 u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
246
247 /* Length of the SIGNAL inside sigbuf */
248 u16 signal_length;
249
250 bulk_data_desc_t bulkdata[UNIFI_MAX_DATA_REFERENCES];
251} card_signal_t;
252
253
254/*
255 * Control structure for a generic ring buffer.
256 */
257#define UNIFI_QUEUE_NAME_MAX_LENGTH 16
258typedef struct
259{
260 card_signal_t *q_body;
261
262 /* Num elements in queue (capacity is one less than this!) */
263 u16 q_length;
264
265 u16 q_wr_ptr;
266 u16 q_rd_ptr;
267
268 char name[UNIFI_QUEUE_NAME_MAX_LENGTH];
269} q_t;
270
271
272#define UNIFI_RESERVED_COMMAND_SLOTS 2
273
274/* Considering approx 500 us per packet giving 0.5 secs */
275#define UNIFI_PACKETS_INTERVAL 1000
276
277/*
278 * Dynamic slot reservation for QoS
279 */
280typedef struct
281{
282 u16 from_host_used_slots[UNIFI_NO_OF_TX_QS];
283 u16 from_host_max_slots[UNIFI_NO_OF_TX_QS];
284 u16 from_host_reserved_slots[UNIFI_NO_OF_TX_QS];
285
286 /* Parameters to determine if a queue was active.
287 If number of packets sent is greater than the threshold
288 for the queue, the queue is considered active and no
289 re reservation is done, it is important not to keep this
290 value too low */
291 /* Packets sent during this interval */
292 u16 packets_txed[UNIFI_NO_OF_TX_QS];
293 u16 total_packets_txed;
294
295 /* Number of packets to see if slots need to be reassigned */
296 u16 packets_interval;
297
298 /* Once a queue reaches a stable state, avoid processing */
299 u8 queue_stable[UNIFI_NO_OF_TX_QS];
300} card_dynamic_slot_t;
301
302
303/* These are type-safe and don't write incorrect values to the
304 * structure. */
305
306/* Return queue slots used count
307 * params:
308 * const q_t *q
309 * returns:
310 * u16
311 */
312#define CSR_WIFI_HIP_Q_SLOTS_USED(q) \
313 (((q)->q_wr_ptr - (q)->q_rd_ptr < 0)? \
314 ((q)->q_wr_ptr - (q)->q_rd_ptr + (q)->q_length) : ((q)->q_wr_ptr - (q)->q_rd_ptr))
315
316/* Return queue slots free count
317 * params:
318 * const q_t *q
319 * returns:
320 * u16
321 */
322#define CSR_WIFI_HIP_Q_SLOTS_FREE(q) \
323 ((q)->q_length - CSR_WIFI_HIP_Q_SLOTS_USED((q)) - 1)
324
325/* Return slot signal data pointer
326 * params:
327 * const q_t *q
328 * u16 slot
329 * returns:
330 * card_signal_t *
331 */
332#define CSR_WIFI_HIP_Q_SLOT_DATA(q, slot) \
333 ((q)->q_body + slot)
334
335/* Return queue next read slot
336 * params:
337 * const q_t *q
338 * returns:
339 * u16 slot offset
340 */
341#define CSR_WIFI_HIP_Q_NEXT_R_SLOT(q) \
342 ((q)->q_rd_ptr)
343
344/* Return queue next write slot
345 * params:
346 * const q_t *q
347 * returns:
348 * u16 slot offset
349 */
350#define CSR_WIFI_HIP_Q_NEXT_W_SLOT(q) \
351 ((q)->q_wr_ptr)
352
353/* Return updated queue pointer wrapped around its length
354 * params:
355 * const q_t *q
356 * u16 x amount to add to queue pointer
357 * returns:
358 * u16 wrapped queue pointer
359 */
360#define CSR_WIFI_HIP_Q_WRAP(q, x) \
361 ((((x) >= (q)->q_length)?((x) % (q)->q_length) : (x)))
362
363/* Advance queue read pointer
364 * params:
365 * const q_t *q
366 */
367#define CSR_WIFI_HIP_Q_INC_R(q) \
368 ((q)->q_rd_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_rd_ptr + 1))
369
370/* Advance queue write pointer
371 * params:
372 * const q_t *q
373 */
374#define CSR_WIFI_HIP_Q_INC_W(q) \
375 ((q)->q_wr_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_wr_ptr + 1))
376
377enum unifi_host_state
378{
379 UNIFI_HOST_STATE_AWAKE = 0,
380 UNIFI_HOST_STATE_DROWSY = 1,
381 UNIFI_HOST_STATE_TORPID = 2
382};
383
384typedef struct
385{
386 bulk_data_desc_t bd;
387 unifi_TrafficQueue queue; /* Used for dynamic slot reservation */
388} slot_desc_t;
389
390/*
391 * Structure describing a UniFi SDIO card.
392 */
393struct card
394{
395 /*
396 * Back pointer for the higher level OS code. This is passed as
397 * an argument to callbacks (e.g. for received data and indications).
398 */
399 void *ospriv;
400
401 /*
402 * mapping of HIP slot to MA-PACKET.req host tag, the
403 * array is indexed by slot numbers and each index stores
404 * information of the last host tag it was used for
405 */
406 u32 *fh_slot_host_tag_record;
407
408
409 /* Info read from Symbol Table during probe */
410 u32 build_id;
411 char build_id_string[128];
412
413 /* Retrieve from SDIO driver. */
414 u16 chip_id;
415
416 /* Read from GBL_CHIP_VERSION. */
417 u16 chip_version;
418
419 /* From the SDIO driver (probably 1) */
420 u8 function;
421
422 /* This is sused to get the register addresses and things. */
423 ChipDescript *helper;
424
425 /*
426 * Bit mask of PIOs for the loader to waggle during download.
427 * We assume these are connected to LEDs. The main firmware gets
428 * the mask from a MIB entry.
429 */
430 s32 loader_led_mask;
431
432 /*
433 * Support for flow control. When the from-host queue of signals
434 * is full, we ask the host upper layer to stop sending packets. When
435 * the queue drains we tell it that it can send packets again.
436 * We use this flag to remember the current state.
437 */
438#define card_is_tx_q_paused(card, q) (card->tx_q_paused_flag[q])
439#define card_tx_q_unpause(card, q) (card->tx_q_paused_flag[q] = 0)
440#define card_tx_q_pause(card, q) (card->tx_q_paused_flag[q] = 1)
441
442 u16 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX + 1 + UNIFI_NO_OF_TX_QS]; /* defensive more than big enough */
443
444 /* UDI callback for logging UniFi interactions */
445 udi_func_t udi_hook;
446
447 u8 bh_reason_host;
448 u8 bh_reason_unifi;
449
450 /* SDIO clock speed request from OS layer */
451 u8 request_max_clock;
452
453 /* Last SDIO clock frequency set */
454 u32 sdio_clock_speed;
455
456 /*
457 * Current host state (copy of value in IOABORT register and
458 * spinlock to protect it.
459 */
460 enum unifi_host_state host_state;
461
462 enum unifi_low_power_mode low_power_mode;
463 enum unifi_periodic_wake_mode periodic_wake_mode;
464
465 /*
466 * Ring buffer of signal structs for a queue of data packets from
467 * the host.
468 * The queue is empty when fh_data_q_num_rd == fh_data_q_num_wr.
469 * To add a packet to the queue, copy it to index given by
470 * (fh_data_q_num_wr%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_wr.
471 * To take a packet from the queue, copy data from index given by
472 * (fh_data_q_num_rd%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_rd.
473 * fh_data_q_num_rd and fh_data_q_num_rd are both modulo 256.
474 */
475 card_signal_t fh_command_q_body[UNIFI_SOFT_COMMAND_Q_LENGTH];
476 q_t fh_command_queue;
477
478 card_signal_t fh_traffic_q_body[UNIFI_NO_OF_TX_QS][UNIFI_SOFT_TRAFFIC_Q_LENGTH];
479 q_t fh_traffic_queue[UNIFI_NO_OF_TX_QS];
480
481 /*
482 * Signal counts from UniFi SDIO Control Data Structure.
483 * These are cached and synchronised with the UniFi before and after
484 * a batch of operations.
485 *
486 * These are the modulo-256 count of signals written to or read from UniFi
487 * The value is incremented for every signal.
488 */
489 s32 from_host_signals_w;
490 s32 from_host_signals_r;
491 s32 to_host_signals_r;
492 s32 to_host_signals_w;
493
494
495 /* Should specify buffer size as a number of signals */
496 /*
497 * Enough for 10 th and 10 fh data slots:
498 * 1 * 10 * 8 = 80
499 * 2 * 10 * 8 = 160
500 */
501#define UNIFI_FH_BUF_SIZE 1024
502 struct sigbuf
503 {
504 u8 *buf; /* buffer area */
505 u8 *ptr; /* current pos */
506 u16 count; /* signal count */
507 u16 bufsize;
508 } fh_buffer;
509 struct sigbuf th_buffer;
510
511
512 /*
513 * Field to use for the incrementing value to write to the UniFi
514 * SHARED_IO_INTERRUPT register.
515 * Flag to say we need to generate an interrupt at end of processing.
516 */
517 u32 unifi_interrupt_seq;
518 u8 generate_interrupt;
519
520
521 /* Pointers to the bulk data slots */
522 slot_desc_t *from_host_data;
523 bulk_data_desc_t *to_host_data;
524
525
526 /*
527 * Index of the next (hopefully) free data slot.
528 * This is an optimisation that starts searching at a more likely point
529 * than the beginning.
530 */
531 s16 from_host_data_head;
532
533 /* Dynamic slot allocation for queues */
534 card_dynamic_slot_t dynamic_slot_data;
535
536 /*
537 * SDIO specific fields
538 */
539
540 /* Interface pointer for the SDIO library */
541 CsrSdioFunction *sdio_if;
542
543 /* Copy of config_data struct from the card */
544 sdio_config_data_t config_data;
545
546 /* SDIO address of the Initialised flag and Control Data struct */
547 u32 init_flag_addr;
548 u32 sdio_ctrl_addr;
549
550 /* The last value written to the Shared Data Memory Page register */
551 u32 proc_select;
552 u32 dmem_page;
553 u32 pmem_page;
554
555 /* SDIO traffic counters limited to 32 bits for Synergy compatibility */
556 u32 sdio_bytes_read;
557 u32 sdio_bytes_written;
558
559 u8 memory_resources_allocated;
560
561 /* UniFi SDIO I/O Block size. */
562 u16 sdio_io_block_size;
563
564 /* Pad transfer sizes to SDIO block boundaries */
565 u8 sdio_io_block_pad;
566
567 /* Read from the XBV */
568 struct FWOV fwov;
569
570#ifndef CSR_WIFI_HIP_TA_DISABLE
571 /* TA sampling */
572 ta_data_t ta_sampling;
573#endif
574
575 /* Auto-coredump */
576 s16 request_coredump_on_reset; /* request coredump on next reset */
577 struct coredump_buf *dump_buf; /* root node */
578 struct coredump_buf *dump_next_write; /* node to fill at next dump */
579 struct coredump_buf *dump_cur_read; /* valid node to read, or NULL */
580
581#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
582 struct cmd_profile
583 {
584 u32 cmd52_count;
585 u32 cmd53_count;
586 u32 tx_count;
587 u32 tx_cfm_count;
588 u32 rx_count;
589 u32 bh_count;
590 u32 process_count;
591 u32 protocol_count;
592
593 u32 cmd52_f0_r_count;
594 u32 cmd52_f0_w_count;
595 u32 cmd52_r8or16_count;
596 u32 cmd52_w8or16_count;
597 u32 cmd52_r16_count;
598 u32 cmd52_w16_count;
599 u32 cmd52_r32_count;
600
601 u32 sdio_cmd_signal;
602 u32 sdio_cmd_clear_slot;
603 u32 sdio_cmd_to_host;
604 u32 sdio_cmd_from_host;
605 u32 sdio_cmd_from_host_and_clear;
606 } hip_prof;
607 struct cmd_profile cmd_prof;
608#endif
609
610 /* Interrupt processing mode flags */
611 u32 intmode;
612
613#ifdef UNIFI_DEBUG
614 u8 lsb;
615#endif
616
617 /* Historic firmware panic codes */
618 u32 panic_data_phy_addr;
619 u32 panic_data_mac_addr;
620 u16 last_phy_panic_code;
621 u16 last_phy_panic_arg;
622 u16 last_mac_panic_code;
623 u16 last_mac_panic_arg;
624#ifdef CSR_PRE_ALLOC_NET_DATA
625 bulk_data_desc_t bulk_data_desc_list[BULK_DATA_PRE_ALLOC_NUM];
626 u16 prealloc_netdata_r;
627 u16 prealloc_netdata_w;
628#endif
629}; /* struct card */
630
631
632/* Reset types */
633enum unifi_reset_type
634{
635 UNIFI_COLD_RESET = 1,
636 UNIFI_WARM_RESET = 2
637};
638
639/*
640 * unifi_set_host_state() implements signalling for waking UniFi from
641 * deep sleep. The host indicates to UniFi that it is in one of three states:
642 * Torpid - host has nothing to send, UniFi can go to sleep.
643 * Drowsy - host has data to send to UniFi. UniFi will respond with an
644 * SDIO interrupt. When hosts responds it moves to Awake.
645 * Awake - host has data to transfer, UniFi must stay awake.
646 * When host has finished, it moves to Torpid.
647 */
648CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state);
649
650
651CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select);
652s32 card_read_signal_counts(card_t *card);
653bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot);
654
655
656CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata);
657CsrResult unifi_readnz(card_t *card, u32 unifi_addr,
658 void *pdata, u16 len);
659s32 unifi_read_shared_count(card_t *card, u32 addr);
660
661CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len);
662
663CsrResult unifi_bulk_rw(card_t *card, u32 handle,
664 void *pdata, u32 len, s16 direction);
665CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle,
666 void *pdata, u32 len, s16 direction);
667#define UNIFI_SDIO_READ 0
668#define UNIFI_SDIO_WRITE 1
669
670CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata);
671CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data);
672CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata);
673CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data);
674
675CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata);
676CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata);
677CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len);
678
679CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data);
680CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len);
681
682CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata);
683CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data);
684
685void unifi_read_panic(card_t *card);
686#ifdef CSR_PRE_ALLOC_NET_DATA
687void prealloc_netdata_free(card_t *card);
688CsrResult prealloc_netdata_alloc(card_t *card);
689#endif
690/* For diagnostic use */
691void dump(void *mem, u16 len);
692void dump16(void *mem, u16 len);
693
694#endif /* __CARD_SDIO_H__ */
drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c+0−2595
@@ -1,2595 +0,0 @@
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 * FILE: csr_wifi_hip_card_sdio_intr.c
14 *
15 * PURPOSE:
16 * Interrupt processing for the UniFi SDIO driver.
17 *
18 * We may need another signal queue of responses to UniFi to hold
19 * bulk data commands generated by read_to_host_signals().
20 *
21 * ---------------------------------------------------------------------------
22 */
23#undef CSR_WIFI_HIP_NOISY
24
25#include "csr_wifi_hip_unifi.h"
26#include "csr_wifi_hip_conversions.h"
27#include "csr_wifi_hip_card.h"
28#include "csr_wifi_hip_xbv.h"
29
30
31/*
32 * If the SDIO link is idle for this time (in milliseconds),
33 * signal UniFi to go into Deep Sleep.
34 * Valid return value of unifi_bh().
35 */
36#define UNIFI_DEFAULT_HOST_IDLE_TIMEOUT 5
37/*
38 * If the UniFi has not woken up for this time (in milliseconds),
39 * signal the bottom half to take action.
40 * Valid return value of unifi_bh().
41 */
42#define UNIFI_DEFAULT_WAKE_TIMEOUT 1000
43
44
45static CsrResult process_bh(card_t *card);
46static CsrResult handle_host_protocol(card_t *card, u8 *processed_something);
47
48static CsrResult flush_fh_buffer(card_t *card);
49
50static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space);
51
52static CsrResult read_to_host_signals(card_t *card, s32 *processed);
53static CsrResult process_to_host_signals(card_t *card, s32 *processed);
54
55static CsrResult process_bulk_data_command(card_t *card,
56 const u8 *cmdptr,
57 s16 cmd, u16 len);
58static CsrResult process_clear_slot_command(card_t *card,
59 const u8 *cmdptr);
60static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed);
61static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed);
62static void restart_packet_flow(card_t *card);
63static CsrResult process_clock_request(card_t *card);
64
65#ifdef CSR_WIFI_HIP_NOISY
66s16 dump_fh_buf = 0;
67#endif /* CSR_WIFI_HIP_NOISY */
68
69#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
70
71/*
72 * The unifi_debug_output buffer can be used to debug the HIP behaviour offline
73 * i.e. without using the tracing functions that change the timing.
74 *
75 * Call unifi_debug_log_to_buf() with printf arguments to store a string into
76 * unifi_debug_output. When unifi_debug_buf_dump() is called, the contents of the
77 * buffer are dumped with dump_str() which has to be implemented in the
78 * OS layer, during the porting exercise. The offset printed, holds the
79 * offset where the last character is (always a zero).
80 *
81 */
82
83#define UNIFI_DEBUG_GBUFFER_SIZE 8192
84static char unifi_debug_output[UNIFI_DEBUG_GBUFFER_SIZE];
85static char *unifi_dbgbuf_ptr = unifi_debug_output;
86static char *unifi_dbgbuf_start = unifi_debug_output;
87
88static void append_char(char c)
89{
90 /* write char and advance pointer */
91 *unifi_dbgbuf_ptr++ = c;
92 /* wrap pointer at end of buffer */
93 if ((unifi_dbgbuf_ptr - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
94 {
95 unifi_dbgbuf_ptr = unifi_debug_output;
96 }
97} /* append_char() */
98
99
100void unifi_debug_string_to_buf(const char *str)
101{
102 const char *p = str;
103 while (*p)
104 {
105 append_char(*p);
106 p++;
107 }
108 /* Update start-of-buffer pointer */
109 unifi_dbgbuf_start = unifi_dbgbuf_ptr + 1;
110 if ((unifi_dbgbuf_start - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
111 {
112 unifi_dbgbuf_start = unifi_debug_output;
113 }
114}
115
116
117void unifi_debug_log_to_buf(const char *fmt, ...)
118{
119#define DEBUG_BUFFER_SIZE 80
120 static char s[DEBUG_BUFFER_SIZE];
121 va_list args;
122
123 va_start(args, fmt);
124 vsnprintf(s, DEBUG_BUFFER_SIZE, fmt, args);
125 va_end(args);
126
127 unifi_debug_string_to_buf(s);
128} /* unifi_debug_log_to_buf() */
129
130
131/* Convert signed 32 bit (or less) integer to string */
132static void CsrUInt16ToHex(u16 number, char *str)
133{
134 u16 index;
135 u16 currentValue;
136
137 for (index = 0; index < 4; index++)
138 {
139 currentValue = (u16) (number & 0x000F);
140 number >>= 4;
141 str[3 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0');
142 }
143 str[4] = '\0';
144}
145
146
147/*
148 * ---------------------------------------------------------------------------
149 * unifi_debug_hex_to_buf
150 *
151 * puts the contents of the passed buffer into the debug buffer as a hex string
152 *
153 * Arguments:
154 * buff buffer to print as hex
155 * length number of chars to print
156 *
157 * Returns:
158 * None.
159 *
160 * ---------------------------------------------------------------------------
161 */
162void unifi_debug_hex_to_buf(const char *buff, u16 length)
163{
164 char s[5];
165 u16 i;
166
167 for (i = 0; i < length; i = i + 2)
168 {
169 CsrUInt16ToHex(*((u16 *)(buff + i)), s);
170 unifi_debug_string_to_buf(s);
171 }
172}
173
174
175void unifi_debug_buf_dump(void)
176{
177 s32 offset = unifi_dbgbuf_ptr - unifi_debug_output;
178
179 unifi_error(NULL, "HIP debug buffer offset=%d\n", offset);
180 dump_str(unifi_debug_output + offset, UNIFI_DEBUG_GBUFFER_SIZE - offset);
181 dump_str(unifi_debug_output, offset);
182} /* unifi_debug_buf_dump() */
183
184
185#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
186
187#ifdef CSR_PRE_ALLOC_NET_DATA
188#define NETDATA_PRE_ALLOC_BUF_SIZE 8000
189
190void prealloc_netdata_free(card_t *card)
191{
192 unifi_warning(card->ospriv, "prealloc_netdata_free: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
193
194 while (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length != 0)
195 {
196 unifi_warning(card->ospriv, "prealloc_netdata_free: r=%d\n", card->prealloc_netdata_r);
197
198 unifi_net_data_free(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_r]);
199 card->prealloc_netdata_r++;
200 card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
201 }
202 card->prealloc_netdata_r = card->prealloc_netdata_w = 0;
203
204 unifi_warning(card->ospriv, "prealloc_netdata_free: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
205}
206
207
208CsrResult prealloc_netdata_alloc(card_t *card)
209{
210 CsrResult r;
211
212 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
213
214 while (card->bulk_data_desc_list[card->prealloc_netdata_w].data_length == 0)
215 {
216 r = unifi_net_data_malloc(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_w], NETDATA_PRE_ALLOC_BUF_SIZE);
217 if (r != CSR_RESULT_SUCCESS)
218 {
219 unifi_error(card->ospriv, "prealloc_netdata_alloc: Failed to allocate t-h bulk data\n");
220 return CSR_RESULT_FAILURE;
221 }
222 card->prealloc_netdata_w++;
223 card->prealloc_netdata_w %= BULK_DATA_PRE_ALLOC_NUM;
224 }
225 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
226
227 return CSR_RESULT_SUCCESS;
228}
229
230
231static CsrResult prealloc_netdata_get(card_t *card, bulk_data_desc_t *bulk_data_slot, u32 size)
232{
233 CsrResult r;
234
235 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
236
237 if (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0)
238 {
239 unifi_error(card->ospriv, "prealloc_netdata_get: data_length = 0\n");
240 }
241
242 if ((size > NETDATA_PRE_ALLOC_BUF_SIZE) || (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0))
243 {
244 unifi_warning(card->ospriv, "prealloc_netdata_get: Calling net_data_malloc\n");
245
246 r = unifi_net_data_malloc(card->ospriv, bulk_data_slot, size);
247 if (r != CSR_RESULT_SUCCESS)
248 {
249 unifi_error(card->ospriv, "prealloc_netdata_get: Failed to allocate t-h bulk data\n");
250 return CSR_RESULT_FAILURE;
251 }
252 return CSR_RESULT_SUCCESS;
253 }
254
255 *bulk_data_slot = card->bulk_data_desc_list[card->prealloc_netdata_r];
256 card->bulk_data_desc_list[card->prealloc_netdata_r].os_data_ptr = NULL;
257 card->bulk_data_desc_list[card->prealloc_netdata_r].os_net_buf_ptr = NULL;
258 card->bulk_data_desc_list[card->prealloc_netdata_r].net_buf_length = 0;
259 card->bulk_data_desc_list[card->prealloc_netdata_r].data_length = 0;
260
261 card->prealloc_netdata_r++;
262 card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
263
264 unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
265
266 return CSR_RESULT_SUCCESS;
267}
268
269
270#endif
271
272/*
273 * ---------------------------------------------------------------------------
274 * unifi_sdio_interrupt_handler
275 *
276 * This function should be called by the OS-dependent code to handle
277 * an SDIO interrupt from the UniFi.
278 *
279 * Arguments:
280 * card Pointer to card context structure.
281 *
282 * Returns:
283 * None.
284 *
285 * Notes: This function may be called in DRS context. In this case,
286 * tracing with the unifi_trace(), etc, is not allowed.
287 * ---------------------------------------------------------------------------
288 */
289void unifi_sdio_interrupt_handler(card_t *card)
290{
291 /*
292 * Set the flag to say reason for waking was SDIO interrupt.
293 * Then ask the OS layer to run the unifi_bh to give attention to the UniFi.
294 */
295 card->bh_reason_unifi = 1;
296 (void)unifi_run_bh(card->ospriv);
297} /* sdio_interrupt_handler() */
298
299
300/*
301 * ---------------------------------------------------------------------------
302 * unifi_configure_low_power_mode
303 *
304 * This function should be called by the OS-dependent when
305 * the deep sleep signaling needs to be enabled or disabled.
306 *
307 * Arguments:
308 * card Pointer to card context structure.
309 * low_power_mode Disable/Enable the deep sleep signaling
310 * periodic_wake_mode UniFi wakes host periodically.
311 *
312 * Returns:
313 * CSR_RESULT_SUCCESS on success or a CSR error code.
314 * ---------------------------------------------------------------------------
315 */
316CsrResult unifi_configure_low_power_mode(card_t *card,
317 enum unifi_low_power_mode low_power_mode,
318 enum unifi_periodic_wake_mode periodic_wake_mode)
319{
320 card->low_power_mode = low_power_mode;
321 card->periodic_wake_mode = periodic_wake_mode;
322
323 unifi_trace(card->ospriv, UDBG1,
324 "unifi_configure_low_power_mode: new mode = %s, wake_host = %s\n",
325 (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled",
326 (periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_DISABLED)?"FALSE" : "TRUE");
327
328 (void)unifi_run_bh(card->ospriv);
329 return CSR_RESULT_SUCCESS;
330} /* unifi_configure_low_power_mode() */
331
332
333/*
334 * ---------------------------------------------------------------------------
335 * unifi_force_low_power_mode
336 *
337 * This function should be called by the OS-dependent when
338 * UniFi needs to be set to the low power mode (e.g. on suspend)
339 *
340 * Arguments:
341 * card Pointer to card context structure.
342 *
343 * Returns:
344 * CSR_RESULT_SUCCESS on success or a CSR error code.
345 * ---------------------------------------------------------------------------
346 */
347CsrResult unifi_force_low_power_mode(card_t *card)
348{
349 if (card->low_power_mode == UNIFI_LOW_POWER_DISABLED)
350 {
351 unifi_error(card->ospriv, "Attempt to set mode to TORPID when lower power mode is disabled\n");
352 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
353 }
354
355 return unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
356} /* unifi_force_low_power_mode() */
357
358
359/*
360 * ---------------------------------------------------------------------------
361 * unifi_bh
362 *
363 * This function should be called by the OS-dependent code when
364 * host and/or UniFi has requested an exchange of messages.
365 *
366 * Arguments:
367 * card Pointer to card context structure.
368 *
369 * Returns:
370 * CSR_RESULT_SUCCESS on success or a CSR error code.
371 * ---------------------------------------------------------------------------
372 */
373CsrResult unifi_bh(card_t *card, u32 *remaining)
374{
375 CsrResult r;
376 CsrResult csrResult;
377 u8 pending;
378 s32 iostate, j;
379 const enum unifi_low_power_mode low_power_mode = card->low_power_mode;
380 u16 data_slots_used = 0;
381
382
383 /* Process request to raise the maximum SDIO clock */
384 r = process_clock_request(card);
385 if (r != CSR_RESULT_SUCCESS)
386 {
387 unifi_error(card->ospriv, "Error setting maximum SDIO clock\n");
388 goto exit;
389 }
390
391 /*
392 * Why was the BH thread woken?
393 * If it was an SDIO interrupt, UniFi is awake and we need to process it.
394 * If it was a host process queueing data, then we need to awaken UniFi.
395 *
396 * Priority of flags is top down.
397 *
398 * ----------------------------------------------------------+
399 * \state| AWAKE | DROWSY | TORPID |
400 * flag\ | | | |
401 * ---------+--------------+----------------+----------------|
402 * | do the host | go to AWAKE and| go to AWAKE and|
403 * unifi | protocol | do the host | do the host |
404 * | | protocol | protocol |
405 * ---------+--------------+----------------+----------------|
406 * | do the host | | |
407 * host | protocol | do nothing | go to DROWSY |
408 * | | | |
409 * ---------+--------------+----------------+----------------|
410 * | | | should not |
411 * timeout | go to TORPID | error, unifi | occur |
412 * | | didn't wake up | do nothing |
413 * ----------------------------------------------------------+
414 *
415 * Note that if we end up in the AWAKE state we always do the host protocol.
416 */
417
418 do
419 {
420 /*
421 * When the host state is set to DROWSY, then we can not disable the
422 * interrupts as UniFi can generate an interrupt even when the INT_ENABLE
423 * register has the interrupts disabled. This interrupt will be lost.
424 */
425 if (card->host_state == UNIFI_HOST_STATE_DROWSY || card->host_state == UNIFI_HOST_STATE_TORPID)
426 {
427 u8 reason_unifi;
428
429 /*
430 * An interrupt may occur while or after we cache the reason.
431 * This interrupt will cause the unifi_bh() to be scheduled again.
432 * Any interrupt that has happened before the register is read
433 * and is considered spurious has to acknowledged.
434 */
435 reason_unifi = card->bh_reason_unifi;
436
437 /*
438 * If an interrupt is received, check if it was a real one,
439 * set the host state to AWAKE and run the BH.
440 */
441 r = CardPendingInt(card, &pending);
442 if (r != CSR_RESULT_SUCCESS)
443 {
444 goto exit;
445 }
446
447 if (pending)
448 {
449 unifi_trace(card->ospriv, UDBG5,
450 "UNIFI_HOST_STATE_%s: Set state to AWAKE.\n",
451 (card->host_state == UNIFI_HOST_STATE_TORPID)?"TORPID" : "DROWSY");
452
453 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
454 if (r == CSR_RESULT_SUCCESS)
455 {
456 (*remaining) = 0;
457 break;
458 }
459 }
460 else if (reason_unifi)
461 {
462 CsrSdioInterruptAcknowledge(card->sdio_if);
463 }
464
465 /*
466 * If an chip is in TORPID, and the host wants to wake it up,
467 * set the host state to DROWSY and wait for the wake-up interrupt.
468 */
469 if ((card->host_state == UNIFI_HOST_STATE_TORPID) && card->bh_reason_host)
470 {
471 r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
472 if (r == CSR_RESULT_SUCCESS)
473 {
474 /*
475 * set the timeout value to UNIFI_DEFAULT_WAKE_TIMEOUT
476 * to capture a wake error.
477 */
478 card->bh_reason_host = 0;
479 (*remaining) = UNIFI_DEFAULT_WAKE_TIMEOUT;
480 return CSR_RESULT_SUCCESS;
481 }
482
483 goto exit;
484 }
485
486 /*
487 * If the chip is in DROWSY, and the timeout expires,
488 * we need to reset the chip. This should never occur.
489 * (If it does, check that the calling thread set "remaining"
490 * according to the time remaining when unifi_bh() was called).
491 */
492 if ((card->host_state == UNIFI_HOST_STATE_DROWSY) && ((*remaining) == 0))
493 {
494 unifi_error(card->ospriv, "UniFi did not wake up on time...\n");
495
496 /*
497 * Check if Function1 has gone away or
498 * if we missed an SDIO interrupt.
499 */
500 r = unifi_check_io_status(card, &iostate);
501 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
502 {
503 goto exit;
504 }
505 /* Need to reset and reboot */
506 return CSR_RESULT_FAILURE;
507 }
508 }
509 else
510 {
511 if (card->bh_reason_unifi || card->bh_reason_host)
512 {
513 break;
514 }
515
516 if (((*remaining) == 0) && (low_power_mode == UNIFI_LOW_POWER_ENABLED))
517 {
518 r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
519 if (r == CSR_RESULT_SUCCESS)
520 {
521 (*remaining) = 0;
522 return CSR_RESULT_SUCCESS;
523 }
524
525 goto exit;
526 }
527 }
528
529 /* No need to run the host protocol */
530 return CSR_RESULT_SUCCESS;
531 } while (0);
532
533
534 /* Disable the SDIO interrupts while doing SDIO ops */
535 csrResult = CsrSdioInterruptDisable(card->sdio_if);
536 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
537 {
538 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
539 goto exit;
540 }
541 if (csrResult != CSR_RESULT_SUCCESS)
542 {
543 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
544 unifi_error(card->ospriv, "Failed to disable SDIO interrupts. unifi_bh queues error.\n");
545 goto exit;
546 }
547
548 /* Now that the interrupts are disabled, ack the interrupt */
549 CsrSdioInterruptAcknowledge(card->sdio_if);
550
551 /* Run the HIP */
552 r = process_bh(card);
553 if (r != CSR_RESULT_SUCCESS)
554 {
555 goto exit;
556 }
557
558 /*
559 * If host is now idle, schedule a timer for the delay before we
560 * let UniFi go into deep sleep.
561 * If the timer goes off, we will move to TORPID state.
562 * If UniFi raises an interrupt in the meantime, we will cancel
563 * the timer and start a new one when we become idle.
564 */
565 for (j = 0; j < UNIFI_NO_OF_TX_QS; j++)
566 {
567 data_slots_used += CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[j]);
568 }
569
570 if ((low_power_mode == UNIFI_LOW_POWER_ENABLED) && (data_slots_used == 0))
571 {
572#ifndef CSR_WIFI_HIP_TA_DISABLE
573 if (card->ta_sampling.traffic_type != CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC)
574 {
575#endif
576 /* return the UNIFI_DEFAULT_HOST_IDLE_TIMEOUT, so we can go to sleep. */
577 unifi_trace(card->ospriv, UDBG5,
578 "Traffic is not periodic, set timer for TORPID.\n");
579 (*remaining) = UNIFI_DEFAULT_HOST_IDLE_TIMEOUT;
580#ifndef CSR_WIFI_HIP_TA_DISABLE
581 }
582 else
583 {
584 unifi_trace(card->ospriv, UDBG5,
585 "Traffic is periodic, set unifi to TORPID immediately.\n");
586 if (CardAreAllFromHostDataSlotsEmpty(card) == 1)
587 {
588 r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
589 if (r != CSR_RESULT_SUCCESS)
590 {
591 goto exit;
592 }
593 }
594 }
595#endif
596 }
597
598 csrResult = CsrSdioInterruptEnable(card->sdio_if);
599 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
600 {
601 r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
602 }
603 if (csrResult != CSR_RESULT_SUCCESS)
604 {
605 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
606 unifi_error(card->ospriv, "Failed to enable SDIO interrupt\n");
607 }
608
609exit:
610
611 unifi_trace(card->ospriv, UDBG4, "New state=%d\n", card->host_state);
612
613 if (r != CSR_RESULT_SUCCESS)
614 {
615#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
616 unifi_debug_buf_dump();
617#endif
618 /* If an interrupt has been raised, ack it here */
619 if (card->bh_reason_unifi)
620 {
621 CsrSdioInterruptAcknowledge(card->sdio_if);
622 }
623
624 unifi_error(card->ospriv,
625 "unifi_bh: state=%d %c, clock=%dkHz, interrupt=%d host=%d, power_save=%s\n",
626 card->host_state,
627 (card->host_state == UNIFI_HOST_STATE_AWAKE)?'A' : (card->host_state == UNIFI_HOST_STATE_DROWSY)?'D' : 'T',
628 card->sdio_clock_speed / 1000,
629 card->bh_reason_unifi, card->bh_reason_host,
630 (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled");
631
632 /* Try to capture firmware panic codes */
633 (void)unifi_capture_panic(card);
634
635 /* Ask for a mini-coredump when the driver has reset UniFi */
636 (void)unifi_coredump_request_at_next_reset(card, 1);
637 }
638
639 return r;
640} /* unifi_bh() */
641
642
643/*
644 * ---------------------------------------------------------------------------
645 * process_clock_request
646 *
647 * Handle request from the OS layer to increase the SDIO clock speed.
648 * The fast clock is limited until the firmware has indicated that it has
649 * completed initialisation to the OS layer.
650 *
651 * Arguments:
652 * card Pointer to card context structure.
653 *
654 * Returns:
655 * CSR_RESULT_SUCCESS on success or CSR error code.
656 * ---------------------------------------------------------------------------
657 */
658static CsrResult process_clock_request(card_t *card)
659{
660 CsrResult r = CSR_RESULT_SUCCESS;
661 CsrResult csrResult;
662
663 if (!card->request_max_clock)
664 {
665 return CSR_RESULT_SUCCESS; /* No pending request */
666 }
667
668 /*
669 * The SDIO clock speed request from the OS layer is only acted upon if
670 * the UniFi is awake. If it was in any other state, the clock speed will
671 * transition through SAFE to MAX while the host wakes it up, and the
672 * final speed reached will be UNIFI_SDIO_CLOCK_MAX_HZ.
673 * This assumes that the SME never requests low power mode while the f/w
674 * initialisation takes place.
675 */
676 if (card->host_state == UNIFI_HOST_STATE_AWAKE)
677 {
678 unifi_trace(card->ospriv, UDBG1, "Set SDIO max clock\n");
679 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_MAX_HZ);
680 if (csrResult != CSR_RESULT_SUCCESS)
681 {
682 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
683 }
684 else
685 {
686 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ; /* log the new freq */
687 }
688 }
689 else
690 {
691 unifi_trace(card->ospriv, UDBG1, "Will set SDIO max clock after wakeup\n");
692 }
693
694 /* Cancel the request now that it has been acted upon, or is about to be
695 * by the wakeup mechanism
696 */
697 card->request_max_clock = 0;
698
699 return r;
700}
701
702
703/*
704 * ---------------------------------------------------------------------------
705 * process_bh
706 *
707 * Exchange messages with UniFi
708 *
709 * Arguments:
710 * card Pointer to card context structure.
711 *
712 * Returns:
713 * CSR_RESULT_SUCCESS on success or CSR error code.
714 * ---------------------------------------------------------------------------
715 */
716static CsrResult process_bh(card_t *card)
717{
718 CsrResult r;
719 u8 more;
720 more = FALSE;
721
722 /* Process the reasons (interrupt, signals) */
723 do
724 {
725 /*
726 * Run in a while loop, to save clearing the interrupts
727 * every time around the outside loop.
728 */
729 do
730 {
731 /* If configured to run the HIP just once, skip first loop */
732 if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
733 {
734 break;
735 }
736
737 r = handle_host_protocol(card, &more);
738 if (r != CSR_RESULT_SUCCESS)
739 {
740 return r;
741 }
742
743#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
744 unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
745 card->cmd_prof.cmd52_count,
746 card->cmd_prof.cmd53_count,
747 card->cmd_prof.tx_count,
748 card->cmd_prof.tx_cfm_count,
749 card->cmd_prof.rx_count,
750 card->cmd_prof.sdio_cmd_signal,
751 card->cmd_prof.sdio_cmd_to_host,
752 card->cmd_prof.sdio_cmd_from_host_and_clear
753 );
754
755 card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
756 card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
757
758 card->cmd_prof.cmd52_f0_r_count = 0;
759 card->cmd_prof.cmd52_f0_w_count = 0;
760 card->cmd_prof.cmd52_r8or16_count = 0;
761 card->cmd_prof.cmd52_w8or16_count = 0;
762 card->cmd_prof.cmd52_r16_count = 0;
763 card->cmd_prof.cmd52_w16_count = 0;
764 card->cmd_prof.cmd52_r32_count = 0;
765
766 card->cmd_prof.sdio_cmd_signal = 0;
767 card->cmd_prof.sdio_cmd_clear_slot = 0;
768 card->cmd_prof.sdio_cmd_to_host = 0;
769 card->cmd_prof.sdio_cmd_from_host = 0;
770 card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
771#endif
772
773
774 } while (more || card->bh_reason_unifi || card->bh_reason_host);
775
776 /* Acknowledge the h/w interrupt */
777 r = CardClearInt(card);
778 if (r != CSR_RESULT_SUCCESS)
779 {
780 unifi_error(card->ospriv, "Failed to acknowledge interrupt.\n");
781 return r;
782 }
783
784 /*
785 * UniFi may have tried to generate an interrupt during the
786 * CardClearInt() was running. So, we need to run the host
787 * protocol again, to check if there are any pending requests.
788 */
789 r = handle_host_protocol(card, &more);
790 if (r != CSR_RESULT_SUCCESS)
791 {
792 return r;
793 }
794
795#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
796 unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
797 card->cmd_prof.cmd52_count,
798 card->cmd_prof.cmd53_count,
799 card->cmd_prof.tx_count,
800 card->cmd_prof.tx_cfm_count,
801 card->cmd_prof.rx_count,
802 card->cmd_prof.sdio_cmd_signal,
803 card->cmd_prof.sdio_cmd_to_host,
804 card->cmd_prof.sdio_cmd_from_host_and_clear
805 );
806
807 card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
808 card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
809
810 card->cmd_prof.cmd52_f0_r_count = 0;
811 card->cmd_prof.cmd52_f0_w_count = 0;
812 card->cmd_prof.cmd52_r8or16_count = 0;
813 card->cmd_prof.cmd52_w8or16_count = 0;
814 card->cmd_prof.cmd52_r16_count = 0;
815 card->cmd_prof.cmd52_w16_count = 0;
816 card->cmd_prof.cmd52_r32_count = 0;
817
818 card->cmd_prof.sdio_cmd_signal = 0;
819 card->cmd_prof.sdio_cmd_clear_slot = 0;
820 card->cmd_prof.sdio_cmd_to_host = 0;
821 card->cmd_prof.sdio_cmd_from_host = 0;
822 card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
823#endif
824 /* If configured to run the HIP just once, work is now done */
825 if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
826 {
827 break;
828 }
829
830 } while (more || card->bh_reason_unifi || card->bh_reason_host);
831
832#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
833 if ((card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) == 0)
834 {
835 unifi_debug_log_to_buf("proc=%d\n",
836 card->cmd_prof.process_count);
837 }
838#endif
839
840 return CSR_RESULT_SUCCESS;
841} /* process_bh() */
842
843
844/*
845 * ---------------------------------------------------------------------------
846 * handle_host_protocol
847 *
848 * This function implements the Host Interface Protocol (HIP) as
849 * described in the Host Interface Protocol Specification.
850 *
851 * Arguments:
852 * card Pointer to card context structure.
853 * processed_something Pointer to location to update processing status:
854 * TRUE when data was transferred
855 * FALSE when no data was transferred (queues empty)
856 *
857 * Returns:
858 * CSR_RESULT_SUCCESS on success or CSR error code.
859 * ---------------------------------------------------------------------------
860 */
861static CsrResult handle_host_protocol(card_t *card, u8 *processed_something)
862{
863 CsrResult r;
864 s32 done;
865
866 *processed_something = FALSE;
867
868#ifdef CSR_WIFI_HIP_NOISY
869 unifi_error(card->ospriv, " ======================== \n");
870#endif /* CSR_WIFI_HIP_NOISY */
871
872#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
873 card->cmd_prof.process_count++;
874#endif
875
876 card->bh_reason_unifi = card->bh_reason_host = 0;
877 card->generate_interrupt = 0;
878
879
880 /*
881 * (Re)fill the T-H signal buffer
882 */
883 r = read_to_host_signals(card, &done);
884 if (r != CSR_RESULT_SUCCESS)
885 {
886 unifi_error(card->ospriv, "Error occurred reading to-host signals\n");
887 return r;
888 }
889 if (done > 0)
890 {
891 *processed_something = TRUE;
892 }
893
894 /*
895 * Process any to-host signals.
896 * Perform any requested CMD53 transfers here, but just queue any
897 * bulk data command responses.
898 */
899 r = process_to_host_signals(card, &done);
900 if (r != CSR_RESULT_SUCCESS)
901 {
902 unifi_error(card->ospriv, "Error occurred processing to-host signals\n");
903 return r;
904 }
905
906 /* Now send any signals in the F-H queues */
907 /* Give precedence to the command queue */
908 r = process_fh_cmd_queue(card, &done);
909 if (r != CSR_RESULT_SUCCESS)
910 {
911 unifi_error(card->ospriv, "Error occurred processing from-host signals\n");
912 return r;
913 }
914 if (done > 0)
915 {
916 *processed_something = TRUE;
917 }
918
919 r = process_fh_traffic_queue(card, &done);
920 if (r != CSR_RESULT_SUCCESS)
921 {
922 unifi_error(card->ospriv, "Error occurred processing from-host data signals\n");
923 return r;
924 }
925 if (done > 0)
926 {
927 *processed_something = TRUE;
928 }
929
930 /* Flush out the batch of signals to the UniFi. */
931 r = flush_fh_buffer(card);
932 if (r != CSR_RESULT_SUCCESS)
933 {
934 unifi_error(card->ospriv, "Failed to copy from-host signals to UniFi\n");
935 return r;
936 }
937
938
939 /*
940 * Send the host interrupt to say the queues have been modified.
941 */
942 if (card->generate_interrupt)
943 {
944 r = CardGenInt(card);
945 if (r != CSR_RESULT_SUCCESS)
946 {
947 unifi_error(card->ospriv, "Failed to notify UniFi that queues have been modified.\n");
948 return r;
949 }
950 }
951
952#ifdef CSR_WIFI_RX_PATH_SPLIT
953#ifdef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
954 unifi_rx_queue_flush(card->ospriv);
955#endif
956#endif
957
958 /* See if we can re-enable transmission now */
959 restart_packet_flow(card);
960
961#ifdef CSR_PRE_ALLOC_NET_DATA
962 r = prealloc_netdata_alloc(card);
963 if (r != CSR_RESULT_SUCCESS)
964 {
965 unifi_error(card->ospriv, "prealloc_netdata failed\n");
966 return r;
967 }
968#endif
969
970 /*
971 * Don't put the thread sleep if we just interacted with the chip,
972 * there might be more to do if we look again.
973 */
974 return r;
975} /* handle_host_protocol() */
976
977
978/*
979 * Rounds the given signal length in bytes to a whole number
980 * of sig_frag_size.
981 */
982#define GET_CHUNKS_FOR(SIG_FRAG_SIZE, LENGTH) (((LENGTH) + ((SIG_FRAG_SIZE)-1)) / (SIG_FRAG_SIZE))
983
984
985/*
986 * ---------------------------------------------------------------------------
987 * read_to_host_signals
988 *
989 * Read everything pending in the UniFi TH signal buffer.
990 * Only do it if the local buffer is empty.
991 *
992 * Arguments:
993 * card Pointer to card context struct
994 * processed Number of signals read:
995 * 0 if there were no signals pending,
996 * 1 if we read at least one signal
997 * Returns:
998 * CSR error code if an error occurred.
999 * ---------------------------------------------------------------------------
1000 */
1001static CsrResult read_to_host_signals(card_t *card, s32 *processed)
1002{
1003 s32 count_thw, count_thr;
1004 s32 unread_chunks, unread_bytes;
1005 CsrResult r;
1006
1007 *processed = 0;
1008
1009 /* Read any pending signals or bulk data commands */
1010 count_thw = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
1011 if (count_thw < 0)
1012 {
1013 unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
1014 return CSR_RESULT_FAILURE;
1015 }
1016 card->to_host_signals_w = count_thw; /* diag */
1017
1018 count_thr = card->to_host_signals_r;
1019
1020 if (count_thw == count_thr)
1021 {
1022 return CSR_RESULT_SUCCESS;
1023 }
1024
1025 unread_chunks =
1026 (((count_thw - count_thr) + 128) % 128) - card->th_buffer.count;
1027
1028 if (unread_chunks == 0)
1029 {
1030 return CSR_RESULT_SUCCESS;
1031 }
1032
1033 unread_bytes = card->config_data.sig_frag_size * unread_chunks;
1034
1035
1036 r = unifi_bulk_rw(card,
1037 card->config_data.tohost_sigbuf_handle,
1038 card->th_buffer.ptr,
1039 unread_bytes,
1040 UNIFI_SDIO_READ);
1041 if (r != CSR_RESULT_SUCCESS)
1042 {
1043 unifi_error(card->ospriv, "Failed to read ToHost signal\n");
1044 return r;
1045 }
1046
1047 card->th_buffer.ptr += unread_bytes;
1048 card->th_buffer.count += (u16)unread_chunks;
1049
1050 *processed = 1;
1051
1052 return CSR_RESULT_SUCCESS;
1053} /* read_to_host_signals() */
1054
1055
1056/*
1057 * ---------------------------------------------------------------------------
1058 * update_to_host_signals_r
1059 *
1060 * Advance the shared-memory count of chunks read from the to-host
1061 * signal buffer.
1062 * Raise a UniFi internal interrupt to tell the firmware that the
1063 * count has changed.
1064 *
1065 * Arguments:
1066 * card Pointer to card context struct
1067 * pending Number of chunks remaining
1068 *
1069 * Returns:
1070 * CSR_RESULT_SUCCESS on success or CSR error code
1071 * ---------------------------------------------------------------------------
1072 */
1073static CsrResult update_to_host_signals_r(card_t *card, s16 pending)
1074{
1075 CsrResult r;
1076
1077 card->to_host_signals_r =
1078 (card->to_host_signals_r + (card->th_buffer.count - pending)) % 128;
1079 card->th_buffer.count = pending;
1080
1081 /* Update the count of signals read */
1082 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 6,
1083 (u8)card->to_host_signals_r);
1084 if (r != CSR_RESULT_SUCCESS)
1085 {
1086 unifi_error(card->ospriv, "Failed to update to-host signals read\n");
1087 return r;
1088 }
1089
1090 r = CardGenInt(card);
1091 if (r != CSR_RESULT_SUCCESS)
1092 {
1093 unifi_error(card->ospriv, "Failed to notify UniFi that we processed to-host signals.\n");
1094 return r;
1095 }
1096
1097 card->generate_interrupt = 0;
1098
1099 return CSR_RESULT_SUCCESS;
1100} /* update_to_host_signals_r() */
1101
1102
1103/*
1104 * ---------------------------------------------------------------------------
1105 * read_unpack_cmd
1106 *
1107 * Converts a wire-formatted command to the host bulk_data_cmd_t structure.
1108 *
1109 * Arguments:
1110 * ptr Pointer to the command
1111 * bulk_data_cmd Pointer to the host structure
1112 *
1113 * Returns:
1114 * None.
1115 * ---------------------------------------------------------------------------
1116 */
1117static void read_unpack_cmd(const u8 *ptr, bulk_data_cmd_t *bulk_data_cmd)
1118{
1119 s16 index = 0;
1120 bulk_data_cmd->cmd_and_len = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1121 index += SIZEOF_UINT16;
1122 bulk_data_cmd->data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1123 index += SIZEOF_UINT16;
1124 bulk_data_cmd->offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1125 index += SIZEOF_UINT16;
1126 bulk_data_cmd->buffer_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1127 index += SIZEOF_UINT16;
1128} /* read_unpack_cmd */
1129
1130
1131/*
1132 * ---------------------------------------------------------------------------
1133 * process_to_host_signals
1134 *
1135 * Read and dispatch signals from the UniFi
1136 *
1137 * Arguments:
1138 * card Pointer to card context struct
1139 * processed Pointer to location to write processing result:
1140 * 0 if there were no signals pending,
1141 * 1 if we read at least one signal
1142 *
1143 * Returns:
1144 * CSR error code if there was an error
1145 *
1146 * Notes:
1147 * Since bulk data transfers can take a long time, if we wait until
1148 * all are done before we acknowledge the signals, the UniFi runs out
1149 * of buffer space. Therefore we keep a count of the bytes transferred
1150 * in bulk data commands, and update the to-host-signals-read count
1151 * if we've done a large transfer.
1152 *
1153 * All data in the f/w is stored in a little endian format, without any
1154 * padding bytes. Every read from the memory has to be transformed in
1155 * host (cpu specific) format, before we can process it. Therefore we
1156 * use read_unpack_cmd() and read_unpack_signal() to convert the raw data
1157 * contained in the card->th_buffer.buf to host structures.
1158 * Important: UDI clients use wire-formatted structures, so we need to
1159 * indicate all data, as we have read it from the device.
1160 * ---------------------------------------------------------------------------
1161 */
1162static CsrResult process_to_host_signals(card_t *card, s32 *processed)
1163{
1164 s16 pending;
1165 s16 remaining;
1166 u8 *bufptr;
1167 bulk_data_param_t data_ptrs;
1168 s16 cmd;
1169 u16 sig_len;
1170 s16 i;
1171 u16 chunks_in_buf;
1172 u16 bytes_transferred = 0;
1173 CsrResult r = CSR_RESULT_SUCCESS;
1174
1175 *processed = 0;
1176
1177 pending = card->th_buffer.count;
1178
1179 /* Are there new to-host signals? */
1180 unifi_trace(card->ospriv, UDBG4, "handling %d to-host chunks\n", pending);
1181
1182 if (!pending)
1183 {
1184 return CSR_RESULT_SUCCESS;
1185 }
1186
1187 /*
1188 * This is a pointer to the raw data we have read from the f/w.
1189 * Can be a signal or a command. Note that we need to convert
1190 * it to a host structure before we process it.
1191 */
1192 bufptr = card->th_buffer.buf;
1193
1194 while (pending > 0)
1195 {
1196 s16 f_flush_count = 0;
1197
1198 /*
1199 * Command and length are common to signal and bulk data msgs.
1200 * If command == 0 (i.e. a signal), len is number of bytes
1201 * *following* the 2-byte header.
1202 */
1203 cmd = bufptr[1] >> 4;
1204 sig_len = bufptr[0] + ((bufptr[1] & 0x0F) << 8);
1205
1206#ifdef CSR_WIFI_HIP_NOISY
1207 unifi_error(card->ospriv, "Received UniFi msg cmd=%d, len=%d\n",
1208 cmd, sig_len);
1209#endif /* CSR_WIFI_HIP_NOISY */
1210
1211 if ((sig_len == 0) &&
1212 ((cmd != SDIO_CMD_CLEAR_SLOT) && (cmd != SDIO_CMD_PADDING)))
1213 {
1214 unifi_error(card->ospriv, "incomplete signal or command: has size zero\n");
1215 return CSR_RESULT_FAILURE;
1216 }
1217 /*
1218 * Make sure the buffer contains a complete message.
1219 * Signals may occupy multiple chunks, bulk-data commands occupy
1220 * one chunk.
1221 */
1222 if (cmd == SDIO_CMD_SIGNAL)
1223 {
1224 chunks_in_buf = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(sig_len + 2));
1225 }
1226 else
1227 {
1228 chunks_in_buf = 1;
1229 }
1230
1231 if (chunks_in_buf > (u16)pending)
1232 {
1233 unifi_error(card->ospriv, "incomplete signal (0x%x?): need %d chunks, got %d\n",
1234 GET_SIGNAL_ID(bufptr + 2),
1235 chunks_in_buf, pending);
1236 unifi_error(card->ospriv, " thsw=%d, thsr=%d\n",
1237 card->to_host_signals_w,
1238 card->to_host_signals_r);
1239 return CSR_RESULT_FAILURE;
1240 }
1241
1242
1243 switch (cmd)
1244 {
1245 case SDIO_CMD_SIGNAL:
1246 /* This is a signal. Read the rest of it and then handle it. */
1247#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1248 card->cmd_prof.sdio_cmd_signal++;
1249#endif
1250
1251 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
1252 {
1253 /* Retrieve dataRefs[i].DataLength */
1254 u16 data_len = GET_PACKED_DATAREF_LEN(bufptr + 2, i);
1255
1256 /*
1257 * The bulk data length in the signal can not be greater than
1258 * the maximun length allowed by the SDIO config structure.
1259 */
1260 if (data_len > card->config_data.data_slot_size)
1261 {
1262 unifi_error(card->ospriv,
1263 "Bulk Data length (%d) exceeds Maximum Bulk Data length (%d)\n",
1264 data_len, card->config_data.data_slot_size);
1265 return CSR_RESULT_FAILURE;
1266 }
1267
1268 /*
1269 * Len here might not be the same as the length in the
1270 * bulk data slot. The slot length will always be even,
1271 * but len could be odd.
1272 */
1273 if (data_len != 0)
1274 {
1275 /* Retrieve dataRefs[i].SlotNumber */
1276 s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
1277
1278 if (slot >= card->config_data.num_tohost_data_slots)
1279 {
1280 unifi_error(card->ospriv, "!!!bad slot number in to-host signal: %d, sig 0x%X\n",
1281 slot, cmd);
1282 return CSR_RESULT_FAILURE;
1283 }
1284
1285 data_ptrs.d[i].os_data_ptr = card->to_host_data[slot].os_data_ptr;
1286 data_ptrs.d[i].os_net_buf_ptr = card->to_host_data[slot].os_net_buf_ptr;
1287 data_ptrs.d[i].net_buf_length = card->to_host_data[slot].net_buf_length;
1288 data_ptrs.d[i].data_length = data_len;
1289 }
1290 else
1291 {
1292 UNIFI_INIT_BULK_DATA(&data_ptrs.d[i]);
1293 }
1294 }
1295
1296 /*
1297 * Log the signal to the UDI, before call unifi_receive_event() as
1298 * it can modify the bulk data.
1299 */
1300 if (card->udi_hook)
1301 {
1302 (*card->udi_hook)(card->ospriv, bufptr + 2, sig_len,
1303 &data_ptrs, UDI_LOG_TO_HOST);
1304 }
1305
1306#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
1307 if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
1308 {
1309 card->cmd_prof.tx_cfm_count++;
1310 }
1311 else if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_INDICATION_ID)
1312 {
1313 if (data_ptrs.d[0].os_data_ptr)
1314 {
1315 if ((*data_ptrs.d[0].os_data_ptr) & 0x08)
1316 {
1317 card->cmd_prof.rx_count++;
1318 }
1319 }
1320 }
1321#endif
1322 /*
1323 * Check if the signal is MA-PACKET.cfm and if so check the status.
1324 * If the status is failure, search through the slot records to find
1325 * if any slots are occupied for this host tag. This can happen if
1326 * f/w has not downloaded the bulkdata and before that itself it has
1327 * signalled the confirm with failure. If it finds a slot with that
1328 * host tag then, it clears the corresponding slot
1329 */
1330
1331 if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
1332 {
1333 /* Get host tag and transmission status */
1334 u32 host_tag = GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(bufptr + 2);
1335 u16 status = GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(bufptr + 2);
1336
1337 unifi_trace(card->ospriv, UDBG4, "process_to_host_signals signal ID=%x host Tag=%x status=%x\n",
1338 GET_SIGNAL_ID(bufptr + 2), host_tag, status);
1339
1340 /* If transmission status is failure then search through the slot records
1341 * and if for any slot records the clear slot is not done then do it now
1342 */
1343
1344 if (status && (card->fh_slot_host_tag_record))
1345 {
1346 u16 num_fh_slots = card->config_data.num_fromhost_data_slots;
1347
1348 /* search through the list of slot records and match with host tag
1349 * If a slot is not yet cleared then clear the slot from here
1350 */
1351 for (i = 0; i < num_fh_slots; i++)
1352 {
1353 if (card->fh_slot_host_tag_record[i] == host_tag)
1354 {
1355#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
1356 /* Invoke the HAL module function to requeue it back to HAL Queues */
1357 r = unifi_reque_ma_packet_request(card->ospriv, host_tag, status, &card->from_host_data[i].bd);
1358 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1359 if (CSR_RESULT_SUCCESS != r)
1360 {
1361 unifi_trace(card->ospriv, UDBG5, "process_to_host_signals: Failed to requeue Packet(hTag:%x) back to HAL \n", host_tag);
1362 CardClearFromHostDataSlot(card, i);
1363 }
1364 else
1365 {
1366 CardClearFromHostDataSlotWithoutFreeingBulkData(card, i);
1367 }
1368
1369#else
1370 unifi_trace(card->ospriv, UDBG4, "process_to_host_signals Clear slot=%x host tag=%x\n", i, host_tag);
1371 card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1372
1373 /* Set length field in from_host_data array to 0 */
1374 CardClearFromHostDataSlot(card, i);
1375#endif
1376 break;
1377 }
1378 }
1379 }
1380 }
1381
1382 /* Pass event to OS layer */
1383 unifi_receive_event(card->ospriv, bufptr + 2, sig_len, &data_ptrs);
1384
1385 /* Initialise the to_host data, so it can be re-used. */
1386 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
1387 {
1388 /* The slot is only valid if the length is non-zero. */
1389 if (GET_PACKED_DATAREF_LEN(bufptr + 2, i) != 0)
1390 {
1391 s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
1392 if (slot < card->config_data.num_tohost_data_slots)
1393 {
1394 UNIFI_INIT_BULK_DATA(&card->to_host_data[slot]);
1395 }
1396 }
1397 }
1398
1399#ifndef CSR_WIFI_DEFER_TH_FLUSH
1400 /*
1401 * If we have previously transferred a lot of data, ack
1402 * the signals read so far, so f/w can reclaim the buffer
1403 * memory sooner.
1404 */
1405 if (bytes_transferred >= TO_HOST_FLUSH_THRESHOLD)
1406 {
1407 f_flush_count = 1;
1408 }
1409#endif
1410 break;
1411
1412
1413 case SDIO_CMD_CLEAR_SLOT:
1414#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1415 card->cmd_prof.sdio_cmd_clear_slot++;
1416#endif
1417 /* This is a clear slot command. */
1418 if (sig_len != 0)
1419 {
1420 unifi_error(card->ospriv, "process_to_host_signals: clear slot, bad data len: 0x%X at offset %d\n",
1421 sig_len, bufptr - card->th_buffer.buf);
1422 return CSR_RESULT_FAILURE;
1423 }
1424
1425 r = process_clear_slot_command(card, bufptr);
1426 if (r != CSR_RESULT_SUCCESS)
1427 {
1428 unifi_error(card->ospriv, "Failed to process clear slot\n");
1429 return r;
1430 }
1431 break;
1432
1433 case SDIO_CMD_TO_HOST_TRANSFER:
1434 case SDIO_CMD_FROM_HOST_TRANSFER:
1435 case SDIO_CMD_FROM_HOST_AND_CLEAR:
1436 case SDIO_CMD_OVERLAY_TRANSFER:
1437 /* This is a bulk data command. */
1438 if (sig_len & 1)
1439 {
1440 unifi_error(card->ospriv, "process_to_host_signals: bulk data, bad data len: 0x%X at offset %d\n",
1441 sig_len, bufptr - card->th_buffer.buf);
1442 return CSR_RESULT_FAILURE;
1443 }
1444
1445 r = process_bulk_data_command(card, bufptr, cmd, sig_len);
1446 if (r != CSR_RESULT_SUCCESS)
1447 {
1448 unifi_error(card->ospriv, "Failed to process bulk cmd\n");
1449 return r;
1450 }
1451 /* Count the bytes transferred */
1452 bytes_transferred += sig_len;
1453
1454 if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
1455 {
1456#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1457 card->cmd_prof.sdio_cmd_from_host_and_clear++;
1458#endif
1459#ifndef CSR_WIFI_DEFER_TH_FLUSH
1460 f_flush_count = 1;
1461#endif
1462 }
1463#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1464 else if (cmd == SDIO_CMD_FROM_HOST_TRANSFER)
1465 {
1466 card->cmd_prof.sdio_cmd_from_host++;
1467 }
1468 else if (cmd == SDIO_CMD_TO_HOST_TRANSFER)
1469 {
1470 card->cmd_prof.sdio_cmd_to_host++;
1471 }
1472#endif
1473 break;
1474
1475 case SDIO_CMD_PADDING:
1476 break;
1477
1478 default:
1479 unifi_error(card->ospriv, "Unrecognised to-host command: %d\n", cmd);
1480 break;
1481 }
1482
1483 bufptr += chunks_in_buf * card->config_data.sig_frag_size;
1484 pending -= chunks_in_buf;
1485
1486 /*
1487 * Write out the host signal count when a significant
1488 * number of bytes of bulk data have been transferred or
1489 * when we have performed a CopyFromHostAndClear.
1490 */
1491 if (f_flush_count)
1492 {
1493 r = update_to_host_signals_r(card, pending);
1494 if (r != CSR_RESULT_SUCCESS)
1495 {
1496 return r;
1497 }
1498 bytes_transferred = 0;
1499 }
1500 }
1501
1502 if (pending)
1503 {
1504 unifi_warning(card->ospriv, "proc_th_sigs: %d unprocessed\n", pending);
1505 }
1506
1507 /* If we processed any signals, write the updated count to UniFi */
1508 if (card->th_buffer.count != pending)
1509 {
1510 r = update_to_host_signals_r(card, pending);
1511 if (r != CSR_RESULT_SUCCESS)
1512 {
1513 return r;
1514 }
1515 }
1516
1517 /*
1518 * Reset the buffer pointer, copying down any un-processed signals.
1519 * This can happen if we enable the optimisation in read_to_host_signals()
1520 * that limits the length to whole blocks.
1521 */
1522 remaining = card->th_buffer.ptr - bufptr;
1523 if (remaining < 0)
1524 {
1525 unifi_error(card->ospriv, "Processing TH signals overran the buffer\n");
1526 return CSR_RESULT_FAILURE;
1527 }
1528 if (remaining > 0)
1529 {
1530 /* Use a safe copy because source and destination may overlap */
1531 u8 *d = card->th_buffer.buf;
1532 u8 *s = bufptr;
1533 s32 n = remaining;
1534 while (n--)
1535 {
1536 *d++ = *s++;
1537 }
1538 }
1539 card->th_buffer.ptr = card->th_buffer.buf + remaining;
1540
1541
1542 /* If we reach here then we processed something */
1543 *processed = 1;
1544 return CSR_RESULT_SUCCESS;
1545} /* process_to_host_signals() */
1546
1547
1548/*
1549 * ---------------------------------------------------------------------------
1550 * process_clear_slot_command
1551 *
1552 * Process a clear slot command fom the UniFi.
1553 *
1554 * Arguments:
1555 * card Pointer to card context struct
1556 * bdcmd Pointer to bulk-data command msg from UniFi
1557 *
1558 * Returns:
1559 * 0 on success, CSR error code on error
1560 * ---------------------------------------------------------------------------
1561 */
1562static CsrResult process_clear_slot_command(card_t *card, const u8 *cmdptr)
1563{
1564 u16 data_slot;
1565 s16 slot;
1566
1567 data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cmdptr + SIZEOF_UINT16);
1568
1569 unifi_trace(card->ospriv, UDBG4, "Processing clear slot cmd, slot=0x%X\n",
1570 data_slot);
1571
1572 slot = data_slot & 0x7FFF;
1573
1574#ifdef CSR_WIFI_HIP_NOISY
1575 unifi_error(card->ospriv, "CMD clear data slot 0x%04x\n", data_slot);
1576#endif /* CSR_WIFI_HIP_NOISY */
1577
1578 if (data_slot & SLOT_DIR_TO_HOST)
1579 {
1580 if (slot >= card->config_data.num_tohost_data_slots)
1581 {
1582 unifi_error(card->ospriv,
1583 "Invalid to-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
1584 slot);
1585 return CSR_RESULT_FAILURE;
1586 }
1587 /* clear to-host data slot */
1588 unifi_warning(card->ospriv, "Unexpected clear to-host data slot cmd: 0x%04x\n",
1589 data_slot);
1590 }
1591 else
1592 {
1593 if (slot >= card->config_data.num_fromhost_data_slots)
1594 {
1595 unifi_error(card->ospriv,
1596 "Invalid from-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
1597 slot);
1598 return CSR_RESULT_FAILURE;
1599 }
1600
1601 /*
1602 * The driver is the owner to clear all slots now
1603 * Ref - comment in process_fh_traffic_queue
1604 * so it will just ignore the clear slot command from firmware
1605 * and return success
1606 */
1607 return CSR_RESULT_SUCCESS;
1608
1609 /* Set length field in from_host_data array to 0 */
1610 /* CardClearFromHostDataSlot(card, slot); */
1611 }
1612
1613 return CSR_RESULT_SUCCESS;
1614} /* process_clear_slot_command() */
1615
1616
1617/*
1618 * ---------------------------------------------------------------------------
1619 * process_bulk_data_command
1620 *
1621 * Process a bulk data request from the UniFi.
1622 *
1623 * Arguments:
1624 * card Pointer to card context struct
1625 * bdcmd Pointer to bulk-data command msg from UniFi
1626 * cmd, len Decoded values of command and length from the msg header
1627 * Cmd will only be one of:
1628 * SDIO_CMD_TO_HOST_TRANSFER
1629 * SDIO_CMD_FROM_HOST_TRANSFER
1630 * SDIO_CMD_FROM_HOST_AND_CLEAR
1631 * SDIO_CMD_OVERLAY_TRANSFER
1632 *
1633 * Returns:
1634 * CSR_RESULT_SUCCESS on success, CSR error code on error
1635 * ---------------------------------------------------------------------------
1636 */
1637static CsrResult process_bulk_data_command(card_t *card, const u8 *cmdptr,
1638 s16 cmd, u16 len)
1639{
1640 bulk_data_desc_t *bdslot;
1641#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1642 u8 *host_bulk_data_slot;
1643#endif
1644 bulk_data_cmd_t bdcmd;
1645 s16 offset;
1646 s16 slot;
1647 s16 dir;
1648 CsrResult r;
1649
1650 read_unpack_cmd(cmdptr, &bdcmd);
1651
1652 unifi_trace(card->ospriv, UDBG4, "Processing bulk data cmd %d %s, len=%d, slot=0x%X\n",
1653 cmd, lookup_bulkcmd_name(cmd), len, bdcmd.data_slot);
1654
1655 /*
1656 * Round up the transfer length if required.
1657 * This is useful to force all transfers to be a multiple of the SDIO block
1658 * size, so the SDIO driver won't try to use a byte-mode CMD53. These are
1659 * broken on some hardware platforms.
1660 */
1661 if (card->sdio_io_block_pad)
1662 {
1663 len = (len + card->sdio_io_block_size - 1) & ~(card->sdio_io_block_size - 1);
1664 unifi_trace(card->ospriv, UDBG4, "Rounded bulk data length up to %d\n", len);
1665 }
1666
1667 slot = bdcmd.data_slot & 0x7FFF;
1668
1669 if (cmd == SDIO_CMD_OVERLAY_TRANSFER)
1670 {
1671 return CSR_WIFI_HIP_RESULT_INVALID_VALUE; /* Not used on CSR6xxx */
1672 }
1673 else
1674 {
1675 if (bdcmd.data_slot & SLOT_DIR_TO_HOST)
1676 {
1677 /* Request is for to-host bulk data */
1678
1679 /* Check sanity of slot number */
1680 if (slot >= card->config_data.num_tohost_data_slots)
1681 {
1682 unifi_error(card->ospriv,
1683 "Invalid to-host data slot in SDIO bulk xfr req: %d\n",
1684 slot);
1685 return CSR_RESULT_FAILURE;
1686 }
1687
1688 /* Allocate memory for card->to_host_data[slot] bulk data here. */
1689#ifdef CSR_PRE_ALLOC_NET_DATA
1690 r = prealloc_netdata_get(card, &card->to_host_data[slot], len);
1691#else
1692 r = unifi_net_data_malloc(card->ospriv, &card->to_host_data[slot], len);
1693#endif
1694 if (r != CSR_RESULT_SUCCESS)
1695 {
1696 unifi_error(card->ospriv, "Failed to allocate t-h bulk data\n");
1697 return CSR_RESULT_FAILURE;
1698 }
1699
1700 bdslot = &card->to_host_data[slot];
1701
1702 /* Make sure that the buffer is 4-bytes aligned */
1703 r = unifi_net_dma_align(card->ospriv, bdslot);
1704 if (r != CSR_RESULT_SUCCESS)
1705 {
1706 unifi_error(card->ospriv, "Failed to align t-h bulk data buffer for DMA\n");
1707 return CSR_RESULT_FAILURE;
1708 }
1709 }
1710 else
1711 {
1712 /* Request is for from-host bulk data */
1713
1714 if (slot >= card->config_data.num_fromhost_data_slots)
1715 {
1716 unifi_error(card->ospriv,
1717 "Invalid from-host data slot in SDIO bulk xfr req: %d\n",
1718 slot);
1719 return CSR_RESULT_FAILURE;
1720 }
1721 bdslot = &card->from_host_data[slot].bd;
1722 }
1723 offset = bdcmd.offset;
1724 }
1725 /* Do the transfer */
1726 dir = (cmd == SDIO_CMD_TO_HOST_TRANSFER)?
1727 UNIFI_SDIO_READ : UNIFI_SDIO_WRITE;
1728
1729 unifi_trace(card->ospriv, UDBG4,
1730 "Bulk %c %s len=%d, handle %d - slot=%d %p+(%d)\n",
1731 (dir == UNIFI_SDIO_READ)?'R' : 'W',
1732 lookup_bulkcmd_name(cmd),
1733 len,
1734 bdcmd.buffer_handle,
1735 slot, bdslot->os_data_ptr, offset);
1736#ifdef CSR_WIFI_HIP_NOISY
1737 unifi_error(card->ospriv, "Bulk %s len=%d, handle %d - slot=%d %p+(%d)\n",
1738 lookup_bulkcmd_name(cmd),
1739 len,
1740 bdcmd.buffer_handle,
1741 slot, bdslot->os_data_ptr, offset);
1742#endif /* CSR_WIFI_HIP_NOISY */
1743
1744
1745 if (bdslot->os_data_ptr == NULL)
1746 {
1747 unifi_error(card->ospriv, "Null os_data_ptr - Bulk %s handle %d - slot=%d o=(%d)\n",
1748 lookup_bulkcmd_name(cmd),
1749 bdcmd.buffer_handle,
1750 slot,
1751 offset);
1752 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1753 }
1754
1755#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1756 /* if os_data_ptr is not 4-byte aligned, then allocate a new buffer and copy data
1757 to new buffer to ensure the address passed to unifi_bulk_rw is 4-byte aligned */
1758
1759 if (len != 0 && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
1760 {
1761 host_bulk_data_slot = kmalloc(len, GFP_KERNEL);
1762
1763 if (!host_bulk_data_slot)
1764 {
1765 unifi_error(card->ospriv, " failed to allocate request_data before unifi_bulk_rw\n");
1766 return -1;
1767 }
1768
1769 memcpy((void *)host_bulk_data_slot,
1770 (void *)(bdslot->os_data_ptr + offset), len);
1771
1772 r = unifi_bulk_rw(card,
1773 bdcmd.buffer_handle,
1774 (void *)host_bulk_data_slot,
1775 len,
1776 dir);
1777 }
1778 else
1779#endif
1780 {
1781 r = unifi_bulk_rw(card,
1782 bdcmd.buffer_handle,
1783 (void *)(bdslot->os_data_ptr + offset),
1784 len,
1785 dir);
1786 }
1787
1788 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1789 {
1790 return r;
1791 }
1792 if (r != CSR_RESULT_SUCCESS)
1793 {
1794 unifi_error(card->ospriv,
1795 "Failed: %s hlen=%d, slen=%d, handle %d - slot=%d %p+0x%X\n",
1796 lookup_bulkcmd_name(cmd),
1797 len, /* Header length */
1798 bdslot->data_length, /* Length stored in slot */
1799 bdcmd.buffer_handle,
1800 slot, bdslot->os_data_ptr, offset);
1801 return r;
1802 }
1803
1804 bdslot->data_length = len;
1805
1806 if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
1807 {
1808 if (slot >= card->config_data.num_fromhost_data_slots)
1809 {
1810 unifi_error(card->ospriv,
1811 "Invalid from-host data slot in SDIO_CMD_FROM_HOST_AND_CLEAR: %d\n",
1812 slot);
1813 return CSR_RESULT_FAILURE;
1814 }
1815
1816#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
1817 /* moving this check before we clear host data slot */
1818 if ((len != 0) && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
1819 {
1820 kfree(host_bulk_data_slot);
1821 }
1822#endif
1823
1824 if (card->fh_slot_host_tag_record)
1825 {
1826 unifi_trace(card->ospriv, UDBG5, "CopyFromHostAndClearSlot Reset entry for slot=%d\n", slot);
1827
1828 /* reset the host tag entry for the corresponding slot */
1829 card->fh_slot_host_tag_record[slot] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
1830 }
1831
1832
1833 /* Set length field in from_host_data array to 0 */
1834 CardClearFromHostDataSlot(card, slot);
1835 }
1836
1837 return CSR_RESULT_SUCCESS;
1838} /* process_bulk_data_command() */
1839
1840
1841/*
1842 * ---------------------------------------------------------------------------
1843 * check_fh_sig_slots
1844 *
1845 * Check whether there are <n> free signal slots available on UniFi.
1846 * This takes into account the signals already batched since the
1847 * from_host_signal counts were last read.
1848 * If the from_host_signal counts indicate not enough space, we read
1849 * the latest count from UniFi to see if some more have been freed.
1850 *
1851 * Arguments:
1852 * None.
1853 *
1854 * Returns:
1855 * CSR_RESULT_SUCCESS, otherwise CSR error code on error.
1856 * ---------------------------------------------------------------------------
1857 */
1858static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space_fh)
1859{
1860 u32 count_fhw;
1861 u32 occupied_fh, slots_fh;
1862 s32 count_fhr;
1863
1864 count_fhw = card->from_host_signals_w;
1865 count_fhr = card->from_host_signals_r;
1866 slots_fh = card->config_data.num_fromhost_sig_frags;
1867
1868 /* Only read the space in from-host queue if necessary */
1869 occupied_fh = (count_fhw - count_fhr) % 128;
1870
1871 if (slots_fh < occupied_fh)
1872 {
1873 *space_fh = 0;
1874 }
1875 else
1876 {
1877 *space_fh = slots_fh - occupied_fh;
1878 }
1879
1880 if ((occupied_fh != 0) && (*space_fh < needed))
1881 {
1882 count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
1883 if (count_fhr < 0)
1884 {
1885 unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
1886 return CSR_RESULT_FAILURE;
1887 }
1888 card->from_host_signals_r = count_fhr; /* diag */
1889
1890 occupied_fh = (count_fhw - count_fhr) % 128;
1891 *space_fh = slots_fh - occupied_fh;
1892 }
1893
1894 return CSR_RESULT_SUCCESS;
1895} /* check_fh_sig_slots() */
1896
1897
1898/*
1899* If we are padding the From-Host signals to the SDIO block size,
1900* we need to round up the needed_chunks to the SDIO block size.
1901*/
1902#define ROUND_UP_NEEDED_CHUNKS(_card, _needed_chunks) \
1903 { \
1904 u16 _chunks_per_block; \
1905 u16 _chunks_in_last_block; \
1906 \
1907 if (_card->sdio_io_block_pad) \
1908 { \
1909 _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
1910 _chunks_in_last_block = _needed_chunks % _chunks_per_block; \
1911 if (_chunks_in_last_block != 0) \
1912 { \
1913 _needed_chunks = _needed_chunks + (_chunks_per_block - _chunks_in_last_block); \
1914 } \
1915 } \
1916 }
1917
1918
1919#define ROUND_UP_SPACE_CHUNKS(_card, _space_chunks) \
1920 { \
1921 u16 _chunks_per_block; \
1922 \
1923 if (_card->sdio_io_block_pad) \
1924 { \
1925 _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
1926 _space_chunks = ((_space_chunks / _chunks_per_block) * _chunks_per_block); \
1927 } \
1928 }
1929
1930
1931
1932
1933
1934/*
1935 * ---------------------------------------------------------------------------
1936 * process_fh_cmd_queue
1937 *
1938 * Take one signal off the from-host queue and copy it to the UniFi.
1939 * Does nothing if the UniFi has no slots free.
1940 *
1941 * Arguments:
1942 * card Pointer to card context struct
1943 * processed Location to write:
1944 * 0 if there is nothing on the queue to process
1945 * 1 if a signal was successfully processed
1946 *
1947 * Returns:
1948 * CSR error code if an error occurred.
1949 *
1950 * Notes:
1951 * The from-host queue contains signal requests from the network driver
1952 * and any UDI clients interspersed. UDI clients' requests have been stored
1953 * in the from-host queue using the wire-format structures, as they arrive.
1954 * All other requests are stored in the from-host queue using the host
1955 * (cpu specific) structures. We use the is_packed member of the card_signal_t
1956 * structure that describes the queue to make the distinction.
1957 * ---------------------------------------------------------------------------
1958 */
1959static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed)
1960{
1961 q_t *sigq = &card->fh_command_queue;
1962
1963 CsrResult r;
1964 u16 pending_sigs;
1965 u16 pending_chunks;
1966 u16 needed_chunks;
1967 s32 space_chunks;
1968 u16 q_index;
1969
1970 *processed = 0;
1971
1972 /* Get the number of pending signals. */
1973 pending_sigs = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
1974 unifi_trace(card->ospriv, UDBG5, "proc_fh: %d pending\n", pending_sigs);
1975 if (pending_sigs == 0)
1976 {
1977 /* Nothing to do */
1978 return CSR_RESULT_SUCCESS;
1979 }
1980
1981 /* Work out how many chunks we have waiting to send */
1982 for (pending_chunks = 0, q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
1983 q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
1984 q_index = CSR_WIFI_HIP_Q_WRAP(sigq, q_index + 1))
1985 {
1986 card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
1987
1988 /*
1989 * Note that GET_CHUNKS_FOR() needs the size of the packed
1990 * (wire-formatted) structure
1991 */
1992 pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
1993 }
1994
1995 /*
1996 * Check whether UniFi has space for all the buffered bulk-data
1997 * commands and signals as well.
1998 */
1999 needed_chunks = pending_chunks + card->fh_buffer.count;
2000
2001 /* Round up to the block size if necessary */
2002 ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
2003
2004 r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
2005 if (r != CSR_RESULT_SUCCESS)
2006 {
2007 /* Error */
2008 unifi_error(card->ospriv, "Failed to read fh sig count\n");
2009 return r;
2010 }
2011
2012#ifdef CSR_WIFI_HIP_NOISY
2013 unifi_error(card->ospriv, "proc_fh: %d chunks free, need %d\n",
2014 space_chunks, needed_chunks);
2015#endif /* CSR_WIFI_HIP_NOISY */
2016
2017
2018 /*
2019 * Coalesce as many from-host signals as possible
2020 * into a single block and write using a single CMD53
2021 */
2022 if (needed_chunks > (u16)space_chunks)
2023 {
2024 /* Round up to the block size if necessary */
2025 ROUND_UP_SPACE_CHUNKS(card, space_chunks);
2026
2027 /*
2028 * If the f/w has less free chunks than those already pending
2029 * return immediately.
2030 */
2031 if ((u16)space_chunks <= card->fh_buffer.count)
2032 {
2033 /*
2034 * No room in UniFi for any signals after the buffered bulk
2035 * data commands have been sent.
2036 */
2037 unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
2038 card->fh_buffer.count, space_chunks);
2039 card->generate_interrupt = 1;
2040 return CSR_RESULT_SUCCESS;
2041 }
2042 pending_chunks = (u16)(space_chunks - card->fh_buffer.count);
2043 }
2044
2045 while (pending_sigs-- && pending_chunks > 0)
2046 {
2047 card_signal_t *csptr;
2048 s16 i;
2049 u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
2050 bulk_data_param_t bulkdata;
2051 u8 *packed_sigptr;
2052 u16 signal_length = 0;
2053
2054 /* Retrieve the entry at the head of the queue */
2055 q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
2056
2057 /* Get a pointer to the containing card_signal_t struct */
2058 csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
2059
2060 /* Get the new length of the packed signal */
2061 signal_length = csptr->signal_length;
2062
2063 if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
2064 {
2065 unifi_error(card->ospriv, "process_fh_queue: Bad len: %d\n", signal_length);
2066 return CSR_RESULT_FAILURE;
2067 }
2068
2069 /* Need space for 2-byte SDIO protocol header + signal */
2070 sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
2071
2072 free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
2073 (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
2074 if (free_chunks_in_fh_buffer < sig_chunks)
2075 {
2076 /* No more room */
2077 unifi_notice(card->ospriv, "proc_fh_cmd_q: no room in fh buffer for 0x%.4X, deferring\n",
2078 (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
2079 break;
2080 }
2081
2082 packed_sigptr = csptr->sigbuf;
2083
2084 /* Claim and set up a from-host data slot */
2085 if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, UNIFI_TRAFFIC_Q_MLME))
2086 {
2087 unifi_notice(card->ospriv, "proc_fh_cmd_q: no fh data slots for 0x%.4X, deferring\n",
2088 (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
2089 break;
2090 }
2091
2092 for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
2093 {
2094 if (csptr->bulkdata[i].data_length == 0)
2095 {
2096 UNIFI_INIT_BULK_DATA(&bulkdata.d[i]);
2097 }
2098 else
2099 {
2100 bulkdata.d[i].os_data_ptr = csptr->bulkdata[i].os_data_ptr;
2101 bulkdata.d[i].data_length = csptr->bulkdata[i].data_length;
2102 }
2103
2104 /* Pass the free responsibility to the lower layer. */
2105 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
2106 }
2107
2108 unifi_trace(card->ospriv, UDBG2, "Sending signal 0x%.4X\n",
2109 GET_SIGNAL_ID(packed_sigptr));
2110#ifdef CSR_WIFI_HIP_NOISY
2111 unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
2112 GET_SIGNAL_ID(packed_sigptr));
2113#endif /* CSR_WIFI_HIP_NOISY */
2114
2115
2116 /* Append packed signal to F-H buffer */
2117 total_length = sig_chunks * card->config_data.sig_frag_size;
2118
2119 card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
2120 card->fh_buffer.ptr[1] =
2121 (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
2122
2123 memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
2124 memset(card->fh_buffer.ptr + 2 + signal_length, 0,
2125 total_length - (2 + signal_length));
2126
2127#ifdef CSR_WIFI_HIP_NOISY
2128 unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
2129 signal_length + 2);
2130 dump(card->fh_buffer.ptr, signal_length + 2);
2131 unifi_trace(card->ospriv, UDBG1, " \n");
2132#endif /* CSR_WIFI_HIP_NOISY */
2133
2134 card->fh_buffer.ptr += total_length;
2135 card->fh_buffer.count += sig_chunks;
2136
2137#ifdef CSR_WIFI_HIP_NOISY
2138 unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
2139 signal_length,
2140 card->fh_buffer.ptr - card->fh_buffer.buf,
2141 card->fh_buffer.count);
2142#endif /* CSR_WIFI_HIP_NOISY */
2143
2144 (*processed)++;
2145 pending_chunks -= sig_chunks;
2146
2147 /* Log the signal to the UDI. */
2148 /* UDI will get the packed structure */
2149 /* Can not log the unpacked signal, unless we reconstruct it! */
2150 if (card->udi_hook)
2151 {
2152 (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
2153 &bulkdata, UDI_LOG_FROM_HOST);
2154 }
2155
2156 /* Remove entry from q */
2157 csptr->signal_length = 0;
2158 CSR_WIFI_HIP_Q_INC_R(sigq);
2159 }
2160
2161 return CSR_RESULT_SUCCESS;
2162} /* process_fh_cmd_queue() */
2163
2164
2165/*
2166 * ---------------------------------------------------------------------------
2167 * process_fh_traffic_queue
2168 *
2169 * Take signals off the from-host queue and copy them to the UniFi.
2170 * Does nothing if the UniFi has no slots free.
2171 *
2172 * Arguments:
2173 * card Pointer to card context struct
2174 * sigq Pointer to the traffic queue
2175 * processed Pointer to location to write:
2176 * 0 if there is nothing on the queue to process
2177 * 1 if a signal was successfully processed
2178 *
2179 * Returns:
2180 * CSR error code if an error occurred.
2181 *
2182 * Notes:
2183 * The from-host queue contains signal requests from the network driver
2184 * and any UDI clients interspersed.
2185 * ---------------------------------------------------------------------------
2186 */
2187static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed)
2188{
2189 q_t *sigq = card->fh_traffic_queue;
2190
2191 CsrResult r;
2192 s16 n = 0;
2193 s32 q_no;
2194 u16 pending_sigs = 0;
2195 u16 pending_chunks = 0;
2196 u16 needed_chunks;
2197 s32 space_chunks;
2198 u16 q_index;
2199 u32 host_tag = 0;
2200 u16 slot_num = 0;
2201
2202 *processed = 0;
2203
2204 /* calculate how many signals are in queues and how many chunks are needed. */
2205 for (n = UNIFI_NO_OF_TX_QS - 1; n >= 0; n--)
2206 {
2207 /* Get the number of pending signals. */
2208 pending_sigs += CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[n]);
2209 unifi_trace(card->ospriv, UDBG5, "proc_fh%d: %d pending\n", n, pending_sigs);
2210
2211 /* Work out how many chunks we have waiting to send */
2212 for (q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[n]);
2213 q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(&sigq[n]);
2214 q_index = CSR_WIFI_HIP_Q_WRAP(&sigq[n], q_index + 1))
2215 {
2216 card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[n], q_index);
2217
2218 /*
2219 * Note that GET_CHUNKS_FOR() needs the size of the packed
2220 * (wire-formatted) structure
2221 */
2222 pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
2223 }
2224 }
2225
2226 /* If there are no pending signals, just return */
2227 if (pending_sigs == 0)
2228 {
2229 /* Nothing to do */
2230 return CSR_RESULT_SUCCESS;
2231 }
2232
2233 /*
2234 * Check whether UniFi has space for all the buffered bulk-data
2235 * commands and signals as well.
2236 */
2237 needed_chunks = pending_chunks + card->fh_buffer.count;
2238
2239 /* Round up to the block size if necessary */
2240 ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
2241
2242 r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
2243 if (r != CSR_RESULT_SUCCESS)
2244 {
2245 /* Error */
2246 unifi_error(card->ospriv, "Failed to read fh sig count\n");
2247 return r;
2248 }
2249
2250#ifdef CSR_WIFI_HIP_NOISY
2251 unifi_error(card->ospriv,
2252 "process_fh_traffic_queue: %d chunks free, need %d\n",
2253 space_chunks, needed_chunks);
2254 read_fhsr(card); /* debugging only */
2255#endif /* CSR_WIFI_HIP_NOISY */
2256
2257 /* Coalesce as many from-host signals as possible
2258 into a single block and write using a single CMD53 */
2259 if (needed_chunks > (u16)space_chunks)
2260 {
2261 /* Round up to the block size if necessary */
2262 ROUND_UP_SPACE_CHUNKS(card, space_chunks);
2263
2264 if ((u16)space_chunks <= card->fh_buffer.count)
2265 {
2266 /*
2267 * No room in UniFi for any signals after the buffered bulk
2268 * data commands have been sent.
2269 */
2270 unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
2271 card->fh_buffer.count, space_chunks);
2272 card->generate_interrupt = 1;
2273 return 0;
2274 }
2275
2276 pending_chunks = (u16)space_chunks - card->fh_buffer.count;
2277 }
2278
2279 q_no = UNIFI_NO_OF_TX_QS - 1;
2280
2281 /*
2282 * pending_sigs will be exhausted if there are is no restriction to the pending
2283 * signals per queue. pending_chunks may be exhausted if there is a restriction.
2284 * q_no check will be exhausted if there is a restriction and our round-robin
2285 * algorith fails to fill all chunks.
2286 */
2287 do
2288 {
2289 card_signal_t *csptr;
2290 u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
2291 bulk_data_param_t bulkdata;
2292 u8 *packed_sigptr;
2293 u16 signal_length = 0;
2294
2295 /* if this queue is empty go to next one. */
2296 if (CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[q_no]) == 0)
2297 {
2298 q_no--;
2299 continue;
2300 }
2301
2302 /* Retrieve the entry at the head of the queue */
2303 q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[q_no]);
2304
2305 /* Get a pointer to the containing card_signal_t struct */
2306 csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[q_no], q_index);
2307
2308 /* Get the new length of the packed signal */
2309 signal_length = csptr->signal_length;
2310
2311 if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
2312 {
2313 unifi_error(card->ospriv, "process_fh_traffic_queue: Bad len: %d\n", signal_length);
2314 return CSR_RESULT_FAILURE;
2315 }
2316
2317 /* Need space for 2-byte SDIO protocol header + signal */
2318 sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
2319 free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
2320 (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
2321 if (free_chunks_in_fh_buffer < sig_chunks)
2322 {
2323 /* No more room */
2324 unifi_notice(card->ospriv, "process_fh_traffic_queue: no more chunks.\n");
2325 break;
2326 }
2327
2328 packed_sigptr = csptr->sigbuf;
2329 /* Claim and set up a from-host data slot */
2330 if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, (unifi_TrafficQueue)q_no))
2331 {
2332 q_no--;
2333 continue;
2334 }
2335
2336 /* Sanity check: MA-PACKET.req must have a valid bulk data */
2337 if ((csptr->bulkdata[0].data_length == 0) || (csptr->bulkdata[0].os_data_ptr == NULL))
2338 {
2339 unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
2340 csptr->bulkdata[0].data_length, csptr->bulkdata[0].os_data_ptr);
2341 dump(packed_sigptr, signal_length);
2342 return CSR_RESULT_FAILURE;
2343 }
2344
2345 bulkdata.d[0].os_data_ptr = csptr->bulkdata[0].os_data_ptr;
2346 bulkdata.d[0].data_length = csptr->bulkdata[0].data_length;
2347 bulkdata.d[0].os_net_buf_ptr = csptr->bulkdata[0].os_net_buf_ptr;
2348 bulkdata.d[0].net_buf_length = csptr->bulkdata[0].net_buf_length;
2349
2350 /* The driver owns clearing of HIP slots for following scenario
2351 * - driver has requested a MA-PACKET.req signal
2352 * - The f/w after receiving the signal decides it can't send it out due to various reasons
2353 * - So the f/w without downloading the bulk data decides to just send a confirmation with fail
2354 * - and then sends a clear slot signal to HIP
2355 *
2356 * But in some cases the clear slot signal never comes and the slot remains --NOT-- freed for ever
2357 *
2358 * To handle this, HIP will keep the record of host tag for each occupied slot
2359 * and then based on status of that Host tag and slot the driver will decide if the slot is
2360 * cleared by f/w signal or the slot has to be freed by driver
2361 */
2362
2363 if (card->fh_slot_host_tag_record)
2364 {
2365 /* Update the f-h slot record for the corresponding host tag */
2366 host_tag = GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(packed_sigptr);
2367 slot_num = GET_PACKED_DATAREF_SLOT(packed_sigptr, 0) & 0x00FF;
2368
2369 unifi_trace(card->ospriv, UDBG5,
2370 "process_fh_traffic_queue signal ID =%x fh slot=%x Host tag =%x\n",
2371 GET_SIGNAL_ID(packed_sigptr), slot_num, host_tag);
2372 card->fh_slot_host_tag_record[slot_num] = host_tag;
2373 }
2374 UNIFI_INIT_BULK_DATA(&bulkdata.d[1]);
2375 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[0]);
2376 UNIFI_INIT_BULK_DATA(&csptr->bulkdata[1]);
2377
2378#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
2379 if (bulkdata.d[0].os_data_ptr)
2380 {
2381 if ((*bulkdata.d[0].os_data_ptr) & 0x08)
2382 {
2383 card->cmd_prof.tx_count++;
2384 }
2385 }
2386#endif
2387 unifi_trace(card->ospriv, UDBG3, "Sending signal 0x%.4X\n",
2388 GET_SIGNAL_ID(packed_sigptr));
2389#ifdef CSR_WIFI_HIP_NOISY
2390 unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
2391 GET_SIGNAL_ID(packed_sigptr));
2392#endif /* CSR_WIFI_HIP_NOISY */
2393
2394 /* Append packed signal to F-H buffer */
2395 total_length = sig_chunks * card->config_data.sig_frag_size;
2396
2397 card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
2398 card->fh_buffer.ptr[1] =
2399 (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
2400
2401 memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
2402 memset(card->fh_buffer.ptr + 2 + signal_length, 0,
2403 total_length - (2 + signal_length));
2404
2405#ifdef CSR_WIFI_HIP_NOISY
2406 unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
2407 signal_length + 2);
2408 dump(card->fh_buffer.ptr, signal_length + 2);
2409 unifi_trace(card->ospriv, UDBG1, " \n");
2410#endif /* CSR_WIFI_HIP_NOISY */
2411
2412 card->fh_buffer.ptr += total_length;
2413 card->fh_buffer.count += sig_chunks;
2414
2415#ifdef CSR_WIFI_HIP_NOISY
2416 unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
2417 signal_length,
2418 card->fh_buffer.ptr - card->fh_buffer.buf,
2419 card->fh_buffer.count);
2420#endif /* CSR_WIFI_HIP_NOISY */
2421
2422 (*processed)++;
2423 pending_sigs--;
2424 pending_chunks -= sig_chunks;
2425
2426 /* Log the signal to the UDI. */
2427 /* UDI will get the packed structure */
2428 /* Can not log the unpacked signal, unless we reconstruct it! */
2429 if (card->udi_hook)
2430 {
2431 (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
2432 &bulkdata, UDI_LOG_FROM_HOST);
2433 }
2434
2435 /* Remove entry from q */
2436 csptr->signal_length = 0;
2437 /* Note that the traffic queue has only one valid bulk data buffer. */
2438 csptr->bulkdata[0].data_length = 0;
2439
2440 CSR_WIFI_HIP_Q_INC_R(&sigq[q_no]);
2441 } while ((pending_sigs > 0) && (pending_chunks > 0) && (q_no >= 0));
2442
2443 return CSR_RESULT_SUCCESS;
2444} /* process_fh_traffic_queue() */
2445
2446
2447/*
2448 * ---------------------------------------------------------------------------
2449 * flush_fh_buffer
2450 *
2451 * Write out the cache from-hosts signals to the UniFi.
2452 *
2453 * Arguments:
2454 * card Pointer to card context struct
2455 *
2456 * Returns:
2457 * CSR error code if an SDIO error occurred.
2458 * ---------------------------------------------------------------------------
2459 */
2460static CsrResult flush_fh_buffer(card_t *card)
2461{
2462 CsrResult r;
2463 u16 len;
2464 u16 sig_units;
2465 u16 data_round;
2466 u16 chunks_in_last_block;
2467 u16 padding_chunks;
2468 u16 i;
2469
2470 len = card->fh_buffer.ptr - card->fh_buffer.buf;
2471
2472#ifdef CSR_WIFI_HIP_NOISY
2473 unifi_error(card->ospriv, "fh_buffer is at %p, ptr= %p\n",
2474 card->fh_buffer.buf, card->fh_buffer.ptr);
2475#endif /* CSR_WIFI_HIP_NOISY */
2476
2477 if (len == 0)
2478 {
2479 return CSR_RESULT_SUCCESS;
2480 }
2481
2482#ifdef CSR_WIFI_HIP_NOISY
2483 if (dump_fh_buf)
2484 {
2485 dump(card->fh_buffer.buf, len);
2486 dump_fh_buf = 0;
2487 }
2488#endif /* CSR_WIFI_HIP_NOISY */
2489
2490 if (card->sdio_io_block_pad)
2491 {
2492 /* Both of these are powers of 2 */
2493 sig_units = card->config_data.sig_frag_size;
2494 data_round = card->sdio_io_block_size;
2495
2496 if (data_round > sig_units)
2497 {
2498 chunks_in_last_block = (len % data_round) / sig_units;
2499
2500 if (chunks_in_last_block != 0)
2501 {
2502 padding_chunks = (data_round / sig_units) - chunks_in_last_block;
2503
2504 memset(card->fh_buffer.ptr, 0, padding_chunks * sig_units);
2505 for (i = 0; i < padding_chunks; i++)
2506 {
2507 card->fh_buffer.ptr[1] = SDIO_CMD_PADDING << 4;
2508 card->fh_buffer.ptr += sig_units;
2509 }
2510
2511 card->fh_buffer.count += padding_chunks;
2512 len += padding_chunks * sig_units;
2513 }
2514 }
2515 }
2516
2517 r = unifi_bulk_rw(card,
2518 card->config_data.fromhost_sigbuf_handle,
2519 card->fh_buffer.buf,
2520 len, UNIFI_SDIO_WRITE);
2521 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
2522 {
2523 return r;
2524 }
2525 if (r != CSR_RESULT_SUCCESS)
2526 {
2527 unifi_error(card->ospriv, "Failed to write fh signals: %u bytes, error %d\n", len, r);
2528 return r;
2529 }
2530
2531 /* Update from-host-signals-written signal count */
2532 card->from_host_signals_w =
2533 (card->from_host_signals_w + card->fh_buffer.count) % 128u;
2534 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 0,
2535 (u8)card->from_host_signals_w);
2536 if (r != CSR_RESULT_SUCCESS)
2537 {
2538 unifi_error(card->ospriv, "Failed to write fh signal count %u with error %d\n",
2539 card->from_host_signals_w, r);
2540 return r;
2541 }
2542 card->generate_interrupt = 1;
2543
2544 /* Reset the fh buffer pointer */
2545 card->fh_buffer.ptr = card->fh_buffer.buf;
2546 card->fh_buffer.count = 0;
2547
2548#ifdef CSR_WIFI_HIP_NOISY
2549 unifi_error(card->ospriv, "END flush: fh len %d, count %d\n",
2550 card->fh_buffer.ptr - card->fh_buffer.buf,
2551 card->fh_buffer.count);
2552#endif /* CSR_WIFI_HIP_NOISY */
2553
2554 return CSR_RESULT_SUCCESS;
2555} /* flush_fh_buffer() */
2556
2557
2558/*
2559 * ---------------------------------------------------------------------------
2560 * restart_packet_flow
2561 *
2562 * This function is called before the bottom-half thread sleeps.
2563 * It checks whether both data and signal resources are available and
2564 * then calls the OS-layer function to re-enable packet transmission.
2565 *
2566 * Arguments:
2567 * card Pointer to card context struct
2568 *
2569 * Returns:
2570 * None.
2571 * ---------------------------------------------------------------------------
2572 */
2573static void restart_packet_flow(card_t *card)
2574{
2575 u8 q;
2576
2577 /*
2578 * We only look at the fh_traffic_queue, because that is where packets from
2579 * the network stack are placed.
2580 */
2581 for (q = 0; q <= UNIFI_TRAFFIC_Q_VO; q++)
2582 {
2583 if (card_is_tx_q_paused(card, q) &&
2584 CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[q]) >= RESUME_XMIT_THRESHOLD)
2585 {
2586#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
2587 unifi_debug_log_to_buf("U");
2588#endif
2589 card_tx_q_unpause(card, q);
2590 unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue)q);
2591 }
2592 }
2593} /* restart_packet_flow() */
2594
2595
drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c+0−1713
@@ -1,1713 +0,0 @@
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 * FILE: csr_wifi_hip_card_sdio_mem.c
14 *
15 * PURPOSE: Implementation of the Card API for SDIO.
16 *
17 * ---------------------------------------------------------------------------
18 */
19#include "csr_wifi_hip_unifi.h"
20#include "csr_wifi_hip_card.h"
21
22#define SDIO_RETRIES 3
23#define CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH 16
24
25
26#define retryable_sdio_error(_csrResult) (((_csrResult) == CSR_SDIO_RESULT_CRC_ERROR) || ((_csrResult) == CSR_SDIO_RESULT_TIMEOUT))
27
28
29/*
30 * ---------------------------------------------------------------------------
31 * retrying_read8
32 * retrying_write8
33 *
34 * These functions provide the first level of retry for SDIO operations.
35 * If an SDIO command fails for reason of a response timeout or CRC
36 * error, it is retried immediately. If three attempts fail we report a
37 * failure.
38 * If the command failed for any other reason, the failure is reported
39 * immediately.
40 *
41 * Arguments:
42 * card Pointer to card structure.
43 * funcnum The SDIO function to access.
44 * Function 0 is the Card Configuration Register space,
45 * function 1/2 is the UniFi register space.
46 * addr Address to access
47 * pdata Pointer in which to return the value read.
48 * data Value to write.
49 *
50 * Returns:
51 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
52 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
53 * CSR_RESULT_FAILURE an SDIO error occurred
54 * ---------------------------------------------------------------------------
55 */
56static CsrResult retrying_read8(card_t *card, s16 funcnum, u32 addr, u8 *pdata)
57{
58 CsrSdioFunction *sdio = card->sdio_if;
59 CsrResult r = CSR_RESULT_SUCCESS;
60 s16 retries;
61 CsrResult csrResult = CSR_RESULT_SUCCESS;
62
63 retries = 0;
64 while (retries++ < SDIO_RETRIES)
65 {
66 if (funcnum == 0)
67 {
68#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
69 unifi_debug_log_to_buf("r0@%02X", addr);
70#endif
71 csrResult = CsrSdioF0Read8(sdio, addr, pdata);
72 }
73 else
74 {
75#ifdef CSR_WIFI_TRANSPORT_CSPI
76 unifi_error(card->ospriv,
77 "retrying_read_f0_8: F1 8-bit reads are not allowed.\n");
78 return CSR_RESULT_FAILURE;
79#else
80#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
81 unifi_debug_log_to_buf("r@%02X", addr);
82#endif
83 csrResult = CsrSdioRead8(sdio, addr, pdata);
84#endif
85 }
86#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
87 if (csrResult != CSR_RESULT_SUCCESS)
88 {
89 unifi_debug_log_to_buf("error=%X\n", csrResult);
90 }
91 else
92 {
93 unifi_debug_log_to_buf("=%X\n", *pdata);
94 }
95#endif
96 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
97 {
98 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
99 }
100 /*
101 * Try again for retryable (CRC or TIMEOUT) errors,
102 * break on success or fatal error
103 */
104 if (!retryable_sdio_error(csrResult))
105 {
106#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
107 card->cmd_prof.cmd52_count++;
108#endif
109 break;
110 }
111 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
112 }
113
114 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
115 {
116 unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
117 }
118
119 if (csrResult != CSR_RESULT_SUCCESS)
120 {
121 unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
122 addr, retries - 1);
123 /* Report any SDIO error as a general i/o error */
124 r = CSR_RESULT_FAILURE;
125 }
126
127 return r;
128} /* retrying_read8() */
129
130
131static CsrResult retrying_write8(card_t *card, s16 funcnum, u32 addr, u8 data)
132{
133 CsrSdioFunction *sdio = card->sdio_if;
134 CsrResult r = CSR_RESULT_SUCCESS;
135 s16 retries;
136 CsrResult csrResult = CSR_RESULT_SUCCESS;
137
138 retries = 0;
139 while (retries++ < SDIO_RETRIES)
140 {
141 if (funcnum == 0)
142 {
143#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
144 unifi_debug_log_to_buf("w0@%02X=%X", addr, data);
145#endif
146 csrResult = CsrSdioF0Write8(sdio, addr, data);
147 }
148 else
149 {
150#ifdef CSR_WIFI_TRANSPORT_CSPI
151 unifi_error(card->ospriv,
152 "retrying_write_f0_8: F1 8-bit writes are not allowed.\n");
153 return CSR_RESULT_FAILURE;
154#else
155#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
156 unifi_debug_log_to_buf("w@%02X=%X", addr, data);
157#endif
158 csrResult = CsrSdioWrite8(sdio, addr, data);
159#endif
160 }
161#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
162 if (csrResult != CSR_RESULT_SUCCESS)
163 {
164 unifi_debug_log_to_buf(",error=%X", csrResult);
165 }
166 unifi_debug_string_to_buf("\n");
167#endif
168 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
169 {
170 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
171 }
172 /*
173 * Try again for retryable (CRC or TIMEOUT) errors,
174 * break on success or fatal error
175 */
176 if (!retryable_sdio_error(csrResult))
177 {
178#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
179 card->cmd_prof.cmd52_count++;
180#endif
181 break;
182 }
183 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
184 data, funcnum, addr);
185 }
186
187 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
188 {
189 unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
190 }
191
192 if (csrResult != CSR_RESULT_SUCCESS)
193 {
194 unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
195 addr, retries - 1);
196 /* Report any SDIO error as a general i/o error */
197 r = CSR_RESULT_FAILURE;
198 }
199
200 return r;
201} /* retrying_write8() */
202
203
204static CsrResult retrying_read16(card_t *card, s16 funcnum,
205 u32 addr, u16 *pdata)
206{
207 CsrSdioFunction *sdio = card->sdio_if;
208 CsrResult r = CSR_RESULT_SUCCESS;
209 s16 retries;
210 CsrResult csrResult = CSR_RESULT_SUCCESS;
211
212 retries = 0;
213 while (retries++ < SDIO_RETRIES)
214 {
215#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
216 unifi_debug_log_to_buf("r@%02X", addr);
217#endif
218 csrResult = CsrSdioRead16(sdio, addr, pdata);
219#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
220 if (csrResult != CSR_RESULT_SUCCESS)
221 {
222 unifi_debug_log_to_buf("error=%X\n", csrResult);
223 }
224 else
225 {
226 unifi_debug_log_to_buf("=%X\n", *pdata);
227 }
228#endif
229 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
230 {
231 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
232 }
233
234 /*
235 * Try again for retryable (CRC or TIMEOUT) errors,
236 * break on success or fatal error
237 */
238 if (!retryable_sdio_error(csrResult))
239 {
240#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
241 card->cmd_prof.cmd52_count++;
242#endif
243 break;
244 }
245 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
246 }
247
248 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
249 {
250 unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
251 }
252
253 if (csrResult != CSR_RESULT_SUCCESS)
254 {
255 unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
256 addr, retries - 1);
257 /* Report any SDIO error as a general i/o error */
258 r = CSR_RESULT_FAILURE;
259 }
260
261 return r;
262} /* retrying_read16() */
263
264
265static CsrResult retrying_write16(card_t *card, s16 funcnum,
266 u32 addr, u16 data)
267{
268 CsrSdioFunction *sdio = card->sdio_if;
269 CsrResult r = CSR_RESULT_SUCCESS;
270 s16 retries;
271 CsrResult csrResult = CSR_RESULT_SUCCESS;
272
273 retries = 0;
274 while (retries++ < SDIO_RETRIES)
275 {
276#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
277 unifi_debug_log_to_buf("w@%02X=%X", addr, data);
278#endif
279 csrResult = CsrSdioWrite16(sdio, addr, data);
280#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
281 if (csrResult != CSR_RESULT_SUCCESS)
282 {
283 unifi_debug_log_to_buf(",error=%X", csrResult);
284 }
285 unifi_debug_string_to_buf("\n");
286#endif
287 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
288 {
289 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
290 }
291
292 /*
293 * Try again for retryable (CRC or TIMEOUT) errors,
294 * break on success or fatal error
295 */
296 if (!retryable_sdio_error(csrResult))
297 {
298#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
299 card->cmd_prof.cmd52_count++;
300#endif
301 break;
302 }
303 unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
304 data, funcnum, addr);
305 }
306
307 if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
308 {
309 unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
310 }
311
312 if (csrResult != CSR_RESULT_SUCCESS)
313 {
314 unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
315 addr, retries - 1);
316 /* Report any SDIO error as a general i/o error */
317 r = CSR_RESULT_FAILURE;
318 }
319
320 return r;
321} /* retrying_write16() */
322
323
324/*
325 * ---------------------------------------------------------------------------
326 * sdio_read_f0
327 *
328 * Reads a byte value from the CCCR (func 0) area of UniFi.
329 *
330 * Arguments:
331 * card Pointer to card structure.
332 * addr Address to read from
333 * pdata Pointer in which to store the read value.
334 *
335 * Returns:
336 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
337 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
338 * CSR_RESULT_FAILURE an SDIO error occurred
339 * ---------------------------------------------------------------------------
340 */
341CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata)
342{
343#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
344 card->cmd_prof.cmd52_f0_r_count++;
345#endif
346 return retrying_read8(card, 0, addr, pdata);
347} /* sdio_read_f0() */
348
349
350/*
351 * ---------------------------------------------------------------------------
352 * sdio_write_f0
353 *
354 * Writes a byte value to the CCCR (func 0) area of UniFi.
355 *
356 * Arguments:
357 * card Pointer to card structure.
358 * addr Address to read from
359 * data Data value to write.
360 *
361 * Returns:
362 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
363 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
364 * CSR_RESULT_FAILURE an SDIO error occurred
365 * ---------------------------------------------------------------------------
366 */
367CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data)
368{
369#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
370 card->cmd_prof.cmd52_f0_w_count++;
371#endif
372 return retrying_write8(card, 0, addr, data);
373} /* sdio_write_f0() */
374
375
376/*
377 * ---------------------------------------------------------------------------
378 * unifi_read_direct_8_or_16
379 *
380 * Read a 8-bit value from the UniFi SDIO interface.
381 *
382 * Arguments:
383 * card Pointer to card structure.
384 * addr Address to read from
385 * pdata Pointer in which to return data.
386 *
387 * Returns:
388 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
389 * ---------------------------------------------------------------------------
390 */
391CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata)
392{
393#ifdef CSR_WIFI_TRANSPORT_CSPI
394 u16 w;
395 CsrResult r;
396
397 r = retrying_read16(card, card->function, addr, &w);
398 *pdata = (u8)(w & 0xFF);
399 return r;
400#else
401 return retrying_read8(card, card->function, addr, pdata);
402#endif
403} /* unifi_read_direct_8_or_16() */
404
405
406/*
407 * ---------------------------------------------------------------------------
408 * unifi_write_direct_8_or_16
409 *
410 * Write a byte value to the UniFi SDIO interface.
411 *
412 * Arguments:
413 * card Pointer to card structure.
414 * addr Address to write to
415 * data Value to write.
416 *
417 * Returns:
418 * CSR_RESULT_SUCCESS on success, non-zero error code on error
419 *
420 * Notes:
421 * If 8-bit write is used, the even address *must* be written second.
422 * This is because writes to odd bytes are cached and not committed
423 * to memory until the preceding even address is written.
424 * ---------------------------------------------------------------------------
425 */
426CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data)
427{
428 if (addr & 1)
429 {
430 unifi_warning(card->ospriv,
431 "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
432 addr);
433 }
434
435#ifdef CSR_WIFI_TRANSPORT_CSPI
436 return retrying_write16(card, card->function, addr, (u16)data);
437#else
438 return retrying_write8(card, card->function, addr, data);
439#endif
440} /* unifi_write_direct_8_or_16() */
441
442
443/*
444 * ---------------------------------------------------------------------------
445 * unifi_read_direct16
446 *
447 * Read a 16-bit value from the UniFi SDIO interface.
448 *
449 * Arguments:
450 * card Pointer to card structure.
451 * addr Address to read from
452 * pdata Pointer in which to return data.
453 *
454 * Returns:
455 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
456 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
457 * CSR_RESULT_FAILURE an SDIO error occurred
458 *
459 * Notes:
460 * The even address *must* be read first. This is because reads from
461 * odd bytes are cached and read from memory when the preceding
462 * even address is read.
463 * ---------------------------------------------------------------------------
464 */
465CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata)
466{
467 return retrying_read16(card, card->function, addr, pdata);
468} /* unifi_read_direct16() */
469
470
471/*
472 * ---------------------------------------------------------------------------
473 * unifi_write_direct16
474 *
475 * Write a 16-bit value to the UniFi SDIO interface.
476 *
477 * Arguments:
478 * card Pointer to card structure.
479 * addr Address to write to
480 * data Value to write.
481 *
482 * Returns:
483 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
484 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
485 * CSR_RESULT_FAILURE an SDIO error occurred
486 *
487 * Notes:
488 * The even address *must* be written second. This is because writes to
489 * odd bytes are cached and not committed to memory until the preceding
490 * even address is written.
491 * ---------------------------------------------------------------------------
492 */
493CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data)
494{
495 return retrying_write16(card, card->function, addr, data);
496} /* unifi_write_direct16() */
497
498
499/*
500 * ---------------------------------------------------------------------------
501 * unifi_read_direct32
502 *
503 * Read a 32-bit value from the UniFi SDIO interface.
504 *
505 * Arguments:
506 * card Pointer to card structure.
507 * addr Address to read from
508 * pdata Pointer in which to return data.
509 *
510 * Returns:
511 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
512 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
513 * CSR_RESULT_FAILURE an SDIO error occurred
514 * ---------------------------------------------------------------------------
515 */
516CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata)
517{
518 CsrResult r;
519 u16 w0, w1;
520
521 r = retrying_read16(card, card->function, addr, &w0);
522 if (r != CSR_RESULT_SUCCESS)
523 {
524 return r;
525 }
526
527 r = retrying_read16(card, card->function, addr + 2, &w1);
528 if (r != CSR_RESULT_SUCCESS)
529 {
530 return r;
531 }
532
533 *pdata = ((u32)w1 << 16) | (u32)w0;
534
535 return CSR_RESULT_SUCCESS;
536} /* unifi_read_direct32() */
537
538
539/*
540 * ---------------------------------------------------------------------------
541 * unifi_read_directn_match
542 *
543 * Read multiple 8-bit values from the UniFi SDIO interface,
544 * stopping when either we have read 'len' bytes or we have read
545 * a octet equal to 'match'. If 'match' is not a valid octet
546 * then this function is the same as 'unifi_read_directn'.
547 *
548 * Arguments:
549 * card Pointer to card structure.
550 * addr Start address to read from.
551 * pdata Pointer to which to write data.
552 * len Maximum umber of bytes to read
553 * match The value to stop reading at.
554 * num Pointer to buffer to write number of bytes read
555 *
556 * Returns:
557 * number of octets read on success, negative error code on error:
558 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
559 * CSR_RESULT_FAILURE an SDIO error occurred
560 *
561 * Notes:
562 * The even address *must* be read first. This is because reads from
563 * odd bytes are cached and read from memory when the preceding
564 * even address is read.
565 * ---------------------------------------------------------------------------
566 */
567static CsrResult unifi_read_directn_match(card_t *card, u32 addr, void *pdata, u16 len, s8 m, u32 *num)
568{
569 CsrResult r;
570 u32 i;
571 u8 *cptr;
572 u16 w;
573
574 *num = 0;
575
576 cptr = (u8 *)pdata;
577 for (i = 0; i < len; i += 2)
578 {
579 r = retrying_read16(card, card->function, addr, &w);
580 if (r != CSR_RESULT_SUCCESS)
581 {
582 return r;
583 }
584
585 *cptr++ = ((u8)w & 0xFF);
586 if ((m >= 0) && (((s8)w & 0xFF) == m))
587 {
588 break;
589 }
590
591 if (i + 1 == len)
592 {
593 /* The len is odd. Ignore the last high byte */
594 break;
595 }
596
597 *cptr++ = ((u8)(w >> 8) & 0xFF);
598 if ((m >= 0) && (((s8)(w >> 8) & 0xFF) == m))
599 {
600 break;
601 }
602
603 addr += 2;
604 }
605
606 *num = (s32)(cptr - (u8 *)pdata);
607 return CSR_RESULT_SUCCESS;
608}
609
610
611/*
612 * ---------------------------------------------------------------------------
613 * unifi_read_directn
614 *
615 * Read multiple 8-bit values from the UniFi SDIO interface.
616 *
617 * Arguments:
618 * card Pointer to card structure.
619 * addr Start address to read from.
620 * pdata Pointer to which to write data.
621 * len Number of bytes to read
622 *
623 * Returns:
624 * 0 on success, non-zero error code on error:
625 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
626 * CSR_RESULT_FAILURE an SDIO error occurred
627 *
628 * Notes:
629 * The even address *must* be read first. This is because reads from
630 * odd bytes are cached and read from memory when the preceding
631 * even address is read.
632 * ---------------------------------------------------------------------------
633 */
634CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len)
635{
636 u32 num;
637
638 return unifi_read_directn_match(card, addr, pdata, len, -1, &num);
639} /* unifi_read_directn() */
640
641
642/*
643 * ---------------------------------------------------------------------------
644 * unifi_write_directn
645 *
646 * Write multiple 8-bit values to the UniFi SDIO interface.
647 *
648 * Arguments:
649 * card Pointer to card structure.
650 * addr Start address to write to.
651 * pdata Source data pointer.
652 * len Number of bytes to write, must be even.
653 *
654 * Returns:
655 * 0 on success, non-zero error code on error:
656 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
657 * CSR_RESULT_FAILURE an SDIO error occurred
658 *
659 * Notes:
660 * The UniFi has a peculiar 16-bit bus architecture. Writes are only
661 * committed to memory when an even address is accessed. Writes to
662 * odd addresses are cached and only committed if the next write is
663 * to the preceding address.
664 * This means we must write data as pairs of bytes in reverse order.
665 * ---------------------------------------------------------------------------
666 */
667CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len)
668{
669 CsrResult r;
670 u8 *cptr;
671 s16 signed_len;
672
673 cptr = (u8 *)pdata;
674 signed_len = (s16)len;
675 while (signed_len > 0)
676 {
677 /* This is UniFi-1 specific code. CSPI not supported so 8-bit write allowed */
678 r = retrying_write16(card, card->function, addr, *cptr);
679 if (r != CSR_RESULT_SUCCESS)
680 {
681 return r;
682 }
683
684 cptr += 2;
685 addr += 2;
686 signed_len -= 2;
687 }
688
689 return CSR_RESULT_SUCCESS;
690} /* unifi_write_directn() */
691
692
693/*
694 * ---------------------------------------------------------------------------
695 * set_dmem_page
696 * set_pmem_page
697 *
698 * Set up the page register for the shared data memory window or program
699 * memory window.
700 *
701 * Arguments:
702 * card Pointer to card structure.
703 * dmem_addr UniFi shared-data-memory address to access.
704 * pmem_addr UniFi program memory address to access. This includes
705 * External FLASH memory at 0x000000
706 * Processor program memory at 0x200000
707 * External SRAM at memory 0x400000
708 * paddr Location to write an SDIO address (24-bit) for
709 * use in a unifi_read_direct or unifi_write_direct call.
710 *
711 * Returns:
712 * CSR_RESULT_SUCCESS on success
713 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
714 * CSR_RESULT_FAILURE an SDIO error occurred
715 * ---------------------------------------------------------------------------
716 */
717static CsrResult set_dmem_page(card_t *card, u32 dmem_addr, u32 *paddr)
718{
719 u16 page, addr;
720 u32 len;
721 CsrResult r;
722
723 *paddr = 0;
724
725 if (!ChipHelper_DecodeWindow(card->helper,
726 CHIP_HELPER_WINDOW_3,
727 CHIP_HELPER_WT_SHARED,
728 dmem_addr / 2,
729 &page, &addr, &len))
730 {
731 unifi_error(card->ospriv, "Failed to decode SHARED_DMEM_PAGE %08lx\n", dmem_addr);
732 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
733 }
734
735 if (page != card->dmem_page)
736 {
737 unifi_trace(card->ospriv, UDBG6, "setting dmem page=0x%X, addr=0x%lX\n", page, addr);
738
739 /* change page register */
740 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, page);
741 if (r != CSR_RESULT_SUCCESS)
742 {
743 unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
744 return r;
745 }
746
747 card->dmem_page = page;
748 }
749
750 *paddr = ((s32)addr * 2) + (dmem_addr & 1);
751
752 return CSR_RESULT_SUCCESS;
753} /* set_dmem_page() */
754
755
756static CsrResult set_pmem_page(card_t *card, u32 pmem_addr,
757 enum chip_helper_window_type mem_type, u32 *paddr)
758{
759 u16 page, addr;
760 u32 len;
761 CsrResult r;
762
763 *paddr = 0;
764
765 if (!ChipHelper_DecodeWindow(card->helper,
766 CHIP_HELPER_WINDOW_2,
767 mem_type,
768 pmem_addr / 2,
769 &page, &addr, &len))
770 {
771 unifi_error(card->ospriv, "Failed to decode PROG MEM PAGE %08lx %d\n", pmem_addr, mem_type);
772 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
773 }
774
775 if (page != card->pmem_page)
776 {
777 unifi_trace(card->ospriv, UDBG6, "setting pmem page=0x%X, addr=0x%lX\n", page, addr);
778
779 /* change page register */
780 r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, page);
781 if (r != CSR_RESULT_SUCCESS)
782 {
783 unifi_error(card->ospriv, "Failed to write PROG MEM PAGE\n");
784 return r;
785 }
786
787 card->pmem_page = page;
788 }
789
790 *paddr = ((s32)addr * 2) + (pmem_addr & 1);
791
792 return CSR_RESULT_SUCCESS;
793} /* set_pmem_page() */
794
795
796/*
797 * ---------------------------------------------------------------------------
798 * set_page
799 *
800 * Sets up the appropriate page register to access the given address.
801 * Returns the sdio address at which the unifi address can be accessed.
802 *
803 * Arguments:
804 * card Pointer to card structure.
805 * generic_addr UniFi internal address to access, in Generic Pointer
806 * format, i.e. top byte is space indicator.
807 * paddr Location to write page address
808 * SDIO address (24-bit) for use in a unifi_read_direct or
809 * unifi_write_direct call
810 *
811 * Returns:
812 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
813 * CSR_RESULT_FAILURE an SDIO error occurred
814 * CSR_WIFI_HIP_RESULT_INVALID_VALUE the address is invalid
815 * ---------------------------------------------------------------------------
816 */
817static CsrResult set_page(card_t *card, u32 generic_addr, u32 *paddr)
818{
819 s32 space;
820 u32 addr;
821 CsrResult r = CSR_RESULT_SUCCESS;
822
823 if (!paddr)
824 {
825 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
826 }
827 *paddr = 0;
828 space = UNIFI_GP_SPACE(generic_addr);
829 addr = UNIFI_GP_OFFSET(generic_addr);
830 switch (space)
831 {
832 case UNIFI_SH_DMEM:
833 /* Shared Data Memory is accessed via the Shared Data Memory window */
834 r = set_dmem_page(card, addr, paddr);
835 if (r != CSR_RESULT_SUCCESS)
836 {
837 return r;
838 }
839 break;
840
841 case UNIFI_EXT_FLASH:
842 if (!ChipHelper_HasFlash(card->helper))
843 {
844 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
845 generic_addr, card->helper);
846 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
847 }
848 /* External FLASH is accessed via the Program Memory window */
849 r = set_pmem_page(card, addr, CHIP_HELPER_WT_FLASH, paddr);
850 break;
851
852 case UNIFI_EXT_SRAM:
853 if (!ChipHelper_HasExtSram(card->helper))
854 {
855 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08l (helper=0x%x)\n",
856 generic_addr, card->helper);
857 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
858 }
859 /* External SRAM is accessed via the Program Memory window */
860 r = set_pmem_page(card, addr, CHIP_HELPER_WT_EXT_SRAM, paddr);
861 break;
862
863 case UNIFI_REGISTERS:
864 /* Registers are accessed directly */
865 *paddr = addr;
866 break;
867
868 case UNIFI_PHY_DMEM:
869 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
870 if (r != CSR_RESULT_SUCCESS)
871 {
872 return r;
873 }
874 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
875 break;
876
877 case UNIFI_MAC_DMEM:
878 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
879 if (r != CSR_RESULT_SUCCESS)
880 {
881 return r;
882 }
883 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
884 break;
885
886 case UNIFI_BT_DMEM:
887 if (!ChipHelper_HasBt(card->helper))
888 {
889 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
890 generic_addr, card->helper);
891 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
892 }
893 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
894 if (r != CSR_RESULT_SUCCESS)
895 {
896 return r;
897 }
898 *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
899 break;
900
901 case UNIFI_PHY_PMEM:
902 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
903 if (r != CSR_RESULT_SUCCESS)
904 {
905 return r;
906 }
907 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
908 break;
909
910 case UNIFI_MAC_PMEM:
911 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
912 if (r != CSR_RESULT_SUCCESS)
913 {
914 return r;
915 }
916 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
917 break;
918
919 case UNIFI_BT_PMEM:
920 if (!ChipHelper_HasBt(card->helper))
921 {
922 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
923 generic_addr, card->helper);
924 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
925 }
926 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
927 if (r != CSR_RESULT_SUCCESS)
928 {
929 return r;
930 }
931 r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
932 break;
933
934 case UNIFI_PHY_ROM:
935 if (!ChipHelper_HasRom(card->helper))
936 {
937 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
938 generic_addr, card->helper);
939 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
940 }
941 r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
942 if (r != CSR_RESULT_SUCCESS)
943 {
944 return r;
945 }
946 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
947 break;
948
949 case UNIFI_MAC_ROM:
950 if (!ChipHelper_HasRom(card->helper))
951 {
952 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
953 generic_addr, card->helper);
954 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
955 }
956 r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
957 if (r != CSR_RESULT_SUCCESS)
958 {
959 return r;
960 }
961 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
962 break;
963
964 case UNIFI_BT_ROM:
965 if (!ChipHelper_HasRom(card->helper) || !ChipHelper_HasBt(card->helper))
966 {
967 unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
968 generic_addr, card->helper);
969 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
970 }
971 r = unifi_set_proc_select(card, UNIFI_PROC_BT);
972 if (r != CSR_RESULT_SUCCESS)
973 {
974 return r;
975 }
976 r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
977 break;
978
979 default:
980 unifi_error(card->ospriv, "Bad address space %d in generic pointer 0x%08lX (helper=0x%x)\n",
981 space, generic_addr, card->helper);
982 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
983 }
984
985 return r;
986} /* set_page() */
987
988
989/*
990 * ---------------------------------------------------------------------------
991 * unifi_set_proc_select
992 *
993 *
994 * Arguments:
995 * card Pointer to card structure.
996 * select Which XAP core to select
997 *
998 * Returns:
999 * 0 on success, non-zero error code on error:
1000 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1001 * CSR_RESULT_FAILURE an SDIO error occurred
1002 * ---------------------------------------------------------------------------
1003 */
1004CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select)
1005{
1006 CsrResult r;
1007
1008 /* Verify the the select value is allowed. */
1009 switch (select)
1010 {
1011 case UNIFI_PROC_MAC:
1012 case UNIFI_PROC_PHY:
1013 case UNIFI_PROC_BOTH:
1014 break;
1015
1016
1017 default:
1018 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1019 }
1020
1021 if (card->proc_select != (u32)select)
1022 {
1023 r = unifi_write_direct16(card,
1024 ChipHelper_DBG_HOST_PROC_SELECT(card->helper) * 2,
1025 (u8)select);
1026 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1027 {
1028 return r;
1029 }
1030 if (r != CSR_RESULT_SUCCESS)
1031 {
1032 unifi_error(card->ospriv, "Failed to write to Proc Select register\n");
1033 return r;
1034 }
1035
1036 card->proc_select = (u32)select;
1037 }
1038
1039 return CSR_RESULT_SUCCESS;
1040}
1041
1042
1043/*
1044 * ---------------------------------------------------------------------------
1045 * unifi_read_8_or_16
1046 *
1047 * Performs a byte read of the given address in shared data memory.
1048 * Set up the shared data memory page register as required.
1049 *
1050 * Arguments:
1051 * card Pointer to card structure.
1052 * unifi_addr UniFi shared-data-memory address to access.
1053 * pdata Pointer to a byte variable for the value read.
1054 *
1055 * Returns:
1056 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1057 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1058 * CSR_RESULT_FAILURE an SDIO error occurred
1059 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1060 * ---------------------------------------------------------------------------
1061 */
1062CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata)
1063{
1064 u32 sdio_addr;
1065 CsrResult r;
1066#ifdef CSR_WIFI_TRANSPORT_CSPI
1067 u16 w;
1068#endif
1069
1070 r = set_page(card, unifi_addr, &sdio_addr);
1071 if (r != CSR_RESULT_SUCCESS)
1072 {
1073 return r;
1074 }
1075
1076#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1077 card->cmd_prof.cmd52_r8or16_count++;
1078#endif
1079#ifdef CSR_WIFI_TRANSPORT_CSPI
1080 r = retrying_read16(card, card->function, sdio_addr, &w);
1081 *pdata = (u8)(w & 0xFF);
1082 return r;
1083#else
1084 return retrying_read8(card, card->function, sdio_addr, pdata);
1085#endif
1086} /* unifi_read_8_or_16() */
1087
1088
1089/*
1090 * ---------------------------------------------------------------------------
1091 * unifi_write_8_or_16
1092 *
1093 * Performs a byte write of the given address in shared data memory.
1094 * Set up the shared data memory page register as required.
1095 *
1096 * Arguments:
1097 * card Pointer to card context struct.
1098 * unifi_addr UniFi shared-data-memory address to access.
1099 * data Value to write.
1100 *
1101 * Returns:
1102 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1103 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1104 * CSR_RESULT_FAILURE an SDIO error occurred
1105 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1106 *
1107 * Notes:
1108 * Beware using unifi_write8() because byte writes are not safe on UniFi.
1109 * Writes to odd bytes are cached, writes to even bytes perform a 16-bit
1110 * write with the previously cached odd byte.
1111 * ---------------------------------------------------------------------------
1112 */
1113CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data)
1114{
1115 u32 sdio_addr;
1116 CsrResult r;
1117#ifdef CSR_WIFI_TRANSPORT_CSPI
1118 u16 w;
1119#endif
1120
1121 r = set_page(card, unifi_addr, &sdio_addr);
1122 if (r != CSR_RESULT_SUCCESS)
1123 {
1124 return r;
1125 }
1126
1127 if (sdio_addr & 1)
1128 {
1129 unifi_warning(card->ospriv,
1130 "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
1131 sdio_addr);
1132 }
1133
1134#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1135 card->cmd_prof.cmd52_w8or16_count++;
1136#endif
1137#ifdef CSR_WIFI_TRANSPORT_CSPI
1138 w = data;
1139 return retrying_write16(card, card->function, sdio_addr, w);
1140#else
1141 return retrying_write8(card, card->function, sdio_addr, data);
1142#endif
1143} /* unifi_write_8_or_16() */
1144
1145
1146/*
1147 * ---------------------------------------------------------------------------
1148 * unifi_card_read16
1149 *
1150 * Performs a 16-bit read of the given address in shared data memory.
1151 * Set up the shared data memory page register as required.
1152 *
1153 * Arguments:
1154 * card Pointer to card structure.
1155 * unifi_addr UniFi shared-data-memory address to access.
1156 * pdata Pointer to a 16-bit int variable for the value read.
1157 *
1158 * Returns:
1159 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1160 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1161 * CSR_RESULT_FAILURE an SDIO error occurred
1162 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1163 * ---------------------------------------------------------------------------
1164 */
1165CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata)
1166{
1167 u32 sdio_addr;
1168 CsrResult r;
1169
1170 r = set_page(card, unifi_addr, &sdio_addr);
1171 if (r != CSR_RESULT_SUCCESS)
1172 {
1173 return r;
1174 }
1175
1176#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1177 card->cmd_prof.cmd52_r16_count++;
1178#endif
1179 return unifi_read_direct16(card, sdio_addr, pdata);
1180} /* unifi_card_read16() */
1181
1182
1183/*
1184 * ---------------------------------------------------------------------------
1185 * unifi_card_write16
1186 *
1187 * Performs a 16-bit write of the given address in shared data memory.
1188 * Set up the shared data memory page register as required.
1189 *
1190 * Arguments:
1191 * card Pointer to card structure.
1192 * unifi_addr UniFi shared-data-memory address to access.
1193 * pdata Pointer to a byte variable for the value write.
1194 *
1195 * Returns:
1196 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1197 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1198 * CSR_RESULT_FAILURE an SDIO error occurred
1199 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1200 * ---------------------------------------------------------------------------
1201 */
1202CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data)
1203{
1204 u32 sdio_addr;
1205 CsrResult r;
1206
1207 r = set_page(card, unifi_addr, &sdio_addr);
1208 if (r != CSR_RESULT_SUCCESS)
1209 {
1210 return r;
1211 }
1212
1213#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1214 card->cmd_prof.cmd52_w16_count++;
1215#endif
1216 return unifi_write_direct16(card, sdio_addr, data);
1217} /* unifi_card_write16() */
1218
1219
1220/*
1221 * ---------------------------------------------------------------------------
1222 * unifi_read32
1223 *
1224 * Performs a 32-bit read of the given address in shared data memory.
1225 * Set up the shared data memory page register as required.
1226 *
1227 * Arguments:
1228 * card Pointer to card structure.
1229 * unifi_addr UniFi shared-data-memory address to access.
1230 * pdata Pointer to a int variable for the value read.
1231 *
1232 * Returns:
1233 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1234 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1235 * CSR_RESULT_FAILURE an SDIO error occurred
1236 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1237 * ---------------------------------------------------------------------------
1238 */
1239CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata)
1240{
1241 u32 sdio_addr;
1242 CsrResult r;
1243
1244 r = set_page(card, unifi_addr, &sdio_addr);
1245 if (r != CSR_RESULT_SUCCESS)
1246 {
1247 return r;
1248 }
1249
1250#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1251 card->cmd_prof.cmd52_r32_count++;
1252#endif
1253 return unifi_read_direct32(card, sdio_addr, pdata);
1254} /* unifi_read32() */
1255
1256
1257/*
1258 * ---------------------------------------------------------------------------
1259 * unifi_card_readn
1260 * unifi_readnz
1261 *
1262 * Read multiple 8-bit values from the UniFi SDIO interface.
1263 * This function interprets the address as a GenericPointer as
1264 * defined in the UniFi Host Interface Protocol Specification.
1265 * The readnz version of this function will stop when it reads a
1266 * zero octet.
1267 *
1268 * Arguments:
1269 * card Pointer to card structure.
1270 * unifi_addr UniFi shared-data-memory address to access.
1271 * pdata Pointer to which to write data.
1272 * len Number of bytes to read
1273 *
1274 * Returns:
1275 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1276 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1277 * CSR_RESULT_FAILURE an SDIO error occurred
1278 * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
1279 * ---------------------------------------------------------------------------
1280 */
1281CsrResult unifi_readn_match(card_t *card, u32 unifi_addr, void *pdata, u16 len, s8 match)
1282{
1283 u32 sdio_addr;
1284 CsrResult r;
1285 u32 num;
1286
1287 r = set_page(card, unifi_addr, &sdio_addr);
1288 if (r != CSR_RESULT_SUCCESS)
1289 {
1290 return r;
1291 }
1292
1293 r = unifi_read_directn_match(card, sdio_addr, pdata, len, match, &num);
1294 return r;
1295} /* unifi_readn_match() */
1296
1297
1298CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1299{
1300 return unifi_readn_match(card, unifi_addr, pdata, len, -1);
1301} /* unifi_card_readn() */
1302
1303
1304CsrResult unifi_readnz(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1305{
1306 return unifi_readn_match(card, unifi_addr, pdata, len, 0);
1307} /* unifi_readnz() */
1308
1309
1310/*
1311 * ---------------------------------------------------------------------------
1312 * unifi_read_shared_count
1313 *
1314 * Read signal count locations, checking for an SDIO error. The
1315 * signal count locations only contain a valid number if the
1316 * highest bit isn't set.
1317 *
1318 * Arguments:
1319 * card Pointer to card context structure.
1320 * addr Shared-memory address to read.
1321 *
1322 * Returns:
1323 * Value read from memory (0-127) or -1 on error
1324 * ---------------------------------------------------------------------------
1325 */
1326s32 unifi_read_shared_count(card_t *card, u32 addr)
1327{
1328 u8 b;
1329 /* I've increased this count, because I have seen cases where
1330 * there were three reads in a row with the top bit set. I'm not
1331 * sure why this might have happened, but I can't see a problem
1332 * with increasing this limit. It's better to take a while to
1333 * recover than to fail. */
1334#define SHARED_READ_RETRY_LIMIT 10
1335 s32 i;
1336
1337 /*
1338 * Get the to-host-signals-written count.
1339 * The top-bit will be set if the firmware was in the process of
1340 * changing the value, in which case we read again.
1341 */
1342 /* Limit the number of repeats so we don't freeze */
1343 for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
1344 {
1345 CsrResult r;
1346 r = unifi_read_8_or_16(card, addr, &b);
1347 if (r != CSR_RESULT_SUCCESS)
1348 {
1349 return -1;
1350 }
1351 if (!(b & 0x80))
1352 {
1353 /* There is a chance that the MSB may have contained invalid data
1354 * (overflow) at the time it was read. Therefore mask off the MSB.
1355 * This avoids a race between driver read and firmware write of the
1356 * word, the value we need is in the lower 8 bits anway.
1357 */
1358 return (s32)(b & 0xff);
1359 }
1360 }
1361
1362 return -1; /* this function has changed in WMM mods */
1363} /* unifi_read_shared_count() */
1364
1365
1366/*
1367 * ---------------------------------------------------------------------------
1368 * unifi_writen
1369 *
1370 * Write multiple 8-bit values to the UniFi SDIO interface using CMD52
1371 * This function interprets the address as a GenericPointer as
1372 * defined in the UniFi Host Interface Protocol Specification.
1373 *
1374 * Arguments:
1375 * card Pointer to card structure.
1376 * unifi_addr UniFi shared-data-memory address to access.
1377 * pdata Pointer to which to write data.
1378 * len Number of bytes to write
1379 *
1380 * Returns:
1381 * 0 on success, non-zero error code on error:
1382 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1383 * CSR_RESULT_FAILURE an SDIO error occurred
1384 * CSR_WIFI_HIP_RESULT_INVALID_VALUE an odd length or length too big.
1385 * ---------------------------------------------------------------------------
1386 */
1387CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len)
1388{
1389 u32 sdio_addr;
1390 CsrResult r;
1391
1392 r = set_page(card, unifi_addr, &sdio_addr);
1393 if (r != CSR_RESULT_SUCCESS)
1394 {
1395 return r;
1396 }
1397
1398 return unifi_write_directn(card, sdio_addr, pdata, len);
1399} /* unifi_writen() */
1400
1401
1402static CsrResult csr_sdio_block_rw(card_t *card, s16 funcnum,
1403 u32 addr, u8 *pdata,
1404 u16 count, s16 dir_is_write)
1405{
1406 CsrResult csrResult;
1407
1408 if (dir_is_write == UNIFI_SDIO_READ)
1409 {
1410#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1411 unifi_debug_log_to_buf("r@%02X#%X=", addr, count);
1412#endif
1413#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1414 unifi_debug_log_to_buf("R");
1415#endif
1416 csrResult = CsrSdioRead(card->sdio_if, addr, pdata, count);
1417#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1418 unifi_debug_log_to_buf("<");
1419#endif
1420 }
1421 else
1422 {
1423#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1424 unifi_debug_log_to_buf("w@%02X#%X=", addr, count);
1425 unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
1426#endif
1427#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1428 unifi_debug_log_to_buf("W");
1429#endif
1430 csrResult = CsrSdioWrite(card->sdio_if, addr, pdata, count);
1431#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
1432 unifi_debug_log_to_buf(">");
1433#endif
1434 }
1435#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
1436 card->cmd_prof.cmd53_count++;
1437#endif
1438#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
1439 if (csrResult != CSR_RESULT_SUCCESS)
1440 {
1441 unifi_debug_log_to_buf("error=%X", csrResult);
1442 }
1443 else if (dir_is_write == UNIFI_SDIO_READ)
1444 {
1445 unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
1446 }
1447 unifi_debug_string_to_buf("\n");
1448#endif
1449 return csrResult; /* CSR SDIO (not HIP) error code */
1450}
1451
1452
1453/*
1454 * ---------------------------------------------------------------------------
1455 * unifi_bulk_rw
1456 *
1457 * Transfer bulk data to or from the UniFi SDIO interface.
1458 * This function is used to read or write signals and bulk data.
1459 *
1460 * Arguments:
1461 * card Pointer to card structure.
1462 * handle Value to put in the Register Address field of the CMD53 req.
1463 * data Pointer to data to write.
1464 * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
1465 *
1466 * Returns:
1467 * CSR_RESULT_SUCCESS on success, non-zero error code on error:
1468 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1469 * CSR_RESULT_FAILURE an SDIO error occurred
1470 *
1471 * Notes:
1472 * This function uses SDIO CMD53, which is the block transfer mode.
1473 * ---------------------------------------------------------------------------
1474 */
1475CsrResult unifi_bulk_rw(card_t *card, u32 handle, void *pdata,
1476 u32 len, s16 direction)
1477{
1478#define CMD53_RETRIES 3
1479 /*
1480 * Ideally instead of sleeping, we want to busy wait.
1481 * Currently there is no framework API to do this. When it becomes available,
1482 * we can use it to busy wait using usecs
1483 */
1484#define REWIND_RETRIES 15 /* when REWIND_DELAY==1msec, or 250 when REWIND_DELAY==50usecs */
1485#define REWIND_POLLING_RETRIES 5
1486#define REWIND_DELAY 1 /* msec or 50usecs */
1487 CsrResult csrResult; /* SDIO error code */
1488 CsrResult r = CSR_RESULT_SUCCESS; /* HIP error code */
1489 s16 retries = CMD53_RETRIES;
1490 s16 stat_retries;
1491 u8 stat;
1492 s16 dump_read;
1493#ifdef UNIFI_DEBUG
1494 u8 *pdata_lsb = ((u8 *)&pdata) + card->lsb;
1495#endif
1496#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
1497 static s16 fake_error;
1498#endif
1499
1500 dump_read = 0;
1501#ifdef UNIFI_DEBUG
1502 if (*pdata_lsb & 1)
1503 {
1504 unifi_notice(card->ospriv, "CD53 request on a unaligned buffer (addr: 0x%X) dir %s-Host\n",
1505 pdata, (direction == UNIFI_SDIO_READ)?"To" : "From");
1506 if (direction == UNIFI_SDIO_WRITE)
1507 {
1508 dump(pdata, (u16)len);
1509 }
1510 else
1511 {
1512 dump_read = 1;
1513 }
1514 }
1515#endif
1516
1517 /* Defensive checks */
1518 if (!pdata)
1519 {
1520 unifi_error(card->ospriv, "Null pdata for unifi_bulk_rw() len: %d\n", len);
1521 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1522 }
1523 if ((len & 1) || (len > 0xffff))
1524 {
1525 unifi_error(card->ospriv, "Impossible CMD53 length requested: %d\n", len);
1526 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
1527 }
1528
1529 while (1)
1530 {
1531 csrResult = csr_sdio_block_rw(card, card->function, handle,
1532 (u8 *)pdata, (u16)len,
1533 direction);
1534 if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
1535 {
1536 return CSR_WIFI_HIP_RESULT_NO_DEVICE;
1537 }
1538#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
1539 if (++fake_error > 100)
1540 {
1541 fake_error = 90;
1542 unifi_warning(card->ospriv, "Faking a CMD53 error,\n");
1543 if (csrResult == CSR_RESULT_SUCCESS)
1544 {
1545 csrResult = CSR_RESULT_FAILURE;
1546 }
1547 }
1548#endif
1549 if (csrResult == CSR_RESULT_SUCCESS)
1550 {
1551 if (dump_read)
1552 {
1553 dump(pdata, (u16)len);
1554 }
1555 break;
1556 }
1557
1558 /*
1559 * At this point the SDIO driver should have written the I/O Abort
1560 * register to notify UniFi that the command has failed.
1561 * UniFi-1 and UniFi-2 (not UF6xxx) use the same register to store the
1562 * Deep Sleep State. This means we have to restore the Deep Sleep
1563 * State (AWAKE in any case since we can not perform a CD53 in any other
1564 * state) by rewriting the I/O Abort register to its previous value.
1565 */
1566 if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
1567 {
1568 (void)unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
1569 }
1570
1571 /* If csr_sdio_block_rw() failed in a non-retryable way, or retries exhausted
1572 * then stop retrying
1573 */
1574 if (!retryable_sdio_error(csrResult))
1575 {
1576 unifi_error(card->ospriv, "Fatal error in a CMD53 transfer\n");
1577 break;
1578 }
1579
1580 /*
1581 * These happen from time to time, try again
1582 */
1583 if (--retries == 0)
1584 {
1585 break;
1586 }
1587
1588 unifi_trace(card->ospriv, UDBG4,
1589 "Error in a CMD53 transfer, retrying (h:%d,l:%u)...\n",
1590 (s16)handle & 0xff, len);
1591
1592 /* The transfer failed, rewind and try again */
1593 r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 8,
1594 (u8)(handle & 0xff));
1595 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1596 {
1597 return r;
1598 }
1599 if (r != CSR_RESULT_SUCCESS)
1600 {
1601 /*
1602 * If we can't even do CMD52 (register read/write) then
1603 * stop here.
1604 */
1605 unifi_error(card->ospriv, "Failed to write REWIND cmd\n");
1606 return r;
1607 }
1608
1609 /* Signal the UniFi to look for the rewind request. */
1610 r = CardGenInt(card);
1611 if (r != CSR_RESULT_SUCCESS)
1612 {
1613 return r;
1614 }
1615
1616 /* Wait for UniFi to acknowledge the rewind */
1617 stat_retries = REWIND_RETRIES;
1618 while (1)
1619 {
1620 r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 8, &stat);
1621 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
1622 {
1623 return r;
1624 }
1625 if (r != CSR_RESULT_SUCCESS)
1626 {
1627 unifi_error(card->ospriv, "Failed to read REWIND status\n");
1628 return CSR_RESULT_FAILURE;
1629 }
1630
1631 if (stat == 0)
1632 {
1633 break;
1634 }
1635 if (--stat_retries == 0)
1636 {
1637 unifi_error(card->ospriv, "Timeout waiting for REWIND ready\n");
1638 return CSR_RESULT_FAILURE;
1639 }
1640
1641 /* Poll for the ack a few times */
1642 if (stat_retries < REWIND_RETRIES - REWIND_POLLING_RETRIES)
1643 {
1644 CsrThreadSleep(REWIND_DELAY);
1645 }
1646 }
1647 }
1648
1649 /* The call to csr_sdio_block_rw() still failed after retrying */
1650 if (csrResult != CSR_RESULT_SUCCESS)
1651 {
1652 unifi_error(card->ospriv, "Block %s failed after %d retries\n",
1653 (direction == UNIFI_SDIO_READ)?"read" : "write",
1654 CMD53_RETRIES - retries);
1655 /* Report any SDIO error as a general i/o error */
1656 return CSR_RESULT_FAILURE;
1657 }
1658
1659 /* Collect some stats */
1660 if (direction == UNIFI_SDIO_READ)
1661 {
1662 card->sdio_bytes_read += len;
1663 }
1664 else
1665 {
1666 card->sdio_bytes_written += len;
1667 }
1668
1669 return CSR_RESULT_SUCCESS;
1670} /* unifi_bulk_rw() */
1671
1672
1673/*
1674 * ---------------------------------------------------------------------------
1675 * unifi_bulk_rw_noretry
1676 *
1677 * Transfer bulk data to or from the UniFi SDIO interface.
1678 * This function is used to read or write signals and bulk data.
1679 *
1680 * Arguments:
1681 * card Pointer to card structure.
1682 * handle Value to put in the Register Address field of
1683 * the CMD53 req.
1684 * data Pointer to data to write.
1685 * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
1686 *
1687 * Returns:
1688 * 0 on success, non-zero error code on error:
1689 * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
1690 * CSR_RESULT_FAILURE an SDIO error occurred
1691 *
1692 * Notes:
1693 * This function uses SDIO CMD53, which is the block transfer mode.
1694 * ---------------------------------------------------------------------------
1695 */
1696CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, void *pdata,
1697 u32 len, s16 direction)
1698{
1699 CsrResult csrResult;
1700
1701 csrResult = csr_sdio_block_rw(card, card->function, handle,
1702 (u8 *)pdata, (u16)len, direction);
1703 if (csrResult != CSR_RESULT_SUCCESS)
1704 {
1705 unifi_error(card->ospriv, "Block %s failed\n",
1706 (direction == UNIFI_SDIO_READ)?"read" : "write");
1707 return csrResult;
1708 }
1709
1710 return CSR_RESULT_SUCCESS;
1711} /* unifi_bulk_rw_noretry() */
1712
1713
drivers/staging/csr/csr_wifi_hip_chiphelper.c+0−793
@@ -1,793 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#include "csr_macro.h"
12#include "csr_wifi_hip_chiphelper_private.h"
13
14#ifndef nelem
15#define nelem(a) (sizeof(a) / sizeof(a[0]))
16#endif
17
18#define counted(foo) { nelem(foo), foo }
19#define null_counted() { 0, NULL }
20
21/* The init values are a set of register writes that we must
22 perform when we first connect to the chip to get it working.
23 They swicth on the correct clocks and possibly set the host
24 interface as a wkaeup source. They should not be used if
25 proper HIP opperation is required, but are useful before we
26 do a code download. */
27static const struct chip_helper_init_values init_vals_v1[] = {
28 { 0xFDBB, 0xFFFF },
29 { 0xFDB6, 0x03FF },
30 { 0xFDB1, 0x01E3 },
31 { 0xFDB3, 0x0FFF },
32 { 0xFEE3, 0x08F0 },
33 { 0xFEE7, 0x3C3F },
34 { 0xFEE6, 0x0050 },
35 { 0xFDBA, 0x0000 }
36};
37
38static const struct chip_helper_init_values init_vals_v2[] = {
39 { 0xFDB6, 0x0FFF },
40 { 0xF023, 0x3F3F },
41 { 0xFDB1, 0x01E3 },
42 { 0xFDB3, 0x0FFF },
43 { 0xF003, 0x08F0 },
44 { 0xF007, 0x3C3F },
45 { 0xF006, 0x0050 }
46};
47
48
49static const struct chip_helper_init_values init_vals_v22_v23[] = {
50 { 0xF81C, 0x00FF },
51 /*{ 0x????, 0x???? }, */
52 { 0xF80C, 0x1FFF },
53 { 0xFA25, 0x001F },
54 { 0xF804, 0x00FF },
55 { 0xF802, 0x0FFF },
56 /*{ 0x????, 0x???? },
57 { 0x????, 0x???? },
58 { 0x????, 0x???? }*/
59};
60
61static const u16 reset_program_a_v1_or_v2[] = {
62 0x0000
63};
64static const u16 reset_program_b_v1_or_v2[] = {
65 0x0010, 0xFE00, 0xA021, 0xFF00, 0x8111, 0x0009, 0x0CA4, 0x0114,
66 0x0280, 0x04F8, 0xFE00, 0x6F25, 0x06E0, 0x0010, 0xFC00, 0x0121,
67 0xFC00, 0x0225, 0xFE00, 0x7125, 0xFE00, 0x6D11, 0x03F0, 0xFE00,
68 0x6E25, 0x0008, 0x00E0
69};
70
71static const struct chip_helper_reset_values reset_program_v1_or_v2[] =
72{
73 {
74 MAKE_GP(REGISTERS, 0x000C),
75 nelem(reset_program_a_v1_or_v2),
76 reset_program_a_v1_or_v2
77 },
78 {
79 MAKE_GP(MAC_PMEM, 0x000000),
80 nelem(reset_program_b_v1_or_v2),
81 reset_program_b_v1_or_v2
82 }
83};
84
85static const struct chip_map_address_t unifi_map_address_v1_v2[] =
86{
87 { 0xFE9F, 0xFE7B }, /* PM1_BANK_SELECT */
88 { 0xFE9E, 0xFE78 }, /* PM2_BANK_SELECT */
89 { 0xFE9D, 0xFE7E }, /* SHARED_DMEM_PAGE */
90 { 0xFE91, 0xFE90 }, /* PROC_SELECT */
91 { 0xFE8D, 0xFE8C }, /* STOP_STATUS */
92};
93
94static const struct chip_map_address_t unifi_map_address_v22_v23[] =
95{
96 { 0xF8F9, 0xF8AC }, /* GW1_CONFIG */
97 { 0xF8FA, 0xF8AD }, /* GW2_CONFIG */
98 { 0xF8FB, 0xF8AE }, /* GW3_CONFIG */
99 { 0xF830, 0xF81E }, /* PROC_SELECT */
100 { 0xF831, 0xF81F }, /* STOP_STATUS */
101 { 0xF8FC, 0xF8AF }, /* IO_LOG_ADDRESS */
102};
103
104static const struct chip_device_regs_t unifi_device_regs_null =
105{
106 0xFE81, /* GBL_CHIP_VERSION */
107 0x0000, /* GBL_MISC_ENABLES */
108 0x0000, /* DBG_EMU_CMD */
109 {
110 0x0000, /* HOST.DBG_PROC_SELECT */
111 0x0000, /* HOST.DBG_STOP_STATUS */
112 0x0000, /* HOST.WINDOW1_PAGE */
113 0x0000, /* HOST.WINDOW2_PAGE */
114 0x0000, /* HOST.WINDOW3_PAGE */
115 0x0000 /* HOST.IO_LOG_ADDR */
116 },
117 {
118 0x0000, /* SPI.DBG_PROC_SELECT */
119 0x0000, /* SPI.DBG_STOP_STATUS */
120 0x0000, /* SPI.WINDOW1_PAGE */
121 0x0000, /* SPI.WINDOW2_PAGE */
122 0x0000, /* SPI.WINDOW3_PAGE */
123 0x0000 /* SPI.IO_LOG_ADDR */
124 },
125 0x0000, /* DBG_RESET */
126 0x0000, /* > DBG_RESET_VALUE */
127 0x0000, /* DBG_RESET_WARN */
128 0x0000, /* DBG_RESET_WARN_VALUE */
129 0x0000, /* DBG_RESET_RESULT */
130 0xFFE9, /* XAP_PCH */
131 0xFFEA, /* XAP_PCL */
132 0x0000, /* PROC_PC_SNOOP */
133 0x0000, /* WATCHDOG_DISABLE */
134 0x0000, /* MAILBOX0 */
135 0x0000, /* MAILBOX1 */
136 0x0000, /* MAILBOX2 */
137 0x0000, /* MAILBOX3 */
138 0x0000, /* SDIO_HOST_INT */
139 0x0000, /* SHARED_IO_INTERRUPT */
140 0x0000, /* SDIO HIP HANDSHAKE */
141 0x0000 /* COEX_STATUS */
142};
143
144/* UF105x */
145static const struct chip_device_regs_t unifi_device_regs_v1 =
146{
147 0xFE81, /* GBL_CHIP_VERSION */
148 0xFE87, /* GBL_MISC_ENABLES */
149 0xFE9C, /* DBG_EMU_CMD */
150 {
151 0xFE90, /* HOST.DBG_PROC_SELECT */
152 0xFE8C, /* HOST.DBG_STOP_STATUS */
153 0xFE7B, /* HOST.WINDOW1_PAGE */
154 0xFE78, /* HOST.WINDOW2_PAGE */
155 0xFE7E, /* HOST.WINDOW3_PAGE */
156 0x0000 /* HOST.IO_LOG_ADDR */
157 },
158 {
159 0xFE91, /* SPI.DBG_PROC_SELECT */
160 0xFE8D, /* SPI.DBG_STOP_STATUS */
161 0xFE9F, /* SPI.WINDOW1_PAGE */
162 0xFE9E, /* SPI.WINDOW2_PAGE */
163 0xFE9D, /* SPI.WINDOW3_PAGE */
164 0x0000 /* SPI.IO_LOG_ADDR */
165 },
166 0xFE92, /* DBG_RESET */
167 0x0001, /* > DBG_RESET_VALUE */
168 0xFDA0, /* DBG_RESET_WARN (HOST_SELECT) */
169 0x0000, /* DBG_RESET_WARN_VALUE */
170 0xFE92, /* DBG_RESET_RESULT */
171 0xFFE9, /* XAP_PCH */
172 0xFFEA, /* XAP_PCL */
173 0x0051, /* PROC_PC_SNOOP */
174 0xFE70, /* WATCHDOG_DISABLE */
175 0xFE6B, /* MAILBOX0 */
176 0xFE6A, /* MAILBOX1 */
177 0xFE69, /* MAILBOX2 */
178 0xFE68, /* MAILBOX3 */
179 0xFE67, /* SDIO_HOST_INT */
180 0xFE65, /* SHARED_IO_INTERRUPT */
181 0xFDE9, /* SDIO HIP HANDSHAKE */
182 0x0000 /* COEX_STATUS */
183};
184
185/* UF2... */
186static const struct chip_device_regs_t unifi_device_regs_v2 =
187{
188 0xFE81, /* GBL_CHIP_VERSION */
189 0xFE87, /* GBL_MISC_ENABLES */
190 0xFE9C, /* DBG_EMU_CMD */
191 {
192 0xFE90, /* HOST.DBG_PROC_SELECT */
193 0xFE8C, /* HOST.DBG_STOP_STATUS */
194 0xFE7B, /* HOST.WINDOW1_PAGE */
195 0xFE78, /* HOST.WINDOW2_PAGE */
196 0xFE7E, /* HOST.WINDOW3_PAGE */
197 0x0000 /* HOST.IO_LOG_ADDR */
198 },
199 {
200 0xFE91, /* SPI.DBG_PROC_SELECT */
201 0xFE8D, /* SPI.DBG_STOP_STATUS */
202 0xFE9F, /* SPI.WINDOW1_PAGE */
203 0xFE9E, /* SPI.WINDOW2_PAGE */
204 0xFE9D, /* SPI.WINDOW3_PAGE */
205 0x0000 /* SPI.IO_LOG_ADDR */
206 },
207 0xFE92, /* DBG_RESET */
208 0x0000, /* > DBG_RESET_VALUE */
209 0xFDE9, /* DBG_RESET_WARN (TEST_FLASH_DATA - SHARED_MAILBOX2B) */
210 0xFFFF, /* DBG_RESET_WARN_VALUE */
211 0xFDE9, /* DBG_RESET_RESULT (TEST_FLASH_DATA) */
212 0xFFE9, /* XAP_PCH */
213 0xFFEA, /* XAP_PCL */
214 0x0051, /* PROC_PC_SNOOP */
215 0xFE70, /* WATCHDOG_DISABLE */
216 0xFE6B, /* MAILBOX0 */
217 0xFE6A, /* MAILBOX1 */
218 0xFE69, /* MAILBOX2 */
219 0xFE68, /* MAILBOX3 */
220 0xFE67, /* SDIO_HOST_INT */
221 0xFE65, /* SHARED_IO_INTERRUPT */
222 0xFE69, /* SDIO HIP HANDSHAKE */
223 0x0000 /* COEX_STATUS */
224};
225
226/* UF60xx */
227static const struct chip_device_regs_t unifi_device_regs_v22_v23 =
228{
229 0xFE81, /* GBL_CHIP_VERSION */
230 0xF84F, /* GBL_MISC_ENABLES */
231 0xF81D, /* DBG_EMU_CMD */
232 {
233 0xF81E, /* HOST.DBG_PROC_SELECT */
234 0xF81F, /* HOST.DBG_STOP_STATUS */
235 0xF8AC, /* HOST.WINDOW1_PAGE */
236 0xF8AD, /* HOST.WINDOW2_PAGE */
237 0xF8AE, /* HOST.WINDOW3_PAGE */
238 0xF8AF /* HOST.IO_LOG_ADDR */
239 },
240 {
241 0xF830, /* SPI.DBG_PROC_SELECT */
242 0xF831, /* SPI.DBG_STOP_STATUS */
243 0xF8F9, /* SPI.WINDOW1_PAGE */
244 0xF8FA, /* SPI.WINDOW2_PAGE */
245 0xF8FB, /* SPI.WINDOW3_PAGE */
246 0xF8FC /* SPI.IO_LOG_ADDR */
247 },
248 0xF82F, /* DBG_RESET */
249 0x0001, /* > DBG_RESET_VALUE */
250 0x0000, /* DBG_RESET_WARN */
251 0x0000, /* DBG_RESET_WARN_VALUE */
252 0xF82F, /* DBG_RESET_RESULT */
253 0xFFE9, /* XAP_PCH */
254 0xFFEA, /* XAP_PCL */
255 0x001B, /* PROC_PC_SNOOP */
256 0x0055, /* WATCHDOG_DISABLE */
257 0xF84B, /* MAILBOX0 */
258 0xF84C, /* MAILBOX1 */
259 0xF84D, /* MAILBOX2 */
260 0xF84E, /* MAILBOX3 */
261 0xF92F, /* SDIO_HOST_INT */
262 0xF92B, /* SDIO_FROMHOST_SCRTACH0 / SHARED_IO_INTERRUPT */
263 0xF84D, /* SDIO HIP HANDSHAKE (MAILBOX2) */
264 0xF9FB /* COEX_STATUS */
265};
266
267/* Program memory window on UF105x. */
268static const struct window_shift_info_t prog_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
269{
270 { TRUE, 11, 0x0200 }, /* CODE RAM */
271 { TRUE, 11, 0x0000 }, /* FLASH */
272 { TRUE, 11, 0x0400 }, /* External SRAM */
273 { FALSE, 0, 0 }, /* ROM */
274 { FALSE, 0, 0 } /* SHARED */
275};
276
277/* Shared memory window on UF105x. */
278static const struct window_shift_info_t shared_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
279{
280 { FALSE, 0, 0 }, /* CODE RAM */
281 { FALSE, 0, 0 }, /* FLASH */
282 { FALSE, 0, 0 }, /* External SRAM */
283 { FALSE, 0, 0 }, /* ROM */
284 { TRUE, 11, 0x0000 } /* SHARED */
285};
286
287/* One of the Generic Windows on UF60xx and later. */
288static const struct window_shift_info_t generic_window_array_unifi_v22_v23[CHIP_HELPER_WT_COUNT] =
289{
290 { TRUE, 11, 0x3800 }, /* CODE RAM */
291 { FALSE, 0, 0 }, /* FLASH */
292 { FALSE, 0, 0 }, /* External SRAM */
293 { TRUE, 11, 0x2000 }, /* ROM */
294 { TRUE, 11, 0x0000 } /* SHARED */
295};
296
297/* The three windows on UF105x. */
298static const struct window_info_t prog1_window_unifi_v1_v2 = { 0x0000, 0x2000, 0x0080, prog_window_array_unifi_v1_v2 };
299static const struct window_info_t prog2_window_unifi_v1_v2 = { 0x2000, 0x2000, 0x0000, prog_window_array_unifi_v1_v2 };
300static const struct window_info_t shared_window_unifi_v1_v2 = { 0x4000, 0x2000, 0x0000, shared_window_array_unifi_v1_v2 };
301
302/* The three windows on UF60xx and later. */
303static const struct window_info_t generic1_window_unifi_v22_v23 = { 0x0000, 0x2000, 0x0080, generic_window_array_unifi_v22_v23 };
304static const struct window_info_t generic2_window_unifi_v22_v23 = { 0x2000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
305static const struct window_info_t generic3_window_unifi_v22_v23 = { 0x4000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
306
307static const struct chip_device_desc_t chip_device_desc_null =
308{
309 { FALSE, 0x0000, 0x0000, 0x00 },
310 "",
311 "",
312 null_counted(), /* init */
313 null_counted(), /* reset_prog */
314 &unifi_device_regs_null, /* regs */
315 {
316 FALSE, /* has_flash */
317 FALSE, /* has_ext_sram */
318 FALSE, /* has_rom */
319 FALSE, /* has_bt */
320 FALSE, /* has_wlan */
321 },
322 null_counted(),
323 /* prog_offset */
324 {
325 0x00000000,
326 0x00000000,
327 0x00000000,
328 0x00000000
329 },
330 /* data_offset */
331 {
332 0x0000 /* ram */
333 },
334 /* windows */
335 {
336 NULL,
337 NULL,
338 NULL
339 }
340};
341
342static const struct chip_device_desc_t unifi_device_desc_v1 =
343{
344 { FALSE, 0xf0ff, 0x1001, 0x01 }, /* UF105x R01 */
345 "UF105x",
346 "UniFi-1",
347 counted(init_vals_v1), /* init */
348 counted(reset_program_v1_or_v2), /* reset_prog */
349 &unifi_device_regs_v1, /* regs */
350 {
351 TRUE, /* has_flash */
352 TRUE, /* has_ext_sram */
353 FALSE, /* has_rom */
354 FALSE, /* has_bt */
355 TRUE, /* has_wlan */
356 },
357 counted(unifi_map_address_v1_v2), /* map */
358 /* prog_offset */
359 {
360 0x00100000, /* ram */
361 0x00000000, /* rom (invalid) */
362 0x00000000, /* flash */
363 0x00200000, /* ext_ram */
364 },
365 /* data_offset */
366 {
367 0x8000 /* ram */
368 },
369 /* windows */
370 {
371 &prog1_window_unifi_v1_v2,
372 &prog2_window_unifi_v1_v2,
373 &shared_window_unifi_v1_v2
374 }
375};
376
377static const struct chip_device_desc_t unifi_device_desc_v2 =
378{
379 { FALSE, 0xf0ff, 0x2001, 0x02 }, /* UF2... R02 */
380 "UF2...",
381 "UniFi-2",
382 counted(init_vals_v2), /* init */
383 counted(reset_program_v1_or_v2), /* reset_prog */
384 &unifi_device_regs_v2, /* regs */
385 {
386 TRUE, /* has_flash */
387 TRUE, /* has_ext_sram */
388 FALSE, /* has_rom */
389 FALSE, /* has_bt */
390 TRUE, /* has_wlan */
391 },
392 counted(unifi_map_address_v1_v2), /* map */
393 /* prog_offset */
394 {
395 0x00100000, /* ram */
396 0x00000000, /* rom (invalid) */
397 0x00000000, /* flash */
398 0x00200000, /* ext_ram */
399 },
400 /* data_offset */
401 {
402 0x8000 /* ram */
403 },
404 /* windows */
405 {
406 &prog1_window_unifi_v1_v2,
407 &prog2_window_unifi_v1_v2,
408 &shared_window_unifi_v1_v2
409 }
410};
411
412static const struct chip_device_desc_t unifi_device_desc_v3 =
413{
414 { FALSE, 0xf0ff, 0x3001, 0x02 }, /* UF2... R03 */
415 "UF2...",
416 "UniFi-3",
417 counted(init_vals_v2), /* init */
418 counted(reset_program_v1_or_v2), /* reset_prog */
419 &unifi_device_regs_v2, /* regs */
420 {
421 TRUE, /* has_flash */
422 TRUE, /* has_ext_sram */
423 FALSE, /* has_rom */
424 FALSE, /* has_bt */
425 TRUE, /* has_wlan */
426 },
427 counted(unifi_map_address_v1_v2), /* map */
428 /* prog_offset */
429 {
430 0x00100000, /* ram */
431 0x00000000, /* rom (invalid) */
432 0x00000000, /* flash */
433 0x00200000, /* ext_ram */
434 },
435 /* data_offset */
436 {
437 0x8000 /* ram */
438 },
439 /* windows */
440 {
441 &prog1_window_unifi_v1_v2,
442 &prog2_window_unifi_v1_v2,
443 &shared_window_unifi_v1_v2
444 }
445};
446
447static const struct chip_device_desc_t unifi_device_desc_v22 =
448{
449 { FALSE, 0x00ff, 0x0022, 0x07 }, /* UF60xx */
450 "UF60xx",
451 "UniFi-4",
452 counted(init_vals_v22_v23), /* init */
453 null_counted(), /* reset_prog */
454 &unifi_device_regs_v22_v23, /* regs */
455 {
456 FALSE, /* has_flash */
457 FALSE, /* has_ext_sram */
458 TRUE, /* has_rom */
459 FALSE, /* has_bt */
460 TRUE, /* has_wlan */
461 },
462 counted(unifi_map_address_v22_v23), /* map */
463 /* prog_offset */
464 {
465 0x00C00000, /* ram */
466 0x00000000, /* rom */
467 0x00000000, /* flash (invalid) */
468 0x00000000, /* ext_ram (invalid) */
469 },
470 /* data_offset */
471 {
472 0x8000 /* ram */
473 },
474 /* windows */
475 {
476 &generic1_window_unifi_v22_v23,
477 &generic2_window_unifi_v22_v23,
478 &generic3_window_unifi_v22_v23
479 }
480};
481
482static const struct chip_device_desc_t unifi_device_desc_v23 =
483{
484 { FALSE, 0x00ff, 0x0023, 0x08 }, /* UF.... */
485 "UF....",
486 "UF.... (5)",
487 counted(init_vals_v22_v23), /* init */
488 null_counted(), /* reset_prog */
489 &unifi_device_regs_v22_v23, /* regs */
490 {
491 FALSE, /* has_flash */
492 FALSE, /* has_ext_sram */
493 TRUE, /* has_rom */
494 TRUE, /* has_bt */
495 TRUE, /* has_wlan */
496 },
497 counted(unifi_map_address_v22_v23),
498 /* prog_offset */
499 {
500 0x00C00000, /* ram */
501 0x00000000, /* rom */
502 0x00000000, /* flash (invalid) */
503 0x00000000, /* ext_sram (invalid) */
504 },
505 /* data_offset */
506 {
507 0x8000 /* ram */
508 },
509 /* windows */
510 {
511 &generic1_window_unifi_v22_v23,
512 &generic2_window_unifi_v22_v23,
513 &generic3_window_unifi_v22_v23
514 }
515};
516
517static const struct chip_device_desc_t hyd_wlan_subsys_desc_v1 =
518{
519 { FALSE, 0x00ff, 0x0044, 0x00 }, /* UF.... */
520 "HYD...",
521 "HYD... ",
522 counted(init_vals_v22_v23), /* init */
523 null_counted(), /* reset_prog */
524 &unifi_device_regs_v22_v23, /* regs */
525 {
526 FALSE, /* has_flash */
527 FALSE, /* has_ext_sram */
528 TRUE, /* has_rom */
529 FALSE, /* has_bt */
530 TRUE, /* has_wlan */
531 },
532 counted(unifi_map_address_v22_v23),
533 /* prog_offset */
534 {
535 0x00C00000, /* ram */
536 0x00000000, /* rom */
537 0x00000000, /* flash (invalid) */
538 0x00000000, /* ext_sram (invalid) */
539 },
540 /* data_offset */
541 {
542 0x8000 /* ram */
543 },
544 /* windows */
545 {
546 &generic1_window_unifi_v22_v23,
547 &generic2_window_unifi_v22_v23,
548 &generic3_window_unifi_v22_v23
549 }
550};
551
552
553/* This is the list of all chips that we know about. I'm
554 assuming that the order here will be important - we
555 might have multiple entries witrh the same SDIO id for
556 instance. The first one in this list will be the one
557 that is returned if a search is done on only that id.
558 The client will then have to call GetVersionXXX again
559 but with more detailed info.
560
561 I don't know if we need to signal this up to the client
562 in some way?
563
564 (We get the SDIO id before we know anything else about
565 the chip. We might not be able to read any of the other
566 registers at first, but we still need to know about the
567 chip). */
568static const struct chip_device_desc_t *chip_ver_to_desc[] =
569{
570 &unifi_device_desc_v1, /* UF105x R01 */
571 &unifi_device_desc_v2, /* UF2... R02 */
572 &unifi_device_desc_v3, /* UF2... R03 */
573 &unifi_device_desc_v22, /* UF60xx */
574 &unifi_device_desc_v23, /* UF.... */
575 &hyd_wlan_subsys_desc_v1
576};
577
578ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_ver)
579{
580 u32 i;
581
582 for (i = 0; i < nelem(chip_ver_to_desc); i++)
583 {
584 if (chip_ver_to_desc[i]->chip_version.sdio == sdio_ver)
585 {
586 return chip_ver_to_desc[i];
587 }
588 }
589
590 return &chip_device_desc_null;
591}
592
593
594ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81)
595{
596 u32 i;
597
598 if ((from_FF9A & 0xFF00) != 0)
599 {
600 for (i = 0; i < nelem(chip_ver_to_desc); i++)
601 {
602 if (chip_ver_to_desc[i]->chip_version.pre_bc7 &&
603 ((from_FF9A & chip_ver_to_desc[i]->chip_version.mask) ==
604 chip_ver_to_desc[i]->chip_version.result))
605 {
606 return chip_ver_to_desc[i];
607 }
608 }
609 }
610 else
611 {
612 for (i = 0; i < nelem(chip_ver_to_desc); i++)
613 {
614 if (!chip_ver_to_desc[i]->chip_version.pre_bc7 &&
615 ((from_FE81 & chip_ver_to_desc[i]->chip_version.mask) ==
616 chip_ver_to_desc[i]->chip_version.result))
617 {
618 return chip_ver_to_desc[i];
619 }
620 }
621 }
622
623 return &chip_device_desc_null;
624}
625
626
627ChipDescript* ChipHelper_GetVersionUniFi(u16 ver)
628{
629 return ChipHelper_GetVersionAny(0x0000, ver);
630}
631
632
633ChipDescript *ChipHelper_Null(void)
634{
635 return &chip_device_desc_null;
636}
637
638
639ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age bc_age, u16 version)
640{
641 if (bc_age == chip_helper_bluecore_pre_bc7)
642 {
643 return ChipHelper_GetVersionAny(version, 0x0000);
644 }
645 else
646 {
647 return ChipHelper_GetVersionAny(0x0000, version);
648 }
649}
650
651
652/* Expand the DEF0 functions into simple code to return the
653 correct thing. The DEF1 functions expand to nothing in
654 this X macro expansion. */
655#define CHIP_HELPER_DEF0_C_DEF(ret_type, name, info) \
656 ret_type ChipHelper_ ## name(ChipDescript * chip_help) \
657 { \
658 return chip_help->info; \
659 }
660#define CHIP_HELPER_DEF1_C_DEF(ret_type, name, type1, name1)
661
662CHIP_HELPER_LIST(C_DEF)
663
664/*
665 * Map register addresses between HOST and SPI access.
666 */
667u16 ChipHelper_MapAddress_SPI2HOST(ChipDescript *chip_help, u16 addr)
668{
669 u32 i;
670 for (i = 0; i < chip_help->map.len; i++)
671 {
672 if (chip_help->map.vals[i].spi == addr)
673 {
674 return chip_help->map.vals[i].host;
675 }
676 }
677 return addr;
678}
679
680
681u16 ChipHelper_MapAddress_HOST2SPI(ChipDescript *chip_help, u16 addr)
682{
683 u32 i;
684 for (i = 0; i < chip_help->map.len; i++)
685 {
686 if (chip_help->map.vals[i].host == addr)
687 {
688 return chip_help->map.vals[i].spi;
689 }
690 }
691 return addr;
692}
693
694
695/* The address returned by this function is the start of the
696 window in the address space, that is where we can start
697 accessing data from. If a section of the window at the
698 start is unusable because something else is cluttering up
699 the address map then that is taken into account and this
700 function returns that address justt past that. */
701u16 ChipHelper_WINDOW_ADDRESS(ChipDescript *chip_help,
702 enum chip_helper_window_index window)
703{
704 if (window < CHIP_HELPER_WINDOW_COUNT &&
705 chip_help->windows[window] != NULL)
706 {
707 return chip_help->windows[window]->address + chip_help->windows[window]->blocked;
708 }
709 return 0;
710}
711
712
713/* This returns the size of the window minus any blocked section */
714u16 ChipHelper_WINDOW_SIZE(ChipDescript *chip_help,
715 enum chip_helper_window_index window)
716{
717 if (window < CHIP_HELPER_WINDOW_COUNT &&
718 chip_help->windows[window] != NULL)
719 {
720 return chip_help->windows[window]->size - chip_help->windows[window]->blocked;
721 }
722 return 0;
723}
724
725
726/* Get the register writes we should do to make sure that
727 the chip is running with most clocks on. */
728u32 ChipHelper_ClockStartupSequence(ChipDescript *chip_help,
729 const struct chip_helper_init_values **val)
730{
731 *val = chip_help->init.vals;
732 return chip_help->init.len;
733}
734
735
736/* Get the set of values tat we should write to the chip to perform a reset. */
737u32 ChipHelper_HostResetSequence(ChipDescript *chip_help,
738 const struct chip_helper_reset_values **val)
739{
740 *val = chip_help->reset_prog.vals;
741 return chip_help->reset_prog.len;
742}
743
744
745/* Decode a windowed access to the chip. */
746s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
747 enum chip_helper_window_index window,
748 enum chip_helper_window_type type,
749 u32 offset,
750 u16 *page, u16 *addr, u32 *len)
751{
752 const struct window_info_t *win;
753 const struct window_shift_info_t *mode;
754 u16 of, pg;
755
756 if (window >= CHIP_HELPER_WINDOW_COUNT)
757 {
758 return FALSE;
759 }
760 if ((win = chip_help->windows[window]) == NULL)
761 {
762 return FALSE;
763 }
764 if (type >= CHIP_HELPER_WT_COUNT)
765 {
766 return FALSE;
767 }
768 if ((mode = &win->mode[type]) == NULL)
769 {
770 return FALSE;
771 }
772 if (!mode->allowed)
773 {
774 return FALSE;
775 }
776
777 pg = (u16)(offset >> mode->page_shift) + mode->page_offset;
778 of = (u16)(offset & ((1 << mode->page_shift) - 1));
779 /* If 'blocked' is zero this does nothing, else decrease
780 the page register and increase the offset until we aren't
781 in the blocked region of the window. */
782 while (of < win->blocked)
783 {
784 of += 1 << mode->page_shift;
785 pg--;
786 }
787 *page = pg;
788 *addr = win->address + of;
789 *len = win->size - of;
790 return TRUE;
791}
792
793
drivers/staging/csr/csr_wifi_hip_chiphelper.h+0−407
@@ -1,407 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_HIP_CHIPHELPER_H__
12#define CSR_WIFI_HIP_CHIPHELPER_H__
13
14
15#include <linux/types.h>
16
17/* The age of the BlueCore chip. This is probably not useful, if
18 you know the age then you can probably work out the version directly. */
19enum chip_helper_bluecore_age
20{
21 chip_helper_bluecore_pre_bc7,
22 chip_helper_bluecore_bc7_or_later
23};
24
25/* We support up to three windowed regions at the moment.
26 Don't reorder these - they're used to index into an array. */
27enum chip_helper_window_index
28{
29 CHIP_HELPER_WINDOW_1 = 0,
30 CHIP_HELPER_WINDOW_2 = 1,
31 CHIP_HELPER_WINDOW_3 = 2,
32 CHIP_HELPER_WINDOW_COUNT = 3
33};
34
35/* These are the things that we can access through a window.
36 Don't reorder these - they're used to index into an array. */
37enum chip_helper_window_type
38{
39 CHIP_HELPER_WT_CODE_RAM = 0,
40 CHIP_HELPER_WT_FLASH = 1,
41 CHIP_HELPER_WT_EXT_SRAM = 2,
42 CHIP_HELPER_WT_ROM = 3,
43 CHIP_HELPER_WT_SHARED = 4,
44 CHIP_HELPER_WT_COUNT = 5
45};
46
47/* Commands to stop and start the XAP */
48enum chip_helper_dbg_emu_cmd_enum
49{
50 CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK = 0x0001,
51 CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK = 0x0002,
52 CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK = 0x0004,
53 CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008
54};
55
56/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */
57enum chip_helper_dbg_stop_status_enum
58{
59 CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK = 0x0000,
60 CHIP_HELPER_DBG_STOP_STATUS_P0_MASK = 0x0001,
61 CHIP_HELPER_DBG_STOP_STATUS_P1_MASK = 0x0002,
62 CHIP_HELPER_DBG_STOP_STATUS_P2_MASK = 0x0004,
63 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK = 0x0008,
64 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK = 0x0010,
65 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK = 0x0020,
66 /* Legacy names/alias */
67 CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK = 0x0001,
68 CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK = 0x0002,
69 CHIP_HELPER_DBG_STOP_STATUS_BT_MASK = 0x0004,
70 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK = 0x0008,
71 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK = 0x0010,
72 CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK = 0x0020
73};
74
75/* Codes to disable the watchdog */
76enum chip_helper_watchdog_disable_enum
77{
78 CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734,
79 CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF,
80 CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E
81};
82
83/* Other bits have changed between versions */
84enum chip_helper_gbl_misc_enum
85{
86 CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK = 0x0001,
87 CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK = 0x0004
88};
89
90/* Coex status register, contains interrupt status and reset pullup status.
91 * CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check
92 * for WAPI on R03 chips and later. */
93enum chip_helper_coex_status_mask_enum
94{
95 CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK = 0x0001,
96 CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK = 0x0008,
97 CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010,
98 CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080,
99 CHIP_HELPER_COEX_STATUS_INT_UART_MASK = 0x0100,
100 CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK = 0x0200
101};
102
103/* How to select the different CPUs */
104enum chip_helper_dbg_proc_sel_enum
105{
106 CHIP_HELPER_DBG_PROC_SEL_MAC = 0,
107 CHIP_HELPER_DBG_PROC_SEL_PHY = 1,
108 CHIP_HELPER_DBG_PROC_SEL_BT = 2,
109 CHIP_HELPER_DBG_PROC_SEL_NONE = 2,
110 CHIP_HELPER_DBG_PROC_SEL_BOTH = 3
111};
112
113/* These are the only registers that we have to know the
114 address of before we know the chip version. */
115enum chip_helper_fixed_registers
116{
117 /* This is the address of GBL_CHIP_VERISON on BC7,
118 UF105x, UF60xx and
119 anything later than that. */
120 CHIP_HELPER_UNIFI_GBL_CHIP_VERSION = 0xFE81,
121
122 CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A
123
124 /* This isn't used at the moment (but might be needed
125 to distinguish the BlueCore sub version?) */
126 /* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */
127};
128
129/* Address-value pairs for defining initialisation values */
130struct chip_helper_init_values
131{
132 u16 addr;
133 u16 value;
134};
135
136/* A block of data that should be written to the device */
137struct chip_helper_reset_values
138{
139 u32 gp_address;
140 u32 len;
141 const u16 *data;
142};
143
144/*
145 * This is the C API.
146 */
147
148/* opaque type */
149typedef const struct chip_device_desc_t ChipDescript;
150
151/* Return a NULL descriptor */
152ChipDescript* ChipHelper_Null(void);
153
154/* This should get the correct version for any CSR chip.
155 The two parameters are what is read from addresses
156 0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and
157 UNIFI_GBL_CHIP_VERSION). These should give a unique identity
158 for most (all?) chips.
159
160 FF9A is the old GBL_CHIP_VERSION register. If the high
161 eight bits are zero then the chip is a new (BC7 +) one
162 and FE81 is the _new_ GBL_CHIP_VERSION register. */
163ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81);
164
165/* The chip is a UniFi, but we don't know which type
166 The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */
167ChipDescript* ChipHelper_GetVersionUniFi(u16 version);
168
169/* This gets the version from the SDIO device id. This only
170 gives quite a coarse grained version, so we should update once
171 we hav access to the function N registers. */
172ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version);
173
174/* The chip is some sort of BlueCore. If "age" is "pre_bc7" then
175 "version" is what was read from FF9A. If "age" is bc7_or_later
176 then "version" is read from FE81. If we don't know if we're pre
177 or post BC7 then we should use "GetVersionAny". */
178ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age,
179 u16 version);
180
181/* The main functions of this class are built with an X macro. This
182 means we can generate the C and C++ versions from the same source
183 without the two diverging.
184
185 The DEF0 functions are simple and take no parameters. The first
186 parameter to the macro is the return type. The second parameter
187 is the function name and the third parameter is where to get the
188 info from (this is hidden from the user).
189
190 The DEF1 functions take one parameter. This time the third macro
191 parameter is the type of this parameter, and the fourth macro
192 parameter is the name of the parameter. The bodies of these
193 functions are hand written. */
194#define CHIP_HELPER_LIST(m) \
195 CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name)) \
196 CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name)) \
197 CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd)) \
198 CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \
199 CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \
200 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \
201 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \
202 CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \
203 CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \
204 CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \
205 CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \
206 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \
207 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \
208 CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \
209 CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \
210 CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset)) \
211 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \
212 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \
213 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \
214 CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \
215 CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \
216 CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop)) \
217 CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \
218 CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \
219 CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch)) \
220 CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl)) \
221 CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0)) \
222 CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1)) \
223 CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2)) \
224 CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3)) \
225 CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake)) \
226 CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int)) \
227 CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status)) \
228 CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \
229 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \
230 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \
231 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \
232 CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \
233 CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \
234 CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash)) \
235 CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram)) \
236 CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom)) \
237 CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt)) \
238 CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan)) \
239 CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \
240 CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \
241 CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr)) \
242 CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr)) \
243 CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \
244 CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val))
245
246/* Some magic to help the expansion */
247#define CHIP_HELPER_DEF0(a, b) \
248 CHIP_HELPER_DEF0_ ## a b
249#define CHIP_HELPER_DEF1(a, b) \
250 CHIP_HELPER_DEF1_ ## a b
251
252/* Macros so that when we expand the list we get "C" function prototypes. */
253#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info) \
254 ret_type ChipHelper_ ## name(ChipDescript * chip_help);
255#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1) \
256 ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1);
257
258CHIP_HELPER_LIST(C_DEC)
259
260/* FriendlyName
261 MarketingName
262
263 These two functions return human readable strings that describe
264 the chip. FriendlyName returns something that a software engineer
265 at CSR might understand. MarketingName returns something more like
266 an external name for a CSR chip.
267*/
268/* DBG_EMU_CMD
269 WATCHDOG_DISABLE
270 PROC_PC_SNOOP
271 GBL_CHIP_VERSION
272 XAP_PCH
273 XAP_PCL
274
275 These registers are used to control the XAPs.
276*/
277/* DBG_HOST_PROC_SELECT DBG_HOST_STOP_STATUS
278 HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE
279 HOST_IO_LOG_ADDR
280 DBG_SPI_PROC_SELECT DBG_SPI_STOP_STATUS
281 SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE
282 SPI_IO_LOG_ADDR
283
284 These register are used to control the XAPs and the memory
285 windows, normally while debugging the code on chip. There
286 are two versons of these registers, one for access via SPI
287 and another for access via the host interface.
288*/
289/* DBG_RESET
290 DBG_RESET_VALUE
291 DBG_RESET_WARN
292 DBG_RESET_WARN_VALUE
293 DBG_RESET_RESULT
294
295 These registers are used to reset the XAP. This can be
296 quite complex for some chips. If DBG_RESET_WARN is non
297 zero the DBG_RESET_WARN_VALUE should be written to address
298 DBG_RESET_WARN before the reset is perfeormed. DBG_RESET_VALUE
299 should then be written to DBG_RESET to make the reset happen.
300 The DBG_RESET_RESULT register should contain 0 if the reset
301 was successful.
302*/
303/* GBL_MISC_ENABLES
304
305 This register controls some special chip features. It
306 should be used with care is it changes quite a lot between
307 chip versions.
308*/
309/* MAILBOX0
310 MAILBOX1
311 MAILBOX2
312 MAILBOX3
313
314 The mailbox registers are for communication between the host
315 and the firmware. There use is described in part by the host
316 interface protcol specifcation.
317*/
318/* SDIO_HIP_HANDSHAKE
319
320 This is one of the more important SDIO HIP registers. On some
321 chips it has the same value as one of the mailbox registers
322 and on other chips it is different.
323*/
324/* SDIO_HOST_INT
325 SHARED_IO_INTERRUPT
326
327 These registers are used by some versions of the host interface
328 protocol specification. Their names should probably be changed
329 to hide the registers and to expose the functions more.
330*/
331/* COEX_STATUS
332
333 Coex status register, contains interrupt status and reset
334 pullup status. The latter is used to detect WAPI.
335*/
336/* PROGRAM_MEMORY_RAM_OFFSET
337 PROGRAM_MEMORY_ROM_OFFSET
338 PROGRAM_MEMORY_FLASH_OFFSET
339 PROGRAM_MEMORY_EXT_SRAM_OFFSET
340 DATA_MEMORY_RAM_OFFSET
341
342 These are constants that describe the offset of the different
343 memory types in the two different address spaces.
344*/
345/* HasFlash HasExtSram HasRom
346 HasBt HasWLan
347
348 These are a set of bools describing the chip.
349*/
350/* WINDOW_ADDRESS WINDOW_SIZE
351
352 These two functions return the size and address of the windows.
353 The address is the address of the lowest value in the address
354 map that is part of the window and the size is the number of
355 visible words.
356
357 Some of the windows have their lowest portion covered by
358 registers. For these windows address is the first address
359 after the registers and size is the siave excluding the part
360 covered by registers.
361*/
362/* MapAddress_SPI2HOST
363 MapAddress_HOST2SPI
364
365 The debugging interface is duplicated on UniFi and later chips
366 so that there are two versions - one over the SPI interaface and
367 the other over the SDIO interface. These functions map the
368 registers between these two interfaces.
369*/
370/* ClockStartupSequence
371
372 This function returns the list of register value pairs that
373 should be forced into UniFi to enable SPI communication. This
374 set of registers is not needed if the firmware is running, but
375 will be needed if the device is being booted from cold. These
376 register writes enable the clocks and setup the PLL to a basic
377 working state. SPI access might be unreliable until these writes
378 have occurred (And they may take mulitple goes).
379*/
380/* HostResetSequence
381
382 This returns a number of chunks of data and generic pointers.
383 All of the XAPs should be stopped. The data should be written
384 to the generic pointers. The instruction pointer for the MAC
385 should then be set to the start of program memory and then the
386 MAC should be "go"d. This will reset the chip in a reliable
387 and orderly manner without resetting the SDIO interface. It
388 is therefore not needed if the chip is being accessed by the
389 SPI interface (the DBG_RESET_ mechanism can be used instead).
390*/
391
392/* The Decode Window function is more complex. For the window
393 'window' it tries to return the address and page register
394 value needed to see offset 'offset' of memory type 'type'.
395
396 It return 1 on success and 0 on failure. 'page' is what
397 should be written to the page register. 'addr' is the
398 address in the XAPs 16 address map to read from. 'len'
399 is the length that we can read without having to change
400 the page registers. */
401s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
402 enum chip_helper_window_index window,
403 enum chip_helper_window_type type,
404 u32 offset,
405 u16 *page, u16 *addr, u32 *len);
406
407#endif
drivers/staging/csr/csr_wifi_hip_chiphelper_private.h+0−200
@@ -1,200 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
12#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
13
14
15#include "csr_wifi_hip_chiphelper.h"
16
17/* This GP stuff should be somewhere else? */
18
19/* Memory spaces encoded in top byte of Generic Pointer type */
20#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
21#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
22#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
23#define UNIFI_REGISTERS 0x04 /* Registers */
24#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
25#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
26#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
27#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
28#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
29#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
30#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
31#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
32#define UNIFI_BT_ROM 0x32 /* BT ROM */
33
34#define MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
35#define GP_OFFSET(GP) ((GP) & 0xFFFFFF)
36#define GP_SPACE(GP) (((GP) >> 24) & 0xFF)
37
38
39/* Address value pairs */
40struct val_array_t
41{
42 u32 len;
43 const struct chip_helper_init_values *vals;
44};
45
46/* Just a (counted) u16 array */
47struct data_array_t
48{
49 u32 len;
50 const u16 *vals;
51};
52
53struct reset_prog_t
54{
55 u32 len;
56 const struct chip_helper_reset_values *vals;
57};
58
59/* The addresses of registers that are equivalent but on
60 different host transports. */
61struct chip_map_address_t
62{
63 u16 spi, host;
64};
65
66struct map_array_t
67{
68 u32 len;
69 const struct chip_map_address_t *vals;
70};
71
72struct chip_device_regs_per_transport_t
73{
74 u16 dbg_proc_select;
75 u16 dbg_stop_status;
76 u16 window1_page; /* PROG_PMEM1 or GW1 */
77 u16 window2_page; /* PROG_PMEM2 or GW2 */
78 u16 window3_page; /* SHARED or GW3 */
79 u16 io_log_addr;
80};
81
82struct chip_device_regs_t
83{
84 u16 gbl_chip_version;
85 u16 gbl_misc_enables;
86 u16 dbg_emu_cmd;
87 struct chip_device_regs_per_transport_t host;
88 struct chip_device_regs_per_transport_t spi;
89 u16 dbg_reset;
90 u16 dbg_reset_value;
91 u16 dbg_reset_warn;
92 u16 dbg_reset_warn_value;
93 u16 dbg_reset_result;
94 u16 xap_pch;
95 u16 xap_pcl;
96 u16 proc_pc_snoop;
97 u16 watchdog_disable;
98 u16 mailbox0;
99 u16 mailbox1;
100 u16 mailbox2;
101 u16 mailbox3;
102 u16 sdio_host_int;
103 u16 shared_io_interrupt;
104 u16 sdio_hip_handshake;
105 u16 coex_status; /* Allows WAPI detection */
106};
107
108/* If allowed is false then this window does not provide this
109 type of access.
110 This describes how addresses should be shifted to make the
111 "page" address. The address is shifted left by 'page_shift'
112 and then has 'page_offset' added. This value should then be
113 written to the page register. */
114struct window_shift_info_t
115{
116 s32 allowed;
117 u32 page_shift;
118 u16 page_offset;
119};
120
121/* Each window has an address and size. These are obvious. It then
122 has a description for each type of memory that might be accessed
123 through it. There might also be a start to the offset of the window.
124 This means that that number of addresses at the start of the window
125 are unusable. */
126struct window_info_t
127{
128 u16 address;
129 u16 size;
130 u16 blocked;
131 const struct window_shift_info_t *mode;
132};
133
134/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result'
135 then this is the correct set of info. If pre_bc7 is true then the
136 address of GBL_CHIP_VERSION is FF9A, else its FE81. */
137struct chip_version_t
138{
139 s32 pre_bc7;
140 u16 mask;
141 u16 result;
142 u8 sdio;
143};
144
145struct chip_device_desc_t
146{
147 struct chip_version_t chip_version;
148
149 /* This is a text string that a human might find useful (BC02, UF105x) */
150 const char *friendly_name;
151 /* This is what we show to customers */
152 const char *marketing_name;
153
154 /* Initialisation values to write following a reset */
155 struct val_array_t init;
156
157 /* Binary sequence for hard reset */
158 struct reset_prog_t reset_prog;
159
160 /* The register map */
161 const struct chip_device_regs_t *regs;
162
163 /* Some misc. info on the chip */
164 struct
165 {
166 u32 has_flash : 1;
167 u32 has_ext_sram : 1;
168 u32 has_rom : 1;
169 u32 has_bt : 1;
170 u32 has_wlan : 1;
171 } bools;
172
173 /* This table is used to remap register addresses depending on what
174 host interface is used. On the BC7 and later chips there are
175 multiple sets of memory window registers, on for each host
176 interafce (SDIO / SPI). The correct one is needed. */
177 struct map_array_t map;
178
179 /* The offsets into the program address space of the different types of memory.
180 The RAM offset is probably the most useful. */
181 struct
182 {
183 u32 ram;
184 u32 rom;
185 u32 flash;
186 u32 ext_sram;
187 } prog_offset;
188
189 /* The offsets into the data address space of interesting things. */
190 struct
191 {
192 u16 ram;
193 /* maybe add shared / page tables? */
194 } data_offset;
195
196 /* Information on the different windows */
197 const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT];
198};
199
200#endif /* CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ */
drivers/staging/csr/csr_wifi_hip_conversions.h+0−73
@@ -1,73 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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_conversions.h
15 *
16 * PURPOSE:
17 * This header file provides the macros for converting to and from
18 * wire format.
19 * These macros *MUST* work for little-endian AND big-endian hosts.
20 *
21 * ---------------------------------------------------------------------------
22 */
23#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
24#define __CSR_WIFI_HIP_CONVERSIONS_H__
25
26#define SIZEOF_UINT16 2
27#define SIZEOF_UINT32 4
28#define SIZEOF_UINT64 8
29
30#define SIZEOF_SIGNAL_HEADER 6
31#define SIZEOF_DATAREF 4
32
33
34/*
35 * Macro to retrieve the signal ID from a wire-format signal.
36 */
37#define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
38
39/*
40 * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
41 * HIP signal.
42 */
43#define GET_PACKED_DATAREF_SLOT(_buf, _ref) \
44 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
45
46#define GET_PACKED_DATAREF_LEN(_buf, _ref) \
47 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
48
49#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \
50 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
51
52#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \
53 CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
54
55#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \
56 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
57
58#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \
59 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
60
61#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \
62 CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
63
64#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \
65 CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
66
67
68s32 get_packed_struct_size(const u8 *buf);
69CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
70CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
71
72#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
73
drivers/staging/csr/csr_wifi_hip_download.c+0−819
@@ -1,819 +0,0 @@
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 * FILE: csr_wifi_hip_download.c
14 *
15 * PURPOSE:
16 * Routines for downloading firmware to UniFi.
17 *
18 * ---------------------------------------------------------------------------
19 */
20#include <linux/slab.h>
21#include "csr_wifi_hip_unifi.h"
22#include "csr_wifi_hip_unifiversion.h"
23#include "csr_wifi_hip_card.h"
24#include "csr_wifi_hip_xbv.h"
25
26#undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
27
28static CsrResult do_patch_download(card_t *card, void *dlpriv,
29 xbv1_t *pfwinfo, u32 boot_ctrl_addr);
30
31static CsrResult do_patch_convert_download(card_t *card,
32 void *dlpriv, xbv1_t *pfwinfo);
33
34/*
35 * ---------------------------------------------------------------------------
36 * _find_in_slut
37 *
38 * Find the offset of the appropriate object in the SLUT of a card
39 *
40 * Arguments:
41 * card Pointer to card struct
42 * psym Pointer to symbol object.
43 * id set up by caller
44 * obj will be set up by this function
45 * pslut Pointer to SLUT address, if 0xffffffff then it must be
46 * read from the chip.
47 * Returns:
48 * CSR_RESULT_SUCCESS on success
49 * Non-zero on error,
50 * CSR_WIFI_HIP_RESULT_NOT_FOUND if not found
51 * ---------------------------------------------------------------------------
52 */
53static CsrResult _find_in_slut(card_t *card, symbol_t *psym, u32 *pslut)
54{
55 u32 slut_address;
56 u16 finger_print;
57 CsrResult r;
58 CsrResult csrResult;
59
60 /* Get SLUT address */
61 if (*pslut == 0xffffffff)
62 {
63 r = card_wait_for_firmware_to_start(card, &slut_address);
64 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
65 {
66 return r;
67 }
68 if (r != CSR_RESULT_SUCCESS)
69 {
70 unifi_error(card->ospriv, "Firmware hasn't started\n");
71 return r;
72 }
73 *pslut = slut_address;
74
75 /*
76 * Firmware has started so set the SDIO bus clock to the initial speed,
77 * faster than UNIFI_SDIO_CLOCK_SAFE_HZ, to speed up the f/w download.
78 */
79 csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
80 if (csrResult != CSR_RESULT_SUCCESS)
81 {
82 r = ConvertCsrSdioToCsrHipResult(card, csrResult);
83 return r;
84 }
85 card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
86 }
87 else
88 {
89 slut_address = *pslut; /* Use previously discovered address */
90 }
91 unifi_trace(card->ospriv, UDBG4, "SLUT addr: 0x%lX\n", slut_address);
92
93 /*
94 * Check the SLUT fingerprint.
95 * The slut_address is a generic pointer so we must use unifi_card_read16().
96 */
97 unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
98 finger_print = 0;
99 r = unifi_card_read16(card, slut_address, &finger_print);
100 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
101 {
102 return r;
103 }
104 if (r != CSR_RESULT_SUCCESS)
105 {
106 unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
107 return r;
108 }
109
110 if (finger_print != SLUT_FINGERPRINT)
111 {
112 unifi_error(card->ospriv, "Failed to find SLUT fingerprint\n");
113 return CSR_RESULT_FAILURE;
114 }
115
116 /* Symbol table starts imedately after the fingerprint */
117 slut_address += 2;
118
119 while (1)
120 {
121 u16 id;
122 u32 obj;
123
124 r = unifi_card_read16(card, slut_address, &id);
125 if (r != CSR_RESULT_SUCCESS)
126 {
127 return r;
128 }
129 slut_address += 2;
130
131 if (id == CSR_SLT_END)
132 {
133 /* End of table reached: not found */
134 r = CSR_WIFI_HIP_RESULT_RANGE;
135 break;
136 }
137
138 r = unifi_read32(card, slut_address, &obj);
139 if (r != CSR_RESULT_SUCCESS)
140 {
141 return r;
142 }
143 slut_address += 4;
144
145 unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", id, obj);
146
147 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
148 /* Found search term? */
149 if (id == psym->id)
150 {
151 unifi_trace(card->ospriv, UDBG1, " matched SLUT id %02d.%08lx\n", id, obj);
152 psym->obj = obj;
153 r = CSR_RESULT_SUCCESS;
154 break;
155 }
156 }
157
158 return r;
159}
160
161
162/*
163 * ---------------------------------------------------------------------------
164 * do_patch_convert_download
165 *
166 * Download the given firmware image to the UniFi, converting from FWDL
167 * to PTDL XBV format.
168 *
169 * Arguments:
170 * card Pointer to card struct
171 * dlpriv Pointer to source firmware image
172 * fwinfo Pointer to source firmware info struct
173 *
174 * Returns:
175 * CSR_RESULT_SUCCESS on success, CSR error code on error
176 *
177 * Notes:
178 * ---------------------------------------------------------------------------
179 */
180static CsrResult do_patch_convert_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo)
181{
182 CsrResult r;
183 u32 slut_base = 0xffffffff;
184 void *pfw;
185 u32 psize;
186 symbol_t sym;
187
188 /* Reset the chip to guarantee that the ROM loader is running */
189 r = unifi_init(card);
190 if (r != CSR_RESULT_SUCCESS)
191 {
192 unifi_error(card->ospriv,
193 "do_patch_convert_download: failed to re-init UniFi\n");
194 return r;
195 }
196
197 /* If no unifi_helper is running, the firmware version must be read */
198 if (card->build_id == 0)
199 {
200 u32 ver = 0;
201 sym.id = CSR_SLT_BUILD_ID_NUMBER;
202 sym.obj = 0; /* To be updated by _find_in_slut() */
203
204 unifi_trace(card->ospriv, UDBG1, "Need f/w version\n");
205
206 /* Find chip build id entry in SLUT */
207 r = _find_in_slut(card, &sym, &slut_base);
208 if (r != CSR_RESULT_SUCCESS)
209 {
210 unifi_error(card->ospriv, "Failed to find CSR_SLT_BUILD_ID_NUMBER\n");
211 return CSR_RESULT_FAILURE;
212 }
213
214 /* Read running f/w version */
215 r = unifi_read32(card, sym.obj, &ver);
216 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
217 {
218 return r;
219 }
220 if (r != CSR_RESULT_SUCCESS)
221 {
222 unifi_error(card->ospriv, "Failed to read f/w id\n");
223 return CSR_RESULT_FAILURE;
224 }
225 card->build_id = ver;
226 }
227
228 /* Convert the ptest firmware to a patch against the running firmware */
229 pfw = xbv_to_patch(card, unifi_fw_read, dlpriv, pfwinfo, &psize);
230 if (!pfw)
231 {
232 unifi_error(card->ospriv, "Failed to convert f/w to patch");
233 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
234 }
235 else
236 {
237 void *desc;
238 sym.id = CSR_SLT_BOOT_LOADER_CONTROL;
239 sym.obj = 0; /* To be updated by _find_in_slut() */
240
241 /* Find boot loader control entry in SLUT */
242 r = _find_in_slut(card, &sym, &slut_base);
243 if (r != CSR_RESULT_SUCCESS)
244 {
245 unifi_error(card->ospriv, "Failed to find BOOT_LOADER_CONTROL\n");
246 kfree(pfw);
247 return CSR_RESULT_FAILURE;
248 }
249
250 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
251 if (r != CSR_RESULT_SUCCESS)
252 {
253 unifi_error(card->ospriv, "Failed to wake UniFi\n");
254 }
255
256 /* Get a dlpriv for the patch buffer so that unifi_fw_read() can
257 * access it.
258 */
259 desc = unifi_fw_open_buffer(card->ospriv, pfw, psize);
260 if (!desc)
261 {
262 kfree(pfw);
263 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
264 }
265
266 /* Download the patch */
267 unifi_info(card->ospriv, "Downloading converted f/w as patch\n");
268 r = unifi_dl_patch(card, desc, sym.obj);
269 kfree(pfw);
270 unifi_fw_close_buffer(card->ospriv, desc);
271
272 if (r != CSR_RESULT_SUCCESS)
273 {
274 unifi_error(card->ospriv, "Converted patch download failed\n");
275 return r;
276 }
277 else
278 {
279 unifi_trace(card->ospriv, UDBG1, "Converted patch downloaded\n");
280 }
281
282 /* This command starts the firmware */
283 r = unifi_do_loader_op(card, sym.obj + 6, UNIFI_BOOT_LOADER_RESTART);
284 if (r != CSR_RESULT_SUCCESS)
285 {
286 unifi_error(card->ospriv, "Failed to write loader restart cmd\n");
287 }
288
289 return r;
290 }
291}
292
293
294/*
295 * ---------------------------------------------------------------------------
296 * unifi_dl_firmware
297 *
298 * Download the given firmware image to the UniFi.
299 *
300 * Arguments:
301 * card Pointer to card struct
302 * dlpriv A context pointer from the calling function to be
303 * passed when calling unifi_fw_read().
304 *
305 * Returns:
306 * CSR_RESULT_SUCCESS on success,
307 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
308 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
309 * CSR_RESULT_FAILURE SDIO error
310 *
311 * Notes:
312 * Stops and resets the chip, does the download and runs the new
313 * firmware.
314 * ---------------------------------------------------------------------------
315 */
316CsrResult unifi_dl_firmware(card_t *card, void *dlpriv)
317{
318 xbv1_t *fwinfo;
319 CsrResult r;
320
321 fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
322 if (fwinfo == NULL)
323 {
324 unifi_error(card->ospriv, "Failed to allocate memory for firmware\n");
325 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
326 }
327
328 /*
329 * Scan the firmware file to find the TLVs we are interested in.
330 * These are:
331 * - check we support the file format version in VERF
332 * - SLTP Symbol Lookup Table Pointer
333 * - FWDL firmware download segments
334 * - FWOV firmware overlay segment
335 * - VMEQ Register probe tests to verify matching h/w
336 */
337 r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
338 if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_firmware)
339 {
340 unifi_error(card->ospriv, "File type is %s, expected firmware.\n",
341 fwinfo->mode == xbv_patch?"patch" : "unknown");
342 kfree(fwinfo);
343 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
344 }
345
346 /* UF6xxx doesn't accept firmware, only patches. Therefore we convert
347 * the file to patch format with version numbers matching the current
348 * running firmware, and then download via the patch mechanism.
349 * The sole purpose of this is to support production test firmware across
350 * different ROM releases, the test firmware being provided in non-patch
351 * format.
352 */
353 if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
354 {
355 unifi_info(card->ospriv, "Must convert f/w to patch format\n");
356 r = do_patch_convert_download(card, dlpriv, fwinfo);
357 }
358 else
359 {
360 /* Older UniFi chips allowed firmware to be directly loaded onto the
361 * chip, which is no longer supported.
362 */
363 unifi_error(card->ospriv, "Only patch downloading supported\n");
364 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
365 }
366
367 kfree(fwinfo);
368 return r;
369} /* unifi_dl_firmware() */
370
371
372/*
373 * ---------------------------------------------------------------------------
374 * unifi_dl_patch
375 *
376 * Load the given patch set into UniFi.
377 *
378 * Arguments:
379 * card Pointer to card struct
380 * dlpriv The os specific handle to the firmware file.
381 * boot_ctrl The address of the boot loader control structure.
382 *
383 * Returns:
384 * CSR_RESULT_SUCCESS on success,
385 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
386 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
387 * CSR_RESULT_FAILURE SDIO error
388 *
389 * Notes:
390 * This ends up telling UniFi to restart.
391 * ---------------------------------------------------------------------------
392 */
393CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl)
394{
395 xbv1_t *fwinfo;
396 CsrResult r;
397
398 unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
399
400 fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
401 if (fwinfo == NULL)
402 {
403 unifi_error(card->ospriv, "Failed to allocate memory for patches\n");
404 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
405 }
406
407 /*
408 * Scan the firmware file to find the TLVs we are interested in.
409 * These are:
410 * - check we support the file format version in VERF
411 * - FWID The build ID of the ROM that we can patch
412 * - PTDL patch download segments
413 */
414 r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
415 if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_patch)
416 {
417 kfree(fwinfo);
418 unifi_error(card->ospriv, "Failed to read in patch file\n");
419 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
420 }
421
422 /*
423 * We have to check the build id read from the SLUT against that
424 * for the patch file. They have to match exactly.
425 * "card->build_id" == XBV1.PTCH.FWID
426 */
427 if (card->build_id != fwinfo->build_id)
428 {
429 unifi_error(card->ospriv, "Wrong patch file for chip (chip = %lu, file = %lu)\n",
430 card->build_id, fwinfo->build_id);
431 kfree(fwinfo);
432#ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
433 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
434#else
435 fwinfo = NULL;
436 dlpriv = NULL;
437 return CSR_RESULT_SUCCESS;
438#endif
439 }
440
441 r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl);
442 if (r != CSR_RESULT_SUCCESS)
443 {
444 unifi_error(card->ospriv, "Failed to patch image\n");
445 }
446
447 kfree(fwinfo);
448
449 return r;
450} /* unifi_dl_patch() */
451
452
453void* unifi_dl_fw_read_start(card_t *card, s8 is_fw)
454{
455 card_info_t card_info;
456
457 unifi_card_info(card, &card_info);
458 unifi_trace(card->ospriv, UDBG5,
459 "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n",
460 card_info.chip_id, card_info.chip_version,
461 card_info.fw_build, card_info.fw_hip_version,
462 card_info.sdio_block_size);
463
464 return unifi_fw_read_start(card->ospriv, is_fw, &card_info);
465}
466
467
468/*
469 * ---------------------------------------------------------------------------
470 * safe_read_shared_location
471 *
472 * Read a shared memory location repeatedly until we get two readings
473 * the same.
474 *
475 * Arguments:
476 * card Pointer to card context struct.
477 * unifi_addr UniFi shared-data-memory address to access.
478 * pdata Pointer to a byte variable for the value read.
479 *
480 *
481 * Returns:
482 * CSR_RESULT_SUCCESS on success, CSR error code on failure
483 * ---------------------------------------------------------------------------
484 */
485static CsrResult safe_read_shared_location(card_t *card, u32 address, u8 *pdata)
486{
487 CsrResult r;
488 u16 limit = 1000;
489 u8 b, b2;
490
491 *pdata = 0;
492
493 r = unifi_read_8_or_16(card, address, &b);
494 if (r != CSR_RESULT_SUCCESS)
495 {
496 return r;
497 }
498
499 while (limit--)
500 {
501 r = unifi_read_8_or_16(card, address, &b2);
502 if (r != CSR_RESULT_SUCCESS)
503 {
504 return r;
505 }
506
507 /* When we have a stable value, return it */
508 if (b == b2)
509 {
510 *pdata = b;
511 return CSR_RESULT_SUCCESS;
512 }
513
514 b = b2;
515 }
516
517 return CSR_RESULT_FAILURE;
518} /* safe_read_shared_location() */
519
520
521/*
522 * ---------------------------------------------------------------------------
523 * unifi_do_loader_op
524 *
525 * Send a loader / boot_loader command to the UniFi and wait for
526 * it to complete.
527 *
528 * Arguments:
529 * card Pointer to card context struct.
530 * op_addr The address of the loader operation control word.
531 * opcode The operation to perform.
532 *
533 * Returns:
534 * CSR_RESULT_SUCCESS on success
535 * CSR_RESULT_FAILURE SDIO error or SDIO/XAP timeout
536 * ---------------------------------------------------------------------------
537 */
538
539/*
540 * Ideally instead of sleeping, we want to busy wait.
541 * Currently there is no framework API to do this. When it becomes available,
542 * we can use it to busy wait using usecs
543 */
544#define OPERATION_TIMEOUT_LOOPS (100) /* when OPERATION_TIMEOUT_DELAY==1, (500) otherwise */
545#define OPERATION_TIMEOUT_DELAY 1 /* msec, or 200usecs */
546
547CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode)
548{
549 CsrResult r;
550 s16 op_retries;
551
552 unifi_trace(card->ospriv, UDBG4, "Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr);
553
554 /* Set the Operation command byte to the opcode */
555 r = unifi_write_8_or_16(card, op_addr, opcode);
556 if (r != CSR_RESULT_SUCCESS)
557 {
558 unifi_error(card->ospriv, "Failed to write loader copy command\n");
559 return r;
560 }
561
562 /* Wait for Operation command byte to be Idle */
563 /* Typically takes ~100us */
564 op_retries = 0;
565 r = CSR_RESULT_SUCCESS;
566 while (1)
567 {
568 u8 op;
569
570 /*
571 * Read the memory location until two successive reads give
572 * the same value.
573 * Then handle it.
574 */
575 r = safe_read_shared_location(card, op_addr, &op);
576 if (r != CSR_RESULT_SUCCESS)
577 {
578 unifi_error(card->ospriv, "Failed to read loader status\n");
579 break;
580 }
581
582 if (op == UNIFI_LOADER_IDLE)
583 {
584 /* Success */
585 break;
586 }
587
588 if (op != opcode)
589 {
590 unifi_error(card->ospriv, "Error reported by loader: 0x%X\n", op);
591 r = CSR_RESULT_FAILURE;
592 break;
593 }
594
595 /* Allow 500us timeout */
596 if (++op_retries >= OPERATION_TIMEOUT_LOOPS)
597 {
598 unifi_error(card->ospriv, "Timeout waiting for loader to ack transfer\n");
599 /* Stop XAPs to aid post-mortem */
600 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
601 if (r != CSR_RESULT_SUCCESS)
602 {
603 unifi_error(card->ospriv, "Failed to stop UniFi processors\n");
604 }
605 else
606 {
607 r = CSR_RESULT_FAILURE;
608 }
609 break;
610 }
611 CsrThreadSleep(OPERATION_TIMEOUT_DELAY);
612 } /* Loop exits with r != CSR_RESULT_SUCCESS on error */
613
614 return r;
615} /* unifi_do_loader_op() */
616
617
618/*
619 * ---------------------------------------------------------------------------
620 * send_ptdl_to_unifi
621 *
622 * Copy a patch block from userland to the UniFi.
623 * This function reads data, 2K at a time, from userland and writes
624 * it to the UniFi.
625 *
626 * Arguments:
627 * card A pointer to the card structure
628 * dlpriv The os specific handle for the firmware file
629 * ptdl A pointer ot the PTDL block
630 * handle The buffer handle to use for the xfer
631 * op_addr The address of the loader operation control word
632 *
633 * Returns:
634 * Number of bytes sent (Positive) or negative value indicating
635 * error code:
636 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
637 * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
638 * CSR_RESULT_FAILURE SDIO error
639 * ---------------------------------------------------------------------------
640 */
641static CsrResult send_ptdl_to_unifi(card_t *card, void *dlpriv,
642 const struct PTDL *ptdl, u32 handle,
643 u32 op_addr)
644{
645 u32 offset;
646 u8 *buf;
647 s32 data_len;
648 u32 write_len;
649 CsrResult r;
650 const u16 buf_size = 2 * 1024;
651
652 offset = ptdl->dl_offset;
653 data_len = ptdl->dl_size;
654
655 if (data_len > buf_size)
656 {
657 unifi_error(card->ospriv, "PTDL block is too large (%u)\n",
658 ptdl->dl_size);
659 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
660 }
661
662 buf = kmalloc(buf_size, GFP_KERNEL);
663 if (buf == NULL)
664 {
665 unifi_error(card->ospriv, "Failed to allocate transfer buffer for firmware download\n");
666 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
667 }
668
669 r = CSR_RESULT_SUCCESS;
670
671 if (unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len)
672 {
673 unifi_error(card->ospriv, "Failed to read from file\n");
674 }
675 else
676 {
677 /* We can always round these if the host wants to */
678 if (card->sdio_io_block_pad)
679 {
680 write_len = (data_len + (card->sdio_io_block_size - 1)) &
681 ~(card->sdio_io_block_size - 1);
682
683 /* Zero out the rest of the buffer (This isn't needed, but it
684 * makes debugging things later much easier). */
685 memset(buf + data_len, 0, write_len - data_len);
686 }
687 else
688 {
689 write_len = data_len;
690 }
691
692 r = unifi_bulk_rw_noretry(card, handle, buf, write_len, UNIFI_SDIO_WRITE);
693 if (r != CSR_RESULT_SUCCESS)
694 {
695 unifi_error(card->ospriv, "CMD53 failed writing %d bytes to handle %ld\n",
696 data_len, handle);
697 }
698 else
699 {
700 /*
701 * Can change the order of things to overlap read from file
702 * with copy to unifi
703 */
704 r = unifi_do_loader_op(card, op_addr, UNIFI_BOOT_LOADER_PATCH);
705 }
706 }
707
708 kfree(buf);
709
710 if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
711 {
712 unifi_error(card->ospriv, "Failed to copy block of %u bytes to UniFi\n",
713 ptdl->dl_size);
714 }
715
716 return r;
717} /* send_ptdl_to_unifi() */
718
719
720/*
721 * ---------------------------------------------------------------------------
722 * do_patch_download
723 *
724 * This function downloads a set of patches to UniFi and then
725 * causes it to restart.
726 *
727 * Arguments:
728 * card Pointer to card struct.
729 * dlpriv A context pointer from the calling function to be
730 * used when reading the XBV file. This can be NULL
731 * in which case not patches are applied.
732 * pfwinfo Pointer to a fwinfo struct describing the f/w
733 * XBV file.
734 * boot_ctrl_addr The address of the boot loader control structure.
735 *
736 * Returns:
737 * 0 on success, or an error code
738 * CSR_WIFI_HIP_RESULT_INVALID_VALUE for a bad laoader version number
739 * ---------------------------------------------------------------------------
740 */
741static CsrResult do_patch_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo, u32 boot_ctrl_addr)
742{
743 CsrResult r;
744 s32 i;
745 u16 loader_version;
746 u16 handle;
747 u32 total_bytes;
748
749 /*
750 * Read info from the SDIO Loader Control Data Structure
751 */
752 /* Check the loader version */
753 r = unifi_card_read16(card, boot_ctrl_addr, &loader_version);
754 if (r != CSR_RESULT_SUCCESS)
755 {
756 unifi_error(card->ospriv, "Patch download: Failed to read loader version\n");
757 return r;
758 }
759 unifi_trace(card->ospriv, UDBG2, "Patch download: boot loader version 0x%04X\n", loader_version);
760 switch (loader_version)
761 {
762 case 0x0000:
763 break;
764
765 default:
766 unifi_error(card->ospriv, "Patch loader version (0x%04X) is not supported by this driver\n",
767 loader_version);
768 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
769 }
770
771 /* Retrieve the handle to use with CMD53 */
772 r = unifi_card_read16(card, boot_ctrl_addr + 4, &handle);
773 if (r != CSR_RESULT_SUCCESS)
774 {
775 unifi_error(card->ospriv, "Patch download: Failed to read loader handle\n");
776 return r;
777 }
778
779 /* Set the mask of LEDs to flash */
780 if (card->loader_led_mask)
781 {
782 r = unifi_card_write16(card, boot_ctrl_addr + 2,
783 (u16)card->loader_led_mask);
784 if (r != CSR_RESULT_SUCCESS)
785 {
786 unifi_error(card->ospriv, "Patch download: Failed to write LED mask\n");
787 return r;
788 }
789 }
790
791 total_bytes = 0;
792
793 /* Copy download data to UniFi memory */
794 for (i = 0; i < pfwinfo->num_ptdl; i++)
795 {
796 unifi_trace(card->ospriv, UDBG3, "Patch download: %d Downloading for %d from offset %d\n",
797 i,
798 pfwinfo->ptdl[i].dl_size,
799 pfwinfo->ptdl[i].dl_offset);
800
801 r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->ptdl[i],
802 handle, boot_ctrl_addr + 6);
803 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
804 {
805 return r;
806 }
807 if (r != CSR_RESULT_SUCCESS)
808 {
809 unifi_error(card->ospriv, "Patch failed after %u bytes\n",
810 total_bytes);
811 return r;
812 }
813 total_bytes += pfwinfo->ptdl[i].dl_size;
814 }
815
816 return CSR_RESULT_SUCCESS;
817} /* do_patch_download() */
818
819
drivers/staging/csr/csr_wifi_hip_dump.c+0−837
@@ -1,837 +0,0 @@
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 * FILE: csr_wifi_hip_dump.c
14 *
15 * PURPOSE:
16 * Routines for retrieving and buffering core status from the UniFi
17 *
18 * ---------------------------------------------------------------------------
19 */
20#include <linux/slab.h>
21#include "csr_wifi_hip_unifi.h"
22#include "csr_wifi_hip_unifiversion.h"
23#include "csr_wifi_hip_card.h"
24
25/* Locations to capture in dump (XAP words) */
26#define HIP_CDUMP_FIRST_CPUREG (0xFFE0) /* First CPU register */
27#define HIP_CDUMP_FIRST_LO (0) /* Start of low address range */
28#define HIP_CDUMP_FIRST_HI_MAC (0x3C00) /* Start of MAC high area */
29#define HIP_CDUMP_FIRST_HI_PHY (0x1C00) /* Start of PHY high area */
30#define HIP_CDUMP_FIRST_SH (0) /* Start of shared memory area */
31
32#define HIP_CDUMP_NCPUREGS (10) /* No. of 16-bit XAP registers */
33#define HIP_CDUMP_NWORDS_LO (0x0100) /* Low area size in 16-bit words */
34#define HIP_CDUMP_NWORDS_HI (0x0400) /* High area size in 16-bit words */
35#define HIP_CDUMP_NWORDS_SH (0x0500) /* Shared memory area size, 16-bit words */
36
37#define HIP_CDUMP_NUM_ZONES 7 /* Number of UniFi memory areas to capture */
38
39/* Mini-coredump state */
40typedef struct coredump_buf
41{
42 u16 count; /* serial number of dump */
43 u32 timestamp; /* host's system time at capture */
44 s16 requestor; /* request: 0=auto dump, 1=manual */
45 u16 chip_ver;
46 u32 fw_ver;
47 u16 *zone[HIP_CDUMP_NUM_ZONES];
48
49 struct coredump_buf *next; /* circular list */
50 struct coredump_buf *prev; /* circular list */
51} coredump_buffer;
52
53/* Structure used to describe a zone of chip memory captured by mini-coredump */
54struct coredump_zone
55{
56 unifi_coredump_space_t space; /* XAP memory space this zone covers */
57 enum unifi_dbg_processors_select cpu; /* XAP CPU core selector */
58 u32 gp; /* Generic Pointer to memory zone on XAP */
59 u16 offset; /* 16-bit XAP word offset of zone in memory space */
60 u16 length; /* Length of zone in XAP words */
61};
62
63static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf);
64static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf);
65static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zone,
66 const struct coredump_zone *def);
67static s32 get_value_from_coredump(const coredump_buffer *dump,
68 const unifi_coredump_space_t space, const u16 offset);
69
70/* Table of chip memory zones we capture on mini-coredump */
71static const struct coredump_zone zonedef_table[HIP_CDUMP_NUM_ZONES] = {
72 { UNIFI_COREDUMP_MAC_REG, UNIFI_PROC_MAC, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
73 { UNIFI_COREDUMP_PHY_REG, UNIFI_PROC_PHY, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
74 { UNIFI_COREDUMP_SH_DMEM, UNIFI_PROC_INVALID, UNIFI_MAKE_GP(SH_DMEM, HIP_CDUMP_FIRST_SH * 2), HIP_CDUMP_FIRST_SH, HIP_CDUMP_NWORDS_SH },
75 { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO },
76 { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_HI_MAC * 2), HIP_CDUMP_FIRST_HI_MAC, HIP_CDUMP_NWORDS_HI },
77 { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO },
78 { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_HI_PHY * 2), HIP_CDUMP_FIRST_HI_PHY, HIP_CDUMP_NWORDS_HI },
79};
80
81/*
82 * ---------------------------------------------------------------------------
83 * unifi_coredump_request_at_next_reset
84 *
85 * Request that a mini-coredump is performed when the driver has
86 * completed resetting the UniFi device.
87 *
88 * Arguments:
89 * card Pointer to card struct
90 * enable If non-zero, sets the request.
91 * If zero, cancels any pending request.
92 *
93 * Returns:
94 * CSR_RESULT_SUCCESS or CSR HIP error code
95 *
96 * Notes:
97 * This function is typically called once the driver has detected that
98 * the UniFi device has become unresponsive due to crash, or internal
99 * watchdog reset. The driver must reset it to regain communication and,
100 * immediately after that, the mini-coredump can be captured.
101 * ---------------------------------------------------------------------------
102 */
103CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable)
104{
105 CsrResult r;
106
107 if (enable)
108 {
109 unifi_trace(card->ospriv, UDBG2, "Mini-coredump requested after reset\n");
110 }
111
112 if (card == NULL)
113 {
114 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
115 }
116 else
117 {
118 card->request_coredump_on_reset = enable?1 : 0;
119 r = CSR_RESULT_SUCCESS;
120 }
121
122 return r;
123}
124
125
126/*
127 * ---------------------------------------------------------------------------
128 * unifi_coredump_handle_request
129 *
130 * Performs a coredump now, if one was requested, and clears the request.
131 *
132 * Arguments:
133 * card Pointer to card struct
134 *
135 * Returns:
136 * CSR_RESULT_SUCCESS or CSR HIP error code
137 *
138 * Notes:
139 * ---------------------------------------------------------------------------
140 */
141CsrResult unifi_coredump_handle_request(card_t *card)
142{
143 CsrResult r = CSR_RESULT_SUCCESS;
144
145 if (card == NULL)
146 {
147 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
148 }
149 else
150 {
151 if (card->request_coredump_on_reset == 1)
152 {
153 card->request_coredump_on_reset = 0;
154 r = unifi_coredump_capture(card, NULL);
155 }
156 }
157
158 return r;
159}
160
161
162/*
163 * ---------------------------------------------------------------------------
164 * unifi_coredump_capture
165 *
166 * Capture the current status of the UniFi device.
167 * Various registers are buffered for future offline inspection.
168 *
169 * Arguments:
170 * card Pointer to card struct
171 * req Pointer to request struct, or NULL:
172 * A coredump requested manually by the user app
173 * will have a request struct pointer, an automatic
174 * coredump will have a NULL pointer.
175 * Returns:
176 * CSR_RESULT_SUCCESS on success,
177 * CSR_RESULT_FAILURE SDIO error
178 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Initialisation not complete
179 *
180 * Notes:
181 * The result is a filled entry in the circular buffer of core dumps,
182 * values from which can be extracted to userland via an ioctl.
183 * ---------------------------------------------------------------------------
184 */
185CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req)
186{
187 CsrResult r = CSR_RESULT_SUCCESS;
188 static u16 dump_seq_no = 1;
189 u32 time_of_capture;
190
191 if (card->dump_next_write == NULL)
192 {
193 r = CSR_RESULT_SUCCESS;
194 goto done;
195 }
196
197 /* Reject forced capture before initialisation has happened */
198 if (card->helper == NULL)
199 {
200 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
201 goto done;
202 }
203
204
205 /*
206 * Force a mini-coredump capture right now
207 */
208 time_of_capture = CsrTimeGet(NULL);
209 unifi_info(card->ospriv, "Mini-coredump capture at t=%u\n", time_of_capture);
210
211 /* Wake up the processors so we can talk to them */
212 r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
213 if (r != CSR_RESULT_SUCCESS)
214 {
215 unifi_error(card->ospriv, "Failed to wake UniFi\n");
216 goto done;
217 }
218 CsrThreadSleep(20);
219
220 /* Stop both XAPs */
221 unifi_trace(card->ospriv, UDBG4, "Stopping XAPs for coredump capture\n");
222 r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
223 if (r != CSR_RESULT_SUCCESS)
224 {
225 unifi_error(card->ospriv, "Failed to stop UniFi XAPs\n");
226 goto done;
227 }
228
229 /* Dump core into the next available slot in the circular list */
230 r = unifi_coredump_from_sdio(card, card->dump_next_write);
231 if (r == CSR_RESULT_SUCCESS)
232 {
233 /* Record whether the dump was manual or automatic */
234 card->dump_next_write->requestor = (req?1 : 0);
235 card->dump_next_write->timestamp = time_of_capture;
236 /* Advance to the next buffer */
237 card->dump_next_write->count = dump_seq_no++;
238 card->dump_cur_read = card->dump_next_write;
239 card->dump_next_write = card->dump_next_write->next;
240
241 /* Sequence no. of zero indicates slot not in use, so handle wrap */
242 if (dump_seq_no == 0)
243 {
244 dump_seq_no = 1;
245 }
246
247 unifi_trace(card->ospriv, UDBG3,
248 "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n",
249 req,
250 card->dump_cur_read->count,
251 card->dump_cur_read, card->dump_next_write);
252 }
253
254 /* Start both XAPs */
255 unifi_trace(card->ospriv, UDBG4, "Restart XAPs after coredump\n");
256 r = card_start_processor(card, UNIFI_PROC_BOTH);
257 if (r != CSR_RESULT_SUCCESS)
258 {
259 unifi_error(card->ospriv, "Failed to start UniFi XAPs\n");
260 goto done;
261 }
262
263done:
264 return r;
265} /* unifi_coredump_capture() */
266
267
268/*
269 * ---------------------------------------------------------------------------
270 * get_value_from_coredump
271 *
272 *
273 *
274 * Arguments:
275 * dump Pointer to buffered coredump data
276 * offset_in_space XAP memory space to retrieve from the buffer (there
277 * may be more than one zone covering the same memory
278 * space, but starting from different offsets).
279 * offset Offset within the XAP memory space to be retrieved
280 *
281 * Returns:
282 * >=0 Register value on success
283 * <0 Register out of range of any captured zones
284 *
285 * Notes:
286 * ---------------------------------------------------------------------------
287 */
288static s32 get_value_from_coredump(const coredump_buffer *coreDump,
289 const unifi_coredump_space_t space,
290 const u16 offset_in_space)
291{
292 s32 r = -1;
293 u16 offset_in_zone;
294 u32 zone_end_offset;
295 s32 i;
296 const struct coredump_zone *def = &zonedef_table[0];
297
298 /* Search zone def table for a match with the requested memory space */
299 for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++, def++)
300 {
301 if (space == def->space)
302 {
303 zone_end_offset = def->offset + def->length;
304
305 /* Is the space offset contained in this zone? */
306 if (offset_in_space < zone_end_offset &&
307 offset_in_space >= def->offset)
308 {
309 /* Calculate the offset of data within the zone buffer */
310 offset_in_zone = offset_in_space - def->offset;
311 r = (s32) * (coreDump->zone[i] + offset_in_zone);
312
313 unifi_trace(NULL, UDBG6,
314 "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n",
315 space, offset_in_space, r,
316 i, def->offset, zone_end_offset - 1);
317 break;
318 }
319 }
320 }
321 return r;
322}
323
324
325/*
326 * ---------------------------------------------------------------------------
327 * unifi_coredump_get_value
328 *
329 * Retrieve the value of a register buffered from a previous core dump,
330 * so that it may be reported back to application code.
331 *
332 * Arguments:
333 * card Pointer to card struct
334 * req_reg Pointer to request parameter partially filled. This
335 * function puts in the values retrieved from the dump.
336 *
337 * Returns:
338 * CSR_RESULT_SUCCESS on success, or:
339 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Null parameter error
340 * CSR_WIFI_HIP_RESULT_RANGE Register out of range
341 * CSR_WIFI_HIP_RESULT_NOT_FOUND Dump index not (yet) captured
342 *
343 * Notes:
344 * ---------------------------------------------------------------------------
345 */
346CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req)
347{
348 CsrResult r;
349 s32 i = 0;
350 coredump_buffer *find_dump = NULL;
351
352 if (req == NULL || card == NULL)
353 {
354 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
355 goto done;
356 }
357 req->value = -1;
358 if (card->dump_buf == NULL)
359 {
360 unifi_trace(card->ospriv, UDBG2, "No coredump buffers\n");
361 r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* Coredumping disabled */
362 goto done;
363 }
364 if (card->dump_cur_read == NULL)
365 {
366 unifi_trace(card->ospriv, UDBG4, "No coredumps captured\n");
367 r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* No coredump yet captured */
368 goto done;
369 }
370
371 /* Find the requested dump buffer */
372 switch (req->index)
373 {
374 case 0: /* Newest */
375 find_dump = card->dump_cur_read;
376 break;
377 case -1: /* Oldest: The next used slot forward */
378 for (find_dump = card->dump_cur_read->next;
379 (find_dump->count == 0) && (find_dump != card->dump_cur_read);
380 find_dump = card->dump_cur_read->next)
381 {
382 }
383 break;
384 default: /* Number of steps back from current read position */
385 for (i = 0, find_dump = card->dump_cur_read;
386 i < req->index;
387 i++, find_dump = find_dump->prev)
388 {
389 /* Walk the list for the index'th entry, but
390 * stop when about to wrap. */
391 unifi_trace(card->ospriv, UDBG6,
392 "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n",
393 i, find_dump->count, find_dump, find_dump->prev,
394 find_dump->next, card->dump_cur_read, card->dump_buf);
395 if (find_dump->prev == card->dump_cur_read)
396 {
397 /* Wrapped but still not found, index out of range */
398 if (i != req->index)
399 {
400 unifi_trace(card->ospriv, UDBG6,
401 "Dump index %d not found %d\n", req->index, i);
402 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
403 goto done;
404 }
405 break;
406 }
407 }
408 break;
409 }
410
411 /* Check if the slot is actually filled with a core dump */
412 if (find_dump->count == 0)
413 {
414 unifi_trace(card->ospriv, UDBG4, "Not captured %d\n", req->index);
415 r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
416 goto done;
417 }
418
419 unifi_trace(card->ospriv, UDBG6, "Req index %d, found seq %d at step %d\n",
420 req->index, find_dump->count, i);
421
422 /* Find the appropriate entry in the buffer */
423 req->value = get_value_from_coredump(find_dump, req->space, (u16)req->offset);
424 if (req->value < 0)
425 {
426 r = CSR_WIFI_HIP_RESULT_RANGE; /* Un-captured register */
427 unifi_trace(card->ospriv, UDBG4,
428 "Can't read space %d, reg 0x%x from coredump buffer %d\n",
429 req->space, req->offset, req->index);
430 }
431 else
432 {
433 r = CSR_RESULT_SUCCESS;
434 }
435
436 /* Update the private request structure with the found values */
437 req->chip_ver = find_dump->chip_ver;
438 req->fw_ver = find_dump->fw_ver;
439 req->timestamp = find_dump->timestamp;
440 req->requestor = find_dump->requestor;
441 req->serial = find_dump->count;
442
443done:
444 return r;
445} /* unifi_coredump_get_value() */
446
447
448/*
449 * ---------------------------------------------------------------------------
450 * unifi_coredump_read_zone
451 *
452 * Captures a UniFi memory zone into a buffer on the host
453 *
454 * Arguments:
455 * card Pointer to card struct
456 * zonebuf Pointer to on-host buffer to dump the memory zone into
457 * def Pointer to description of the memory zone to read from UniFi.
458 *
459 * Returns:
460 * CSR_RESULT_SUCCESS on success, or:
461 * CSR_RESULT_FAILURE SDIO error
462 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
463 *
464 * Notes:
465 * It is assumed that the caller has already stopped the XAPs
466 * ---------------------------------------------------------------------------
467 */
468static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zonebuf, const struct coredump_zone *def)
469{
470 CsrResult r;
471
472 if (zonebuf == NULL || def == NULL)
473 {
474 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
475 goto done;
476 }
477
478 /* Select XAP CPU if necessary */
479 if (def->cpu != UNIFI_PROC_INVALID)
480 {
481 if (def->cpu != UNIFI_PROC_MAC && def->cpu != UNIFI_PROC_PHY)
482 {
483 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
484 goto done;
485 }
486 r = unifi_set_proc_select(card, def->cpu);
487 if (r != CSR_RESULT_SUCCESS)
488 {
489 goto done;
490 }
491 }
492
493 unifi_trace(card->ospriv, UDBG4,
494 "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n",
495 def->space, def->offset, def->length, def->gp, def->cpu);
496
497 /* Read on-chip RAM (byte-wise) */
498 r = unifi_card_readn(card, def->gp, zonebuf, (u16)(def->length * 2));
499 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
500 {
501 goto done;
502 }
503 if (r != CSR_RESULT_SUCCESS)
504 {
505 unifi_error(card->ospriv, "Can't read UniFi shared data area\n");
506 goto done;
507 }
508
509done:
510 return r;
511}
512
513
514/*
515 * ---------------------------------------------------------------------------
516 * unifi_coredump_read_zones
517 *
518 * Walks through the table of on-chip memory zones defined in zonedef_table,
519 * and reads each of them from the UniFi chip
520 *
521 * Arguments:
522 * card Pointer to card struct
523 * dump_buf Buffer into which register values will be dumped
524 *
525 * Returns:
526 * CSR_RESULT_SUCCESS on success, or:
527 * CSR_RESULT_FAILURE SDIO error
528 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
529 *
530 * Notes:
531 * It is assumed that the caller has already stopped the XAPs
532 * ---------------------------------------------------------------------------
533 */
534static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf)
535{
536 CsrResult r = CSR_RESULT_SUCCESS;
537 s32 i;
538
539 /* Walk the table of coredump zone definitions and read them from the chip */
540 for (i = 0;
541 (i < HIP_CDUMP_NUM_ZONES) && (r == 0);
542 i++)
543 {
544 r = unifi_coredump_read_zone(card, dump_buf->zone[i], &zonedef_table[i]);
545 }
546
547 return r;
548}
549
550
551/*
552 * ---------------------------------------------------------------------------
553 * unifi_coredump_from_sdio
554 *
555 * Capture the status of the UniFi processors, over SDIO
556 *
557 * Arguments:
558 * card Pointer to card struct
559 * reg_buffer Buffer into which register values will be dumped
560 *
561 * Returns:
562 * CSR_RESULT_SUCCESS on success, or:
563 * CSR_RESULT_FAILURE SDIO error
564 * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
565 *
566 * Notes:
567 * ---------------------------------------------------------------------------
568 */
569static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf)
570{
571 u16 val;
572 CsrResult r;
573 u32 sdio_addr;
574
575 if (dump_buf == NULL)
576 {
577 r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
578 goto done;
579 }
580
581
582 /* Chip and firmware version */
583 unifi_trace(card->ospriv, UDBG4, "Get chip version\n");
584 sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper);
585 if (sdio_addr != 0)
586 {
587 r = unifi_read_direct16(card, sdio_addr, &val);
588 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
589 {
590 goto done;
591 }
592 if (r != CSR_RESULT_SUCCESS)
593 {
594 unifi_error(card->ospriv, "Can't read GBL_CHIP_VERSION\n");
595 goto done;
596 }
597 }
598 dump_buf->chip_ver = val;
599 dump_buf->fw_ver = card->build_id;
600
601 unifi_trace(card->ospriv, UDBG4, "chip_ver 0x%04x, fw_ver %u\n",
602 dump_buf->chip_ver, dump_buf->fw_ver);
603
604 /* Capture the memory zones required from UniFi */
605 r = unifi_coredump_read_zones(card, dump_buf);
606 if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
607 {
608 goto done;
609 }
610 if (r != CSR_RESULT_SUCCESS)
611 {
612 unifi_error(card->ospriv, "Can't read UniFi memory areas\n");
613 goto done;
614 }
615
616done:
617 return r;
618} /* unifi_coredump_from_sdio() */
619
620
621#ifndef UNIFI_DISABLE_COREDUMP
622/*
623 * ---------------------------------------------------------------------------
624 * new_coredump_node
625 *
626 * Allocates a coredump linked-list node, and links it to the previous.
627 *
628 * Arguments:
629 * ospriv OS context
630 * prevnode Previous node to link into
631 *
632 * Returns:
633 * Pointer to valid coredump_buffer on success
634 * NULL on memory allocation failure
635 *
636 * Notes:
637 * Allocates "all or nothing"
638 * ---------------------------------------------------------------------------
639 */
640static
641coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode)
642{
643 coredump_buffer *newnode = NULL;
644 u16 *newzone = NULL;
645 s32 i;
646 u32 zone_size;
647
648 /* Allocate node header */
649 newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL);
650 if (newnode == NULL)
651 {
652 return NULL;
653 }
654
655 /* Allocate chip memory zone capture buffers */
656 for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++)
657 {
658 zone_size = sizeof(u16) * zonedef_table[i].length;
659 newzone = kzalloc(zone_size, GFP_KERNEL);
660 newnode->zone[i] = newzone;
661 if (newzone == NULL)
662 {
663 unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n",
664 i, zonedef_table[i].length);
665 break;
666 }
667 }
668
669 /* Clean up if any zone alloc failed */
670 if (newzone == NULL)
671 {
672 for (i = 0; newnode->zone[i] != NULL; i++)
673 {
674 kfree(newnode->zone[i]);
675 newnode->zone[i] = NULL;
676 }
677 }
678
679 /* Link to previous node */
680 newnode->prev = prevnode;
681 if (prevnode)
682 {
683 prevnode->next = newnode;
684 }
685 newnode->next = NULL;
686
687 return newnode;
688}
689
690
691#endif /* UNIFI_DISABLE_COREDUMP */
692
693/*
694 * ---------------------------------------------------------------------------
695 * unifi_coredump_init
696 *
697 * Allocates buffers for the automatic SDIO core dump
698 *
699 * Arguments:
700 * card Pointer to card struct
701 * num_dump_buffers Number of buffers to reserve for coredumps
702 *
703 * Returns:
704 * CSR_RESULT_SUCCESS on success, or:
705 * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
706 *
707 * Notes:
708 * Allocates space in advance, to be used for the last n coredump buffers
709 * the intention being that the size is sufficient for at least one dump,
710 * probably several.
711 * It's probably advisable to have at least 2 coredump buffers to allow
712 * one to be enquired with the unifi_coredump tool, while leaving another
713 * free for capturing.
714 * ---------------------------------------------------------------------------
715 */
716CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers)
717{
718#ifndef UNIFI_DISABLE_COREDUMP
719 void *ospriv = card->ospriv;
720 coredump_buffer *prev = NULL;
721 coredump_buffer *newnode = NULL;
722 u32 i = 0;
723#endif
724
725 card->request_coredump_on_reset = 0;
726 card->dump_next_write = NULL;
727 card->dump_cur_read = NULL;
728 card->dump_buf = NULL;
729
730#ifndef UNIFI_DISABLE_COREDUMP
731 unifi_trace(ospriv, UDBG1,
732 "Allocate buffers for %d core dumps\n", num_dump_buffers);
733 if (num_dump_buffers == 0)
734 {
735 goto done;
736 }
737
738 /* Root node */
739 card->dump_buf = new_coredump_node(ospriv, NULL);
740 if (card->dump_buf == NULL)
741 {
742 goto fail;
743 }
744 prev = card->dump_buf;
745 newnode = card->dump_buf;
746
747 /* Add each subsequent node at tail */
748 for (i = 1; i < num_dump_buffers; i++)
749 {
750 newnode = new_coredump_node(ospriv, prev);
751 if (newnode == NULL)
752 {
753 goto fail;
754 }
755 prev = newnode;
756 }
757
758 /* Link the first and last nodes to make the list circular */
759 card->dump_buf->prev = newnode;
760 newnode->next = card->dump_buf;
761
762 /* Set initial r/w access pointers */
763 card->dump_next_write = card->dump_buf;
764 card->dump_cur_read = NULL;
765
766 unifi_trace(ospriv, UDBG2, "Core dump configured (%d dumps max)\n", i);
767
768done:
769#endif
770 return CSR_RESULT_SUCCESS;
771
772#ifndef UNIFI_DISABLE_COREDUMP
773fail:
774 /* Unwind what we allocated so far */
775 unifi_error(ospriv, "Out of memory allocating core dump node %d\n", i);
776 unifi_coredump_free(card);
777 return CSR_WIFI_HIP_RESULT_NO_MEMORY;
778#endif
779} /* unifi_coreump_init() */
780
781
782/*
783 * ---------------------------------------------------------------------------
784 * unifi_coredump_free
785 *
786 * Free all memory dynamically allocated for core dump
787 *
788 * Arguments:
789 * card Pointer to card struct
790 *
791 * Returns:
792 * None
793 *
794 * Notes:
795 * ---------------------------------------------------------------------------
796 */
797void unifi_coredump_free(card_t *card)
798{
799 void *ospriv = card->ospriv;
800 coredump_buffer *node, *del_node;
801 s16 i = 0;
802 s16 j;
803
804 unifi_trace(ospriv, UDBG2, "Core dump de-configured\n");
805
806 if (card->dump_buf == NULL)
807 {
808 return;
809 }
810
811 node = card->dump_buf;
812 do
813 {
814 /* Free payload zones */
815 for (j = 0; j < HIP_CDUMP_NUM_ZONES; j++)
816 {
817 kfree(node->zone[j]);
818 node->zone[j] = NULL;
819 }
820
821 /* Detach */
822 del_node = node;
823 node = node->next;
824
825 /* Free header */
826 kfree(del_node);
827 i++;
828 } while ((node != NULL) && (node != card->dump_buf));
829
830 unifi_trace(ospriv, UDBG3, "Freed %d coredump buffers\n", i);
831
832 card->dump_buf = NULL;
833 card->dump_next_write = NULL;
834 card->dump_cur_read = NULL;
835} /* unifi_coredump_free() */
836
837
drivers/staging/csr/csr_wifi_hip_packing.c+0−4804
@@ -1,4804 +0,0 @@
1/*****************************************************************************
2
3 (c) Cambridge Silicon Radio Limited 2011
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/* Note: this is an auto-generated file. */
12
13#include "csr_wifi_hip_signals.h"
14#include "csr_wifi_hip_unifi.h"
15#include "csr_wifi_hip_conversions.h"
16
17
18/*
19 * ---------------------------------------------------------------------------
20 * get_packed_struct_size
21 *
22 * Examine a buffer containing a UniFi signal in wire-format.
23 * The first two bytes contain the signal ID, decode the signal ID and
24 * return the size, in bytes, of the signal, not including any bulk
25 * data.
26 *
27 * WARNING: This function is auto-generated, DO NOT EDIT!
28 *
29 * Arguments:
30 * buf Pointer to buffer to decode.
31 *
32 * Returns:
33 * 0 if the signal ID is not recognised (i.e. zero length),
34 * otherwise the number of bytes occupied by the signal in the buffer.
35 * This is useful for stepping past the signal to the object in the buffer.
36 * ---------------------------------------------------------------------------
37 */
38s32 get_packed_struct_size(const u8 *buf)
39{
40 s32 size = 0;
41 u16 sig_id;
42
43 sig_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(buf);
44
45 size += SIZEOF_UINT16;
46 size += SIZEOF_UINT16;
47 size += SIZEOF_UINT16;
48 switch (sig_id)
49 {
50#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
51 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
52 size += SIZEOF_UINT16;
53 size += SIZEOF_UINT16;
54 size += SIZEOF_UINT16;
55 size += SIZEOF_UINT16;
56 size += SIZEOF_UINT16;
57 size += SIZEOF_UINT16;
58 break;
59#endif
60#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
61 case CSR_MLME_SETKEYS_CONFIRM_ID:
62 size += SIZEOF_UINT16;
63 size += SIZEOF_UINT16;
64 size += SIZEOF_UINT16;
65 size += SIZEOF_UINT16;
66 size += SIZEOF_UINT16;
67 size += SIZEOF_UINT16;
68 break;
69#endif
70#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
71 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
72 size += SIZEOF_UINT16;
73 size += SIZEOF_UINT16;
74 size += SIZEOF_UINT16;
75 size += SIZEOF_UINT16;
76 size += SIZEOF_UINT16;
77 break;
78#endif
79#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
80 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
81 size += SIZEOF_UINT16;
82 size += SIZEOF_UINT16;
83 size += SIZEOF_UINT16;
84 size += SIZEOF_UINT16;
85 size += SIZEOF_UINT16;
86 size += SIZEOF_UINT16;
87 size += SIZEOF_UINT16;
88 break;
89#endif
90#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
91 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
92 size += SIZEOF_UINT16;
93 size += SIZEOF_UINT16;
94 size += SIZEOF_UINT16;
95 size += SIZEOF_UINT16;
96 size += SIZEOF_UINT16;
97 size += SIZEOF_UINT16;
98 size += SIZEOF_UINT16;
99 break;
100#endif
101#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
102 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
103 size += SIZEOF_UINT16;
104 size += SIZEOF_UINT16;
105 size += SIZEOF_UINT16;
106 size += SIZEOF_UINT16;
107 size += SIZEOF_UINT16;
108 size += SIZEOF_UINT16;
109 break;
110#endif
111#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
112 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
113 size += SIZEOF_UINT16;
114 size += SIZEOF_UINT16;
115 size += SIZEOF_UINT16;
116 size += SIZEOF_UINT16;
117 size += SIZEOF_UINT16;
118 size += SIZEOF_UINT16;
119 size += SIZEOF_UINT16;
120 size += SIZEOF_UINT16;
121 size += SIZEOF_UINT16;
122 size += SIZEOF_UINT16;
123 size += SIZEOF_UINT16;
124 size += SIZEOF_UINT16;
125 size += SIZEOF_UINT16;
126 size += SIZEOF_UINT16;
127 break;
128#endif
129#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
130 case CSR_MLME_SM_START_CONFIRM_ID:
131 size += SIZEOF_UINT16;
132 size += SIZEOF_UINT16;
133 size += SIZEOF_UINT16;
134 size += SIZEOF_UINT16;
135 size += SIZEOF_UINT16;
136 size += SIZEOF_UINT16;
137 break;
138#endif
139#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
140 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
141 size += SIZEOF_UINT16;
142 size += SIZEOF_UINT16;
143 size += SIZEOF_UINT16;
144 size += SIZEOF_UINT16;
145 size += SIZEOF_UINT16;
146 size += 48 / 8;
147 size += SIZEOF_UINT16;
148 size += SIZEOF_UINT16;
149 size += SIZEOF_UINT16;
150 break;
151#endif
152#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
153 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
154 size += SIZEOF_UINT16;
155 size += SIZEOF_UINT16;
156 size += SIZEOF_UINT16;
157 size += SIZEOF_UINT16;
158 size += SIZEOF_UINT16;
159 size += SIZEOF_UINT16;
160 size += SIZEOF_UINT16;
161 break;
162#endif
163 case CSR_DEBUG_WORD16_INDICATION_ID:
164 size += SIZEOF_UINT16;
165 size += SIZEOF_UINT16;
166 size += SIZEOF_UINT16;
167 size += SIZEOF_UINT16;
168 size += SIZEOF_UINT16;
169 size += SIZEOF_UINT16;
170 size += SIZEOF_UINT16;
171 size += SIZEOF_UINT16;
172 size += SIZEOF_UINT16;
173 size += SIZEOF_UINT16;
174 size += SIZEOF_UINT16;
175 size += SIZEOF_UINT16;
176 size += SIZEOF_UINT16;
177 size += SIZEOF_UINT16;
178 size += SIZEOF_UINT16;
179 size += SIZEOF_UINT16;
180 size += SIZEOF_UINT16;
181 size += SIZEOF_UINT16;
182 size += SIZEOF_UINT16;
183 size += SIZEOF_UINT16;
184 break;
185 case CSR_DEBUG_GENERIC_CONFIRM_ID:
186 size += SIZEOF_UINT16;
187 size += SIZEOF_UINT16;
188 size += SIZEOF_UINT16;
189 size += SIZEOF_UINT16;
190 size += SIZEOF_UINT16;
191 size += SIZEOF_UINT16;
192 size += SIZEOF_UINT16;
193 size += SIZEOF_UINT16;
194 size += SIZEOF_UINT16;
195 size += SIZEOF_UINT16;
196 size += SIZEOF_UINT16;
197 size += SIZEOF_UINT16;
198 break;
199 case CSR_MA_PACKET_INDICATION_ID:
200 size += SIZEOF_UINT16;
201 size += SIZEOF_UINT16;
202 size += SIZEOF_UINT16;
203 size += SIZEOF_UINT16;
204 size += SIZEOF_UINT16;
205 size += SIZEOF_UINT64;
206 size += SIZEOF_UINT16;
207 size += SIZEOF_UINT16;
208 size += SIZEOF_UINT16;
209 size += SIZEOF_UINT16;
210 size += SIZEOF_UINT16;
211 size += SIZEOF_UINT16;
212 break;
213 case CSR_MLME_SET_TIM_REQUEST_ID:
214 size += SIZEOF_UINT16;
215 size += SIZEOF_UINT16;
216 size += SIZEOF_UINT16;
217 size += SIZEOF_UINT16;
218 size += SIZEOF_UINT16;
219 size += SIZEOF_UINT16;
220 size += SIZEOF_UINT16;
221 break;
222#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
223 case CSR_MLME_CONNECTED_INDICATION_ID:
224 size += SIZEOF_UINT16;
225 size += SIZEOF_UINT16;
226 size += SIZEOF_UINT16;
227 size += SIZEOF_UINT16;
228 size += SIZEOF_UINT16;
229 size += SIZEOF_UINT16;
230 size += 48 / 8;
231 break;
232#endif
233#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
234 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
235 size += SIZEOF_UINT16;
236 size += SIZEOF_UINT16;
237 size += SIZEOF_UINT16;
238 size += SIZEOF_UINT16;
239 size += SIZEOF_UINT16;
240 size += SIZEOF_UINT16;
241 break;
242#endif
243#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
244 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
245 size += SIZEOF_UINT16;
246 size += SIZEOF_UINT16;
247 size += SIZEOF_UINT16;
248 size += SIZEOF_UINT16;
249 size += SIZEOF_UINT16;
250 size += SIZEOF_UINT16;
251 size += SIZEOF_UINT16;
252 size += SIZEOF_UINT16;
253 break;
254#endif
255#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
256 case CSR_MLME_SCAN_REQUEST_ID:
257 size += SIZEOF_UINT16;
258 size += SIZEOF_UINT16;
259 size += SIZEOF_UINT16;
260 size += SIZEOF_UINT16;
261 size += SIZEOF_UINT16;
262 size += SIZEOF_UINT16;
263 size += SIZEOF_UINT16;
264 size += SIZEOF_UINT32;
265 size += SIZEOF_UINT16;
266 size += SIZEOF_UINT16;
267 break;
268#endif
269#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
270 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
271 size += SIZEOF_UINT16;
272 size += SIZEOF_UINT16;
273 size += SIZEOF_UINT16;
274 size += SIZEOF_UINT16;
275 size += SIZEOF_UINT16;
276 size += SIZEOF_UINT16;
277 break;
278#endif
279#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
280 case CSR_MLME_GET_NEXT_REQUEST_ID:
281 size += SIZEOF_UINT16;
282 size += SIZEOF_UINT16;
283 size += SIZEOF_UINT16;
284 size += SIZEOF_UINT16;
285 break;
286#endif
287#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
288 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
289 size += SIZEOF_UINT16;
290 size += SIZEOF_UINT16;
291 size += SIZEOF_UINT16;
292 size += SIZEOF_UINT16;
293 size += SIZEOF_UINT16;
294 size += SIZEOF_UINT16;
295 break;
296#endif
297#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
298 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
299 size += SIZEOF_UINT16;
300 size += SIZEOF_UINT16;
301 size += SIZEOF_UINT16;
302 size += SIZEOF_UINT16;
303 size += SIZEOF_UINT16;
304 size += 48 / 8;
305 size += SIZEOF_UINT16;
306 size += SIZEOF_UINT16;
307 size += SIZEOF_UINT16;
308 size += SIZEOF_UINT16;
309 size += SIZEOF_UINT16;
310 break;
311#endif
312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
313 case CSR_MLME_HL_SYNC_REQUEST_ID:
314 size += SIZEOF_UINT16;
315 size += SIZEOF_UINT16;
316 size += SIZEOF_UINT16;
317 size += SIZEOF_UINT16;
318 size += 48 / 8;
319 break;
320#endif
321 case CSR_DEBUG_GENERIC_REQUEST_ID:
322 size += SIZEOF_UINT16;
323 size += SIZEOF_UINT16;
324 size += SIZEOF_UINT16;
325 size += SIZEOF_UINT16;
326 size += SIZEOF_UINT16;
327 size += SIZEOF_UINT16;
328 size += SIZEOF_UINT16;
329 size += SIZEOF_UINT16;
330 size += SIZEOF_UINT16;
331 size += SIZEOF_UINT16;
332 size += SIZEOF_UINT16;
333 size += SIZEOF_UINT16;
334 break;
335#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
336 case CSR_MLME_LEAVE_CONFIRM_ID:
337 size += SIZEOF_UINT16;
338 size += SIZEOF_UINT16;
339 size += SIZEOF_UINT16;
340 size += SIZEOF_UINT16;
341 size += SIZEOF_UINT16;
342 size += SIZEOF_UINT16;
343 break;
344#endif
345#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
346 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
347 size += SIZEOF_UINT16;
348 size += SIZEOF_UINT16;
349 size += SIZEOF_UINT16;
350 size += SIZEOF_UINT16;
351 size += SIZEOF_UINT16;
352 size += SIZEOF_UINT16;
353 break;
354#endif
355#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
356 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
357 size += SIZEOF_UINT16;
358 size += SIZEOF_UINT16;
359 size += SIZEOF_UINT16;
360 size += SIZEOF_UINT16;
361 size += SIZEOF_UINT16;
362 size += SIZEOF_UINT16;
363 break;
364#endif
365#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
366 case CSR_MLME_RESET_REQUEST_ID:
367 size += SIZEOF_UINT16;
368 size += SIZEOF_UINT16;
369 size += SIZEOF_UINT16;
370 size += SIZEOF_UINT16;
371 size += 48 / 8;
372 size += SIZEOF_UINT16;
373 break;
374#endif
375#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
376 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
377 size += SIZEOF_UINT16;
378 size += SIZEOF_UINT16;
379 size += SIZEOF_UINT16;
380 size += SIZEOF_UINT16;
381 size += SIZEOF_UINT16;
382 break;
383#endif
384#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
385 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
386 size += SIZEOF_UINT16;
387 size += SIZEOF_UINT16;
388 size += SIZEOF_UINT16;
389 size += SIZEOF_UINT16;
390 size += SIZEOF_UINT16;
391 size += SIZEOF_UINT16;
392 size += SIZEOF_UINT16;
393 break;
394#endif
395#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
396 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
397 size += SIZEOF_UINT16;
398 size += SIZEOF_UINT16;
399 size += SIZEOF_UINT16;
400 size += SIZEOF_UINT16;
401 size += SIZEOF_UINT16;
402 size += SIZEOF_UINT16;
403 size += SIZEOF_UINT32;
404 break;
405#endif
406#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
407 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
408 size += SIZEOF_UINT16;
409 size += SIZEOF_UINT16;
410 size += SIZEOF_UINT16;
411 size += SIZEOF_UINT16;
412 size += SIZEOF_UINT16;
413 size += SIZEOF_UINT16;
414 size += SIZEOF_UINT16;
415 break;
416#endif
417#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
418 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
419 size += SIZEOF_UINT16;
420 size += SIZEOF_UINT16;
421 size += SIZEOF_UINT16;
422 size += SIZEOF_UINT16;
423 size += SIZEOF_UINT16;
424 size += SIZEOF_UINT16;
425 size += 48 / 8;
426 size += SIZEOF_UINT16;
427 size += SIZEOF_UINT16;
428 break;
429#endif
430#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
431 case CSR_MLME_LEAVE_REQUEST_ID:
432 size += SIZEOF_UINT16;
433 size += SIZEOF_UINT16;
434 size += SIZEOF_UINT16;
435 size += SIZEOF_UINT16;
436 size += SIZEOF_UINT16;
437 break;
438#endif
439#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
440 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
441 size += SIZEOF_UINT16;
442 size += SIZEOF_UINT16;
443 size += SIZEOF_UINT16;
444 size += SIZEOF_UINT16;
445 size += SIZEOF_UINT16;
446 size += SIZEOF_UINT16;
447 size += SIZEOF_UINT16;
448 size += SIZEOF_UINT16;
449 size += SIZEOF_UINT16;
450 break;
451#endif
452#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
453 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
454 size += SIZEOF_UINT16;
455 size += SIZEOF_UINT16;
456 size += SIZEOF_UINT16;
457 size += SIZEOF_UINT16;
458 size += SIZEOF_UINT16;
459 size += SIZEOF_UINT16;
460 size += SIZEOF_UINT16;
461 break;
462#endif
463 case CSR_MLME_SET_TIM_CONFIRM_ID:
464 size += SIZEOF_UINT16;
465 size += SIZEOF_UINT16;
466 size += SIZEOF_UINT16;
467 size += SIZEOF_UINT16;
468 size += SIZEOF_UINT16;
469 size += SIZEOF_UINT16;
470 break;
471#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
472 case CSR_MLME_MEASURE_INDICATION_ID:
473 size += SIZEOF_UINT16;
474 size += SIZEOF_UINT16;
475 size += SIZEOF_UINT16;
476 size += SIZEOF_UINT16;
477 size += SIZEOF_UINT16;
478 break;
479#endif
480#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
481 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
482 size += SIZEOF_UINT16;
483 size += SIZEOF_UINT16;
484 size += SIZEOF_UINT16;
485 size += SIZEOF_UINT16;
486 size += SIZEOF_UINT16;
487 size += SIZEOF_UINT16;
488 size += SIZEOF_UINT16;
489 break;
490#endif
491#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
492 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
493 size += SIZEOF_UINT16;
494 size += SIZEOF_UINT16;
495 size += SIZEOF_UINT16;
496 size += SIZEOF_UINT16;
497 size += SIZEOF_UINT16;
498 size += SIZEOF_UINT16;
499 size += SIZEOF_UINT16;
500 break;
501#endif
502 case CSR_DEBUG_GENERIC_INDICATION_ID:
503 size += SIZEOF_UINT16;
504 size += SIZEOF_UINT16;
505 size += SIZEOF_UINT16;
506 size += SIZEOF_UINT16;
507 size += SIZEOF_UINT16;
508 size += SIZEOF_UINT16;
509 size += SIZEOF_UINT16;
510 size += SIZEOF_UINT16;
511 size += SIZEOF_UINT16;
512 size += SIZEOF_UINT16;
513 size += SIZEOF_UINT16;
514 size += SIZEOF_UINT16;
515 break;
516 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
517 size += SIZEOF_UINT16;
518 size += SIZEOF_UINT16;
519 size += SIZEOF_UINT16;
520 size += SIZEOF_UINT16;
521 size += SIZEOF_UINT16;
522 size += SIZEOF_UINT32;
523 break;
524#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
525 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
526 size += SIZEOF_UINT16;
527 size += SIZEOF_UINT16;
528 size += SIZEOF_UINT16;
529 size += SIZEOF_UINT16;
530 size += SIZEOF_UINT16;
531 size += SIZEOF_UINT16;
532 break;
533#endif
534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
535 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
536 size += SIZEOF_UINT16;
537 size += SIZEOF_UINT16;
538 size += SIZEOF_UINT16;
539 size += SIZEOF_UINT16;
540 size += SIZEOF_UINT16;
541 size += SIZEOF_UINT16;
542 size += SIZEOF_UINT16;
543 break;
544#endif
545 case CSR_MA_PACKET_REQUEST_ID:
546 size += SIZEOF_UINT16;
547 size += SIZEOF_UINT16;
548 size += SIZEOF_UINT16;
549 size += SIZEOF_UINT16;
550 size += SIZEOF_UINT16;
551 size += SIZEOF_UINT16;
552 size += SIZEOF_UINT32;
553 size += SIZEOF_UINT16;
554 size += 48 / 8;
555 size += SIZEOF_UINT16;
556 break;
557#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
558 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
559 size += SIZEOF_UINT16;
560 size += SIZEOF_UINT16;
561 size += SIZEOF_UINT16;
562 size += SIZEOF_UINT16;
563 size += SIZEOF_UINT16;
564 size += SIZEOF_UINT16;
565 size += SIZEOF_UINT16;
566 size += SIZEOF_UINT16;
567 size += 48 / 8;
568 size += SIZEOF_UINT16;
569 break;
570#endif
571#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
572 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
573 size += SIZEOF_UINT16;
574 size += SIZEOF_UINT16;
575 size += SIZEOF_UINT16;
576 size += SIZEOF_UINT16;
577 size += SIZEOF_UINT16;
578 size += SIZEOF_UINT16;
579 size += SIZEOF_UINT16;
580 break;
581#endif
582 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
583 size += SIZEOF_UINT16;
584 size += SIZEOF_UINT16;
585 size += SIZEOF_UINT16;
586 size += SIZEOF_UINT16;
587 size += SIZEOF_UINT16;
588 size += SIZEOF_UINT16;
589 break;
590#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
591 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
592 size += SIZEOF_UINT16;
593 size += SIZEOF_UINT16;
594 size += SIZEOF_UINT16;
595 size += SIZEOF_UINT16;
596 size += 48 / 8;
597 break;
598#endif
599#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
600 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
601 size += SIZEOF_UINT16;
602 size += SIZEOF_UINT16;
603 size += SIZEOF_UINT16;
604 size += SIZEOF_UINT16;
605 size += SIZEOF_UINT16;
606 size += SIZEOF_UINT16;
607 break;
608#endif
609#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
610 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
611 size += SIZEOF_UINT16;
612 size += SIZEOF_UINT16;
613 size += SIZEOF_UINT16;
614 size += SIZEOF_UINT16;
615 size += SIZEOF_UINT16;
616 size += SIZEOF_UINT16;
617 break;
618#endif
619#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
620 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
621 size += SIZEOF_UINT16;
622 size += SIZEOF_UINT16;
623 size += SIZEOF_UINT16;
624 size += SIZEOF_UINT16;
625 size += SIZEOF_UINT16;
626 size += SIZEOF_UINT16;
627 size += SIZEOF_UINT16;
628 break;
629#endif
630#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
631 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
632 size += SIZEOF_UINT16;
633 size += SIZEOF_UINT16;
634 size += SIZEOF_UINT16;
635 size += SIZEOF_UINT16;
636 size += SIZEOF_UINT16;
637 size += SIZEOF_UINT16;
638 size += SIZEOF_UINT16;
639 size += 48 / 8;
640 break;
641#endif
642#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
643 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
644 size += SIZEOF_UINT16;
645 size += SIZEOF_UINT16;
646 size += SIZEOF_UINT16;
647 size += SIZEOF_UINT16;
648 size += SIZEOF_UINT16;
649 size += SIZEOF_UINT16;
650 size += SIZEOF_UINT16;
651 size += 48 / 8;
652 size += SIZEOF_UINT16;
653 size += SIZEOF_UINT16;
654 break;
655#endif
656#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
657 case CSR_MLME_MEASURE_CONFIRM_ID:
658 size += SIZEOF_UINT16;
659 size += SIZEOF_UINT16;
660 size += SIZEOF_UINT16;
661 size += SIZEOF_UINT16;
662 size += SIZEOF_UINT16;
663 size += SIZEOF_UINT16;
664 break;
665#endif
666#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
667 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
668 size += SIZEOF_UINT16;
669 size += SIZEOF_UINT16;
670 size += SIZEOF_UINT16;
671 size += SIZEOF_UINT16;
672 size += SIZEOF_UINT16;
673 size += SIZEOF_UINT16;
674 break;
675#endif
676#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
677 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
678 size += SIZEOF_UINT16;
679 size += SIZEOF_UINT16;
680 size += SIZEOF_UINT16;
681 size += SIZEOF_UINT16;
682 size += SIZEOF_UINT16;
683 size += 48 / 8;
684 break;
685#endif
686 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
687 size += SIZEOF_UINT16;
688 size += SIZEOF_UINT16;
689 size += SIZEOF_UINT16;
690 size += SIZEOF_UINT16;
691 size += SIZEOF_UINT16;
692 size += SIZEOF_UINT16;
693 break;
694#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
695 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
696 size += SIZEOF_UINT16;
697 size += SIZEOF_UINT16;
698 size += SIZEOF_UINT16;
699 size += SIZEOF_UINT16;
700 size += SIZEOF_UINT16;
701 size += SIZEOF_UINT16;
702 size += SIZEOF_UINT16;
703 break;
704#endif
705#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
706 case CSR_MLME_POWERMGT_CONFIRM_ID:
707 size += SIZEOF_UINT16;
708 size += SIZEOF_UINT16;
709 size += SIZEOF_UINT16;
710 size += SIZEOF_UINT16;
711 size += SIZEOF_UINT16;
712 size += SIZEOF_UINT16;
713 break;
714#endif
715#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
716 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
717 size += SIZEOF_UINT16;
718 size += SIZEOF_UINT16;
719 size += SIZEOF_UINT16;
720 size += SIZEOF_UINT16;
721 size += SIZEOF_UINT16;
722 size += SIZEOF_UINT16;
723 size += SIZEOF_UINT16;
724 break;
725#endif
726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
727 case CSR_MLME_GET_CONFIRM_ID:
728 size += SIZEOF_UINT16;
729 size += SIZEOF_UINT16;
730 size += SIZEOF_UINT16;
731 size += SIZEOF_UINT16;
732 size += SIZEOF_UINT16;
733 size += SIZEOF_UINT16;
734 break;
735#endif
736#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
737 case CSR_MLME_GET_NEXT_CONFIRM_ID:
738 size += SIZEOF_UINT16;
739 size += SIZEOF_UINT16;
740 size += SIZEOF_UINT16;
741 size += SIZEOF_UINT16;
742 size += SIZEOF_UINT16;
743 size += SIZEOF_UINT16;
744 break;
745#endif
746#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
747 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
748 size += SIZEOF_UINT16;
749 size += SIZEOF_UINT16;
750 size += SIZEOF_UINT16;
751 size += SIZEOF_UINT16;
752 size += SIZEOF_UINT16;
753 size += 48 / 8;
754 size += SIZEOF_UINT16;
755 size += SIZEOF_UINT16;
756 break;
757#endif
758#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
759 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
760 size += SIZEOF_UINT16;
761 size += SIZEOF_UINT16;
762 size += SIZEOF_UINT16;
763 size += SIZEOF_UINT16;
764 size += SIZEOF_UINT16;
765 size += SIZEOF_UINT16;
766 size += SIZEOF_UINT16;
767 break;
768#endif
769#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
770 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
771 size += SIZEOF_UINT16;
772 size += SIZEOF_UINT16;
773 size += SIZEOF_UINT16;
774 size += SIZEOF_UINT16;
775 size += SIZEOF_UINT16;
776 size += SIZEOF_UINT16;
777 size += SIZEOF_UINT16;
778 size += SIZEOF_UINT16;
779 size += SIZEOF_UINT32;
780 size += SIZEOF_UINT32;
781 size += SIZEOF_UINT32;
782 size += 48 / 8;
783 size += SIZEOF_UINT16;
784 break;
785#endif
786#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
787 case CSR_MLME_DELETEKEYS_REQUEST_ID:
788 size += SIZEOF_UINT16;
789 size += SIZEOF_UINT16;
790 size += SIZEOF_UINT16;
791 size += SIZEOF_UINT16;
792 size += SIZEOF_UINT16;
793 size += SIZEOF_UINT16;
794 size += SIZEOF_UINT16;
795 size += 48 / 8;
796 break;
797#endif
798#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
799 case CSR_MLME_RESET_CONFIRM_ID:
800 size += SIZEOF_UINT16;
801 size += SIZEOF_UINT16;
802 size += SIZEOF_UINT16;
803 size += SIZEOF_UINT16;
804 size += SIZEOF_UINT16;
805 break;
806#endif
807#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
808 case CSR_MLME_HL_SYNC_CONFIRM_ID:
809 size += SIZEOF_UINT16;
810 size += SIZEOF_UINT16;
811 size += SIZEOF_UINT16;
812 size += SIZEOF_UINT16;
813 size += 48 / 8;
814 size += SIZEOF_UINT16;
815 break;
816#endif
817#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
818 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
819 size += SIZEOF_UINT16;
820 size += SIZEOF_UINT16;
821 size += SIZEOF_UINT16;
822 size += SIZEOF_UINT16;
823 size += SIZEOF_UINT16;
824 size += SIZEOF_UINT16;
825 size += SIZEOF_UINT16;
826 size += SIZEOF_UINT16;
827 size += SIZEOF_UINT16;
828 size += SIZEOF_UINT32;
829 size += SIZEOF_UINT16;
830 size += SIZEOF_UINT16;
831 break;
832#endif
833#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
834 case CSR_MLME_SET_REQUEST_ID:
835 size += SIZEOF_UINT16;
836 size += SIZEOF_UINT16;
837 size += SIZEOF_UINT16;
838 size += SIZEOF_UINT16;
839 break;
840#endif
841#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
842 case CSR_MLME_SM_START_REQUEST_ID:
843 size += SIZEOF_UINT16;
844 size += SIZEOF_UINT16;
845 size += SIZEOF_UINT16;
846 size += SIZEOF_UINT16;
847 size += SIZEOF_UINT16;
848 size += SIZEOF_UINT16;
849 size += SIZEOF_UINT16;
850 size += 48 / 8;
851 size += 48 / 8;
852 size += SIZEOF_UINT16;
853 size += SIZEOF_UINT16;
854 size += SIZEOF_UINT16;
855 break;
856#endif
857#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
858 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
859 size += SIZEOF_UINT16;
860 size += SIZEOF_UINT16;
861 size += SIZEOF_UINT16;
862 size += SIZEOF_UINT16;
863 size += SIZEOF_UINT16;
864 size += SIZEOF_UINT16;
865 break;
866#endif
867#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
868 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
869 size += SIZEOF_UINT16;
870 size += SIZEOF_UINT16;
871 size += SIZEOF_UINT16;
872 size += SIZEOF_UINT16;
873 size += SIZEOF_UINT16;
874 size += SIZEOF_UINT16;
875 size += SIZEOF_UINT16;
876 break;
877#endif
878#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
879 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
880 size += SIZEOF_UINT16;
881 size += SIZEOF_UINT16;
882 size += SIZEOF_UINT16;
883 size += SIZEOF_UINT16;
884 size += SIZEOF_UINT16;
885 size += SIZEOF_UINT16;
886 break;
887#endif
888#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
889 case CSR_MLME_SETKEYS_REQUEST_ID:
890 size += SIZEOF_UINT16;
891 size += SIZEOF_UINT16;
892 size += SIZEOF_UINT16;
893 size += SIZEOF_UINT16;
894 size += SIZEOF_UINT16;
895 size += SIZEOF_UINT16;
896 size += SIZEOF_UINT16;
897 size += SIZEOF_UINT16;
898 size += 48 / 8;
899 size += SIZEOF_UINT16;
900 size += SIZEOF_UINT16;
901 size += SIZEOF_UINT16;
902 size += SIZEOF_UINT16;
903 size += SIZEOF_UINT16;
904 size += SIZEOF_UINT16;
905 size += SIZEOF_UINT16;
906 size += SIZEOF_UINT16;
907 size += 32 / 8;
908 break;
909#endif
910#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
911 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
912 size += SIZEOF_UINT16;
913 size += SIZEOF_UINT16;
914 size += SIZEOF_UINT16;
915 size += SIZEOF_UINT16;
916 size += SIZEOF_UINT16;
917 size += SIZEOF_UINT16;
918 size += SIZEOF_UINT16;
919 break;
920#endif
921#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
922 case CSR_MLME_GET_REQUEST_ID:
923 size += SIZEOF_UINT16;
924 size += SIZEOF_UINT16;
925 size += SIZEOF_UINT16;
926 size += SIZEOF_UINT16;
927 break;
928#endif
929#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
930 case CSR_MLME_POWERMGT_REQUEST_ID:
931 size += SIZEOF_UINT16;
932 size += SIZEOF_UINT16;
933 size += SIZEOF_UINT16;
934 size += SIZEOF_UINT16;
935 size += SIZEOF_UINT16;
936 size += SIZEOF_UINT16;
937 size += SIZEOF_UINT16;
938 size += SIZEOF_UINT16;
939 size += SIZEOF_UINT16;
940 break;
941#endif
942 case CSR_MA_PACKET_ERROR_INDICATION_ID:
943 size += SIZEOF_UINT16;
944 size += SIZEOF_UINT16;
945 size += SIZEOF_UINT16;
946 size += SIZEOF_UINT16;
947 size += SIZEOF_UINT16;
948 size += 48 / 8;
949 size += SIZEOF_UINT16;
950 size += SIZEOF_UINT16;
951 break;
952#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
953 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
954 size += SIZEOF_UINT16;
955 size += SIZEOF_UINT16;
956 size += SIZEOF_UINT16;
957 size += SIZEOF_UINT16;
958 size += SIZEOF_UINT16;
959 size += SIZEOF_UINT16;
960 size += SIZEOF_UINT32;
961 size += SIZEOF_UINT16;
962 size += SIZEOF_UINT16;
963 size += SIZEOF_UINT16;
964 break;
965#endif
966#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
967 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
968 size += SIZEOF_UINT16;
969 size += SIZEOF_UINT16;
970 size += SIZEOF_UINT16;
971 size += SIZEOF_UINT16;
972 size += SIZEOF_UINT16;
973 size += SIZEOF_UINT16;
974 size += SIZEOF_UINT16;
975 size += SIZEOF_UINT16;
976 size += SIZEOF_UINT16;
977 size += SIZEOF_UINT32;
978 size += SIZEOF_UINT32;
979 size += SIZEOF_UINT16;
980 break;
981#endif
982#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
983 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
984 size += SIZEOF_UINT16;
985 size += SIZEOF_UINT16;
986 size += SIZEOF_UINT16;
987 size += SIZEOF_UINT16;
988 size += SIZEOF_UINT16;
989 size += SIZEOF_UINT16;
990 break;
991#endif
992#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
993 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
994 size += SIZEOF_UINT16;
995 size += SIZEOF_UINT16;
996 size += SIZEOF_UINT16;
997 size += SIZEOF_UINT16;
998 size += SIZEOF_UINT16;
999 size += SIZEOF_UINT16;
1000 size += SIZEOF_UINT16;
1001 break;
1002#endif
1003#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1004 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
1005 size += SIZEOF_UINT16;
1006 size += SIZEOF_UINT16;
1007 size += SIZEOF_UINT16;
1008 size += SIZEOF_UINT16;
1009 size += SIZEOF_UINT16;
1010 break;
1011#endif
1012#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1013 case CSR_MLME_SCAN_CONFIRM_ID:
1014 size += SIZEOF_UINT16;
1015 size += SIZEOF_UINT16;
1016 size += SIZEOF_UINT16;
1017 size += SIZEOF_UINT16;
1018 size += SIZEOF_UINT16;
1019 size += SIZEOF_UINT16;
1020 break;
1021#endif
1022 case CSR_DEBUG_STRING_INDICATION_ID:
1023 size += SIZEOF_UINT16;
1024 size += SIZEOF_UINT16;
1025 size += SIZEOF_UINT16;
1026 size += SIZEOF_UINT16;
1027 break;
1028#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1029 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
1030 size += SIZEOF_UINT16;
1031 size += SIZEOF_UINT16;
1032 size += SIZEOF_UINT16;
1033 size += SIZEOF_UINT16;
1034 size += SIZEOF_UINT16;
1035 size += SIZEOF_UINT16;
1036 size += SIZEOF_UINT16;
1037 break;
1038#endif
1039#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1040 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
1041 size += SIZEOF_UINT16;
1042 size += SIZEOF_UINT16;
1043 size += SIZEOF_UINT16;
1044 size += SIZEOF_UINT16;
1045 size += SIZEOF_UINT16;
1046 size += SIZEOF_UINT16;
1047 size += 48 / 8;
1048 break;
1049#endif
1050#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1051 case CSR_MLME_SET_CONFIRM_ID:
1052 size += SIZEOF_UINT16;
1053 size += SIZEOF_UINT16;
1054 size += SIZEOF_UINT16;
1055 size += SIZEOF_UINT16;
1056 size += SIZEOF_UINT16;
1057 size += SIZEOF_UINT16;
1058 break;
1059#endif
1060#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1061 case CSR_MLME_MEASURE_REQUEST_ID:
1062 size += SIZEOF_UINT16;
1063 size += SIZEOF_UINT16;
1064 size += SIZEOF_UINT16;
1065 size += SIZEOF_UINT16;
1066 size += SIZEOF_UINT16;
1067 break;
1068#endif
1069#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1070 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
1071 size += SIZEOF_UINT16;
1072 size += SIZEOF_UINT16;
1073 size += SIZEOF_UINT16;
1074 size += SIZEOF_UINT16;
1075 size += SIZEOF_UINT16;
1076 size += 48 / 8;
1077 size += SIZEOF_UINT16;
1078 size += SIZEOF_UINT16;
1079 size += SIZEOF_UINT16;
1080 size += SIZEOF_UINT16;
1081 break;
1082#endif
1083#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1084 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
1085 size += SIZEOF_UINT16;
1086 size += SIZEOF_UINT16;
1087 size += SIZEOF_UINT16;
1088 size += SIZEOF_UINT16;
1089 size += SIZEOF_UINT16;
1090 size += SIZEOF_UINT16;
1091 break;
1092#endif
1093 case CSR_MA_PACKET_CONFIRM_ID:
1094 size += SIZEOF_UINT16;
1095 size += SIZEOF_UINT16;
1096 size += SIZEOF_UINT16;
1097 size += SIZEOF_UINT16;
1098 size += SIZEOF_UINT16;
1099 size += SIZEOF_UINT16;
1100 size += SIZEOF_UINT16;
1101 size += SIZEOF_UINT16;
1102 size += SIZEOF_UINT32;
1103 break;
1104#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1105 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
1106 size += SIZEOF_UINT16;
1107 size += SIZEOF_UINT16;
1108 size += SIZEOF_UINT16;
1109 size += SIZEOF_UINT16;
1110 size += SIZEOF_UINT16;
1111 size += SIZEOF_UINT16;
1112 size += SIZEOF_UINT16;
1113 break;
1114#endif
1115#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1116 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
1117 size += SIZEOF_UINT16;
1118 size += SIZEOF_UINT16;
1119 size += SIZEOF_UINT16;
1120 size += SIZEOF_UINT16;
1121 size += SIZEOF_UINT16;
1122 break;
1123#endif
1124 default:
1125 size = 0;
1126 }
1127 return size;
1128} /* get_packed_struct_size() */
1129
1130
1131/*
1132 * ---------------------------------------------------------------------------
1133 * read_unpack_signal
1134 *
1135 * Unpack a wire-format signal into a host-native structure.
1136 * This function handles any necessary conversions for endianness and
1137 * places no restrictions on packing or alignment for the structure
1138 * definition.
1139 *
1140 * WARNING: This function is auto-generated, DO NOT EDIT!
1141 *
1142 * Arguments:
1143 * ptr Signal buffer to unpack.
1144 * sig Pointer to destination structure to populate.
1145 *
1146 * Returns:
1147 * CSR_RESULT_SUCCESS on success,
1148 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
1149 * ---------------------------------------------------------------------------
1150 */
1151CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig)
1152{
1153 s32 index = 0;
1154
1155 sig->SignalPrimitiveHeader.SignalId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1156 index += SIZEOF_UINT16;
1157
1158 sig->SignalPrimitiveHeader.ReceiverProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1159 index += SIZEOF_UINT16;
1160
1161 sig->SignalPrimitiveHeader.SenderProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1162 index += SIZEOF_UINT16;
1163
1164 switch (sig->SignalPrimitiveHeader.SignalId)
1165 {
1166#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1167 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
1168 sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1169 index += SIZEOF_UINT16;
1170 sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1171 index += SIZEOF_UINT16;
1172 sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1173 index += SIZEOF_UINT16;
1174 sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1175 index += SIZEOF_UINT16;
1176 sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1177 index += SIZEOF_UINT16;
1178 sig->u.MlmeSetPacketFilterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1179 index += SIZEOF_UINT16;
1180 break;
1181#endif
1182#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1183 case CSR_MLME_SETKEYS_CONFIRM_ID:
1184 sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1185 index += SIZEOF_UINT16;
1186 sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1187 index += SIZEOF_UINT16;
1188 sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1189 index += SIZEOF_UINT16;
1190 sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1191 index += SIZEOF_UINT16;
1192 sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1193 index += SIZEOF_UINT16;
1194 sig->u.MlmeSetkeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1195 index += SIZEOF_UINT16;
1196 break;
1197#endif
1198#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1199 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
1200 sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1201 index += SIZEOF_UINT16;
1202 sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1203 index += SIZEOF_UINT16;
1204 sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1205 index += SIZEOF_UINT16;
1206 sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1207 index += SIZEOF_UINT16;
1208 sig->u.MlmeConfigQueueConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1209 index += SIZEOF_UINT16;
1210 break;
1211#endif
1212#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1213 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
1214 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1215 index += SIZEOF_UINT16;
1216 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1217 index += SIZEOF_UINT16;
1218 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1219 index += SIZEOF_UINT16;
1220 sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1221 index += SIZEOF_UINT16;
1222 sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1223 index += SIZEOF_UINT16;
1224 sig->u.MlmeAddAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1225 index += SIZEOF_UINT16;
1226 sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1227 index += SIZEOF_UINT16;
1228 break;
1229#endif
1230#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1231 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
1232 sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1233 index += SIZEOF_UINT16;
1234 sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1235 index += SIZEOF_UINT16;
1236 sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1237 index += SIZEOF_UINT16;
1238 sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1239 index += SIZEOF_UINT16;
1240 sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1241 index += SIZEOF_UINT16;
1242 sig->u.MlmeAddBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1243 index += SIZEOF_UINT16;
1244 sig->u.MlmeAddBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1245 index += SIZEOF_UINT16;
1246 break;
1247#endif
1248#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1249 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
1250 sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1251 index += SIZEOF_UINT16;
1252 sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1253 index += SIZEOF_UINT16;
1254 sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1255 index += SIZEOF_UINT16;
1256 sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1257 index += SIZEOF_UINT16;
1258 sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1259 index += SIZEOF_UINT16;
1260 sig->u.MlmeDelBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1261 index += SIZEOF_UINT16;
1262 break;
1263#endif
1264#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1265 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
1266 sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1267 index += SIZEOF_UINT16;
1268 sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1269 index += SIZEOF_UINT16;
1270 sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1271 index += SIZEOF_UINT16;
1272 sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1273 index += SIZEOF_UINT16;
1274 sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1275 index += SIZEOF_UINT16;
1276 sig->u.MlmeGetKeySequenceConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1277 index += SIZEOF_UINT16;
1278 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1279 index += SIZEOF_UINT16;
1280 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1281 index += SIZEOF_UINT16;
1282 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1283 index += SIZEOF_UINT16;
1284 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1285 index += SIZEOF_UINT16;
1286 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1287 index += SIZEOF_UINT16;
1288 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1289 index += SIZEOF_UINT16;
1290 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1291 index += SIZEOF_UINT16;
1292 sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1293 index += SIZEOF_UINT16;
1294 break;
1295#endif
1296#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1297 case CSR_MLME_SM_START_CONFIRM_ID:
1298 sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1299 index += SIZEOF_UINT16;
1300 sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1301 index += SIZEOF_UINT16;
1302 sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1303 index += SIZEOF_UINT16;
1304 sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1305 index += SIZEOF_UINT16;
1306 sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1307 index += SIZEOF_UINT16;
1308 sig->u.MlmeSmStartConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1309 index += SIZEOF_UINT16;
1310 break;
1311#endif
1312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1313 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
1314 sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1315 index += SIZEOF_UINT16;
1316 sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1317 index += SIZEOF_UINT16;
1318 sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1319 index += SIZEOF_UINT16;
1320 sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1321 index += SIZEOF_UINT16;
1322 sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1323 index += SIZEOF_UINT16;
1324 memcpy(sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
1325 index += 48 / 8;
1326 sig->u.MlmeStopAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1327 index += SIZEOF_UINT16;
1328 sig->u.MlmeStopAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1329 index += SIZEOF_UINT16;
1330 sig->u.MlmeStopAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1331 index += SIZEOF_UINT16;
1332 break;
1333#endif
1334#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1335 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
1336 sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1337 index += SIZEOF_UINT16;
1338 sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1339 index += SIZEOF_UINT16;
1340 sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1341 index += SIZEOF_UINT16;
1342 sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1343 index += SIZEOF_UINT16;
1344 sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1345 index += SIZEOF_UINT16;
1346 sig->u.MlmeDelTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1347 index += SIZEOF_UINT16;
1348 sig->u.MlmeDelTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1349 index += SIZEOF_UINT16;
1350 break;
1351#endif
1352 case CSR_DEBUG_WORD16_INDICATION_ID:
1353 sig->u.DebugWord16Indication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1354 index += SIZEOF_UINT16;
1355 sig->u.DebugWord16Indication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1356 index += SIZEOF_UINT16;
1357 sig->u.DebugWord16Indication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1358 index += SIZEOF_UINT16;
1359 sig->u.DebugWord16Indication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1360 index += SIZEOF_UINT16;
1361 sig->u.DebugWord16Indication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1362 index += SIZEOF_UINT16;
1363 sig->u.DebugWord16Indication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1364 index += SIZEOF_UINT16;
1365 sig->u.DebugWord16Indication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1366 index += SIZEOF_UINT16;
1367 sig->u.DebugWord16Indication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1368 index += SIZEOF_UINT16;
1369 sig->u.DebugWord16Indication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1370 index += SIZEOF_UINT16;
1371 sig->u.DebugWord16Indication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1372 index += SIZEOF_UINT16;
1373 sig->u.DebugWord16Indication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1374 index += SIZEOF_UINT16;
1375 sig->u.DebugWord16Indication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1376 index += SIZEOF_UINT16;
1377 sig->u.DebugWord16Indication.DebugWords[8] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1378 index += SIZEOF_UINT16;
1379 sig->u.DebugWord16Indication.DebugWords[9] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1380 index += SIZEOF_UINT16;
1381 sig->u.DebugWord16Indication.DebugWords[10] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1382 index += SIZEOF_UINT16;
1383 sig->u.DebugWord16Indication.DebugWords[11] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1384 index += SIZEOF_UINT16;
1385 sig->u.DebugWord16Indication.DebugWords[12] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1386 index += SIZEOF_UINT16;
1387 sig->u.DebugWord16Indication.DebugWords[13] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1388 index += SIZEOF_UINT16;
1389 sig->u.DebugWord16Indication.DebugWords[14] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1390 index += SIZEOF_UINT16;
1391 sig->u.DebugWord16Indication.DebugWords[15] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1392 index += SIZEOF_UINT16;
1393 break;
1394 case CSR_DEBUG_GENERIC_CONFIRM_ID:
1395 sig->u.DebugGenericConfirm.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1396 index += SIZEOF_UINT16;
1397 sig->u.DebugGenericConfirm.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1398 index += SIZEOF_UINT16;
1399 sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1400 index += SIZEOF_UINT16;
1401 sig->u.DebugGenericConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1402 index += SIZEOF_UINT16;
1403 sig->u.DebugGenericConfirm.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1404 index += SIZEOF_UINT16;
1405 sig->u.DebugGenericConfirm.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1406 index += SIZEOF_UINT16;
1407 sig->u.DebugGenericConfirm.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1408 index += SIZEOF_UINT16;
1409 sig->u.DebugGenericConfirm.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1410 index += SIZEOF_UINT16;
1411 sig->u.DebugGenericConfirm.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1412 index += SIZEOF_UINT16;
1413 sig->u.DebugGenericConfirm.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1414 index += SIZEOF_UINT16;
1415 sig->u.DebugGenericConfirm.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1416 index += SIZEOF_UINT16;
1417 sig->u.DebugGenericConfirm.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1418 index += SIZEOF_UINT16;
1419 break;
1420 case CSR_MA_PACKET_INDICATION_ID:
1421 sig->u.MaPacketIndication.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1422 index += SIZEOF_UINT16;
1423 sig->u.MaPacketIndication.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1424 index += SIZEOF_UINT16;
1425 sig->u.MaPacketIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1426 index += SIZEOF_UINT16;
1427 sig->u.MaPacketIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1428 index += SIZEOF_UINT16;
1429 sig->u.MaPacketIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1430 index += SIZEOF_UINT16;
1431 memcpy(sig->u.MaPacketIndication.LocalTime.x, &ptr[index], 64 / 8);
1432 index += 64 / 8;
1433 sig->u.MaPacketIndication.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1434 index += SIZEOF_UINT16;
1435 sig->u.MaPacketIndication.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1436 index += SIZEOF_UINT16;
1437 sig->u.MaPacketIndication.ReceptionStatus = (CSR_RECEPTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1438 index += SIZEOF_UINT16;
1439 sig->u.MaPacketIndication.Rssi = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1440 index += SIZEOF_UINT16;
1441 sig->u.MaPacketIndication.Snr = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1442 index += SIZEOF_UINT16;
1443 sig->u.MaPacketIndication.ReceivedRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1444 index += SIZEOF_UINT16;
1445 break;
1446 case CSR_MLME_SET_TIM_REQUEST_ID:
1447 sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1448 index += SIZEOF_UINT16;
1449 sig->u.MlmeSetTimRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1450 index += SIZEOF_UINT16;
1451 sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1452 index += SIZEOF_UINT16;
1453 sig->u.MlmeSetTimRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1454 index += SIZEOF_UINT16;
1455 sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1456 index += SIZEOF_UINT16;
1457 sig->u.MlmeSetTimRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1458 index += SIZEOF_UINT16;
1459 sig->u.MlmeSetTimRequest.TimValue = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1460 index += SIZEOF_UINT16;
1461 break;
1462#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1463 case CSR_MLME_CONNECTED_INDICATION_ID:
1464 sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1465 index += SIZEOF_UINT16;
1466 sig->u.MlmeConnectedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1467 index += SIZEOF_UINT16;
1468 sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1469 index += SIZEOF_UINT16;
1470 sig->u.MlmeConnectedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1471 index += SIZEOF_UINT16;
1472 sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1473 index += SIZEOF_UINT16;
1474 sig->u.MlmeConnectedIndication.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1475 index += SIZEOF_UINT16;
1476 memcpy(sig->u.MlmeConnectedIndication.PeerMacAddress.x, &ptr[index], 48 / 8);
1477 index += 48 / 8;
1478 break;
1479#endif
1480#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1481 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
1482 sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1483 index += SIZEOF_UINT16;
1484 sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1485 index += SIZEOF_UINT16;
1486 sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1487 index += SIZEOF_UINT16;
1488 sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1489 index += SIZEOF_UINT16;
1490 sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1491 index += SIZEOF_UINT16;
1492 sig->u.MlmeDelRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1493 index += SIZEOF_UINT16;
1494 break;
1495#endif
1496#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1497 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
1498 sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1499 index += SIZEOF_UINT16;
1500 sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1501 index += SIZEOF_UINT16;
1502 sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1503 index += SIZEOF_UINT16;
1504 sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1505 index += SIZEOF_UINT16;
1506 sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1507 index += SIZEOF_UINT16;
1508 sig->u.MlmeTriggeredGetIndication.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1509 index += SIZEOF_UINT16;
1510 sig->u.MlmeTriggeredGetIndication.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1511 index += SIZEOF_UINT16;
1512 sig->u.MlmeTriggeredGetIndication.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1513 index += SIZEOF_UINT16;
1514 break;
1515#endif
1516#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1517 case CSR_MLME_SCAN_REQUEST_ID:
1518 sig->u.MlmeScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1519 index += SIZEOF_UINT16;
1520 sig->u.MlmeScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1521 index += SIZEOF_UINT16;
1522 sig->u.MlmeScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1523 index += SIZEOF_UINT16;
1524 sig->u.MlmeScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1525 index += SIZEOF_UINT16;
1526 sig->u.MlmeScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1527 index += SIZEOF_UINT16;
1528 sig->u.MlmeScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1529 index += SIZEOF_UINT16;
1530 sig->u.MlmeScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1531 index += SIZEOF_UINT16;
1532 sig->u.MlmeScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1533 index += SIZEOF_UINT32;
1534 sig->u.MlmeScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1535 index += SIZEOF_UINT16;
1536 sig->u.MlmeScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1537 index += SIZEOF_UINT16;
1538 break;
1539#endif
1540#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1541 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
1542 sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1543 index += SIZEOF_UINT16;
1544 sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1545 index += SIZEOF_UINT16;
1546 sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1547 index += SIZEOF_UINT16;
1548 sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1549 index += SIZEOF_UINT16;
1550 sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1551 index += SIZEOF_UINT16;
1552 sig->u.MlmeDeletekeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1553 index += SIZEOF_UINT16;
1554 break;
1555#endif
1556#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1557 case CSR_MLME_GET_NEXT_REQUEST_ID:
1558 sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1559 index += SIZEOF_UINT16;
1560 sig->u.MlmeGetNextRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1561 index += SIZEOF_UINT16;
1562 sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1563 index += SIZEOF_UINT16;
1564 sig->u.MlmeGetNextRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1565 index += SIZEOF_UINT16;
1566 break;
1567#endif
1568#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1569 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
1570 sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1571 index += SIZEOF_UINT16;
1572 sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1573 index += SIZEOF_UINT16;
1574 sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1575 index += SIZEOF_UINT16;
1576 sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1577 index += SIZEOF_UINT16;
1578 sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1579 index += SIZEOF_UINT16;
1580 sig->u.MlmeSetChannelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1581 index += SIZEOF_UINT16;
1582 break;
1583#endif
1584#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1585 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
1586 sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1587 index += SIZEOF_UINT16;
1588 sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1589 index += SIZEOF_UINT16;
1590 sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1591 index += SIZEOF_UINT16;
1592 sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1593 index += SIZEOF_UINT16;
1594 sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1595 index += SIZEOF_UINT16;
1596 memcpy(sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
1597 index += 48 / 8;
1598 sig->u.MlmeStartAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1599 index += SIZEOF_UINT16;
1600 sig->u.MlmeStartAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1601 index += SIZEOF_UINT16;
1602 sig->u.MlmeStartAggregationRequest.StartingSequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1603 index += SIZEOF_UINT16;
1604 sig->u.MlmeStartAggregationRequest.BufferSize = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1605 index += SIZEOF_UINT16;
1606 sig->u.MlmeStartAggregationRequest.BlockAckTimeout = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1607 index += SIZEOF_UINT16;
1608 break;
1609#endif
1610#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1611 case CSR_MLME_HL_SYNC_REQUEST_ID:
1612 sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1613 index += SIZEOF_UINT16;
1614 sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1615 index += SIZEOF_UINT16;
1616 sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1617 index += SIZEOF_UINT16;
1618 sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1619 index += SIZEOF_UINT16;
1620 memcpy(sig->u.MlmeHlSyncRequest.GroupAddress.x, &ptr[index], 48 / 8);
1621 index += 48 / 8;
1622 break;
1623#endif
1624 case CSR_DEBUG_GENERIC_REQUEST_ID:
1625 sig->u.DebugGenericRequest.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1626 index += SIZEOF_UINT16;
1627 sig->u.DebugGenericRequest.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1628 index += SIZEOF_UINT16;
1629 sig->u.DebugGenericRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1630 index += SIZEOF_UINT16;
1631 sig->u.DebugGenericRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1632 index += SIZEOF_UINT16;
1633 sig->u.DebugGenericRequest.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1634 index += SIZEOF_UINT16;
1635 sig->u.DebugGenericRequest.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1636 index += SIZEOF_UINT16;
1637 sig->u.DebugGenericRequest.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1638 index += SIZEOF_UINT16;
1639 sig->u.DebugGenericRequest.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1640 index += SIZEOF_UINT16;
1641 sig->u.DebugGenericRequest.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1642 index += SIZEOF_UINT16;
1643 sig->u.DebugGenericRequest.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1644 index += SIZEOF_UINT16;
1645 sig->u.DebugGenericRequest.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1646 index += SIZEOF_UINT16;
1647 sig->u.DebugGenericRequest.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1648 index += SIZEOF_UINT16;
1649 break;
1650#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1651 case CSR_MLME_LEAVE_CONFIRM_ID:
1652 sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1653 index += SIZEOF_UINT16;
1654 sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1655 index += SIZEOF_UINT16;
1656 sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1657 index += SIZEOF_UINT16;
1658 sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1659 index += SIZEOF_UINT16;
1660 sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1661 index += SIZEOF_UINT16;
1662 sig->u.MlmeLeaveConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1663 index += SIZEOF_UINT16;
1664 break;
1665#endif
1666#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1667 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
1668 sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1669 index += SIZEOF_UINT16;
1670 sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1671 index += SIZEOF_UINT16;
1672 sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1673 index += SIZEOF_UINT16;
1674 sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1675 index += SIZEOF_UINT16;
1676 sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1677 index += SIZEOF_UINT16;
1678 sig->u.MlmeDelTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1679 index += SIZEOF_UINT16;
1680 break;
1681#endif
1682#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1683 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
1684 sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1685 index += SIZEOF_UINT16;
1686 sig->u.MlmeAddMulticastAddressRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1687 index += SIZEOF_UINT16;
1688 sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1689 index += SIZEOF_UINT16;
1690 sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1691 index += SIZEOF_UINT16;
1692 sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1693 index += SIZEOF_UINT16;
1694 sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1695 index += SIZEOF_UINT16;
1696 break;
1697#endif
1698#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1699 case CSR_MLME_RESET_REQUEST_ID:
1700 sig->u.MlmeResetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1701 index += SIZEOF_UINT16;
1702 sig->u.MlmeResetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1703 index += SIZEOF_UINT16;
1704 sig->u.MlmeResetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1705 index += SIZEOF_UINT16;
1706 sig->u.MlmeResetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1707 index += SIZEOF_UINT16;
1708 memcpy(sig->u.MlmeResetRequest.StaAddress.x, &ptr[index], 48 / 8);
1709 index += 48 / 8;
1710 sig->u.MlmeResetRequest.SetDefaultMib = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1711 index += SIZEOF_UINT16;
1712 break;
1713#endif
1714#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1715 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
1716 sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1717 index += SIZEOF_UINT16;
1718 sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1719 index += SIZEOF_UINT16;
1720 sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1721 index += SIZEOF_UINT16;
1722 sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1723 index += SIZEOF_UINT16;
1724 sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1725 index += SIZEOF_UINT16;
1726 break;
1727#endif
1728#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1729 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
1730 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1731 index += SIZEOF_UINT16;
1732 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1733 index += SIZEOF_UINT16;
1734 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1735 index += SIZEOF_UINT16;
1736 sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1737 index += SIZEOF_UINT16;
1738 sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1739 index += SIZEOF_UINT16;
1740 sig->u.MlmeAddTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1741 index += SIZEOF_UINT16;
1742 sig->u.MlmeAddTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1743 index += SIZEOF_UINT16;
1744 break;
1745#endif
1746#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1747 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
1748 sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1749 index += SIZEOF_UINT16;
1750 sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1751 index += SIZEOF_UINT16;
1752 sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1753 index += SIZEOF_UINT16;
1754 sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1755 index += SIZEOF_UINT16;
1756 sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1757 index += SIZEOF_UINT16;
1758 sig->u.MlmeSetPacketFilterRequest.PacketFilterMode = (CSR_PACKET_FILTER_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1759 index += SIZEOF_UINT16;
1760 sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1761 index += SIZEOF_UINT32;
1762 break;
1763#endif
1764#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1765 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
1766 sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1767 index += SIZEOF_UINT16;
1768 sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1769 index += SIZEOF_UINT16;
1770 sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1771 index += SIZEOF_UINT16;
1772 sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1773 index += SIZEOF_UINT16;
1774 sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1775 index += SIZEOF_UINT16;
1776 sig->u.MlmeDelRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1777 index += SIZEOF_UINT16;
1778 sig->u.MlmeDelRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1779 index += SIZEOF_UINT16;
1780 break;
1781#endif
1782#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1783 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
1784 sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1785 index += SIZEOF_UINT16;
1786 sig->u.MlmeConnectStatusRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1787 index += SIZEOF_UINT16;
1788 sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1789 index += SIZEOF_UINT16;
1790 sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1791 index += SIZEOF_UINT16;
1792 sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1793 index += SIZEOF_UINT16;
1794 sig->u.MlmeConnectStatusRequest.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1795 index += SIZEOF_UINT16;
1796 memcpy(sig->u.MlmeConnectStatusRequest.StaAddress.x, &ptr[index], 48 / 8);
1797 index += 48 / 8;
1798 sig->u.MlmeConnectStatusRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1799 index += SIZEOF_UINT16;
1800 sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1801 index += SIZEOF_UINT16;
1802 break;
1803#endif
1804#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1805 case CSR_MLME_LEAVE_REQUEST_ID:
1806 sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1807 index += SIZEOF_UINT16;
1808 sig->u.MlmeLeaveRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1809 index += SIZEOF_UINT16;
1810 sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1811 index += SIZEOF_UINT16;
1812 sig->u.MlmeLeaveRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1813 index += SIZEOF_UINT16;
1814 sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1815 index += SIZEOF_UINT16;
1816 break;
1817#endif
1818#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1819 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
1820 sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1821 index += SIZEOF_UINT16;
1822 sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1823 index += SIZEOF_UINT16;
1824 sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1825 index += SIZEOF_UINT16;
1826 sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1827 index += SIZEOF_UINT16;
1828 sig->u.MlmeConfigQueueRequest.QueueIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1829 index += SIZEOF_UINT16;
1830 sig->u.MlmeConfigQueueRequest.Aifs = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1831 index += SIZEOF_UINT16;
1832 sig->u.MlmeConfigQueueRequest.Cwmin = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1833 index += SIZEOF_UINT16;
1834 sig->u.MlmeConfigQueueRequest.Cwmax = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1835 index += SIZEOF_UINT16;
1836 sig->u.MlmeConfigQueueRequest.TxopLimit = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1837 index += SIZEOF_UINT16;
1838 break;
1839#endif
1840#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1841 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
1842 sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1843 index += SIZEOF_UINT16;
1844 sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1845 index += SIZEOF_UINT16;
1846 sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1847 index += SIZEOF_UINT16;
1848 sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1849 index += SIZEOF_UINT16;
1850 sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1851 index += SIZEOF_UINT16;
1852 sig->u.MlmeDelTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1853 index += SIZEOF_UINT16;
1854 sig->u.MlmeDelTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1855 index += SIZEOF_UINT16;
1856 break;
1857#endif
1858 case CSR_MLME_SET_TIM_CONFIRM_ID:
1859 sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1860 index += SIZEOF_UINT16;
1861 sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1862 index += SIZEOF_UINT16;
1863 sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1864 index += SIZEOF_UINT16;
1865 sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1866 index += SIZEOF_UINT16;
1867 sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1868 index += SIZEOF_UINT16;
1869 sig->u.MlmeSetTimConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1870 index += SIZEOF_UINT16;
1871 break;
1872#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1873 case CSR_MLME_MEASURE_INDICATION_ID:
1874 sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1875 index += SIZEOF_UINT16;
1876 sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1877 index += SIZEOF_UINT16;
1878 sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1879 index += SIZEOF_UINT16;
1880 sig->u.MlmeMeasureIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1881 index += SIZEOF_UINT16;
1882 sig->u.MlmeMeasureIndication.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1883 index += SIZEOF_UINT16;
1884 break;
1885#endif
1886#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1887 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
1888 sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1889 index += SIZEOF_UINT16;
1890 sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1891 index += SIZEOF_UINT16;
1892 sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1893 index += SIZEOF_UINT16;
1894 sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1895 index += SIZEOF_UINT16;
1896 sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1897 index += SIZEOF_UINT16;
1898 sig->u.MlmeDelBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1899 index += SIZEOF_UINT16;
1900 sig->u.MlmeDelBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1901 index += SIZEOF_UINT16;
1902 break;
1903#endif
1904#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1905 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
1906 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1907 index += SIZEOF_UINT16;
1908 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1909 index += SIZEOF_UINT16;
1910 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1911 index += SIZEOF_UINT16;
1912 sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1913 index += SIZEOF_UINT16;
1914 sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1915 index += SIZEOF_UINT16;
1916 sig->u.MlmeDelTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1917 index += SIZEOF_UINT16;
1918 sig->u.MlmeDelTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1919 index += SIZEOF_UINT16;
1920 break;
1921#endif
1922 case CSR_DEBUG_GENERIC_INDICATION_ID:
1923 sig->u.DebugGenericIndication.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1924 index += SIZEOF_UINT16;
1925 sig->u.DebugGenericIndication.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1926 index += SIZEOF_UINT16;
1927 sig->u.DebugGenericIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1928 index += SIZEOF_UINT16;
1929 sig->u.DebugGenericIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1930 index += SIZEOF_UINT16;
1931 sig->u.DebugGenericIndication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1932 index += SIZEOF_UINT16;
1933 sig->u.DebugGenericIndication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1934 index += SIZEOF_UINT16;
1935 sig->u.DebugGenericIndication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1936 index += SIZEOF_UINT16;
1937 sig->u.DebugGenericIndication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1938 index += SIZEOF_UINT16;
1939 sig->u.DebugGenericIndication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1940 index += SIZEOF_UINT16;
1941 sig->u.DebugGenericIndication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1942 index += SIZEOF_UINT16;
1943 sig->u.DebugGenericIndication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1944 index += SIZEOF_UINT16;
1945 sig->u.DebugGenericIndication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1946 index += SIZEOF_UINT16;
1947 break;
1948 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
1949 sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1950 index += SIZEOF_UINT16;
1951 sig->u.MaPacketCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1952 index += SIZEOF_UINT16;
1953 sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1954 index += SIZEOF_UINT16;
1955 sig->u.MaPacketCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1956 index += SIZEOF_UINT16;
1957 sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1958 index += SIZEOF_UINT16;
1959 sig->u.MaPacketCancelRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
1960 index += SIZEOF_UINT32;
1961 break;
1962#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1963 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
1964 sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1965 index += SIZEOF_UINT16;
1966 sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1967 index += SIZEOF_UINT16;
1968 sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1969 index += SIZEOF_UINT16;
1970 sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1971 index += SIZEOF_UINT16;
1972 sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1973 index += SIZEOF_UINT16;
1974 sig->u.MlmeModifyBssParameterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1975 index += SIZEOF_UINT16;
1976 break;
1977#endif
1978#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
1979 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
1980 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1981 index += SIZEOF_UINT16;
1982 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1983 index += SIZEOF_UINT16;
1984 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1985 index += SIZEOF_UINT16;
1986 sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1987 index += SIZEOF_UINT16;
1988 sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1989 index += SIZEOF_UINT16;
1990 sig->u.MlmePauseAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1991 index += SIZEOF_UINT16;
1992 sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1993 index += SIZEOF_UINT16;
1994 break;
1995#endif
1996 case CSR_MA_PACKET_REQUEST_ID:
1997 sig->u.MaPacketRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
1998 index += SIZEOF_UINT16;
1999 sig->u.MaPacketRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2000 index += SIZEOF_UINT16;
2001 sig->u.MaPacketRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2002 index += SIZEOF_UINT16;
2003 sig->u.MaPacketRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2004 index += SIZEOF_UINT16;
2005 sig->u.MaPacketRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2006 index += SIZEOF_UINT16;
2007 sig->u.MaPacketRequest.TransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2008 index += SIZEOF_UINT16;
2009 sig->u.MaPacketRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2010 index += SIZEOF_UINT32;
2011 sig->u.MaPacketRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2012 index += SIZEOF_UINT16;
2013 memcpy(sig->u.MaPacketRequest.Ra.x, &ptr[index], 48 / 8);
2014 index += 48 / 8;
2015 sig->u.MaPacketRequest.TransmissionControl = (CSR_TRANSMISSION_CONTROL) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2016 index += SIZEOF_UINT16;
2017 break;
2018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2019 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
2020 sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2021 index += SIZEOF_UINT16;
2022 sig->u.MlmeModifyBssParameterRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2023 index += SIZEOF_UINT16;
2024 sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2025 index += SIZEOF_UINT16;
2026 sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2027 index += SIZEOF_UINT16;
2028 sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2029 index += SIZEOF_UINT16;
2030 sig->u.MlmeModifyBssParameterRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2031 index += SIZEOF_UINT16;
2032 sig->u.MlmeModifyBssParameterRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2033 index += SIZEOF_UINT16;
2034 sig->u.MlmeModifyBssParameterRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2035 index += SIZEOF_UINT16;
2036 memcpy(sig->u.MlmeModifyBssParameterRequest.Bssid.x, &ptr[index], 48 / 8);
2037 index += 48 / 8;
2038 sig->u.MlmeModifyBssParameterRequest.RtsThreshold = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2039 index += SIZEOF_UINT16;
2040 break;
2041#endif
2042#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2043 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
2044 sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2045 index += SIZEOF_UINT16;
2046 sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2047 index += SIZEOF_UINT16;
2048 sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2049 index += SIZEOF_UINT16;
2050 sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2051 index += SIZEOF_UINT16;
2052 sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2053 index += SIZEOF_UINT16;
2054 sig->u.MlmeAddRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2055 index += SIZEOF_UINT16;
2056 sig->u.MlmeAddRxTriggerRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2057 index += SIZEOF_UINT16;
2058 break;
2059#endif
2060 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
2061 sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2062 index += SIZEOF_UINT16;
2063 sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2064 index += SIZEOF_UINT16;
2065 sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2066 index += SIZEOF_UINT16;
2067 sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2068 index += SIZEOF_UINT16;
2069 sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2070 index += SIZEOF_UINT16;
2071 sig->u.MaVifAvailabilityIndication.Multicast = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2072 index += SIZEOF_UINT16;
2073 break;
2074#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2075 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
2076 sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2077 index += SIZEOF_UINT16;
2078 sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2079 index += SIZEOF_UINT16;
2080 sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2081 index += SIZEOF_UINT16;
2082 sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2083 index += SIZEOF_UINT16;
2084 memcpy(sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, &ptr[index], 48 / 8);
2085 index += 48 / 8;
2086 break;
2087#endif
2088#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2089 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
2090 sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2091 index += SIZEOF_UINT16;
2092 sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2093 index += SIZEOF_UINT16;
2094 sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2095 index += SIZEOF_UINT16;
2096 sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2097 index += SIZEOF_UINT16;
2098 sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2099 index += SIZEOF_UINT16;
2100 sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2101 index += SIZEOF_UINT16;
2102 break;
2103#endif
2104#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2105 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
2106 sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2107 index += SIZEOF_UINT16;
2108 sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2109 index += SIZEOF_UINT16;
2110 sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2111 index += SIZEOF_UINT16;
2112 sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2113 index += SIZEOF_UINT16;
2114 sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2115 index += SIZEOF_UINT16;
2116 sig->u.MlmeBlackoutEndedIndication.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2117 index += SIZEOF_UINT16;
2118 break;
2119#endif
2120#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2121 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
2122 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2123 index += SIZEOF_UINT16;
2124 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2125 index += SIZEOF_UINT16;
2126 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2127 index += SIZEOF_UINT16;
2128 sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2129 index += SIZEOF_UINT16;
2130 sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2131 index += SIZEOF_UINT16;
2132 sig->u.MlmeAutonomousScanDoneIndication.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2133 index += SIZEOF_UINT16;
2134 sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2135 index += SIZEOF_UINT16;
2136 break;
2137#endif
2138#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2139 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
2140 sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2141 index += SIZEOF_UINT16;
2142 sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2143 index += SIZEOF_UINT16;
2144 sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2145 index += SIZEOF_UINT16;
2146 sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2147 index += SIZEOF_UINT16;
2148 sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2149 index += SIZEOF_UINT16;
2150 sig->u.MlmeGetKeySequenceRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2151 index += SIZEOF_UINT16;
2152 sig->u.MlmeGetKeySequenceRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2153 index += SIZEOF_UINT16;
2154 memcpy(sig->u.MlmeGetKeySequenceRequest.Address.x, &ptr[index], 48 / 8);
2155 index += 48 / 8;
2156 break;
2157#endif
2158#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2159 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
2160 sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2161 index += SIZEOF_UINT16;
2162 sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2163 index += SIZEOF_UINT16;
2164 sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2165 index += SIZEOF_UINT16;
2166 sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2167 index += SIZEOF_UINT16;
2168 sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2169 index += SIZEOF_UINT16;
2170 sig->u.MlmeSetChannelRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2171 index += SIZEOF_UINT16;
2172 sig->u.MlmeSetChannelRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2173 index += SIZEOF_UINT16;
2174 memcpy(sig->u.MlmeSetChannelRequest.Address.x, &ptr[index], 48 / 8);
2175 index += 48 / 8;
2176 sig->u.MlmeSetChannelRequest.AvailabilityDuration = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2177 index += SIZEOF_UINT16;
2178 sig->u.MlmeSetChannelRequest.AvailabilityInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2179 index += SIZEOF_UINT16;
2180 break;
2181#endif
2182#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2183 case CSR_MLME_MEASURE_CONFIRM_ID:
2184 sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2185 index += SIZEOF_UINT16;
2186 sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2187 index += SIZEOF_UINT16;
2188 sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2189 index += SIZEOF_UINT16;
2190 sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2191 index += SIZEOF_UINT16;
2192 sig->u.MlmeMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2193 index += SIZEOF_UINT16;
2194 sig->u.MlmeMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2195 index += SIZEOF_UINT16;
2196 break;
2197#endif
2198#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2199 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
2200 sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2201 index += SIZEOF_UINT16;
2202 sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2203 index += SIZEOF_UINT16;
2204 sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2205 index += SIZEOF_UINT16;
2206 sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2207 index += SIZEOF_UINT16;
2208 sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2209 index += SIZEOF_UINT16;
2210 sig->u.MlmeAddTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2211 index += SIZEOF_UINT16;
2212 break;
2213#endif
2214#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2215 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
2216 sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2217 index += SIZEOF_UINT16;
2218 sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2219 index += SIZEOF_UINT16;
2220 sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2221 index += SIZEOF_UINT16;
2222 sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2223 index += SIZEOF_UINT16;
2224 sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2225 index += SIZEOF_UINT16;
2226 memcpy(sig->u.MlmeAutonomousScanLossIndication.Bssid.x, &ptr[index], 48 / 8);
2227 index += 48 / 8;
2228 break;
2229#endif
2230 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
2231 sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2232 index += SIZEOF_UINT16;
2233 sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2234 index += SIZEOF_UINT16;
2235 sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2236 index += SIZEOF_UINT16;
2237 sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2238 index += SIZEOF_UINT16;
2239 sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2240 index += SIZEOF_UINT16;
2241 sig->u.MaVifAvailabilityResponse.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2242 index += SIZEOF_UINT16;
2243 break;
2244#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2245 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
2246 sig->u.MlmeAddTemplateRequest.Data1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2247 index += SIZEOF_UINT16;
2248 sig->u.MlmeAddTemplateRequest.Data1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2249 index += SIZEOF_UINT16;
2250 sig->u.MlmeAddTemplateRequest.Data2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2251 index += SIZEOF_UINT16;
2252 sig->u.MlmeAddTemplateRequest.Data2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2253 index += SIZEOF_UINT16;
2254 sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2255 index += SIZEOF_UINT16;
2256 sig->u.MlmeAddTemplateRequest.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2257 index += SIZEOF_UINT16;
2258 sig->u.MlmeAddTemplateRequest.MinTransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2259 index += SIZEOF_UINT16;
2260 break;
2261#endif
2262#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2263 case CSR_MLME_POWERMGT_CONFIRM_ID:
2264 sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2265 index += SIZEOF_UINT16;
2266 sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2267 index += SIZEOF_UINT16;
2268 sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2269 index += SIZEOF_UINT16;
2270 sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2271 index += SIZEOF_UINT16;
2272 sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2273 index += SIZEOF_UINT16;
2274 sig->u.MlmePowermgtConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2275 index += SIZEOF_UINT16;
2276 break;
2277#endif
2278#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2279 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
2280 sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2281 index += SIZEOF_UINT16;
2282 sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2283 index += SIZEOF_UINT16;
2284 sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2285 index += SIZEOF_UINT16;
2286 sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2287 index += SIZEOF_UINT16;
2288 sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2289 index += SIZEOF_UINT16;
2290 sig->u.MlmeAddPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2291 index += SIZEOF_UINT16;
2292 sig->u.MlmeAddPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2293 index += SIZEOF_UINT16;
2294 break;
2295#endif
2296#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2297 case CSR_MLME_GET_CONFIRM_ID:
2298 sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2299 index += SIZEOF_UINT16;
2300 sig->u.MlmeGetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2301 index += SIZEOF_UINT16;
2302 sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2303 index += SIZEOF_UINT16;
2304 sig->u.MlmeGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2305 index += SIZEOF_UINT16;
2306 sig->u.MlmeGetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2307 index += SIZEOF_UINT16;
2308 sig->u.MlmeGetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2309 index += SIZEOF_UINT16;
2310 break;
2311#endif
2312#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2313 case CSR_MLME_GET_NEXT_CONFIRM_ID:
2314 sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2315 index += SIZEOF_UINT16;
2316 sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2317 index += SIZEOF_UINT16;
2318 sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2319 index += SIZEOF_UINT16;
2320 sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2321 index += SIZEOF_UINT16;
2322 sig->u.MlmeGetNextConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2323 index += SIZEOF_UINT16;
2324 sig->u.MlmeGetNextConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2325 index += SIZEOF_UINT16;
2326 break;
2327#endif
2328#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2329 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
2330 sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2331 index += SIZEOF_UINT16;
2332 sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2333 index += SIZEOF_UINT16;
2334 sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2335 index += SIZEOF_UINT16;
2336 sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2337 index += SIZEOF_UINT16;
2338 sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2339 index += SIZEOF_UINT16;
2340 memcpy(sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
2341 index += 48 / 8;
2342 sig->u.MlmeStopAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2343 index += SIZEOF_UINT16;
2344 sig->u.MlmeStopAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2345 index += SIZEOF_UINT16;
2346 break;
2347#endif
2348#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2349 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
2350 sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2351 index += SIZEOF_UINT16;
2352 sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2353 index += SIZEOF_UINT16;
2354 sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2355 index += SIZEOF_UINT16;
2356 sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2357 index += SIZEOF_UINT16;
2358 sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2359 index += SIZEOF_UINT16;
2360 sig->u.MlmeAddRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2361 index += SIZEOF_UINT16;
2362 sig->u.MlmeAddRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2363 index += SIZEOF_UINT16;
2364 break;
2365#endif
2366#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2367 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
2368 sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2369 index += SIZEOF_UINT16;
2370 sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2371 index += SIZEOF_UINT16;
2372 sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2373 index += SIZEOF_UINT16;
2374 sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2375 index += SIZEOF_UINT16;
2376 sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2377 index += SIZEOF_UINT16;
2378 sig->u.MlmeAddBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2379 index += SIZEOF_UINT16;
2380 sig->u.MlmeAddBlackoutRequest.BlackoutType = (CSR_BLACKOUT_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2381 index += SIZEOF_UINT16;
2382 sig->u.MlmeAddBlackoutRequest.BlackoutSource = (CSR_BLACKOUT_SOURCE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2383 index += SIZEOF_UINT16;
2384 sig->u.MlmeAddBlackoutRequest.BlackoutStartReference = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2385 index += SIZEOF_UINT32;
2386 sig->u.MlmeAddBlackoutRequest.BlackoutPeriod = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2387 index += SIZEOF_UINT32;
2388 sig->u.MlmeAddBlackoutRequest.BlackoutDuration = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2389 index += SIZEOF_UINT32;
2390 memcpy(sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, &ptr[index], 48 / 8);
2391 index += 48 / 8;
2392 sig->u.MlmeAddBlackoutRequest.BlackoutCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2393 index += SIZEOF_UINT16;
2394 break;
2395#endif
2396#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2397 case CSR_MLME_DELETEKEYS_REQUEST_ID:
2398 sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2399 index += SIZEOF_UINT16;
2400 sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2401 index += SIZEOF_UINT16;
2402 sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2403 index += SIZEOF_UINT16;
2404 sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2405 index += SIZEOF_UINT16;
2406 sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2407 index += SIZEOF_UINT16;
2408 sig->u.MlmeDeletekeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2409 index += SIZEOF_UINT16;
2410 sig->u.MlmeDeletekeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2411 index += SIZEOF_UINT16;
2412 memcpy(sig->u.MlmeDeletekeysRequest.Address.x, &ptr[index], 48 / 8);
2413 index += 48 / 8;
2414 break;
2415#endif
2416#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2417 case CSR_MLME_RESET_CONFIRM_ID:
2418 sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2419 index += SIZEOF_UINT16;
2420 sig->u.MlmeResetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2421 index += SIZEOF_UINT16;
2422 sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2423 index += SIZEOF_UINT16;
2424 sig->u.MlmeResetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2425 index += SIZEOF_UINT16;
2426 sig->u.MlmeResetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2427 index += SIZEOF_UINT16;
2428 break;
2429#endif
2430#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2431 case CSR_MLME_HL_SYNC_CONFIRM_ID:
2432 sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2433 index += SIZEOF_UINT16;
2434 sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2435 index += SIZEOF_UINT16;
2436 sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2437 index += SIZEOF_UINT16;
2438 sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2439 index += SIZEOF_UINT16;
2440 memcpy(sig->u.MlmeHlSyncConfirm.GroupAddress.x, &ptr[index], 48 / 8);
2441 index += 48 / 8;
2442 sig->u.MlmeHlSyncConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2443 index += SIZEOF_UINT16;
2444 break;
2445#endif
2446#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2447 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
2448 sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2449 index += SIZEOF_UINT16;
2450 sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2451 index += SIZEOF_UINT16;
2452 sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2453 index += SIZEOF_UINT16;
2454 sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2455 index += SIZEOF_UINT16;
2456 sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2457 index += SIZEOF_UINT16;
2458 sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2459 index += SIZEOF_UINT16;
2460 sig->u.MlmeAddAutonomousScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2461 index += SIZEOF_UINT16;
2462 sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2463 index += SIZEOF_UINT16;
2464 sig->u.MlmeAddAutonomousScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2465 index += SIZEOF_UINT16;
2466 sig->u.MlmeAddAutonomousScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2467 index += SIZEOF_UINT32;
2468 sig->u.MlmeAddAutonomousScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2469 index += SIZEOF_UINT16;
2470 sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2471 index += SIZEOF_UINT16;
2472 break;
2473#endif
2474#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2475 case CSR_MLME_SET_REQUEST_ID:
2476 sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2477 index += SIZEOF_UINT16;
2478 sig->u.MlmeSetRequest.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2479 index += SIZEOF_UINT16;
2480 sig->u.MlmeSetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2481 index += SIZEOF_UINT16;
2482 sig->u.MlmeSetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2483 index += SIZEOF_UINT16;
2484 break;
2485#endif
2486#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2487 case CSR_MLME_SM_START_REQUEST_ID:
2488 sig->u.MlmeSmStartRequest.Beacon.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2489 index += SIZEOF_UINT16;
2490 sig->u.MlmeSmStartRequest.Beacon.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2491 index += SIZEOF_UINT16;
2492 sig->u.MlmeSmStartRequest.BssParameters.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2493 index += SIZEOF_UINT16;
2494 sig->u.MlmeSmStartRequest.BssParameters.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2495 index += SIZEOF_UINT16;
2496 sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2497 index += SIZEOF_UINT16;
2498 sig->u.MlmeSmStartRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2499 index += SIZEOF_UINT16;
2500 sig->u.MlmeSmStartRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2501 index += SIZEOF_UINT16;
2502 memcpy(sig->u.MlmeSmStartRequest.InterfaceAddress.x, &ptr[index], 48 / 8);
2503 index += 48 / 8;
2504 memcpy(sig->u.MlmeSmStartRequest.Bssid.x, &ptr[index], 48 / 8);
2505 index += 48 / 8;
2506 sig->u.MlmeSmStartRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2507 index += SIZEOF_UINT16;
2508 sig->u.MlmeSmStartRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2509 index += SIZEOF_UINT16;
2510 sig->u.MlmeSmStartRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2511 index += SIZEOF_UINT16;
2512 break;
2513#endif
2514#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2515 case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
2516 sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2517 index += SIZEOF_UINT16;
2518 sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2519 index += SIZEOF_UINT16;
2520 sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2521 index += SIZEOF_UINT16;
2522 sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2523 index += SIZEOF_UINT16;
2524 sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2525 index += SIZEOF_UINT16;
2526 sig->u.MlmeConnectStatusConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2527 index += SIZEOF_UINT16;
2528 break;
2529#endif
2530#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2531 case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
2532 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2533 index += SIZEOF_UINT16;
2534 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2535 index += SIZEOF_UINT16;
2536 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2537 index += SIZEOF_UINT16;
2538 sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2539 index += SIZEOF_UINT16;
2540 sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2541 index += SIZEOF_UINT16;
2542 sig->u.MlmeDelAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2543 index += SIZEOF_UINT16;
2544 sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2545 index += SIZEOF_UINT16;
2546 break;
2547#endif
2548#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2549 case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
2550 sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2551 index += SIZEOF_UINT16;
2552 sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2553 index += SIZEOF_UINT16;
2554 sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2555 index += SIZEOF_UINT16;
2556 sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2557 index += SIZEOF_UINT16;
2558 sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2559 index += SIZEOF_UINT16;
2560 sig->u.MlmeDelPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2561 index += SIZEOF_UINT16;
2562 break;
2563#endif
2564#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2565 case CSR_MLME_SETKEYS_REQUEST_ID:
2566 sig->u.MlmeSetkeysRequest.Key.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2567 index += SIZEOF_UINT16;
2568 sig->u.MlmeSetkeysRequest.Key.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2569 index += SIZEOF_UINT16;
2570 sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2571 index += SIZEOF_UINT16;
2572 sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2573 index += SIZEOF_UINT16;
2574 sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2575 index += SIZEOF_UINT16;
2576 sig->u.MlmeSetkeysRequest.Length = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2577 index += SIZEOF_UINT16;
2578 sig->u.MlmeSetkeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2579 index += SIZEOF_UINT16;
2580 sig->u.MlmeSetkeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2581 index += SIZEOF_UINT16;
2582 memcpy(sig->u.MlmeSetkeysRequest.Address.x, &ptr[index], 48 / 8);
2583 index += 48 / 8;
2584 sig->u.MlmeSetkeysRequest.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2585 index += SIZEOF_UINT16;
2586 sig->u.MlmeSetkeysRequest.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2587 index += SIZEOF_UINT16;
2588 sig->u.MlmeSetkeysRequest.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2589 index += SIZEOF_UINT16;
2590 sig->u.MlmeSetkeysRequest.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2591 index += SIZEOF_UINT16;
2592 sig->u.MlmeSetkeysRequest.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2593 index += SIZEOF_UINT16;
2594 sig->u.MlmeSetkeysRequest.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2595 index += SIZEOF_UINT16;
2596 sig->u.MlmeSetkeysRequest.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2597 index += SIZEOF_UINT16;
2598 sig->u.MlmeSetkeysRequest.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2599 index += SIZEOF_UINT16;
2600 memcpy(&sig->u.MlmeSetkeysRequest.CipherSuiteSelector, &ptr[index], 32 / 8);
2601 index += 32 / 8;
2602 break;
2603#endif
2604#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2605 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
2606 sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2607 index += SIZEOF_UINT16;
2608 sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2609 index += SIZEOF_UINT16;
2610 sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2611 index += SIZEOF_UINT16;
2612 sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2613 index += SIZEOF_UINT16;
2614 sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2615 index += SIZEOF_UINT16;
2616 sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2617 index += SIZEOF_UINT16;
2618 sig->u.MlmePauseAutonomousScanRequest.Pause = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2619 index += SIZEOF_UINT16;
2620 break;
2621#endif
2622#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2623 case CSR_MLME_GET_REQUEST_ID:
2624 sig->u.MlmeGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2625 index += SIZEOF_UINT16;
2626 sig->u.MlmeGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2627 index += SIZEOF_UINT16;
2628 sig->u.MlmeGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2629 index += SIZEOF_UINT16;
2630 sig->u.MlmeGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2631 index += SIZEOF_UINT16;
2632 break;
2633#endif
2634#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2635 case CSR_MLME_POWERMGT_REQUEST_ID:
2636 sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2637 index += SIZEOF_UINT16;
2638 sig->u.MlmePowermgtRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2639 index += SIZEOF_UINT16;
2640 sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2641 index += SIZEOF_UINT16;
2642 sig->u.MlmePowermgtRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2643 index += SIZEOF_UINT16;
2644 sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2645 index += SIZEOF_UINT16;
2646 sig->u.MlmePowermgtRequest.PowerManagementMode = (CSR_POWER_MANAGEMENT_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2647 index += SIZEOF_UINT16;
2648 sig->u.MlmePowermgtRequest.ReceiveDtims = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2649 index += SIZEOF_UINT16;
2650 sig->u.MlmePowermgtRequest.ListenInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2651 index += SIZEOF_UINT16;
2652 sig->u.MlmePowermgtRequest.TrafficWindow = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2653 index += SIZEOF_UINT16;
2654 break;
2655#endif
2656 case CSR_MA_PACKET_ERROR_INDICATION_ID:
2657 sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2658 index += SIZEOF_UINT16;
2659 sig->u.MaPacketErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2660 index += SIZEOF_UINT16;
2661 sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2662 index += SIZEOF_UINT16;
2663 sig->u.MaPacketErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2664 index += SIZEOF_UINT16;
2665 sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2666 index += SIZEOF_UINT16;
2667 memcpy(sig->u.MaPacketErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
2668 index += 48 / 8;
2669 sig->u.MaPacketErrorIndication.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2670 index += SIZEOF_UINT16;
2671 sig->u.MaPacketErrorIndication.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2672 index += SIZEOF_UINT16;
2673 break;
2674#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2675 case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
2676 sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2677 index += SIZEOF_UINT16;
2678 sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2679 index += SIZEOF_UINT16;
2680 sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2681 index += SIZEOF_UINT16;
2682 sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2683 index += SIZEOF_UINT16;
2684 sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2685 index += SIZEOF_UINT16;
2686 sig->u.MlmeAddPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2687 index += SIZEOF_UINT16;
2688 sig->u.MlmeAddPeriodicRequest.MaximumLatency = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2689 index += SIZEOF_UINT32;
2690 sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode = (CSR_PERIODIC_SCHEDULING_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2691 index += SIZEOF_UINT16;
2692 sig->u.MlmeAddPeriodicRequest.WakeHost = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2693 index += SIZEOF_UINT16;
2694 sig->u.MlmeAddPeriodicRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2695 index += SIZEOF_UINT16;
2696 break;
2697#endif
2698#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2699 case CSR_MLME_ADD_TSPEC_REQUEST_ID:
2700 sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2701 index += SIZEOF_UINT16;
2702 sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2703 index += SIZEOF_UINT16;
2704 sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2705 index += SIZEOF_UINT16;
2706 sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2707 index += SIZEOF_UINT16;
2708 sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2709 index += SIZEOF_UINT16;
2710 sig->u.MlmeAddTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2711 index += SIZEOF_UINT16;
2712 sig->u.MlmeAddTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2713 index += SIZEOF_UINT16;
2714 sig->u.MlmeAddTspecRequest.PsScheme = (CSR_PS_SCHEME) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2715 index += SIZEOF_UINT16;
2716 sig->u.MlmeAddTspecRequest.MediumTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2717 index += SIZEOF_UINT16;
2718 sig->u.MlmeAddTspecRequest.ServiceStartTime = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2719 index += SIZEOF_UINT32;
2720 sig->u.MlmeAddTspecRequest.ServiceInterval = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2721 index += SIZEOF_UINT32;
2722 sig->u.MlmeAddTspecRequest.MinimumDataRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2723 index += SIZEOF_UINT16;
2724 break;
2725#endif
2726#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2727 case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
2728 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2729 index += SIZEOF_UINT16;
2730 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2731 index += SIZEOF_UINT16;
2732 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2733 index += SIZEOF_UINT16;
2734 sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2735 index += SIZEOF_UINT16;
2736 sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2737 index += SIZEOF_UINT16;
2738 sig->u.MlmeAddMulticastAddressConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2739 index += SIZEOF_UINT16;
2740 break;
2741#endif
2742#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2743 case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
2744 sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2745 index += SIZEOF_UINT16;
2746 sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2747 index += SIZEOF_UINT16;
2748 sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2749 index += SIZEOF_UINT16;
2750 sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2751 index += SIZEOF_UINT16;
2752 sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2753 index += SIZEOF_UINT16;
2754 sig->u.MlmeAddTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2755 index += SIZEOF_UINT16;
2756 sig->u.MlmeAddTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2757 index += SIZEOF_UINT16;
2758 break;
2759#endif
2760#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2761 case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
2762 sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2763 index += SIZEOF_UINT16;
2764 sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2765 index += SIZEOF_UINT16;
2766 sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2767 index += SIZEOF_UINT16;
2768 sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2769 index += SIZEOF_UINT16;
2770 sig->u.MlmeHlSyncCancelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2771 index += SIZEOF_UINT16;
2772 break;
2773#endif
2774#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2775 case CSR_MLME_SCAN_CONFIRM_ID:
2776 sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2777 index += SIZEOF_UINT16;
2778 sig->u.MlmeScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2779 index += SIZEOF_UINT16;
2780 sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2781 index += SIZEOF_UINT16;
2782 sig->u.MlmeScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2783 index += SIZEOF_UINT16;
2784 sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2785 index += SIZEOF_UINT16;
2786 sig->u.MlmeScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2787 index += SIZEOF_UINT16;
2788 break;
2789#endif
2790 case CSR_DEBUG_STRING_INDICATION_ID:
2791 sig->u.DebugStringIndication.DebugMessage.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2792 index += SIZEOF_UINT16;
2793 sig->u.DebugStringIndication.DebugMessage.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2794 index += SIZEOF_UINT16;
2795 sig->u.DebugStringIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2796 index += SIZEOF_UINT16;
2797 sig->u.DebugStringIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2798 index += SIZEOF_UINT16;
2799 break;
2800#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2801 case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
2802 sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2803 index += SIZEOF_UINT16;
2804 sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2805 index += SIZEOF_UINT16;
2806 sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2807 index += SIZEOF_UINT16;
2808 sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2809 index += SIZEOF_UINT16;
2810 sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2811 index += SIZEOF_UINT16;
2812 sig->u.MlmeAddTemplateConfirm.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2813 index += SIZEOF_UINT16;
2814 sig->u.MlmeAddTemplateConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2815 index += SIZEOF_UINT16;
2816 break;
2817#endif
2818#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2819 case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
2820 sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2821 index += SIZEOF_UINT16;
2822 sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2823 index += SIZEOF_UINT16;
2824 sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2825 index += SIZEOF_UINT16;
2826 sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2827 index += SIZEOF_UINT16;
2828 sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2829 index += SIZEOF_UINT16;
2830 sig->u.MlmeBlockackErrorIndication.ResultCode = (CSR_REASON_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2831 index += SIZEOF_UINT16;
2832 memcpy(sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
2833 index += 48 / 8;
2834 break;
2835#endif
2836#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2837 case CSR_MLME_SET_CONFIRM_ID:
2838 sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2839 index += SIZEOF_UINT16;
2840 sig->u.MlmeSetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2841 index += SIZEOF_UINT16;
2842 sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2843 index += SIZEOF_UINT16;
2844 sig->u.MlmeSetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2845 index += SIZEOF_UINT16;
2846 sig->u.MlmeSetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2847 index += SIZEOF_UINT16;
2848 sig->u.MlmeSetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2849 index += SIZEOF_UINT16;
2850 break;
2851#endif
2852#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2853 case CSR_MLME_MEASURE_REQUEST_ID:
2854 sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2855 index += SIZEOF_UINT16;
2856 sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2857 index += SIZEOF_UINT16;
2858 sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2859 index += SIZEOF_UINT16;
2860 sig->u.MlmeMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2861 index += SIZEOF_UINT16;
2862 sig->u.MlmeMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2863 index += SIZEOF_UINT16;
2864 break;
2865#endif
2866#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2867 case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
2868 sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2869 index += SIZEOF_UINT16;
2870 sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2871 index += SIZEOF_UINT16;
2872 sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2873 index += SIZEOF_UINT16;
2874 sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2875 index += SIZEOF_UINT16;
2876 sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2877 index += SIZEOF_UINT16;
2878 memcpy(sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
2879 index += 48 / 8;
2880 sig->u.MlmeStartAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2881 index += SIZEOF_UINT16;
2882 sig->u.MlmeStartAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2883 index += SIZEOF_UINT16;
2884 sig->u.MlmeStartAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2885 index += SIZEOF_UINT16;
2886 sig->u.MlmeStartAggregationConfirm.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2887 index += SIZEOF_UINT16;
2888 break;
2889#endif
2890#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2891 case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
2892 sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2893 index += SIZEOF_UINT16;
2894 sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2895 index += SIZEOF_UINT16;
2896 sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2897 index += SIZEOF_UINT16;
2898 sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2899 index += SIZEOF_UINT16;
2900 sig->u.MlmeStopMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2901 index += SIZEOF_UINT16;
2902 sig->u.MlmeStopMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2903 index += SIZEOF_UINT16;
2904 break;
2905#endif
2906 case CSR_MA_PACKET_CONFIRM_ID:
2907 sig->u.MaPacketConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2908 index += SIZEOF_UINT16;
2909 sig->u.MaPacketConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2910 index += SIZEOF_UINT16;
2911 sig->u.MaPacketConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2912 index += SIZEOF_UINT16;
2913 sig->u.MaPacketConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2914 index += SIZEOF_UINT16;
2915 sig->u.MaPacketConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2916 index += SIZEOF_UINT16;
2917 sig->u.MaPacketConfirm.TransmissionStatus = (CSR_TRANSMISSION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2918 index += SIZEOF_UINT16;
2919 sig->u.MaPacketConfirm.RetryCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2920 index += SIZEOF_UINT16;
2921 sig->u.MaPacketConfirm.Rate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2922 index += SIZEOF_UINT16;
2923 sig->u.MaPacketConfirm.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
2924 index += SIZEOF_UINT32;
2925 break;
2926#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2927 case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
2928 sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2929 index += SIZEOF_UINT16;
2930 sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2931 index += SIZEOF_UINT16;
2932 sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2933 index += SIZEOF_UINT16;
2934 sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2935 index += SIZEOF_UINT16;
2936 sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2937 index += SIZEOF_UINT16;
2938 sig->u.MlmeDelPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2939 index += SIZEOF_UINT16;
2940 sig->u.MlmeDelPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2941 index += SIZEOF_UINT16;
2942 break;
2943#endif
2944#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
2945 case CSR_MLME_STOP_MEASURE_REQUEST_ID:
2946 sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2947 index += SIZEOF_UINT16;
2948 sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2949 index += SIZEOF_UINT16;
2950 sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2951 index += SIZEOF_UINT16;
2952 sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2953 index += SIZEOF_UINT16;
2954 sig->u.MlmeStopMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
2955 index += SIZEOF_UINT16;
2956 break;
2957#endif
2958
2959 default:
2960 return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
2961 }
2962 return CSR_RESULT_SUCCESS;
2963} /* read_unpack_signal() */
2964
2965
2966/*
2967 * ---------------------------------------------------------------------------
2968 * write_pack
2969 *
2970 * Convert a signal structure, in host-native format, to the
2971 * little-endian wire format specified in the UniFi Host Interface
2972 * Protocol Specification.
2973 *
2974 * WARNING: This function is auto-generated, DO NOT EDIT!
2975 *
2976 * Arguments:
2977 * sig Pointer to signal structure to pack.
2978 * ptr Destination buffer to pack into.
2979 * sig_len Returns the length of the packed signal, i.e. the
2980 * number of bytes written to ptr.
2981 *
2982 * Returns:
2983 * CSR_RESULT_SUCCESS on success,
2984 * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
2985 * ---------------------------------------------------------------------------
2986 */
2987CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len)
2988{
2989 s16 index = 0;
2990
2991 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SignalId, ptr + index);
2992 index += SIZEOF_UINT16;
2993
2994 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.ReceiverProcessId, ptr + index);
2995 index += SIZEOF_UINT16;
2996
2997 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SenderProcessId, ptr + index);
2998 index += SIZEOF_UINT16;
2999
3000 switch (sig->SignalPrimitiveHeader.SignalId)
3001 {
3002#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3003 case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
3004 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber, ptr + index);
3005 index += SIZEOF_UINT16;
3006 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength, ptr + index);
3007 index += SIZEOF_UINT16;
3008 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber, ptr + index);
3009 index += SIZEOF_UINT16;
3010 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength, ptr + index);
3011 index += SIZEOF_UINT16;
3012 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier, ptr + index);
3013 index += SIZEOF_UINT16;
3014 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.ResultCode, ptr + index);
3015 index += SIZEOF_UINT16;
3016 break;
3017#endif
3018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3019 case CSR_MLME_SETKEYS_CONFIRM_ID:
3020 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber, ptr + index);
3021 index += SIZEOF_UINT16;
3022 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength, ptr + index);
3023 index += SIZEOF_UINT16;
3024 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber, ptr + index);
3025 index += SIZEOF_UINT16;
3026 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength, ptr + index);
3027 index += SIZEOF_UINT16;
3028 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier, ptr + index);
3029 index += SIZEOF_UINT16;
3030 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.ResultCode, ptr + index);
3031 index += SIZEOF_UINT16;
3032 break;
3033#endif
3034#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3035 case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
3036 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber, ptr + index);
3037 index += SIZEOF_UINT16;
3038 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength, ptr + index);
3039 index += SIZEOF_UINT16;
3040 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber, ptr + index);
3041 index += SIZEOF_UINT16;
3042 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength, ptr + index);
3043 index += SIZEOF_UINT16;
3044 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.ResultCode, ptr + index);
3045 index += SIZEOF_UINT16;
3046 break;
3047#endif
3048#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3049 case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
3050 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
3051 index += SIZEOF_UINT16;
3052 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
3053 index += SIZEOF_UINT16;
3054 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
3055 index += SIZEOF_UINT16;
3056 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
3057 index += SIZEOF_UINT16;
3058 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
3059 index += SIZEOF_UINT16;
3060 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.ResultCode, ptr + index);
3061 index += SIZEOF_UINT16;
3062 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId, ptr + index);
3063 index += SIZEOF_UINT16;
3064 break;
3065#endif
3066#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3067 case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
3068 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
3069 index += SIZEOF_UINT16;
3070 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
3071 index += SIZEOF_UINT16;
3072 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
3073 index += SIZEOF_UINT16;
3074 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
3075 index += SIZEOF_UINT16;
3076 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
3077 index += SIZEOF_UINT16;
3078 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.BlackoutId, ptr + index);
3079 index += SIZEOF_UINT16;
3080 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.ResultCode, ptr + index);
3081 index += SIZEOF_UINT16;
3082 break;
3083#endif
3084#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3085 case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
3086 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
3087 index += SIZEOF_UINT16;
3088 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength, ptr + index);
3089 index += SIZEOF_UINT16;
3090 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
3091 index += SIZEOF_UINT16;
3092 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength, ptr + index);
3093 index += SIZEOF_UINT16;
3094 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
3095 index += SIZEOF_UINT16;
3096 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.BlackoutId, ptr + index);
3097 index += SIZEOF_UINT16;
3098 break;
3099#endif
3100#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3101 case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
3102 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber, ptr + index);
3103 index += SIZEOF_UINT16;
3104 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength, ptr + index);
3105 index += SIZEOF_UINT16;
3106 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber, ptr + index);
3107 index += SIZEOF_UINT16;
3108 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength, ptr + index);
3109 index += SIZEOF_UINT16;
3110 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier, ptr + index);
3111 index += SIZEOF_UINT16;
3112 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.ResultCode, ptr + index);
3113 index += SIZEOF_UINT16;
3114 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0], ptr + index);
3115 index += SIZEOF_UINT16;
3116 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1], ptr + index);
3117 index += SIZEOF_UINT16;
3118 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2], ptr + index);
3119 index += SIZEOF_UINT16;
3120 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3], ptr + index);
3121 index += SIZEOF_UINT16;
3122 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4], ptr + index);
3123 index += SIZEOF_UINT16;
3124 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5], ptr + index);
3125 index += SIZEOF_UINT16;
3126 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6], ptr + index);
3127 index += SIZEOF_UINT16;
3128 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7], ptr + index);
3129 index += SIZEOF_UINT16;
3130 break;
3131#endif
3132#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3133 case CSR_MLME_SM_START_CONFIRM_ID:
3134 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber, ptr + index);
3135 index += SIZEOF_UINT16;
3136 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength, ptr + index);
3137 index += SIZEOF_UINT16;
3138 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber, ptr + index);
3139 index += SIZEOF_UINT16;
3140 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength, ptr + index);
3141 index += SIZEOF_UINT16;
3142 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier, ptr + index);
3143 index += SIZEOF_UINT16;
3144 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.ResultCode, ptr + index);
3145 index += SIZEOF_UINT16;
3146 break;
3147#endif
3148#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3149 case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
3150 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
3151 index += SIZEOF_UINT16;
3152 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength, ptr + index);
3153 index += SIZEOF_UINT16;
3154 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
3155 index += SIZEOF_UINT16;
3156 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength, ptr + index);
3157 index += SIZEOF_UINT16;
3158 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
3159 index += SIZEOF_UINT16;
3160 memcpy(ptr + index, sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, 48 / 8);
3161 index += 48 / 8;
3162 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.UserPriority, ptr + index);
3163 index += SIZEOF_UINT16;
3164 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Direction, ptr + index);
3165 index += SIZEOF_UINT16;
3166 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.ResultCode, ptr + index);
3167 index += SIZEOF_UINT16;
3168 break;
3169#endif
3170#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3171 case CSR_MLME_DEL_TSPEC_REQUEST_ID:
3172 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber, ptr + index);
3173 index += SIZEOF_UINT16;
3174 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength, ptr + index);
3175 index += SIZEOF_UINT16;
3176 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber, ptr + index);
3177 index += SIZEOF_UINT16;
3178 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength, ptr + index);
3179 index += SIZEOF_UINT16;
3180 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier, ptr + index);
3181 index += SIZEOF_UINT16;
3182 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.UserPriority, ptr + index);
3183 index += SIZEOF_UINT16;
3184 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Direction, ptr + index);
3185 index += SIZEOF_UINT16;
3186 break;
3187#endif
3188 case CSR_DEBUG_WORD16_INDICATION_ID:
3189 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.SlotNumber, ptr + index);
3190 index += SIZEOF_UINT16;
3191 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.DataLength, ptr + index);
3192 index += SIZEOF_UINT16;
3193 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.SlotNumber, ptr + index);
3194 index += SIZEOF_UINT16;
3195 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.DataLength, ptr + index);
3196 index += SIZEOF_UINT16;
3197 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[0], ptr + index);
3198 index += SIZEOF_UINT16;
3199 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[1], ptr + index);
3200 index += SIZEOF_UINT16;
3201 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[2], ptr + index);
3202 index += SIZEOF_UINT16;
3203 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[3], ptr + index);
3204 index += SIZEOF_UINT16;
3205 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[4], ptr + index);
3206 index += SIZEOF_UINT16;
3207 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[5], ptr + index);
3208 index += SIZEOF_UINT16;
3209 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[6], ptr + index);
3210 index += SIZEOF_UINT16;
3211 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[7], ptr + index);
3212 index += SIZEOF_UINT16;
3213 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[8], ptr + index);
3214 index += SIZEOF_UINT16;
3215 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[9], ptr + index);
3216 index += SIZEOF_UINT16;
3217 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[10], ptr + index);
3218 index += SIZEOF_UINT16;
3219 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[11], ptr + index);
3220 index += SIZEOF_UINT16;
3221 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[12], ptr + index);
3222 index += SIZEOF_UINT16;
3223 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[13], ptr + index);
3224 index += SIZEOF_UINT16;
3225 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[14], ptr + index);
3226 index += SIZEOF_UINT16;
3227 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[15], ptr + index);
3228 index += SIZEOF_UINT16;
3229 break;
3230 case CSR_DEBUG_GENERIC_CONFIRM_ID:
3231 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.SlotNumber, ptr + index);
3232 index += SIZEOF_UINT16;
3233 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.DataLength, ptr + index);
3234 index += SIZEOF_UINT16;
3235 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber, ptr + index);
3236 index += SIZEOF_UINT16;
3237 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.DataLength, ptr + index);
3238 index += SIZEOF_UINT16;
3239 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[0], ptr + index);
3240 index += SIZEOF_UINT16;
3241 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[1], ptr + index);
3242 index += SIZEOF_UINT16;
3243 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[2], ptr + index);
3244 index += SIZEOF_UINT16;
3245 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[3], ptr + index);
3246 index += SIZEOF_UINT16;
3247 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[4], ptr + index);
3248 index += SIZEOF_UINT16;
3249 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[5], ptr + index);
3250 index += SIZEOF_UINT16;
3251 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[6], ptr + index);
3252 index += SIZEOF_UINT16;
3253 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[7], ptr + index);
3254 index += SIZEOF_UINT16;
3255 break;
3256 case CSR_MA_PACKET_INDICATION_ID:
3257 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.SlotNumber, ptr + index);
3258 index += SIZEOF_UINT16;
3259 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.DataLength, ptr + index);
3260 index += SIZEOF_UINT16;
3261 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.SlotNumber, ptr + index);
3262 index += SIZEOF_UINT16;
3263 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.DataLength, ptr + index);
3264 index += SIZEOF_UINT16;
3265 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.VirtualInterfaceIdentifier, ptr + index);
3266 index += SIZEOF_UINT16;
3267 memcpy(ptr + index, sig->u.MaPacketIndication.LocalTime.x, 64 / 8);
3268 index += 64 / 8;
3269 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Ifindex, ptr + index);
3270 index += SIZEOF_UINT16;
3271 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Channel, ptr + index);
3272 index += SIZEOF_UINT16;
3273 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceptionStatus, ptr + index);
3274 index += SIZEOF_UINT16;
3275 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Rssi, ptr + index);
3276 index += SIZEOF_UINT16;
3277 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Snr, ptr + index);
3278 index += SIZEOF_UINT16;
3279 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceivedRate, ptr + index);
3280 index += SIZEOF_UINT16;
3281 break;
3282 case CSR_MLME_SET_TIM_REQUEST_ID:
3283 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber, ptr + index);
3284 index += SIZEOF_UINT16;
3285 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.DataLength, ptr + index);
3286 index += SIZEOF_UINT16;
3287 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber, ptr + index);
3288 index += SIZEOF_UINT16;
3289 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.DataLength, ptr + index);
3290 index += SIZEOF_UINT16;
3291 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier, ptr + index);
3292 index += SIZEOF_UINT16;
3293 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.AssociationId, ptr + index);
3294 index += SIZEOF_UINT16;
3295 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.TimValue, ptr + index);
3296 index += SIZEOF_UINT16;
3297 break;
3298#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3299 case CSR_MLME_CONNECTED_INDICATION_ID:
3300 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber, ptr + index);
3301 index += SIZEOF_UINT16;
3302 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.DataLength, ptr + index);
3303 index += SIZEOF_UINT16;
3304 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber, ptr + index);
3305 index += SIZEOF_UINT16;
3306 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.DataLength, ptr + index);
3307 index += SIZEOF_UINT16;
3308 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier, ptr + index);
3309 index += SIZEOF_UINT16;
3310 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.ConnectionStatus, ptr + index);
3311 index += SIZEOF_UINT16;
3312 memcpy(ptr + index, sig->u.MlmeConnectedIndication.PeerMacAddress.x, 48 / 8);
3313 index += 48 / 8;
3314 break;
3315#endif
3316#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3317 case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
3318 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber, ptr + index);
3319 index += SIZEOF_UINT16;
3320 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength, ptr + index);
3321 index += SIZEOF_UINT16;
3322 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
3323 index += SIZEOF_UINT16;
3324 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
3325 index += SIZEOF_UINT16;
3326 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
3327 index += SIZEOF_UINT16;
3328 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.TriggerId, ptr + index);
3329 index += SIZEOF_UINT16;
3330 break;
3331#endif
3332#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3333 case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
3334 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber, ptr + index);
3335 index += SIZEOF_UINT16;
3336 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength, ptr + index);
3337 index += SIZEOF_UINT16;
3338 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber, ptr + index);
3339 index += SIZEOF_UINT16;
3340 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength, ptr + index);
3341 index += SIZEOF_UINT16;
3342 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier, ptr + index);
3343 index += SIZEOF_UINT16;
3344 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Status, ptr + index);
3345 index += SIZEOF_UINT16;
3346 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.ErrorIndex, ptr + index);
3347 index += SIZEOF_UINT16;
3348 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.TriggeredId, ptr + index);
3349 index += SIZEOF_UINT16;
3350 break;
3351#endif
3352#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3353 case CSR_MLME_SCAN_REQUEST_ID:
3354 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.SlotNumber, ptr + index);
3355 index += SIZEOF_UINT16;
3356 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.DataLength, ptr + index);
3357 index += SIZEOF_UINT16;
3358 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.SlotNumber, ptr + index);
3359 index += SIZEOF_UINT16;
3360 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.DataLength, ptr + index);
3361 index += SIZEOF_UINT16;
3362 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.VirtualInterfaceIdentifier, ptr + index);
3363 index += SIZEOF_UINT16;
3364 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.Ifindex, ptr + index);
3365 index += SIZEOF_UINT16;
3366 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ScanType, ptr + index);
3367 index += SIZEOF_UINT16;
3368 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ProbeDelay, ptr + index);
3369 index += SIZEOF_UINT32;
3370 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MinChannelTime, ptr + index);
3371 index += SIZEOF_UINT16;
3372 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MaxChannelTime, ptr + index);
3373 index += SIZEOF_UINT16;
3374 break;
3375#endif
3376#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3377 case CSR_MLME_DELETEKEYS_CONFIRM_ID:
3378 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber, ptr + index);
3379 index += SIZEOF_UINT16;
3380 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength, ptr + index);
3381 index += SIZEOF_UINT16;
3382 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber, ptr + index);
3383 index += SIZEOF_UINT16;
3384 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength, ptr + index);
3385 index += SIZEOF_UINT16;
3386 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier, ptr + index);
3387 index += SIZEOF_UINT16;
3388 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.ResultCode, ptr + index);
3389 index += SIZEOF_UINT16;
3390 break;
3391#endif
3392#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3393 case CSR_MLME_GET_NEXT_REQUEST_ID:
3394 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber, ptr + index);
3395 index += SIZEOF_UINT16;
3396 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.DataLength, ptr + index);
3397 index += SIZEOF_UINT16;
3398 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber, ptr + index);
3399 index += SIZEOF_UINT16;
3400 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.DataLength, ptr + index);
3401 index += SIZEOF_UINT16;
3402 break;
3403#endif
3404#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3405 case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
3406 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber, ptr + index);
3407 index += SIZEOF_UINT16;
3408 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength, ptr + index);
3409 index += SIZEOF_UINT16;
3410 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber, ptr + index);
3411 index += SIZEOF_UINT16;
3412 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength, ptr + index);
3413 index += SIZEOF_UINT16;
3414 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier, ptr + index);
3415 index += SIZEOF_UINT16;
3416 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.ResultCode, ptr + index);
3417 index += SIZEOF_UINT16;
3418 break;
3419#endif
3420#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3421 case CSR_MLME_START_AGGREGATION_REQUEST_ID:
3422 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
3423 index += SIZEOF_UINT16;
3424 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength, ptr + index);
3425 index += SIZEOF_UINT16;
3426 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
3427 index += SIZEOF_UINT16;
3428 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength, ptr + index);
3429 index += SIZEOF_UINT16;
3430 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
3431 index += SIZEOF_UINT16;
3432 memcpy(ptr + index, sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, 48 / 8);
3433 index += 48 / 8;
3434 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.UserPriority, ptr + index);
3435 index += SIZEOF_UINT16;
3436 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Direction, ptr + index);
3437 index += SIZEOF_UINT16;
3438 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.StartingSequenceNumber, ptr + index);
3439 index += SIZEOF_UINT16;
3440 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BufferSize, ptr + index);
3441 index += SIZEOF_UINT16;
3442 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BlockAckTimeout, ptr + index);
3443 index += SIZEOF_UINT16;
3444 break;
3445#endif
3446#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3447 case CSR_MLME_HL_SYNC_REQUEST_ID:
3448 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber, ptr + index);
3449 index += SIZEOF_UINT16;
3450 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength, ptr + index);
3451 index += SIZEOF_UINT16;
3452 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber, ptr + index);
3453 index += SIZEOF_UINT16;
3454 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength, ptr + index);
3455 index += SIZEOF_UINT16;
3456 memcpy(ptr + index, sig->u.MlmeHlSyncRequest.GroupAddress.x, 48 / 8);
3457 index += 48 / 8;
3458 break;
3459#endif
3460 case CSR_DEBUG_GENERIC_REQUEST_ID:
3461 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.SlotNumber, ptr + index);
3462 index += SIZEOF_UINT16;
3463 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.DataLength, ptr + index);
3464 index += SIZEOF_UINT16;
3465 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.SlotNumber, ptr + index);
3466 index += SIZEOF_UINT16;
3467 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.DataLength, ptr + index);
3468 index += SIZEOF_UINT16;
3469 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[0], ptr + index);
3470 index += SIZEOF_UINT16;
3471 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[1], ptr + index);
3472 index += SIZEOF_UINT16;
3473 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[2], ptr + index);
3474 index += SIZEOF_UINT16;
3475 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[3], ptr + index);
3476 index += SIZEOF_UINT16;
3477 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[4], ptr + index);
3478 index += SIZEOF_UINT16;
3479 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[5], ptr + index);
3480 index += SIZEOF_UINT16;
3481 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[6], ptr + index);
3482 index += SIZEOF_UINT16;
3483 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[7], ptr + index);
3484 index += SIZEOF_UINT16;
3485 break;
3486#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3487 case CSR_MLME_LEAVE_CONFIRM_ID:
3488 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber, ptr + index);
3489 index += SIZEOF_UINT16;
3490 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength, ptr + index);
3491 index += SIZEOF_UINT16;
3492 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber, ptr + index);
3493 index += SIZEOF_UINT16;
3494 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength, ptr + index);
3495 index += SIZEOF_UINT16;
3496 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier, ptr + index);
3497 index += SIZEOF_UINT16;
3498 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.ResultCode, ptr + index);
3499 index += SIZEOF_UINT16;
3500 break;
3501#endif
3502#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3503 case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
3504 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber, ptr + index);
3505 index += SIZEOF_UINT16;
3506 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength, ptr + index);
3507 index += SIZEOF_UINT16;
3508 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
3509 index += SIZEOF_UINT16;
3510 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
3511 index += SIZEOF_UINT16;
3512 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
3513 index += SIZEOF_UINT16;
3514 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.TriggeredId, ptr + index);
3515 index += SIZEOF_UINT16;
3516 break;
3517#endif
3518#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3519 case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
3520 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber, ptr + index);
3521 index += SIZEOF_UINT16;
3522 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.DataLength, ptr + index);
3523 index += SIZEOF_UINT16;
3524 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber, ptr + index);
3525 index += SIZEOF_UINT16;
3526 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength, ptr + index);
3527 index += SIZEOF_UINT16;
3528 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier, ptr + index);
3529 index += SIZEOF_UINT16;
3530 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses, ptr + index);
3531 index += SIZEOF_UINT16;
3532 break;
3533#endif
3534#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3535 case CSR_MLME_RESET_REQUEST_ID:
3536 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.SlotNumber, ptr + index);
3537 index += SIZEOF_UINT16;
3538 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.DataLength, ptr + index);
3539 index += SIZEOF_UINT16;
3540 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.SlotNumber, ptr + index);
3541 index += SIZEOF_UINT16;
3542 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.DataLength, ptr + index);
3543 index += SIZEOF_UINT16;
3544 memcpy(ptr + index, sig->u.MlmeResetRequest.StaAddress.x, 48 / 8);
3545 index += 48 / 8;
3546 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.SetDefaultMib, ptr + index);
3547 index += SIZEOF_UINT16;
3548 break;
3549#endif
3550#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3551 case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
3552 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3553 index += SIZEOF_UINT16;
3554 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength, ptr + index);
3555 index += SIZEOF_UINT16;
3556 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3557 index += SIZEOF_UINT16;
3558 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength, ptr + index);
3559 index += SIZEOF_UINT16;
3560 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier, ptr + index);
3561 index += SIZEOF_UINT16;
3562 break;
3563#endif
3564#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3565 case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
3566 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
3567 index += SIZEOF_UINT16;
3568 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
3569 index += SIZEOF_UINT16;
3570 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
3571 index += SIZEOF_UINT16;
3572 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
3573 index += SIZEOF_UINT16;
3574 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
3575 index += SIZEOF_UINT16;
3576 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.ResultCode, ptr + index);
3577 index += SIZEOF_UINT16;
3578 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.TriggeredId, ptr + index);
3579 index += SIZEOF_UINT16;
3580 break;
3581#endif
3582#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3583 case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
3584 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber, ptr + index);
3585 index += SIZEOF_UINT16;
3586 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength, ptr + index);
3587 index += SIZEOF_UINT16;
3588 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber, ptr + index);
3589 index += SIZEOF_UINT16;
3590 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength, ptr + index);
3591 index += SIZEOF_UINT16;
3592 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier, ptr + index);
3593 index += SIZEOF_UINT16;
3594 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.PacketFilterMode, ptr + index);
3595 index += SIZEOF_UINT16;
3596 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress, ptr + index);
3597 index += SIZEOF_UINT32;
3598 break;
3599#endif
3600#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3601 case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
3602 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
3603 index += SIZEOF_UINT16;
3604 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
3605 index += SIZEOF_UINT16;
3606 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
3607 index += SIZEOF_UINT16;
3608 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
3609 index += SIZEOF_UINT16;
3610 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
3611 index += SIZEOF_UINT16;
3612 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.TriggerId, ptr + index);
3613 index += SIZEOF_UINT16;
3614 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.ResultCode, ptr + index);
3615 index += SIZEOF_UINT16;
3616 break;
3617#endif
3618#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3619 case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
3620 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber, ptr + index);
3621 index += SIZEOF_UINT16;
3622 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.DataLength, ptr + index);
3623 index += SIZEOF_UINT16;
3624 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber, ptr + index);
3625 index += SIZEOF_UINT16;
3626 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength, ptr + index);
3627 index += SIZEOF_UINT16;
3628 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier, ptr + index);
3629 index += SIZEOF_UINT16;
3630 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.ConnectionStatus, ptr + index);
3631 index += SIZEOF_UINT16;
3632 memcpy(ptr + index, sig->u.MlmeConnectStatusRequest.StaAddress.x, 48 / 8);
3633 index += 48 / 8;
3634 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationId, ptr + index);
3635 index += SIZEOF_UINT16;
3636 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation, ptr + index);
3637 index += SIZEOF_UINT16;
3638 break;
3639#endif
3640#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3641 case CSR_MLME_LEAVE_REQUEST_ID:
3642 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber, ptr + index);
3643 index += SIZEOF_UINT16;
3644 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.DataLength, ptr + index);
3645 index += SIZEOF_UINT16;
3646 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber, ptr + index);
3647 index += SIZEOF_UINT16;
3648 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.DataLength, ptr + index);
3649 index += SIZEOF_UINT16;
3650 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier, ptr + index);
3651 index += SIZEOF_UINT16;
3652 break;
3653#endif
3654#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3655 case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
3656 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber, ptr + index);
3657 index += SIZEOF_UINT16;
3658 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength, ptr + index);
3659 index += SIZEOF_UINT16;
3660 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber, ptr + index);
3661 index += SIZEOF_UINT16;
3662 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength, ptr + index);
3663 index += SIZEOF_UINT16;
3664 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.QueueIndex, ptr + index);
3665 index += SIZEOF_UINT16;
3666 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Aifs, ptr + index);
3667 index += SIZEOF_UINT16;
3668 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmin, ptr + index);
3669 index += SIZEOF_UINT16;
3670 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmax, ptr + index);
3671 index += SIZEOF_UINT16;
3672 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.TxopLimit, ptr + index);
3673 index += SIZEOF_UINT16;
3674 break;
3675#endif
3676#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3677 case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
3678 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
3679 index += SIZEOF_UINT16;
3680 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength, ptr + index);
3681 index += SIZEOF_UINT16;
3682 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
3683 index += SIZEOF_UINT16;
3684 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength, ptr + index);
3685 index += SIZEOF_UINT16;
3686 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
3687 index += SIZEOF_UINT16;
3688 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.UserPriority, ptr + index);
3689 index += SIZEOF_UINT16;
3690 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.ResultCode, ptr + index);
3691 index += SIZEOF_UINT16;
3692 break;
3693#endif
3694 case CSR_MLME_SET_TIM_CONFIRM_ID:
3695 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber, ptr + index);
3696 index += SIZEOF_UINT16;
3697 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength, ptr + index);
3698 index += SIZEOF_UINT16;
3699 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber, ptr + index);
3700 index += SIZEOF_UINT16;
3701 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength, ptr + index);
3702 index += SIZEOF_UINT16;
3703 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier, ptr + index);
3704 index += SIZEOF_UINT16;
3705 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.ResultCode, ptr + index);
3706 index += SIZEOF_UINT16;
3707 break;
3708#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3709 case CSR_MLME_MEASURE_INDICATION_ID:
3710 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber, ptr + index);
3711 index += SIZEOF_UINT16;
3712 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength, ptr + index);
3713 index += SIZEOF_UINT16;
3714 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber, ptr + index);
3715 index += SIZEOF_UINT16;
3716 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.DataLength, ptr + index);
3717 index += SIZEOF_UINT16;
3718 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.DialogToken, ptr + index);
3719 index += SIZEOF_UINT16;
3720 break;
3721#endif
3722#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3723 case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
3724 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
3725 index += SIZEOF_UINT16;
3726 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
3727 index += SIZEOF_UINT16;
3728 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
3729 index += SIZEOF_UINT16;
3730 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
3731 index += SIZEOF_UINT16;
3732 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
3733 index += SIZEOF_UINT16;
3734 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.BlackoutId, ptr + index);
3735 index += SIZEOF_UINT16;
3736 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.ResultCode, ptr + index);
3737 index += SIZEOF_UINT16;
3738 break;
3739#endif
3740#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3741 case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
3742 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
3743 index += SIZEOF_UINT16;
3744 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
3745 index += SIZEOF_UINT16;
3746 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
3747 index += SIZEOF_UINT16;
3748 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
3749 index += SIZEOF_UINT16;
3750 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
3751 index += SIZEOF_UINT16;
3752 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.ResultCode, ptr + index);
3753 index += SIZEOF_UINT16;
3754 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.TriggeredId, ptr + index);
3755 index += SIZEOF_UINT16;
3756 break;
3757#endif
3758 case CSR_DEBUG_GENERIC_INDICATION_ID:
3759 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.SlotNumber, ptr + index);
3760 index += SIZEOF_UINT16;
3761 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.DataLength, ptr + index);
3762 index += SIZEOF_UINT16;
3763 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.SlotNumber, ptr + index);
3764 index += SIZEOF_UINT16;
3765 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.DataLength, ptr + index);
3766 index += SIZEOF_UINT16;
3767 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[0], ptr + index);
3768 index += SIZEOF_UINT16;
3769 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[1], ptr + index);
3770 index += SIZEOF_UINT16;
3771 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[2], ptr + index);
3772 index += SIZEOF_UINT16;
3773 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[3], ptr + index);
3774 index += SIZEOF_UINT16;
3775 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[4], ptr + index);
3776 index += SIZEOF_UINT16;
3777 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[5], ptr + index);
3778 index += SIZEOF_UINT16;
3779 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[6], ptr + index);
3780 index += SIZEOF_UINT16;
3781 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[7], ptr + index);
3782 index += SIZEOF_UINT16;
3783 break;
3784 case CSR_MA_PACKET_CANCEL_REQUEST_ID:
3785 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3786 index += SIZEOF_UINT16;
3787 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.DataLength, ptr + index);
3788 index += SIZEOF_UINT16;
3789 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3790 index += SIZEOF_UINT16;
3791 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.DataLength, ptr + index);
3792 index += SIZEOF_UINT16;
3793 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier, ptr + index);
3794 index += SIZEOF_UINT16;
3795 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.HostTag, ptr + index);
3796 index += SIZEOF_UINT32;
3797 break;
3798#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3799 case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
3800 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber, ptr + index);
3801 index += SIZEOF_UINT16;
3802 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength, ptr + index);
3803 index += SIZEOF_UINT16;
3804 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber, ptr + index);
3805 index += SIZEOF_UINT16;
3806 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength, ptr + index);
3807 index += SIZEOF_UINT16;
3808 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier, ptr + index);
3809 index += SIZEOF_UINT16;
3810 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.ResultCode, ptr + index);
3811 index += SIZEOF_UINT16;
3812 break;
3813#endif
3814#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3815 case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
3816 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
3817 index += SIZEOF_UINT16;
3818 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
3819 index += SIZEOF_UINT16;
3820 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
3821 index += SIZEOF_UINT16;
3822 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
3823 index += SIZEOF_UINT16;
3824 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
3825 index += SIZEOF_UINT16;
3826 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.ResultCode, ptr + index);
3827 index += SIZEOF_UINT16;
3828 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId, ptr + index);
3829 index += SIZEOF_UINT16;
3830 break;
3831#endif
3832 case CSR_MA_PACKET_REQUEST_ID:
3833 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.SlotNumber, ptr + index);
3834 index += SIZEOF_UINT16;
3835 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.DataLength, ptr + index);
3836 index += SIZEOF_UINT16;
3837 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.SlotNumber, ptr + index);
3838 index += SIZEOF_UINT16;
3839 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.DataLength, ptr + index);
3840 index += SIZEOF_UINT16;
3841 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.VirtualInterfaceIdentifier, ptr + index);
3842 index += SIZEOF_UINT16;
3843 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmitRate, ptr + index);
3844 index += SIZEOF_UINT16;
3845 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.HostTag, ptr + index);
3846 index += SIZEOF_UINT32;
3847 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Priority, ptr + index);
3848 index += SIZEOF_UINT16;
3849 memcpy(ptr + index, sig->u.MaPacketRequest.Ra.x, 48 / 8);
3850 index += 48 / 8;
3851 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmissionControl, ptr + index);
3852 index += SIZEOF_UINT16;
3853 break;
3854#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3855 case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
3856 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber, ptr + index);
3857 index += SIZEOF_UINT16;
3858 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.DataLength, ptr + index);
3859 index += SIZEOF_UINT16;
3860 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber, ptr + index);
3861 index += SIZEOF_UINT16;
3862 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength, ptr + index);
3863 index += SIZEOF_UINT16;
3864 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier, ptr + index);
3865 index += SIZEOF_UINT16;
3866 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.BeaconPeriod, ptr + index);
3867 index += SIZEOF_UINT16;
3868 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.DtimPeriod, ptr + index);
3869 index += SIZEOF_UINT16;
3870 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.CapabilityInformation, ptr + index);
3871 index += SIZEOF_UINT16;
3872 memcpy(ptr + index, sig->u.MlmeModifyBssParameterRequest.Bssid.x, 48 / 8);
3873 index += 48 / 8;
3874 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.RtsThreshold, ptr + index);
3875 index += SIZEOF_UINT16;
3876 break;
3877#endif
3878#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3879 case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
3880 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber, ptr + index);
3881 index += SIZEOF_UINT16;
3882 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength, ptr + index);
3883 index += SIZEOF_UINT16;
3884 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
3885 index += SIZEOF_UINT16;
3886 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
3887 index += SIZEOF_UINT16;
3888 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
3889 index += SIZEOF_UINT16;
3890 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.TriggerId, ptr + index);
3891 index += SIZEOF_UINT16;
3892 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Priority, ptr + index);
3893 index += SIZEOF_UINT16;
3894 break;
3895#endif
3896 case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
3897 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber, ptr + index);
3898 index += SIZEOF_UINT16;
3899 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength, ptr + index);
3900 index += SIZEOF_UINT16;
3901 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber, ptr + index);
3902 index += SIZEOF_UINT16;
3903 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength, ptr + index);
3904 index += SIZEOF_UINT16;
3905 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier, ptr + index);
3906 index += SIZEOF_UINT16;
3907 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Multicast, ptr + index);
3908 index += SIZEOF_UINT16;
3909 break;
3910#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3911 case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
3912 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber, ptr + index);
3913 index += SIZEOF_UINT16;
3914 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength, ptr + index);
3915 index += SIZEOF_UINT16;
3916 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber, ptr + index);
3917 index += SIZEOF_UINT16;
3918 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength, ptr + index);
3919 index += SIZEOF_UINT16;
3920 memcpy(ptr + index, sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, 48 / 8);
3921 index += 48 / 8;
3922 break;
3923#endif
3924#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3925 case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
3926 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
3927 index += SIZEOF_UINT16;
3928 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
3929 index += SIZEOF_UINT16;
3930 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
3931 index += SIZEOF_UINT16;
3932 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
3933 index += SIZEOF_UINT16;
3934 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
3935 index += SIZEOF_UINT16;
3936 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId, ptr + index);
3937 index += SIZEOF_UINT16;
3938 break;
3939#endif
3940#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3941 case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
3942 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber, ptr + index);
3943 index += SIZEOF_UINT16;
3944 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength, ptr + index);
3945 index += SIZEOF_UINT16;
3946 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber, ptr + index);
3947 index += SIZEOF_UINT16;
3948 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength, ptr + index);
3949 index += SIZEOF_UINT16;
3950 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier, ptr + index);
3951 index += SIZEOF_UINT16;
3952 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.BlackoutId, ptr + index);
3953 index += SIZEOF_UINT16;
3954 break;
3955#endif
3956#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3957 case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
3958 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber, ptr + index);
3959 index += SIZEOF_UINT16;
3960 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength, ptr + index);
3961 index += SIZEOF_UINT16;
3962 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber, ptr + index);
3963 index += SIZEOF_UINT16;
3964 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength, ptr + index);
3965 index += SIZEOF_UINT16;
3966 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier, ptr + index);
3967 index += SIZEOF_UINT16;
3968 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.ResultCode, ptr + index);
3969 index += SIZEOF_UINT16;
3970 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId, ptr + index);
3971 index += SIZEOF_UINT16;
3972 break;
3973#endif
3974#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3975 case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
3976 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber, ptr + index);
3977 index += SIZEOF_UINT16;
3978 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength, ptr + index);
3979 index += SIZEOF_UINT16;
3980 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber, ptr + index);
3981 index += SIZEOF_UINT16;
3982 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength, ptr + index);
3983 index += SIZEOF_UINT16;
3984 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier, ptr + index);
3985 index += SIZEOF_UINT16;
3986 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyId, ptr + index);
3987 index += SIZEOF_UINT16;
3988 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyType, ptr + index);
3989 index += SIZEOF_UINT16;
3990 memcpy(ptr + index, sig->u.MlmeGetKeySequenceRequest.Address.x, 48 / 8);
3991 index += 48 / 8;
3992 break;
3993#endif
3994#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
3995 case CSR_MLME_SET_CHANNEL_REQUEST_ID:
3996 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber, ptr + index);
3997 index += SIZEOF_UINT16;
3998 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength, ptr + index);
3999 index += SIZEOF_UINT16;
4000 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber, ptr + index);
4001 index += SIZEOF_UINT16;
4002 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength, ptr + index);
4003 index += SIZEOF_UINT16;
4004 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier, ptr + index);
4005 index += SIZEOF_UINT16;
4006 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Ifindex, ptr + index);
4007 index += SIZEOF_UINT16;
4008 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Channel, ptr + index);
4009 index += SIZEOF_UINT16;
4010 memcpy(ptr + index, sig->u.MlmeSetChannelRequest.Address.x, 48 / 8);
4011 index += 48 / 8;
4012 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityDuration, ptr + index);
4013 index += SIZEOF_UINT16;
4014 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityInterval, ptr + index);
4015 index += SIZEOF_UINT16;
4016 break;
4017#endif
4018#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4019 case CSR_MLME_MEASURE_CONFIRM_ID:
4020 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
4021 index += SIZEOF_UINT16;
4022 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength, ptr + index);
4023 index += SIZEOF_UINT16;
4024 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
4025 index += SIZEOF_UINT16;
4026 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength, ptr + index);
4027 index += SIZEOF_UINT16;
4028 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.ResultCode, ptr + index);
4029 index += SIZEOF_UINT16;
4030 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.DialogToken, ptr + index);
4031 index += SIZEOF_UINT16;
4032 break;
4033#endif
4034#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4035 case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
4036 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber, ptr + index);
4037 index += SIZEOF_UINT16;
4038 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength, ptr + index);
4039 index += SIZEOF_UINT16;
4040 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
4041 index += SIZEOF_UINT16;
4042 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
4043 index += SIZEOF_UINT16;
4044 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
4045 index += SIZEOF_UINT16;
4046 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.TriggeredId, ptr + index);
4047 index += SIZEOF_UINT16;
4048 break;
4049#endif
4050#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4051 case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
4052 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber, ptr + index);
4053 index += SIZEOF_UINT16;
4054 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength, ptr + index);
4055 index += SIZEOF_UINT16;
4056 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber, ptr + index);
4057 index += SIZEOF_UINT16;
4058 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength, ptr + index);
4059 index += SIZEOF_UINT16;
4060 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier, ptr + index);
4061 index += SIZEOF_UINT16;
4062 memcpy(ptr + index, sig->u.MlmeAutonomousScanLossIndication.Bssid.x, 48 / 8);
4063 index += 48 / 8;
4064 break;
4065#endif
4066 case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
4067 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber, ptr + index);
4068 index += SIZEOF_UINT16;
4069 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength, ptr + index);
4070 index += SIZEOF_UINT16;
4071 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber, ptr + index);
4072 index += SIZEOF_UINT16;
4073 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength, ptr + index);
4074 index += SIZEOF_UINT16;
4075 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier, ptr + index);
4076 index += SIZEOF_UINT16;
4077 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.ResultCode, ptr + index);
4078 index += SIZEOF_UINT16;
4079 break;
4080#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4081 case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
4082 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.SlotNumber, ptr + index);
4083 index += SIZEOF_UINT16;
4084 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.DataLength, ptr + index);
4085 index += SIZEOF_UINT16;
4086 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.SlotNumber, ptr + index);
4087 index += SIZEOF_UINT16;
4088 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.DataLength, ptr + index);
4089 index += SIZEOF_UINT16;
4090 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier, ptr + index);
4091 index += SIZEOF_UINT16;
4092 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.FrameType, ptr + index);
4093 index += SIZEOF_UINT16;
4094 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.MinTransmitRate, ptr + index);
4095 index += SIZEOF_UINT16;
4096 break;
4097#endif
4098#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4099 case CSR_MLME_POWERMGT_CONFIRM_ID:
4100 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber, ptr + index);
4101 index += SIZEOF_UINT16;
4102 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength, ptr + index);
4103 index += SIZEOF_UINT16;
4104 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber, ptr + index);
4105 index += SIZEOF_UINT16;
4106 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength, ptr + index);
4107 index += SIZEOF_UINT16;
4108 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier, ptr + index);
4109 index += SIZEOF_UINT16;
4110 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.ResultCode, ptr + index);
4111 index += SIZEOF_UINT16;
4112 break;
4113#endif
4114#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4115 case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
4116 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
4117 index += SIZEOF_UINT16;
4118 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
4119 index += SIZEOF_UINT16;
4120 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
4121 index += SIZEOF_UINT16;
4122 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
4123 index += SIZEOF_UINT16;
4124 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
4125 index += SIZEOF_UINT16;
4126 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.PeriodicId, ptr + index);
4127 index += SIZEOF_UINT16;
4128 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.ResultCode, ptr + index);
4129 index += SIZEOF_UINT16;
4130 break;
4131#endif
4132#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4133 case CSR_MLME_GET_CONFIRM_ID:
4134 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber, ptr + index);
4135 index += SIZEOF_UINT16;
4136 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.DataLength, ptr + index);
4137 index += SIZEOF_UINT16;
4138 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber, ptr + index);
4139 index += SIZEOF_UINT16;
4140 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.DataLength, ptr + index);
4141 index += SIZEOF_UINT16;
4142 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Status, ptr + index);
4143 index += SIZEOF_UINT16;
4144 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.ErrorIndex, ptr + index);
4145 index += SIZEOF_UINT16;
4146 break;
4147#endif
4148#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4149 case CSR_MLME_GET_NEXT_CONFIRM_ID:
4150 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber, ptr + index);
4151 index += SIZEOF_UINT16;
4152 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength, ptr + index);
4153 index += SIZEOF_UINT16;
4154 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber, ptr + index);
4155 index += SIZEOF_UINT16;
4156 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength, ptr + index);
4157 index += SIZEOF_UINT16;
4158 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Status, ptr + index);
4159 index += SIZEOF_UINT16;
4160 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.ErrorIndex, ptr + index);
4161 index += SIZEOF_UINT16;
4162 break;
4163#endif
4164#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4165 case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
4166 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
4167 index += SIZEOF_UINT16;
4168 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength, ptr + index);
4169 index += SIZEOF_UINT16;
4170 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
4171 index += SIZEOF_UINT16;
4172 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength, ptr + index);
4173 index += SIZEOF_UINT16;
4174 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
4175 index += SIZEOF_UINT16;
4176 memcpy(ptr + index, sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, 48 / 8);
4177 index += 48 / 8;
4178 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.UserPriority, ptr + index);
4179 index += SIZEOF_UINT16;
4180 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Direction, ptr + index);
4181 index += SIZEOF_UINT16;
4182 break;
4183#endif
4184#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4185 case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
4186 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
4187 index += SIZEOF_UINT16;
4188 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
4189 index += SIZEOF_UINT16;
4190 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
4191 index += SIZEOF_UINT16;
4192 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
4193 index += SIZEOF_UINT16;
4194 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
4195 index += SIZEOF_UINT16;
4196 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.TriggerId, ptr + index);
4197 index += SIZEOF_UINT16;
4198 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.ResultCode, ptr + index);
4199 index += SIZEOF_UINT16;
4200 break;
4201#endif
4202#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4203 case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
4204 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
4205 index += SIZEOF_UINT16;
4206 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength, ptr + index);
4207 index += SIZEOF_UINT16;
4208 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
4209 index += SIZEOF_UINT16;
4210 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength, ptr + index);
4211 index += SIZEOF_UINT16;
4212 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
4213 index += SIZEOF_UINT16;
4214 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutId, ptr + index);
4215 index += SIZEOF_UINT16;
4216 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutType, ptr + index);
4217 index += SIZEOF_UINT16;
4218 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutSource, ptr + index);
4219 index += SIZEOF_UINT16;
4220 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutStartReference, ptr + index);
4221 index += SIZEOF_UINT32;
4222 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutPeriod, ptr + index);
4223 index += SIZEOF_UINT32;
4224 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutDuration, ptr + index);
4225 index += SIZEOF_UINT32;
4226 memcpy(ptr + index, sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, 48 / 8);
4227 index += 48 / 8;
4228 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutCount, ptr + index);
4229 index += SIZEOF_UINT16;
4230 break;
4231#endif
4232#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4233 case CSR_MLME_DELETEKEYS_REQUEST_ID:
4234 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber, ptr + index);
4235 index += SIZEOF_UINT16;
4236 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength, ptr + index);
4237 index += SIZEOF_UINT16;
4238 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber, ptr + index);
4239 index += SIZEOF_UINT16;
4240 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength, ptr + index);
4241 index += SIZEOF_UINT16;
4242 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier, ptr + index);
4243 index += SIZEOF_UINT16;
4244 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyId, ptr + index);
4245 index += SIZEOF_UINT16;
4246 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyType, ptr + index);
4247 index += SIZEOF_UINT16;
4248 memcpy(ptr + index, sig->u.MlmeDeletekeysRequest.Address.x, 48 / 8);
4249 index += 48 / 8;
4250 break;
4251#endif
4252#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4253 case CSR_MLME_RESET_CONFIRM_ID:
4254 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber, ptr + index);
4255 index += SIZEOF_UINT16;
4256 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.DataLength, ptr + index);
4257 index += SIZEOF_UINT16;
4258 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber, ptr + index);
4259 index += SIZEOF_UINT16;
4260 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.DataLength, ptr + index);
4261 index += SIZEOF_UINT16;
4262 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.ResultCode, ptr + index);
4263 index += SIZEOF_UINT16;
4264 break;
4265#endif
4266#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4267 case CSR_MLME_HL_SYNC_CONFIRM_ID:
4268 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber, ptr + index);
4269 index += SIZEOF_UINT16;
4270 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength, ptr + index);
4271 index += SIZEOF_UINT16;
4272 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber, ptr + index);
4273 index += SIZEOF_UINT16;
4274 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength, ptr + index);
4275 index += SIZEOF_UINT16;
4276 memcpy(ptr + index, sig->u.MlmeHlSyncConfirm.GroupAddress.x, 48 / 8);
4277 index += 48 / 8;
4278 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.ResultCode, ptr + index);
4279 index += SIZEOF_UINT16;
4280 break;
4281#endif
4282#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4283 case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
4284 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber, ptr + index);
4285 index += SIZEOF_UINT16;
4286 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength, ptr + index);
4287 index += SIZEOF_UINT16;
4288 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber, ptr + index);
4289 index += SIZEOF_UINT16;
4290 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength, ptr + index);
4291 index += SIZEOF_UINT16;
4292 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
4293 index += SIZEOF_UINT16;
4294 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId, ptr + index);
4295 index += SIZEOF_UINT16;
4296 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.Ifindex, ptr + index);
4297 index += SIZEOF_UINT16;
4298 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor, ptr + index);
4299 index += SIZEOF_UINT16;
4300 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ScanType, ptr + index);
4301 index += SIZEOF_UINT16;
4302 CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ProbeDelay, ptr + index);
4303 index += SIZEOF_UINT32;
4304 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MinChannelTime, ptr + index);
4305 index += SIZEOF_UINT16;
4306 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime, ptr + index);
4307 index += SIZEOF_UINT16;
4308 break;
4309#endif
4310#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4311 case CSR_MLME_SET_REQUEST_ID:
4312 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber, ptr + index);
4313 index += SIZEOF_UINT16;
4314 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.DataLength, ptr + index);
4315 index += SIZEOF_UINT16;
4316 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.SlotNumber, ptr + index);
4317 index += SIZEOF_UINT16;
4318 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.DataLength, ptr + index);
4319 index += SIZEOF_UINT16;
4320 break;
4321#endif
4322#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
4323 case CSR_MLME_SM_START_REQUEST_ID:
4324 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.SlotNumber, ptr + index);
4325 index += SIZEOF_UINT16;
4326 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.DataLength, ptr + index);
4327 index += SIZEOF_UINT16;
4328 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.SlotNumber, ptr + index);
4329 index += SIZEOF_UINT16;
4330 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.DataLength, ptr + index);
4331 index += SIZEOF_UINT16;
4332 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier, ptr + index);
4333 index += SIZEOF_UINT16;
4334 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Ifindex, ptr + index);
4335 index += SIZEOF_UINT16;
4336 CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Channel, ptr + index);
4337 index += SIZEOF_UINT16;
4338 memcpy(ptr + index, sig->u.MlmeSmStartRequest.InterfaceAddress.x, 48 / 8);
4339 index += 48 / 8;
4340 memcpy(ptr + index, sig->u.MlmeSmStartRequest.Bssid.x, 48 / 8);
4341 index += 48 / 8;

463 more lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_send.c+0−415

This diff is large: its 416 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_signals.c+0−1313

This diff is large: its 1314 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_signals.h+0−128

This diff is large: its 129 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_sigs.h+0−1417

This diff is large: its 1418 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_ta_sampling.c+0−541

This diff is large: its 542 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_ta_sampling.h+0−66

This diff is large: its 67 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_udi.c+0−173

This diff is large: its 174 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_unifi.h+0−871

This diff is large: its 872 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c+0−41

This diff is large: its 42 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_unifi_udi.h+0−52

This diff is large: its 53 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_unifihw.h+0−59

This diff is large: its 60 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_unifiversion.h+0−30

This diff is large: its 31 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_xbv.c+0−1076

This diff is large: its 1077 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hip_xbv.h+0−119

This diff is large: its 120 lines aren’t shown here.

drivers/staging/csr/csr_wifi_hostio_prim.h+0−18

This diff is large: its 19 lines aren’t shown here.

drivers/staging/csr/csr_wifi_lib.h+0−103

This diff is large: its 104 lines aren’t shown here.

drivers/staging/csr/csr_wifi_msgconv.h+0−49

This diff is large: its 50 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_converter_init.c+0−90

This diff is large: its 91 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_converter_init.h+0−41

This diff is large: its 42 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c+0−84

This diff is large: its 85 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c+0−39

This diff is large: its 40 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_lib.h+0−495

This diff is large: its 496 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_prim.h+0−494

This diff is large: its 495 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_sef.c+0−30

This diff is large: its 31 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_sef.h+0−21

This diff is large: its 22 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_serialize.c+0−909

This diff is large: its 910 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_ap_serialize.h+0−94

This diff is large: its 95 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_converter_init.h+0−38

This diff is large: its 39 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_lib.h+0−991

This diff is large: its 992 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_prim.h+0−1657

This diff is large: its 1658 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_serialize.h+0−166

This diff is large: its 167 lines aren’t shown here.

drivers/staging/csr/csr_wifi_nme_task.h+0−27

This diff is large: its 28 lines aren’t shown here.

drivers/staging/csr/csr_wifi_private_common.h+0−81

This diff is large: its 82 lines aren’t shown here.

drivers/staging/csr/csr_wifi_result.h+0−27

This diff is large: its 28 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_converter_init.c+0−82

This diff is large: its 83 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_converter_init.h+0−34

This diff is large: its 35 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c+0−134

This diff is large: its 135 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h+0−34

This diff is large: its 35 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c+0−108

This diff is large: its 109 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c+0−87

This diff is large: its 88 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_lib.h+0−2082

This diff is large: its 2083 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_prim.h+0−2113

This diff is large: its 2114 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_sef.c+0−46

This diff is large: its 47 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_sef.h+0−51

This diff is large: its 52 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_serialize.c+0−2591

This diff is large: its 2592 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_ctrl_serialize.h+0−333

This diff is large: its 334 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_free_downstream_contents.c+0−53

This diff is large: its 54 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_free_upstream_contents.c+0−47

This diff is large: its 48 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_lib.h+0−417

This diff is large: its 418 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_prim.h+0−421

This diff is large: its 422 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_sef.c+0−19

This diff is large: its 20 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_sef.h+0−25

This diff is large: its 26 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_serialize.c+0−418

This diff is large: its 419 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_serialize.h+0−67

This diff is large: its 68 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_task.h+0−25

This diff is large: its 26 lines aren’t shown here.

drivers/staging/csr/csr_wifi_router_transport.c+0−199

This diff is large: its 200 lines aren’t shown here.

drivers/staging/csr/csr_wifi_serialize_primitive_types.c+0−256

This diff is large: its 257 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_ap_lib.h+0−774

This diff is large: its 775 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_ap_prim.h+0−1030

This diff is large: its 1031 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_converter_init.c+0−201

This diff is large: its 202 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_converter_init.h+0−34

This diff is large: its 35 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c+0−187

This diff is large: its 188 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c+0−275

This diff is large: its 276 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_lib.h+0−4303

This diff is large: its 4304 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_prim.h+0−6510

This diff is large: its 6511 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_sef.c+0−85

This diff is large: its 86 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_sef.h+0−142

This diff is large: its 143 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_serialize.c+0−5809

This diff is large: its 5810 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_serialize.h+0−666

This diff is large: its 667 lines aren’t shown here.

drivers/staging/csr/csr_wifi_sme_task.h+0−25

This diff is large: its 26 lines aren’t shown here.

drivers/staging/csr/csr_wifi_vif_utils.h+0−27

This diff is large: its 28 lines aren’t shown here.

drivers/staging/csr/data_tx.c+0−54

This diff is large: its 55 lines aren’t shown here.

drivers/staging/csr/drv.c+0−2193

This diff is large: its 2194 lines aren’t shown here.

drivers/staging/csr/firmware.c+0−396

This diff is large: its 397 lines aren’t shown here.

drivers/staging/csr/inet.c+0−104

This diff is large: its 105 lines aren’t shown here.

drivers/staging/csr/init_hw.c+0−108

This diff is large: its 109 lines aren’t shown here.

drivers/staging/csr/io.c+0−1098

This diff is large: its 1099 lines aren’t shown here.

drivers/staging/csr/mlme.c+0−433

This diff is large: its 434 lines aren’t shown here.

drivers/staging/csr/monitor.c+0−384

This diff is large: its 385 lines aren’t shown here.

drivers/staging/csr/netdev.c+0−3307

This diff is large: its 3308 lines aren’t shown here.

drivers/staging/csr/os.c+0−477

This diff is large: its 478 lines aren’t shown here.

drivers/staging/csr/putest.c+0−685

This diff is large: its 686 lines aren’t shown here.

drivers/staging/csr/sdio_events.c+0−134

This diff is large: its 135 lines aren’t shown here.

drivers/staging/csr/sdio_mmc.c+0−1288

This diff is large: its 1289 lines aren’t shown here.

drivers/staging/csr/sdio_stubs.c+0−82

This diff is large: its 83 lines aren’t shown here.

drivers/staging/csr/sme_blocking.c+0−1466

This diff is large: its 1467 lines aren’t shown here.

drivers/staging/csr/sme_mgt.c+0−1012

This diff is large: its 1013 lines aren’t shown here.

drivers/staging/csr/sme_native.c+0−566

This diff is large: its 567 lines aren’t shown here.

drivers/staging/csr/sme_sys.c+0−3260

This diff is large: its 3261 lines aren’t shown here.

drivers/staging/csr/sme_userspace.c+0−315

This diff is large: its 316 lines aren’t shown here.

drivers/staging/csr/sme_userspace.h+0−38

This diff is large: its 39 lines aren’t shown here.

drivers/staging/csr/sme_wext.c+0−3327

This diff is large: its 3328 lines aren’t shown here.

drivers/staging/csr/ul_int.c+0−528

This diff is large: its 529 lines aren’t shown here.

drivers/staging/csr/unifi_clients.h+0−129

This diff is large: its 130 lines aren’t shown here.

drivers/staging/csr/unifi_config.h+0−34

This diff is large: its 35 lines aren’t shown here.

drivers/staging/csr/unifi_dbg.c+0−110

This diff is large: its 111 lines aren’t shown here.

drivers/staging/csr/unifi_event.c+0−692

This diff is large: its 693 lines aren’t shown here.

drivers/staging/csr/unifi_native.h+0−257

This diff is large: its 258 lines aren’t shown here.

drivers/staging/csr/unifi_os.h+0−122

This diff is large: its 123 lines aren’t shown here.

drivers/staging/csr/unifi_pdu_processing.c+0−3729

This diff is large: its 3730 lines aren’t shown here.

drivers/staging/csr/unifi_priv.h+0−1136

This diff is large: its 1137 lines aren’t shown here.

drivers/staging/csr/unifi_sme.c+0−1225

This diff is large: its 1226 lines aren’t shown here.

drivers/staging/csr/unifi_sme.h+0−245

This diff is large: its 246 lines aren’t shown here.

drivers/staging/csr/unifi_wext.h+0−108

This diff is large: its 109 lines aren’t shown here.

drivers/staging/csr/unifiio.h+0−398

This diff is large: its 399 lines aren’t shown here.

drivers/staging/csr/wext_events.c+0−283

This diff is large: its 284 lines aren’t shown here.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t