34 #include <linux/version.h>
65 #define UNIFI_DEV_NOT_IN_USE 0
66 #define UNIFI_DEV_IN_USE 1
67 #define UNIFI_DEV_CLEANUP 2
82 int *eof,
void *
data);
84 #ifdef CSR_WIFI_RX_PATH_SPLIT
91 priv->rxSignalBuffer.writePointer =
92 priv->rxSignalBuffer.readPointer = 0;
93 priv->rxSignalBuffer.size =
size;
97 priv->rxSignalBuffer.rx_buff[
i].sig_len=0;
99 if (priv->rxSignalBuffer.rx_buff[i].bufptr ==
NULL)
102 unifi_error(priv,
"signal_buffer_init:Failed to Allocate shared memory for T-H signals \n");
105 priv->rxSignalBuffer.rx_buff[
j].sig_len=0;
106 kfree(priv->rxSignalBuffer.rx_buff[j].bufptr);
107 priv->rxSignalBuffer.rx_buff[
j].bufptr =
NULL;
118 static void signal_buffer_free(
unifi_priv_t * priv,
int size)
122 for(i=0; i<
size; i++)
124 priv->rxSignalBuffer.rx_buff[
i].sig_len=0;
125 kfree(priv->rxSignalBuffer.rx_buff[i].bufptr);
126 priv->rxSignalBuffer.rx_buff[
i].bufptr =
NULL;
157 unifi_error(priv,
"uf_register_netdev bad interfaceTag\n");
166 interfaceTag, priv->
netdev[interfaceTag]);
169 unifi_error(priv,
"Failed to register net device\n");
176 #ifdef CSR_SUPPORT_SME
209 #ifdef CSR_SUPPORT_SME
218 "uf_unregister_netdev: netdev %d - 0x%p\n",
271 unifi_error(priv,
"register_unifi_sdio: invalid device %d\n",
276 down(&Unifi_instance_mutex);
279 unifi_error(priv,
"register_unifi_sdio: device %d is already in use\n",
288 unifi_error(priv,
"Failed to allocate driver private\n");
302 unifi_error(priv,
"Failed to allocate UniFi driver card struct.\n");
306 if (Unifi_instances[bus_id]) {
307 unifi_error(priv,
"Internal error: instance for slot %d is already taken\n",
310 Unifi_instances[bus_id] =
priv;
319 unifi_error(priv,
"Couldn't allocate mini-coredump buffers\n");
337 uf_read_proc, (
void *)(
long)priv->
instance))
339 unifi_error(priv,
"unifi: can't create /proc/driver/unifi\n");
355 unifi_error(priv,
"Failed to allocate driver private for interface[%d]\n",i);
366 Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES +
i] = netdev_priv(priv->
netdev[i]);
377 #ifdef CSR_WIFI_RX_PATH_SPLIT
378 if (signal_buffer_init(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE))
380 unifi_error(priv,
"Failed to allocate shared memory for T-H signals\n");
384 if (priv->rx_workqueue ==
NULL) {
385 unifi_error(priv,
"create_singlethread_workqueue failed \n");
388 INIT_WORK(&priv->rx_work_struct, rx_wq_handler);
391 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
394 uf_register_hip_offline_debug(priv);
416 up(&Unifi_instance_mutex);
422 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
425 uf_unregister_hip_offline_debug(priv);
428 #ifdef CSR_WIFI_RX_PATH_SPLIT
432 signal_buffer_free(priv,CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
442 if (priv && priv->
card) {
450 up(&Unifi_instance_mutex);
512 static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
540 #ifdef CSR_SME_USERSPACE
541 priv->smepriv =
NULL;
544 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
547 uf_unregister_hip_offline_debug(priv);
578 Unifi_netdev_instances[priv->
instance * CSR_WIFI_NUM_INTERFACES +
i] =
NULL;
588 #ifdef CSR_WIFI_RX_PATH_SPLIT
591 signal_buffer_free(priv,CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
626 unregister_unifi_sdio(
int bus_id)
638 priv = Unifi_instances[bus_id];
640 unifi_error(priv,
"unregister_unifi_sdio: device %d is not registered\n",
653 netif_tx_stop_all_queues(priv->
netdev[interfaceTag]);
657 #ifdef CSR_NATIVE_LINUX
668 "csr_sdio_linux_remove_irq failed to talk to card.\n");
690 cleanup_unifi_sdio(priv);
714 return Unifi_instances[inst];
741 if (Unifi_instances[inst] == priv) {
772 if (Unifi_netdev_instances[inst] == priv) {
799 down(&Unifi_instance_mutex);
806 up(&Unifi_instance_mutex);
830 down(&Unifi_instance_mutex);
836 ask_unifi_sdio_cleanup(priv);
840 up(&Unifi_instance_mutex);
862 #ifdef CONFIG_PROC_FS
865 int *eof,
void *
data)
867 #define UNIFI_DEBUG_TXT_BUFFER 8*1024
869 int actual_amount_to_copy;
871 s32 remain = UNIFI_DEBUG_TXT_BUFFER;
888 written =
scnprintf(p, remain,
"UniFi SDIO Driver: %s %s %s\n",
891 #ifdef CSR_SME_USERSPACE
892 written =
scnprintf(p, remain,
"SME: CSR userspace ");
894 #ifdef CSR_SUPPORT_WEXT
895 written =
scnprintf(p, remain,
"with WEXT support\n");
901 #ifdef CSR_NATIVE_LINUX
902 written =
scnprintf(p, remain,
"SME: native\n");
906 #ifdef CSR_SUPPORT_SME
908 "Firmware (ROM) build:%u, Patch:%u\n",
910 priv->sme_versions.firmwarePatch);
915 written =
scnprintf(p, remain,
"Last dbg str: %s\n",
919 written =
scnprintf(p, remain,
"Last dbg16:");
921 for (i = 0; i < 8; i++) {
930 for (; i < 16; i++) {
939 written = UNIFI_DEBUG_TXT_BUFFER - remain;
941 if( offset >= written )
948 if( offset + count > written )
950 actual_amount_to_copy = written -
offset;
955 actual_amount_to_copy =
count;
958 memcpy( page, &(orig_p[offset]), actual_amount_to_copy );
962 return( actual_amount_to_copy );
999 active_slot = bus_id;
1000 os_devices[bus_id] = os_device;
1012 active_slot = bus_id;
1013 os_devices[bus_id] =
NULL;
1022 sdio_ctx, active_slot, os_devices[active_slot]);
1024 priv = register_unifi_sdio(sdio_ctx, active_slot, os_devices[active_slot]);
1039 unregister_unifi_sdio(active_slot);
1071 return uf_sdio_dsr_handler;
1100 .removed = uf_sdio_removed,
1101 .intr = uf_sdio_int_handler,
1102 .suspend = uf_lx_suspend,
1103 .resume = uf_lx_resume,
1106 .idsCount =
sizeof(unifi_ids) /
sizeof(unifi_ids[0])
1133 unifi_error(
NULL,
"Failed to register UniFi SDIO driver: csrResult=%d\n", csrResult);