aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000/linux_wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/wilc1000/linux_wlan.c')
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c1625
1 files changed, 390 insertions, 1235 deletions
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index b3cc9f5c7937..2a5b36fd8b48 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -2,11 +2,6 @@
#include "linux_wlan_common.h"
#include "wilc_wlan_if.h"
#include "wilc_wlan.h"
-#ifdef USE_WIRELESS
-#include "wilc_wfi_cfgoperations.h"
-#endif
-
-#include "linux_wlan_common.h"
#include <linux/slab.h>
#include <linux/sched.h>
@@ -22,9 +17,7 @@
#include <linux/init.h>
#include <linux/netdevice.h>
-#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
#include <linux/inetdevice.h>
-#endif
#include <linux/etherdevice.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -39,17 +32,6 @@
#include "linux_wlan_spi.h"
#endif
-#ifdef WILC_FULLY_HOSTING_AP
-#include "wilc_host_ap.h"
-#endif
-
-#ifdef STATIC_MACADDRESS /* brandy_0724 [[ */
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-struct task_struct *wilc_mac_thread;
-unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2};
-#endif /* brandy_0724 ]] */
-
#if defined(CUSTOMER_PLATFORM)
/*
TODO : Write power control functions as customer platform.
@@ -63,16 +45,10 @@ unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2};
#define _linux_wlan_device_removal() {}
#endif
-#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
extern bool g_obtainingIP;
-#endif
-extern u16 Set_machw_change_vir_if(bool bValue);
extern void resolve_disconnect_aberration(void *drvHandler);
extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
-void wilc1000_wlan_deinit(linux_wlan_t *nic);
-#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
extern struct timer_list hDuringIpTimer;
-#endif
static int linux_wlan_device_power(int on_off)
{
@@ -102,35 +78,11 @@ static int linux_wlan_device_detection(int on_off)
return 0;
}
-#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr);
static struct notifier_block g_dev_notifier = {
.notifier_call = dev_state_ev_handler
};
-#endif
-
-#define wilc_wlan_deinit(nic) { if (&g_linux_wlan->oup != NULL) \
- if (g_linux_wlan->oup.wlan_cleanup != NULL) \
- g_linux_wlan->oup.wlan_cleanup(); }
-
-#ifndef STA_FIRMWARE
-#define STA_FIRMWARE "wifi_firmware.bin"
-#endif
-
-#ifndef AP_FIRMWARE
-#define AP_FIRMWARE "wifi_firmware_ap.bin"
-#endif
-
-#ifndef P2P_CONCURRENCY_FIRMWARE
-#define P2P_CONCURRENCY_FIRMWARE "wifi_firmware_p2p_concurrency.bin"
-#endif
-
-typedef struct android_wifi_priv_cmd {
- char *buf;
- int used_len;
- int total_len;
-} android_wifi_priv_cmd;
#define IRQ_WAIT 1
#define IRQ_NO_WAIT 0
@@ -141,20 +93,13 @@ typedef struct android_wifi_priv_cmd {
* deinitialized from mdoule_exit
*/
static struct semaphore close_exit_sync;
-unsigned int int_rcvdU;
-unsigned int int_rcvdB;
-unsigned int int_clrd;
-
-static int wlan_deinit_locks(linux_wlan_t *nic);
-static void wlan_deinitialize_threads(linux_wlan_t *nic);
-static void linux_wlan_lock(void *vp);
-void linux_wlan_unlock(void *vp);
-extern void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
-extern void WILC_WFI_p2p_rx(struct net_device *dev, uint8_t *buff, uint32_t size);
-
-static void *internal_alloc(uint32_t size, uint32_t flag);
+
+static int wlan_deinit_locks(struct net_device *dev);
+static void wlan_deinitialize_threads(struct net_device *dev);
+extern void WILC_WFI_monitor_rx(u8 *buff, u32 size);
+extern void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size);
+
static void linux_wlan_tx_complete(void *priv, int status);
-void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset);
static int mac_init_fn(struct net_device *ndev);
int mac_xmit(struct sk_buff *skb, struct net_device *dev);
int mac_open(struct net_device *ndev);
@@ -167,8 +112,7 @@ static void wilc_set_multicast_list(struct net_device *dev);
* for now - in frmw_to_linux there should be private data to be passed to it
* and this data should be pointer to net device
*/
-linux_wlan_t *g_linux_wlan;
-wilc_wlan_oup_t *gpstrWlanOps;
+struct wilc *g_linux_wlan;
bool bEnablePS = true;
static const struct net_device_ops wilc_netdev_ops = {
@@ -182,65 +126,11 @@ static const struct net_device_ops wilc_netdev_ops = {
};
-#ifdef DEBUG_MODE
-
-extern volatile int timeNo;
-
-#define DEGUG_BUFFER_LENGTH 1000
-volatile int WatchDogdebuggerCounter;
-char DebugBuffer[DEGUG_BUFFER_LENGTH + 20] = {0};
-static char *ps8current = DebugBuffer;
-
-void printk_later(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- ps8current += vsprintf(ps8current, format, args);
- va_end(args);
- if ((ps8current - DebugBuffer) > DEGUG_BUFFER_LENGTH)
- ps8current = DebugBuffer;
-
-}
-
-void dump_logs(void)
-{
- if (DebugBuffer[0]) {
- DebugBuffer[DEGUG_BUFFER_LENGTH] = 0;
- PRINT_INFO(GENERIC_DBG, "early printed\n");
- PRINT_D(GENERIC_DBG, ps8current + 1);
- ps8current[1] = 0;
- PRINT_INFO(GENERIC_DBG, "latest printed\n");
- PRINT_D(GENERIC_DBG, DebugBuffer);
- DebugBuffer[0] = 0;
- ps8current = DebugBuffer;
- }
-}
-
-void Reset_WatchDogdebugger(void)
-{
- WatchDogdebuggerCounter = 0;
-}
-
-static int DebuggingThreadTask(void *vp)
-{
- while (1) {
- while (!WatchDogdebuggerCounter) {
- PRINT_D(GENERIC_DBG, "Debug Thread Running %d\n", timeNo);
- WatchDogdebuggerCounter = 1;
- msleep(10000);
- }
- dump_logs();
- WatchDogdebuggerCounter = 0;
- }
-}
-#endif
-
-#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr)
{
struct in_ifaddr *dev_iface = (struct in_ifaddr *)ptr;
- struct WILC_WFI_priv *priv;
- tstrWILC_WFIDrv *pstrWFIDrv;
+ struct wilc_priv *priv;
+ struct host_if_drv *pstrWFIDrv;
struct net_device *dev;
u8 *pIP_Add_buff;
perInterface_wlan_t *nic;
@@ -267,7 +157,7 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event
PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
return NOTIFY_DONE;
}
- pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
nic = netdev_priv(dev);
if (nic == NULL || pstrWFIDrv == NULL) {
PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
@@ -334,136 +224,56 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event
return NOTIFY_DONE;
}
-#endif
-
-/*
- * Interrupt initialization and handling functions
- */
-
-void linux_wlan_enable_irq(void)
-{
-
-#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
- PRINT_D(INT_DBG, "Enabling IRQ ...\n");
- enable_irq(g_linux_wlan->dev_irq_num);
-#endif
-#endif
-}
-
-void linux_wlan_disable_irq(int wait)
-{
-#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
- if (wait) {
- PRINT_D(INT_DBG, "Disabling IRQ ...\n");
- disable_irq(g_linux_wlan->dev_irq_num);
- } else {
- PRINT_D(INT_DBG, "Disabling IRQ ...\n");
- disable_irq_nosync(g_linux_wlan->dev_irq_num);
- }
-#endif
-}
#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
static irqreturn_t isr_uh_routine(int irq, void *user_data)
{
- int_rcvdU++;
-#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
- linux_wlan_disable_irq(IRQ_NO_WAIT);
-#endif
+ perInterface_wlan_t *nic;
+ struct wilc *wilc;
+ struct net_device *dev = (struct net_device *)user_data;
+
+ nic = netdev_priv(dev);
+ wilc = nic->wilc;
PRINT_D(INT_DBG, "Interrupt received UH\n");
/*While mac is closing cacncel the handling of any interrupts received*/
- if (g_linux_wlan->close) {
+ if (wilc->close) {
PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n");
- #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
- #else
- return IRQ_NONE;
- #endif
-
}
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- schedule_work(&g_linux_wlan->rx_work_queue);
- return IRQ_HANDLED;
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
- linux_wlan_unlock(&g_linux_wlan->rx_sem);
- return IRQ_HANDLED;
-#elif (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_WAKE_THREAD;
-#endif
-
}
#endif
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE || RX_BH_TYPE == RX_BH_THREADED_IRQ)
-
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
irqreturn_t isr_bh_routine(int irq, void *userdata)
{
- linux_wlan_t *nic;
- nic = (linux_wlan_t *)userdata;
-#else
-static void isr_bh_routine(struct work_struct *work)
-{
perInterface_wlan_t *nic;
- nic = (perInterface_wlan_t *)container_of(work, linux_wlan_t, rx_work_queue);
-#endif
+ struct wilc *wilc;
+
+ nic = netdev_priv(userdata);
+ wilc = nic->wilc;
/*While mac is closing cacncel the handling of any interrupts received*/
- if (g_linux_wlan->close) {
+ if (wilc->close) {
PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n");
- #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
- #else
- return;
- #endif
}
- int_rcvdB++;
PRINT_D(INT_DBG, "Interrupt received BH\n");
- if (g_linux_wlan->oup.wlan_handle_rx_isr != 0)
- g_linux_wlan->oup.wlan_handle_rx_isr();
- else
- PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
+ wilc_handle_isr(wilc);
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
return IRQ_HANDLED;
-#endif
-}
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
-static int isr_bh_routine(void *vp)
-{
- linux_wlan_t *nic;
-
- nic = (linux_wlan_t *)vp;
-
- while (1) {
- linux_wlan_lock(&nic->rx_sem);
- if (g_linux_wlan->close) {
-
- while (!kthread_should_stop())
- schedule();
-
- break;
- }
- int_rcvdB++;
- PRINT_D(INT_DBG, "Interrupt received BH\n");
- if (g_linux_wlan->oup.wlan_handle_rx_isr != 0)
- g_linux_wlan->oup.wlan_handle_rx_isr();
- else
- PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
- }
-
- return 0;
}
-#endif
#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
-static int init_irq(linux_wlan_t *p_nic)
+static int init_irq(struct net_device *dev)
{
int ret = 0;
- linux_wlan_t *nic = p_nic;
+ perInterface_wlan_t *nic;
+ struct wilc *wl;
+
+ nic = netdev_priv(dev);
+ wl = nic->wilc;
/*initialize GPIO and register IRQ num*/
/*GPIO request*/
@@ -475,49 +285,42 @@ static int init_irq(linux_wlan_t *p_nic)
*
* ex) nic->dev_irq_num = gpio_to_irq(GPIO_NUM);
*/
-#elif defined(NM73131_0_BOARD)
- nic->dev_irq_num = IRQ_WILC1000;
-#elif defined(PANDA_BOARD)
- gpio_export(GPIO_NUM, 1);
- nic->dev_irq_num = OMAP_GPIO_IRQ(GPIO_NUM);
- irq_set_irq_type(nic->dev_irq_num, IRQ_TYPE_LEVEL_LOW);
#else
- nic->dev_irq_num = gpio_to_irq(GPIO_NUM);
+ wl->dev_irq_num = gpio_to_irq(GPIO_NUM);
#endif
} else {
ret = -1;
PRINT_ER("could not obtain gpio for WILC_INTR\n");
}
-#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
- if ((ret != -1) && (request_threaded_irq(nic->dev_irq_num, isr_uh_routine, isr_bh_routine,
+ if ((ret != -1) && (request_threaded_irq(wl->dev_irq_num, isr_uh_routine, isr_bh_routine,
IRQF_TRIGGER_LOW | IRQF_ONESHOT, /*Without IRQF_ONESHOT the uh will remain kicked in and dont gave a chance to bh*/
- "WILC_IRQ", nic)) < 0) {
-
-#else
- /*Request IRQ*/
- if ((ret != -1) && (request_irq(nic->dev_irq_num, isr_uh_routine,
- IRQF_TRIGGER_LOW, "WILC_IRQ", nic) < 0)) {
+ "WILC_IRQ", dev)) < 0) {
-#endif
PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM);
ret = -1;
} else {
PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
- nic->dev_irq_num, GPIO_NUM);
+ wl->dev_irq_num, GPIO_NUM);
}
return ret;
}
#endif
-static void deinit_irq(linux_wlan_t *nic)
+static void deinit_irq(struct net_device *dev)
{
+ perInterface_wlan_t *nic;
+ struct wilc *wilc;
+
+ nic = netdev_priv(dev);
+ wilc = nic->wilc;
+
#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
/* Deintialize IRQ */
- if (&nic->dev_irq_num != 0) {
- free_irq(nic->dev_irq_num, g_linux_wlan);
+ if (&wilc->dev_irq_num != 0) {
+ free_irq(wilc->dev_irq_num, wilc);
gpio_free(GPIO_NUM);
}
@@ -527,83 +330,15 @@ static void deinit_irq(linux_wlan_t *nic)
/*
* OS functions
*/
-static void linux_wlan_msleep(uint32_t msc)
-{
- if (msc <= 4000000) {
- u32 u32Temp = msc * 1000;
- usleep_range(u32Temp, u32Temp);
- } else {
- msleep(msc);
- }
-}
-
-static void linux_wlan_atomic_msleep(uint32_t msc)
-{
- mdelay(msc);
-}
-static void linux_wlan_dbg(uint8_t *buff)
+void linux_wlan_dbg(u8 *buff)
{
PRINT_D(INIT_DBG, "%d\n", *buff);
}
-static void *linux_wlan_malloc_atomic(uint32_t sz)
-{
- char *pntr = NULL;
- pntr = kmalloc(sz, GFP_ATOMIC);
- PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
- return (void *)pntr;
-
-}
-static void *linux_wlan_malloc(uint32_t sz)
-{
- char *pntr = NULL;
- pntr = kmalloc(sz, GFP_KERNEL);
- PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
- return (void *)pntr;
-}
-
-void linux_wlan_free(void *vp)
-{
- if (vp != NULL) {
- PRINT_D(MEM_DBG, "Freeing %p\n", vp);
- kfree(vp);
- }
-}
-
-static void *internal_alloc(uint32_t size, uint32_t flag)
-{
- char *pntr = NULL;
- pntr = kmalloc(size, flag);
- PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr);
- return (void *)pntr;
-}
-
-static void linux_wlan_init_lock(char *lockName, void *plock, int count)
-{
- sema_init((struct semaphore *)plock, count);
- PRINT_D(LOCK_DBG, "Initializing [%s][%p]\n", lockName, plock);
-
-}
-
-static void linux_wlan_deinit_lock(void *plock)
-{
- /* mutex_destroy((struct mutex*)plock); */
-}
-
-static void linux_wlan_lock(void *vp)
-{
- PRINT_D(LOCK_DBG, "Locking %p\n", vp);
- if (vp != NULL) {
- while (down_interruptible((struct semaphore *) vp))
- ;
- } else {
- PRINT_ER("Failed, mutex is NULL\n");
- }
-}
-
-static int linux_wlan_lock_timeout(void *vp, u32 timeout)
+int linux_wlan_lock_timeout(void *vp, u32 timeout)
{
int error = -1;
+
PRINT_D(LOCK_DBG, "Locking %p\n", vp);
if (vp != NULL)
error = down_timeout((struct semaphore *)vp, msecs_to_jiffies(timeout));
@@ -612,113 +347,23 @@ static int linux_wlan_lock_timeout(void *vp, u32 timeout)
return error;
}
-void linux_wlan_unlock(void *vp)
-{
- PRINT_D(LOCK_DBG, "Unlocking %p\n", vp);
- if (vp != NULL)
- up((struct semaphore *)vp);
- else
- PRINT_ER("Failed, mutex is NULL\n");
-}
-
-static void linux_wlan_init_mutex(char *lockName, void *plock, int count)
-{
- mutex_init((struct mutex *)plock);
- PRINT_D(LOCK_DBG, "Initializing mutex [%s][%p]\n", lockName, plock);
-
-}
-
-static void linux_wlan_deinit_mutex(void *plock)
-{
- mutex_destroy((struct mutex *)plock);
-}
-
-static void linux_wlan_lock_mutex(void *vp)
-{
- PRINT_D(LOCK_DBG, "Locking mutex %p\n", vp);
- if (vp != NULL) {
- /*
- * if(mutex_is_locked((struct mutex*)vp))
- * {
- * //PRINT_ER("Mutex already locked - %p \n",vp);
- * }
- */
- mutex_lock((struct mutex *)vp);
-
- } else {
- PRINT_ER("Failed, mutex is NULL\n");
- }
-}
-
-static void linux_wlan_unlock_mutex(void *vp)
-{
- PRINT_D(LOCK_DBG, "Unlocking mutex %p\n", vp);
- if (vp != NULL) {
-
- if (mutex_is_locked((struct mutex *)vp)) {
- mutex_unlock((struct mutex *)vp);
- } else {
- /* PRINT_ER("Mutex already unlocked - %p\n",vp); */
- }
-
- } else {
- PRINT_ER("Failed, mutex is NULL\n");
- }
-}
-
-/*Added by Amr - BugID_4720*/
-static void linux_wlan_init_spin_lock(char *lockName, void *plock, int count)
-{
- spin_lock_init((spinlock_t *)plock);
- PRINT_D(SPIN_DEBUG, "Initializing mutex [%s][%p]\n", lockName, plock);
-
-}
-
-static void linux_wlan_deinit_spin_lock(void *plock)
-{
-
-}
-static void linux_wlan_spin_lock(void *vp, unsigned long *flags)
-{
- unsigned long lflags;
- PRINT_D(SPIN_DEBUG, "Lock spin %p\n", vp);
- if (vp != NULL) {
- spin_lock_irqsave((spinlock_t *)vp, lflags);
- *flags = lflags;
- } else {
- PRINT_ER("Failed, spin lock is NULL\n");
- }
-}
-static void linux_wlan_spin_unlock(void *vp, unsigned long *flags)
-{
- unsigned long lflags = *flags;
- PRINT_D(SPIN_DEBUG, "Unlock spin %p\n", vp);
- if (vp != NULL) {
- spin_unlock_irqrestore((spinlock_t *)vp, lflags);
- *flags = lflags;
- } else {
- PRINT_ER("Failed, spin lock is NULL\n");
- }
-}
-
-static void linux_wlan_mac_indicate(int flag)
+void linux_wlan_mac_indicate(struct wilc *wilc, int flag)
{
/*I have to do it that way becuase there is no mean to encapsulate device pointer
* as a parameter
*/
- linux_wlan_t *pd = g_linux_wlan;
int status;
if (flag == WILC_MAC_INDICATE_STATUS) {
- pd->oup.wlan_cfg_get_value(WID_STATUS, (unsigned char *)&status, 4);
- if (pd->mac_status == WILC_MAC_STATUS_INIT) {
- pd->mac_status = status;
- linux_wlan_unlock(&pd->sync_event);
+ wilc_wlan_cfg_get_val(WID_STATUS, (unsigned char *)&status, 4);
+ if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
+ wilc->mac_status = status;
+ up(&wilc->sync_event);
} else {
- pd->mac_status = status;
+ wilc->mac_status = status;
}
- if (pd->mac_status == WILC_MAC_STATUS_CONNECT) { /* Connect */
+ if (wilc->mac_status == WILC_MAC_STATUS_CONNECT) { /* Connect */
}
} else if (flag == WILC_MAC_INDICATE_SCAN) {
@@ -728,92 +373,65 @@ static void linux_wlan_mac_indicate(int flag)
}
-struct net_device *GetIfHandler(uint8_t *pMacHeader)
+struct net_device *GetIfHandler(struct wilc *wilc, u8 *pMacHeader)
{
- uint8_t *Bssid, *Bssid1;
+ u8 *Bssid, *Bssid1;
int i = 0;
Bssid = pMacHeader + 10;
Bssid1 = pMacHeader + 4;
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) ||
- !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) {
- return g_linux_wlan->strInterfaceInfo[i].wilc_netdev;
- }
- }
+ for (i = 0; i < wilc->vif_num; i++)
+ if (!memcmp(Bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
+ !memcmp(Bssid, wilc->vif[i].bssid, ETH_ALEN))
+ return wilc->vif[i].ndev;
+
PRINT_INFO(INIT_DBG, "Invalide handle\n");
for (i = 0; i < 25; i++)
PRINT_D(INIT_DBG, "%02x ", pMacHeader[i]);
Bssid = pMacHeader + 18;
Bssid1 = pMacHeader + 12;
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) ||
- !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) {
- PRINT_D(INIT_DBG, "Ctx [%p]\n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- return g_linux_wlan->strInterfaceInfo[i].wilc_netdev;
- }
- }
+ for (i = 0; i < wilc->vif_num; i++)
+ if (!memcmp(Bssid1, wilc->vif[i].bssid, ETH_ALEN) ||
+ !memcmp(Bssid, wilc->vif[i].bssid, ETH_ALEN))
+ return wilc->vif[i].ndev;
+
PRINT_INFO(INIT_DBG, "\n");
return NULL;
}
-int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID)
+int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID)
{
int i = 0;
int ret = -1;
+ perInterface_wlan_t *nic;
+ struct wilc *wilc;
- PRINT_D(INIT_DBG, "set bssid on[%p]\n", wilc_netdev);
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev == wilc_netdev) {
- PRINT_D(INIT_DBG, "set bssid [%x][%x][%x]\n", pBSSID[0], pBSSID[1], pBSSID[2]);
- memcpy(g_linux_wlan->strInterfaceInfo[i].aBSSID, pBSSID, 6);
+ nic = netdev_priv(wilc_netdev);
+ wilc = nic->wilc;
+
+ for (i = 0; i < wilc->vif_num; i++)
+ if (wilc->vif[i].ndev == wilc_netdev) {
+ memcpy(wilc->vif[i].bssid, pBSSID, 6);
ret = 0;
break;
}
- }
+
return ret;
}
-/*BugID_5213*/
/*Function to get number of connected interfaces*/
int linux_wlan_get_num_conn_ifcs(void)
{
- uint8_t i = 0;
- uint8_t null_bssid[6] = {0};
- uint8_t ret_val = 0;
+ u8 i = 0;
+ u8 null_bssid[6] = {0};
+ u8 ret_val = 0;
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- if (memcmp(g_linux_wlan->strInterfaceInfo[i].aBSSID, null_bssid, 6))
+ for (i = 0; i < g_linux_wlan->vif_num; i++)
+ if (memcmp(g_linux_wlan->vif[i].bssid, null_bssid, 6))
ret_val++;
- }
- return ret_val;
-}
-
-static int linux_wlan_rxq_task(void *vp)
-{
-
- /* inform wilc1000_wlan_init that RXQ task is started. */
- linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
- while (1) {
- linux_wlan_lock(&g_linux_wlan->rxq_event);
- /* wait_for_completion(&g_linux_wlan->rxq_event); */
-
- if (g_linux_wlan->close) {
- /*Unlock the mutex in the mac_close function to indicate the exiting of the RX thread */
- linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
- while (!kthread_should_stop())
- schedule();
-
- PRINT_D(RX_DBG, " RX thread stopped\n");
- break;
- }
- PRINT_D(RX_DBG, "Calling wlan_handle_rx_que()\n");
-
- g_linux_wlan->oup.wlan_handle_rx_que();
- }
- return 0;
+ return ret_val;
}
#define USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
@@ -821,7 +439,9 @@ static int linux_wlan_rxq_task(void *vp)
static int linux_wlan_txq_task(void *vp)
{
int ret, txq_count;
-
+ perInterface_wlan_t *nic;
+ struct wilc *wl;
+ struct net_device *dev = vp;
#if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
#define TX_BACKOFF_WEIGHT_INCR_STEP (1)
#define TX_BACKOFF_WEIGHT_DECR_STEP (1)
@@ -831,18 +451,21 @@ static int linux_wlan_txq_task(void *vp)
int backoff_weight = TX_BACKOFF_WEIGHT_MIN;
#endif
+ nic = netdev_priv(dev);
+ wl = nic->wilc;
+
/* inform wilc1000_wlan_init that TXQ task is started. */
- linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+ up(&wl->txq_thread_started);
while (1) {
PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
- linux_wlan_lock(&g_linux_wlan->txq_event);
+ down(&wl->txq_event);
/* wait_for_completion(&pd->txq_event); */
PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
- if (g_linux_wlan->close) {
+ if (wl->close) {
/*Unlock the mutex in the mac_close function to indicate the exiting of the TX thread */
- linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+ up(&wl->txq_thread_started);
while (!kthread_should_stop())
schedule();
@@ -852,17 +475,17 @@ static int linux_wlan_txq_task(void *vp)
}
PRINT_D(TX_DBG, "txq_task handle the sending packet and let me go to sleep.\n");
#if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
- g_linux_wlan->oup.wlan_handle_tx_que();
+ ret = wilc_wlan_handle_txq(dev, &txq_count);
#else
do {
- ret = g_linux_wlan->oup.wlan_handle_tx_que(&txq_count);
+ ret = wilc_wlan_handle_txq(dev, &txq_count);
if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && netif_queue_stopped(pd->wilc_netdev)*/) {
PRINT_D(TX_DBG, "Waking up queue\n");
/* netif_wake_queue(pd->wilc_netdev); */
- if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[0].wilc_netdev))
- netif_wake_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev);
- if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[1].wilc_netdev))
- netif_wake_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev);
+ if (netif_queue_stopped(wl->vif[0].ndev))
+ netif_wake_queue(wl->vif[0].ndev);
+ if (netif_queue_stopped(wl->vif[1].ndev))
+ netif_wake_queue(wl->vif[1].ndev);
}
if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate buffers in chip. */
@@ -884,13 +507,13 @@ static int linux_wlan_txq_task(void *vp)
}
}
/*TODO: drop packets after a certain time/number of retry count. */
- } while (ret == WILC_TX_ERR_NO_BUF && !g_linux_wlan->close); /* retry sending packets if no more buffers in chip. */
+ } while (ret == WILC_TX_ERR_NO_BUF && !wl->close); /* retry sending packets if no more buffers in chip. */
#endif
}
return 0;
}
-static void linux_wlan_rx_complete(void)
+void linux_wlan_rx_complete(void)
{
PRINT_D(RX_DBG, "RX completed\n");
}
@@ -908,7 +531,6 @@ int linux_wlan_get_firmware(perInterface_wlan_t *p_nic)
else if (nic->iftype == STATION_MODE)
firmware = STA_FIRMWARE;
- /*BugID_5137*/
else {
PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n");
firmware = P2P_CONCURRENCY_FIRMWARE;
@@ -940,7 +562,7 @@ int linux_wlan_get_firmware(perInterface_wlan_t *p_nic)
goto _fail_;
}
#endif
- g_linux_wlan->wilc_firmware = wilc_firmware; /* Bug 4703 */
+ g_linux_wlan->firmware = wilc_firmware;
_fail_:
@@ -948,17 +570,13 @@ _fail_:
}
-#ifdef COMPLEMENT_BOOT
-int repeat_power_cycle(perInterface_wlan_t *nic);
-#endif
-
static int linux_wlan_start_firmware(perInterface_wlan_t *nic)
{
int ret = 0;
/* start firmware */
PRINT_D(INIT_DBG, "Starting Firmware ...\n");
- ret = g_linux_wlan->oup.wlan_start();
+ ret = wilc_wlan_start();
if (ret < 0) {
PRINT_ER("Failed to start Firmware\n");
goto _fail_;
@@ -968,18 +586,6 @@ static int linux_wlan_start_firmware(perInterface_wlan_t *nic)
PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n");
ret = linux_wlan_lock_timeout(&g_linux_wlan->sync_event, 5000);
if (ret) {
-#ifdef COMPLEMENT_BOOT
- static int timeout = 5;
-
- if (timeout--) {
- PRINT_D(INIT_DBG, "repeat power cycle[%d]", timeout);
- ret = repeat_power_cycle(nic);
- } else {
- timeout = 5;
- ret = -1;
- goto _fail_;
- }
-#endif
PRINT_D(INIT_DBG, "Firmware start timed out");
goto _fail_;
}
@@ -992,12 +598,12 @@ static int linux_wlan_start_firmware(perInterface_wlan_t *nic)
_fail_:
return ret;
}
-static int linux_wlan_firmware_download(linux_wlan_t *p_nic)
+static int linux_wlan_firmware_download(struct wilc *p_nic)
{
int ret = 0;
- if (g_linux_wlan->wilc_firmware == NULL) {
+ if (!g_linux_wlan->firmware) {
PRINT_ER("Firmware buffer is NULL\n");
ret = -ENOBUFS;
goto _FAIL_;
@@ -1006,15 +612,15 @@ static int linux_wlan_firmware_download(linux_wlan_t *p_nic)
* do the firmware download
**/
PRINT_D(INIT_DBG, "Downloading Firmware ...\n");
- ret = g_linux_wlan->oup.wlan_firmware_download(g_linux_wlan->wilc_firmware->data, g_linux_wlan->wilc_firmware->size);
+ ret = wilc_wlan_firmware_download(g_linux_wlan->firmware->data,
+ g_linux_wlan->firmware->size);
if (ret < 0)
goto _FAIL_;
/* Freeing FW buffer */
PRINT_D(INIT_DBG, "Freeing FW buffer ...\n");
PRINT_D(INIT_DBG, "Releasing firmware\n");
- release_firmware(g_linux_wlan->wilc_firmware);
- g_linux_wlan->wilc_firmware = NULL;
+ release_firmware(g_linux_wlan->firmware);
PRINT_D(INIT_DBG, "Download Succeeded\n");
@@ -1023,90 +629,74 @@ _FAIL_:
}
/* startup configuration - could be changed later using iconfig*/
-static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_nic)
+static int linux_wlan_init_test_config(struct net_device *dev, struct wilc *p_nic)
{
unsigned char c_val[64];
- #ifndef STATIC_MACADDRESS
unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff};
- #endif
- /*BugID_5077*/
- struct WILC_WFI_priv *priv;
- tstrWILC_WFIDrv *pstrWFIDrv;
+ struct wilc_priv *priv;
+ struct host_if_drv *pstrWFIDrv;
PRINT_D(TX_DBG, "Start configuring Firmware\n");
- #ifndef STATIC_MACADDRESS
get_random_bytes(&mac_add[5], 1);
get_random_bytes(&mac_add[4], 1);
- #endif
priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
- pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
PRINT_D(INIT_DBG, "Host = %p\n", pstrWFIDrv);
PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]);
wilc_get_chipid(0);
- if (g_linux_wlan->oup.wlan_cfg_set == NULL) {
- PRINT_D(INIT_DBG, "Null p[ointer\n");
- goto _fail_;
- }
-
- *(int *)c_val = (u32)pstrWFIDrv;
+ *(int *)c_val = 1;
- if (!g_linux_wlan->oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
goto _fail_;
/*to tell fw that we are going to use PC test - WILC specific*/
c_val[0] = 0;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = INFRASTRUCTURE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0))
goto _fail_;
- /* c_val[0] = RATE_AUTO; / * bug 4275: Enable autorate and limit it to 24Mbps * / */
+ /* c_val[0] = RATE_AUTO; */
c_val[0] = RATE_AUTO;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = G_MIXED_11B_2_MODE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 1;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = G_SHORT_PREAMBLE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = AUTO_PROT;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
goto _fail_;
-#ifdef SWITCH_LOG_TERMINAL
- c_val[0] = AUTO_PROT;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LOGTerminal_Switch, c_val, 1, 0, 0))
- goto _fail_;
-#endif
-
c_val[0] = ACTIVE_SCAN;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = SITE_SURVEY_OFF;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0))
goto _fail_;
*((int *)c_val) = 0xffff; /* Never use RTS-CTS */
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
goto _fail_;
*((int *)c_val) = 2346;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
goto _fail_;
/* SSID */
@@ -1116,30 +706,24 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* ( In BSS Station Set SSID to "" (null string) */
/* to enable Broadcast SSID suppport ) */
/* -------------------------------------------------------------- */
-#ifndef USE_WIRELESS
- strcpy(c_val, "nwifi");
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SSID, c_val, (strlen(c_val) + 1), 0, 0))
- goto _fail_;
-#endif
-
c_val[0] = 0;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 1;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = NO_POWERSAVE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = NO_ENCRYPT; /* NO_ENCRYPT, 0x79 */
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = OPEN_SYSTEM;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0))
goto _fail_;
/* WEP/802 11I Configuration */
@@ -1151,7 +735,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* ------------------------------------------------------------------ */
strcpy(c_val, "123456790abcdef1234567890");
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0))
goto _fail_;
/* WEP/802 11I Configuration */
@@ -1161,7 +745,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* and less than 64 bytes */
/* ------------------------------------------------------------------ */
strcpy(c_val, "12345678");
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0))
goto _fail_;
/* IEEE802.1X Key Configuration */
@@ -1171,7 +755,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* and less than 65 bytes */
/* ------------------------------------------------------------------ */
strcpy(c_val, "password");
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0))
goto _fail_;
/* IEEE802.1X Server Address Configuration */
@@ -1183,31 +767,31 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
c_val[1] = 168;
c_val[2] = 1;
c_val[3] = 112;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
goto _fail_;
c_val[0] = 3;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 3;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = NORMAL_ACK;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 0;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 48;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 28;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0))
goto _fail_;
/* Beacon Interval */
@@ -1217,11 +801,11 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* -------------------------------------------------------------------- */
*((int *)c_val) = 100;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
goto _fail_;
c_val[0] = REKEY_DISABLE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0))
goto _fail_;
/* Rekey Time (s) (Used only when the Rekey policy is 2 or 4) */
@@ -1230,7 +814,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* Values to set : 32-bit value */
/* -------------------------------------------------------------------- */
*((int *)c_val) = 84600;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
goto _fail_;
/* Rekey Packet Count (in 1000s; used when Rekey Policy is 3) */
@@ -1239,59 +823,59 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
/* Values to set : 32-bit Value */
/* -------------------------------------------------------------------- */
*((int *)c_val) = 500;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0))
goto _fail_;
c_val[0] = 1;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = G_SELF_CTS_PROT;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 1; /* Enable N */
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = HT_MIXED_MODE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 1; /* TXOP Prot disable in N mode: No RTS-CTS on TX A-MPDUs to save air-time. */
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0))
goto _fail_;
memcpy(c_val, mac_add, 6);
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0))
goto _fail_;
/**
* AP only
**/
c_val[0] = DETECT_PROTECT_REPORT;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = RTS_CTS_NONHT_PROT;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 0;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = MIMO_MODE;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 7;
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0))
+ if (!wilc_wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0))
goto _fail_;
c_val[0] = 1; /* Enable N with immediate block ack. */
- if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (u32)pstrWFIDrv))
+ if (!wilc_wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, 1))
goto _fail_;
return 0;
@@ -1301,17 +885,21 @@ _fail_:
}
/**************************/
-void wilc1000_wlan_deinit(linux_wlan_t *nic)
+void wilc1000_wlan_deinit(struct net_device *dev)
{
+ perInterface_wlan_t *nic;
+ struct wilc *wl;
- if (g_linux_wlan->wilc1000_initialized) {
+ nic = netdev_priv(dev);
+ wl = nic->wilc;
- printk("Deinitializing wilc1000 ...\n");
+ if (!wl) {
+ netdev_err(dev, "wl is NULL\n");
+ return;
+ }
- if (nic == NULL) {
- PRINT_ER("nic is NULL\n");
- return;
- }
+ if (wl->initialized) {
+ netdev_info(dev, "Deinitializing wilc1000...\n");
#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
/* johnny : remove */
@@ -1321,64 +909,40 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic)
#endif
PRINT_D(INIT_DBG, "Disabling IRQ\n");
- #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- linux_wlan_disable_irq(IRQ_WAIT);
- #else
- #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
-
- #else
- linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs);
+#ifdef WILC_SDIO
+ mutex_lock(&wl->hif_cs);
disable_sdio_interrupt();
- linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs);
- #endif
- #endif
-
- /* not sure if the following unlocks are needed or not*/
- if (&g_linux_wlan->rxq_event != NULL)
- linux_wlan_unlock(&g_linux_wlan->rxq_event);
-
- if (&g_linux_wlan->txq_event != NULL)
- linux_wlan_unlock(&g_linux_wlan->txq_event);
-
- #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- /*Removing the work struct from the linux kernel workqueue*/
- if (&g_linux_wlan->rx_work_queue != NULL)
- flush_work(&g_linux_wlan->rx_work_queue);
-
- #elif (RX_BH_TYPE == RX_BH_KTHREAD)
- /* if(&nic->rx_sem != NULL) */
- /* linux_wlan_unlock(&nic->rx_sem); */
- #endif
+ mutex_unlock(&wl->hif_cs);
+#endif
+ if (&wl->txq_event != NULL)
+ up(&wl->txq_event);
PRINT_D(INIT_DBG, "Deinitializing Threads\n");
- wlan_deinitialize_threads(nic);
+ wlan_deinitialize_threads(dev);
PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
- deinit_irq(g_linux_wlan);
+ deinit_irq(dev);
- if (&g_linux_wlan->oup != NULL) {
- if (g_linux_wlan->oup.wlan_stop != NULL)
- g_linux_wlan->oup.wlan_stop();
- }
+ wilc_wlan_stop();
PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
- wilc_wlan_deinit(nic);
+ wilc_wlan_cleanup(dev);
#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
- linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs);
+ mutex_lock(&wl->hif_cs);
disable_sdio_interrupt();
- linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs);
+ mutex_unlock(&wl->hif_cs);
#endif
#endif
/*De-Initialize locks*/
PRINT_D(INIT_DBG, "Deinitializing Locks\n");
- wlan_deinit_locks(g_linux_wlan);
+ wlan_deinit_locks(dev);
/* announce that wilc1000 is not initialized */
- g_linux_wlan->wilc1000_initialized = 0;
+ wl->initialized = false;
PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n");
@@ -1387,120 +951,56 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic)
}
}
-int wlan_init_locks(linux_wlan_t *p_nic)
+int wlan_init_locks(struct net_device *dev)
{
+ perInterface_wlan_t *nic;
+ struct wilc *wl;
- PRINT_D(INIT_DBG, "Initializing Locks ...\n");
-
- /*initialize mutexes*/
- linux_wlan_init_mutex("hif_lock/hif_cs", &g_linux_wlan->hif_cs, 1);
- linux_wlan_init_mutex("rxq_lock/rxq_cs", &g_linux_wlan->rxq_cs, 1);
- linux_wlan_init_mutex("txq_lock/txq_cs", &g_linux_wlan->txq_cs, 1);
+ nic = netdev_priv(dev);
+ wl = nic->wilc;
- /*Added by Amr - BugID_4720*/
- linux_wlan_init_spin_lock("txq_spin_lock/txq_cs", &g_linux_wlan->txq_spinlock, 1);
+ PRINT_D(INIT_DBG, "Initializing Locks ...\n");
- /*Added by Amr - BugID_4720*/
- linux_wlan_init_lock("txq_add_to_head_lock/txq_cs", &g_linux_wlan->txq_add_to_head_cs, 1);
+ mutex_init(&wl->hif_cs);
+ mutex_init(&wl->rxq_cs);
- linux_wlan_init_lock("txq_wait/txq_event", &g_linux_wlan->txq_event, 0);
- linux_wlan_init_lock("rxq_wait/rxq_event", &g_linux_wlan->rxq_event, 0);
+ spin_lock_init(&wl->txq_spinlock);
+ sema_init(&wl->txq_add_to_head_cs, 1);
- linux_wlan_init_lock("cfg_wait/cfg_event", &g_linux_wlan->cfg_event, 0);
- linux_wlan_init_lock("sync_event", &g_linux_wlan->sync_event, 0);
+ sema_init(&wl->txq_event, 0);
- linux_wlan_init_lock("rxq_lock/rxq_started", &g_linux_wlan->rxq_thread_started, 0);
- linux_wlan_init_lock("rxq_lock/txq_started", &g_linux_wlan->txq_thread_started, 0);
+ sema_init(&wl->cfg_event, 0);
+ sema_init(&wl->sync_event, 0);
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- linux_wlan_init_lock("BH_SEM", &g_linux_wlan->rx_sem, 0);
- #endif
+ sema_init(&wl->txq_thread_started, 0);
return 0;
}
-static int wlan_deinit_locks(linux_wlan_t *nic)
+static int wlan_deinit_locks(struct net_device *dev)
{
- PRINT_D(INIT_DBG, "De-Initializing Locks\n");
-
- if (&g_linux_wlan->hif_cs != NULL)
- linux_wlan_deinit_mutex(&g_linux_wlan->hif_cs);
-
- if (&g_linux_wlan->rxq_cs != NULL)
- linux_wlan_deinit_mutex(&g_linux_wlan->rxq_cs);
-
- if (&g_linux_wlan->txq_cs != NULL)
- linux_wlan_deinit_mutex(&g_linux_wlan->txq_cs);
-
- /*Added by Amr - BugID_4720*/
- if (&g_linux_wlan->txq_spinlock != NULL)
- linux_wlan_deinit_spin_lock(&g_linux_wlan->txq_spinlock);
-
- if (&g_linux_wlan->rxq_event != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->rxq_event);
-
- if (&g_linux_wlan->txq_event != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->txq_event);
-
- /*Added by Amr - BugID_4720*/
- if (&g_linux_wlan->txq_add_to_head_cs != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->txq_add_to_head_cs);
+ perInterface_wlan_t *nic;
+ struct wilc *wilc;
- if (&g_linux_wlan->rxq_thread_started != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->rxq_thread_started);
+ nic = netdev_priv(dev);
+ wilc = nic->wilc;
- if (&g_linux_wlan->txq_thread_started != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->txq_thread_started);
+ PRINT_D(INIT_DBG, "De-Initializing Locks\n");
- if (&g_linux_wlan->cfg_event != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->cfg_event);
+ if (&wilc->hif_cs != NULL)
+ mutex_destroy(&wilc->hif_cs);
- if (&g_linux_wlan->sync_event != NULL)
- linux_wlan_deinit_lock(&g_linux_wlan->sync_event);
+ if (&wilc->rxq_cs != NULL)
+ mutex_destroy(&wilc->rxq_cs);
return 0;
}
-void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic)
+void linux_to_wlan(wilc_wlan_inp_t *nwi, struct wilc *nic)
{
PRINT_D(INIT_DBG, "Linux to Wlan services ...\n");
- nwi->os_context.hif_critical_section = (void *)&g_linux_wlan->hif_cs;
nwi->os_context.os_private = (void *)nic;
- nwi->os_context.tx_buffer_size = LINUX_TX_SIZE;
- nwi->os_context.txq_critical_section = (void *)&g_linux_wlan->txq_cs;
-
- /*Added by Amr - BugID_4720*/
- nwi->os_context.txq_add_to_head_critical_section = (void *)&g_linux_wlan->txq_add_to_head_cs;
-
- /*Added by Amr - BugID_4720*/
- nwi->os_context.txq_spin_lock = (void *)&g_linux_wlan->txq_spinlock;
-
- nwi->os_context.txq_wait_event = (void *)&g_linux_wlan->txq_event;
-
-#if defined(MEMORY_STATIC)
- nwi->os_context.rx_buffer_size = LINUX_RX_SIZE;
-#endif
- nwi->os_context.rxq_critical_section = (void *)&g_linux_wlan->rxq_cs;
- nwi->os_context.rxq_wait_event = (void *)&g_linux_wlan->rxq_event;
- nwi->os_context.cfg_wait_event = (void *)&g_linux_wlan->cfg_event;
-
- nwi->os_func.os_sleep = linux_wlan_msleep;
- nwi->os_func.os_atomic_sleep = linux_wlan_atomic_msleep;
- nwi->os_func.os_debug = linux_wlan_dbg;
- nwi->os_func.os_malloc = linux_wlan_malloc;
- nwi->os_func.os_malloc_atomic = linux_wlan_malloc_atomic;
- nwi->os_func.os_free = linux_wlan_free;
- nwi->os_func.os_lock = linux_wlan_lock;
- nwi->os_func.os_unlock = linux_wlan_unlock;
- nwi->os_func.os_wait = linux_wlan_lock_timeout;
- nwi->os_func.os_signal = linux_wlan_unlock;
- nwi->os_func.os_enter_cs = linux_wlan_lock_mutex;
- nwi->os_func.os_leave_cs = linux_wlan_unlock_mutex;
-
- /*Added by Amr - BugID_4720*/
- nwi->os_func.os_spin_lock = linux_wlan_spin_lock;
- nwi->os_func.os_spin_unlock = linux_wlan_spin_unlock;
#ifdef WILC_SDIO
nwi->io_func.io_type = HIF_SDIO;
@@ -1519,331 +1019,95 @@ void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic)
nwi->io_func.u.spi.spi_trx = linux_spi_write_read;
nwi->io_func.u.spi.spi_max_speed = linux_spi_set_max_speed;
#endif
-
- /*for now - to be revised*/
- #ifdef WILC_FULLY_HOSTING_AP
- /* incase of Fully hosted AP, all non cfg pkts are processed here*/
- nwi->net_func.rx_indicate = WILC_Process_rx_frame;
- #else
- nwi->net_func.rx_indicate = frmw_to_linux;
- #endif
- nwi->net_func.rx_complete = linux_wlan_rx_complete;
- nwi->indicate_func.mac_indicate = linux_wlan_mac_indicate;
}
-int wlan_initialize_threads(perInterface_wlan_t *nic)
+int wlan_initialize_threads(struct net_device *dev)
{
-
+ perInterface_wlan_t *nic;
+ struct wilc *wilc;
int ret = 0;
- PRINT_D(INIT_DBG, "Initializing Threads ...\n");
-
-#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
- /*Initialize rx work queue task*/
- INIT_WORK(&g_linux_wlan->rx_work_queue, isr_bh_routine);
-#elif (RX_BH_TYPE == RX_BH_KTHREAD)
- PRINT_D(INIT_DBG, "Creating kthread for Rxq BH\n");
- g_linux_wlan->rx_bh_thread = kthread_run(isr_bh_routine, (void *)g_linux_wlan, "K_RXQ_BH");
- if (g_linux_wlan->rx_bh_thread == 0) {
- PRINT_ER("couldn't create RX BH thread\n");
- ret = -ENOBUFS;
- goto _fail_;
- }
-#endif
-
-#ifndef TCP_ENHANCEMENTS
- /* create rx task */
- PRINT_D(INIT_DBG, "Creating kthread for reception\n");
- g_linux_wlan->rxq_thread = kthread_run(linux_wlan_rxq_task, (void *)g_linux_wlan, "K_RXQ_TASK");
- if (g_linux_wlan->rxq_thread == 0) {
- PRINT_ER("couldn't create RXQ thread\n");
- ret = -ENOBUFS;
- goto _fail_1;
- }
- /* wait for RXQ task to start. */
- linux_wlan_lock(&g_linux_wlan->rxq_thread_started);
+ nic = netdev_priv(dev);
+ wilc = nic->wilc;
-#endif
+ PRINT_D(INIT_DBG, "Initializing Threads ...\n");
/* create tx task */
PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
- g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void *)g_linux_wlan, "K_TXQ_TASK");
- if (g_linux_wlan->txq_thread == 0) {
- PRINT_ER("couldn't create TXQ thread\n");
- ret = -ENOBUFS;
- goto _fail_2;
- }
-#ifdef DEBUG_MODE
- PRINT_D(INIT_DBG, "Creating kthread for Debugging\n");
- g_linux_wlan->txq_thread = kthread_run(DebuggingThreadTask, (void *)g_linux_wlan, "DebugThread");
- if (g_linux_wlan->txq_thread == 0) {
+ wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev,
+ "K_TXQ_TASK");
+ if (!wilc->txq_thread) {
PRINT_ER("couldn't create TXQ thread\n");
ret = -ENOBUFS;
goto _fail_2;
}
-#endif
/* wait for TXQ task to start. */
- linux_wlan_lock(&g_linux_wlan->txq_thread_started);
+ down(&wilc->txq_thread_started);
return 0;
_fail_2:
/*De-Initialize 2nd thread*/
- g_linux_wlan->close = 1;
- linux_wlan_unlock(&g_linux_wlan->rxq_event);
- kthread_stop(g_linux_wlan->rxq_thread);
-
-#ifndef TCP_ENHANCEMENTS
-_fail_1:
-#endif
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- /*De-Initialize 1st thread*/
- g_linux_wlan->close = 1;
- linux_wlan_unlock(&g_linux_wlan->rx_sem);
- kthread_stop(g_linux_wlan->rx_bh_thread);
-_fail_:
- #endif
- g_linux_wlan->close = 0;
+ wilc->close = 0;
return ret;
}
-static void wlan_deinitialize_threads(linux_wlan_t *nic)
-{
-
- g_linux_wlan->close = 1;
- PRINT_D(INIT_DBG, "Deinitializing Threads\n");
- if (&g_linux_wlan->rxq_event != NULL)
- linux_wlan_unlock(&g_linux_wlan->rxq_event);
-
- if (g_linux_wlan->rxq_thread != NULL) {
- kthread_stop(g_linux_wlan->rxq_thread);
- g_linux_wlan->rxq_thread = NULL;
- }
-
- if (&g_linux_wlan->txq_event != NULL)
- linux_wlan_unlock(&g_linux_wlan->txq_event);
-
- if (g_linux_wlan->txq_thread != NULL) {
- kthread_stop(g_linux_wlan->txq_thread);
- g_linux_wlan->txq_thread = NULL;
- }
-
- #if (RX_BH_TYPE == RX_BH_KTHREAD)
- if (&g_linux_wlan->rx_sem != NULL)
- linux_wlan_unlock(&g_linux_wlan->rx_sem);
-
- if (g_linux_wlan->rx_bh_thread != NULL) {
- kthread_stop(g_linux_wlan->rx_bh_thread);
- g_linux_wlan->rx_bh_thread = NULL;
- }
- #endif
-}
-
-#ifdef STATIC_MACADDRESS
-const char *path_string[] = {
- "/etc/wlan",
- "/data/wlan",
-};
-
-static int linux_wlan_read_mac_addr(void *vp)
+static void wlan_deinitialize_threads(struct net_device *dev)
{
- int ret = 0;
- struct file *fp = (struct file *)-ENOENT;
- mm_segment_t old_fs;
- loff_t pos = 0;
- int index;
- int array_size = ARRAY_SIZE(path_string);
-
- /* change to KERNEL_DS address limit */
- old_fs = get_fs();
- set_fs(KERNEL_DS);
-
- for (index = 0; index < array_size; index++) {
- fp = filp_open(path_string[index], O_WRONLY, 0640);
- if (!fp) {
- ret = -1;
- goto exit;
- }
-
- /*No such file or directory */
- if (IS_ERR(fp) || !fp->f_op) {
- get_random_bytes(&mac_add[3], 3);
- /* open file to write */
- fp = filp_open(path_string[index], O_WRONLY | O_CREAT, 0640);
-
- if (!fp || IS_ERR(fp)) {
- ret = -1;
- continue;
- } else {
- /* write buf to file */
- fp->f_op->write(fp, mac_add, 6, &pos);
- break;
- }
- } else {
- /* read file to buf */
- fp->f_op->read(fp, mac_add, 6, &pos);
- break;
- }
- }
-
- if (index == array_size)
- PRINT_ER("random MAC\n");
-
-exit:
- if (fp && !IS_ERR(fp))
- filp_close(fp, NULL);
-
- set_fs(old_fs);
-
- return ret;
-}
-#endif
-
-#ifdef COMPLEMENT_BOOT
-
-extern volatile int probe;
-extern uint8_t core_11b_ready(void);
-
-#define READY_CHECK_THRESHOLD 30
-extern void wilc_wlan_global_reset(void);
-uint8_t wilc1000_prepare_11b_core(wilc_wlan_inp_t *nwi, wilc_wlan_oup_t *nwo, linux_wlan_t *nic)
-{
- uint8_t trials = 0;
- while ((core_11b_ready() && (READY_CHECK_THRESHOLD > (trials++)))) {
- PRINT_D(INIT_DBG, "11b core not ready yet: %u\n", trials);
- wilc_wlan_deinit(nic);
- wilc_wlan_global_reset();
- sdio_unregister_driver(&wilc_bus);
-
- linux_wlan_device_detection(0);
-
- mdelay(100);
-
- linux_wlan_device_detection(1);
-
- sdio_register_driver(&wilc_bus);
-
- while (!probe)
- msleep(100);
- probe = 0;
- g_linux_wlan->wilc_sdio_func = local_sdio_func;
- linux_to_wlan(nwi, nic);
- wilc_wlan_init(nwi, nwo);
- }
-
- if (READY_CHECK_THRESHOLD <= trials)
- return 1;
- else
- return 0;
-
-}
-
-int repeat_power_cycle(perInterface_wlan_t *nic)
-{
- int ret = 0;
- wilc_wlan_inp_t nwi;
- wilc_wlan_oup_t nwo;
- sdio_unregister_driver(&wilc_bus);
-
- linux_wlan_device_detection(0);
- linux_wlan_device_power(0);
- msleep(100);
- linux_wlan_device_power(1);
- msleep(80);
- linux_wlan_device_detection(1);
- msleep(20);
-
- sdio_register_driver(&wilc_bus);
+ perInterface_wlan_t *nic;
+ struct wilc *wl;
- /* msleep(1000); */
- while (!probe)
- msleep(100);
- probe = 0;
- g_linux_wlan->wilc_sdio_func = local_sdio_func;
- linux_to_wlan(&nwi, g_linux_wlan);
- ret = wilc_wlan_init(&nwi, &nwo);
+ nic = netdev_priv(dev);
+ wl = nic->wilc;
- g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT;
- #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
- enable_sdio_interrupt();
- #endif
+ wl->close = 1;
+ PRINT_D(INIT_DBG, "Deinitializing Threads\n");
- if (linux_wlan_get_firmware(nic)) {
- PRINT_ER("Can't get firmware\n");
- ret = -1;
- goto __fail__;
- }
+ if (&wl->txq_event != NULL)
+ up(&wl->txq_event);
- /*Download firmware*/
- ret = linux_wlan_firmware_download(g_linux_wlan);
- if (ret < 0) {
- PRINT_ER("Failed to download firmware\n");
- goto __fail__;
+ if (wl->txq_thread != NULL) {
+ kthread_stop(wl->txq_thread);
+ wl->txq_thread = NULL;
}
- /* Start firmware*/
- ret = linux_wlan_start_firmware(nic);
- if (ret < 0)
- PRINT_ER("Failed to start firmware\n");
-__fail__:
- return ret;
}
-#endif
int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
{
wilc_wlan_inp_t nwi;
- wilc_wlan_oup_t nwo;
perInterface_wlan_t *nic = p_nic;
int ret = 0;
+ struct wilc *wl = nic->wilc;
- if (!g_linux_wlan->wilc1000_initialized) {
- g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT;
- g_linux_wlan->close = 0;
- g_linux_wlan->wilc1000_initialized = 0;
+ if (!wl->initialized) {
+ wl->mac_status = WILC_MAC_STATUS_INIT;
+ wl->close = 0;
- wlan_init_locks(g_linux_wlan);
+ wlan_init_locks(dev);
-#ifdef STATIC_MACADDRESS
- wilc_mac_thread = kthread_run(linux_wlan_read_mac_addr, NULL, "wilc_mac_thread");
- if (wilc_mac_thread < 0)
- PRINT_ER("couldn't create Mac addr thread\n");
-#endif
+ linux_to_wlan(&nwi, wl);
- linux_to_wlan(&nwi, g_linux_wlan);
-
- ret = wilc_wlan_init(&nwi, &nwo);
+ ret = wilc_wlan_init(&nwi);
if (ret < 0) {
PRINT_ER("Initializing WILC_Wlan FAILED\n");
ret = -EIO;
goto _fail_locks_;
}
- memcpy(&g_linux_wlan->oup, &nwo, sizeof(wilc_wlan_oup_t));
-
- /*Save the oup structre into global pointer*/
- gpstrWlanOps = &g_linux_wlan->oup;
-
- ret = wlan_initialize_threads(nic);
- if (ret < 0) {
- PRINT_ER("Initializing Threads FAILED\n");
- ret = -EIO;
- goto _fail_wilc_wlan_;
- }
-#if (defined WILC_SDIO) && (defined COMPLEMENT_BOOT)
- if (wilc1000_prepare_11b_core(&nwi, &nwo, g_linux_wlan)) {
- PRINT_ER("11b Core is not ready\n");
+#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
+ if (init_irq(dev)) {
+ PRINT_ER("couldn't initialize IRQ\n");
ret = -EIO;
- goto _fail_threads_;
+ goto _fail_locks_;
}
#endif
-#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- if (init_irq(g_linux_wlan)) {
- PRINT_ER("couldn't initialize IRQ\n");
+ ret = wlan_initialize_threads(dev);
+ if (ret < 0) {
+ PRINT_ER("Initializing Threads FAILED\n");
ret = -EIO;
- goto _fail_threads_;
+ goto _fail_wilc_wlan_;
}
-#endif
#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
if (enable_sdio_interrupt()) {
@@ -1860,7 +1124,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
}
/*Download firmware*/
- ret = linux_wlan_firmware_download(g_linux_wlan);
+ ret = linux_wlan_firmware_download(wl);
if (ret < 0) {
PRINT_ER("Failed to download firmware\n");
ret = -EIO;
@@ -1877,17 +1141,18 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
wilc_bus_set_max_speed();
- if (g_linux_wlan->oup.wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
+ if (wilc_wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
int size;
char Firmware_ver[20];
- size = g_linux_wlan->oup.wlan_cfg_get_value(
+
+ size = wilc_wlan_cfg_get_val(
WID_FIRMWARE_VERSION,
Firmware_ver, sizeof(Firmware_ver));
Firmware_ver[size] = '\0';
PRINT_D(INIT_DBG, "***** Firmware Ver = %s *******\n", Firmware_ver);
}
/* Initialize firmware with default configuration */
- ret = linux_wlan_init_test_config(dev, g_linux_wlan);
+ ret = linux_wlan_init_test_config(dev, wl);
if (ret < 0) {
PRINT_ER("Failed to configure firmware\n");
@@ -1895,14 +1160,11 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
goto _fail_fw_start_;
}
- g_linux_wlan->wilc1000_initialized = 1;
+ wl->initialized = true;
return 0; /*success*/
_fail_fw_start_:
- if (&g_linux_wlan->oup != NULL) {
- if (g_linux_wlan->oup.wlan_stop != NULL)
- g_linux_wlan->oup.wlan_stop();
- }
+ wilc_wlan_stop();
_fail_irq_enable_:
#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
@@ -1910,15 +1172,14 @@ _fail_irq_enable_:
_fail_irq_init_:
#endif
#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
- deinit_irq(g_linux_wlan);
+ deinit_irq(dev);
#endif
-_fail_threads_:
- wlan_deinitialize_threads(g_linux_wlan);
+ wlan_deinitialize_threads(dev);
_fail_wilc_wlan_:
- wilc_wlan_deinit(g_linux_wlan);
+ wilc_wlan_cleanup(dev);
_fail_locks_:
- wlan_deinit_locks(g_linux_wlan);
+ wlan_deinit_locks(dev);
PRINT_ER("WLAN Iinitialization FAILED\n");
} else {
PRINT_D(INIT_DBG, "wilc1000 already initialized\n");
@@ -1930,7 +1191,6 @@ _fail_locks_:
* - this function will be called automatically by OS when module inserted.
*/
-#if !defined(NM73131_0_BOARD)
int mac_init_fn(struct net_device *ndev)
{
@@ -1940,79 +1200,65 @@ int mac_init_fn(struct net_device *ndev)
return 0;
}
-#else
-int mac_init_fn(struct net_device *ndev)
-{
-
- unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x00};
- /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/
- memcpy(ndev->dev_addr, mac_add, 6);
-
- if (!is_valid_ether_addr(ndev->dev_addr)) {
- PRINT_ER("Error: Wrong MAC address\n");
- return -EINVAL;
- }
-
- return 0;
-}
-#endif
-
-void WILC_WFI_frame_register(struct wiphy *wiphy, struct net_device *dev,
- u16 frame_type, bool reg);
/* This fn is called, when this device is setup using ifconfig */
-#if !defined(NM73131_0_BOARD)
int mac_open(struct net_device *ndev)
{
perInterface_wlan_t *nic;
- /*BugID_5213*/
/*No need for setting mac address here anymore,*/
/*Just set it in init_test_config()*/
unsigned char mac_add[ETH_ALEN] = {0};
int ret = 0;
int i = 0;
- struct WILC_WFI_priv *priv;
+ struct wilc_priv *priv;
+ struct wilc *wl;
+
+ nic = netdev_priv(ndev);
+ wl = nic->wilc;
+#ifdef WILC_SPI
+ if (!wl|| !wl->wilc_spidev) {
+ netdev_err(ndev, "wilc1000: SPI device not ready\n");
+ return -ENODEV;
+ }
+#endif
nic = netdev_priv(ndev);
priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);
- #ifdef USE_WIRELESS
- ret = WILC_WFI_InitHostInt(ndev);
+ ret = wilc_init_host_int(ndev);
if (ret < 0) {
PRINT_ER("Failed to initialize host interface\n");
return ret;
}
- #endif
/*initialize platform*/
PRINT_D(INIT_DBG, "*** re-init ***\n");
ret = wilc1000_wlan_init(ndev, nic);
if (ret < 0) {
PRINT_ER("Failed to initialize wilc1000\n");
- WILC_WFI_DeInitHostInt(ndev);
+ wilc_deinit_host_int(ndev);
return ret;
}
- Set_machw_change_vir_if(false);
+ Set_machw_change_vir_if(ndev, false);
host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add);
- PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2],
- mac_add[3], mac_add[4], mac_add[5]);
+ PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add);
/* loop through the NUM of supported devices and set the MAC address */
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- if (ndev == g_linux_wlan->strInterfaceInfo[i].wilc_netdev) {
- memcpy(g_linux_wlan->strInterfaceInfo[i].aSrcAddress, mac_add, ETH_ALEN);
- g_linux_wlan->strInterfaceInfo[i].drvHandler = priv->hWILCWFIDrv;
+ for (i = 0; i < wl->vif_num; i++) {
+ if (ndev == wl->vif[i].ndev) {
+ memcpy(wl->vif[i].src_addr, mac_add, ETH_ALEN);
+ wl->vif[i].hif_drv = priv->hWILCWFIDrv;
break;
}
}
/* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/
- memcpy(ndev->dev_addr, g_linux_wlan->strInterfaceInfo[i].aSrcAddress, ETH_ALEN);
+ memcpy(ndev->dev_addr, wl->vif[i].src_addr, ETH_ALEN);
if (!is_valid_ether_addr(ndev->dev_addr)) {
PRINT_ER("Error: Wrong MAC address\n");
@@ -2020,39 +1266,20 @@ int mac_open(struct net_device *ndev)
goto _err_;
}
- WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev,
- nic->g_struct_frame_reg[0].frame_type, nic->g_struct_frame_reg[0].reg);
- WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev,
- nic->g_struct_frame_reg[1].frame_type, nic->g_struct_frame_reg[1].reg);
+ wilc_mgmt_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev->ieee80211_ptr,
+ nic->g_struct_frame_reg[0].frame_type, nic->g_struct_frame_reg[0].reg);
+ wilc_mgmt_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev->ieee80211_ptr,
+ nic->g_struct_frame_reg[1].frame_type, nic->g_struct_frame_reg[1].reg);
netif_wake_queue(ndev);
- g_linux_wlan->open_ifcs++;
+ wl->open_ifcs++;
nic->mac_opened = 1;
return 0;
_err_:
- WILC_WFI_DeInitHostInt(ndev);
- wilc1000_wlan_deinit(g_linux_wlan);
+ wilc_deinit_host_int(ndev);
+ wilc1000_wlan_deinit(ndev);
return ret;
}
-#else
-int mac_open(struct net_device *ndev)
-{
-
- linux_wlan_t *nic;
- nic = netdev_priv(ndev);
-
- /*initialize platform*/
- if (wilc1000_wlan_init(nic)) {
- PRINT_ER("Failed to initialize platform\n");
- return 1;
- }
- /* Start the network interface queue for this device */
- PRINT_D(INIT_DBG, "Starting netifQ\n");
- netif_start_queue(ndev);
-/* linux_wlan_lock(&close_exit_sync); */
- return 0;
-}
-#endif
struct net_device_stats *mac_stats(struct net_device *dev)
{
@@ -2066,11 +1293,12 @@ static void wilc_set_multicast_list(struct net_device *dev)
{
struct netdev_hw_addr *ha;
- struct WILC_WFI_priv *priv;
- tstrWILC_WFIDrv *pstrWFIDrv;
+ struct wilc_priv *priv;
+ struct host_if_drv *pstrWFIDrv;
int i = 0;
+
priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
- pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
if (!dev)
return;
@@ -2120,13 +1348,14 @@ static void linux_wlan_tx_complete(void *priv, int status)
{
struct tx_complete_data *pv_data = (struct tx_complete_data *)priv;
+
if (status == 1)
PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
else
PRINT_D(TX_DBG, "Couldn't send packet - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
/* Free the SK Buffer, its work is done */
dev_kfree_skb(pv_data->skb);
- linux_wlan_free(pv_data);
+ kfree(pv_data);
}
int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
@@ -2137,9 +1366,11 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
char *pu8UdpBuffer;
struct iphdr *ih;
struct ethhdr *eth_h;
+ struct wilc *wilc;
+
nic = netdev_priv(ndev);
+ wilc = nic->wilc;
- PRINT_D(INT_DBG, "\n========\n IntUH: %d - IntBH: %d - IntCld: %d\n========\n", int_rcvdU, int_rcvdB, int_clrd);
PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n");
/* Stop the network interface queue */
@@ -2148,7 +1379,7 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
return 0;
}
- tx_data = (struct tx_complete_data *)internal_alloc(sizeof(struct tx_complete_data), GFP_ATOMIC);
+ tx_data = kmalloc(sizeof(struct tx_complete_data), GFP_ATOMIC);
if (tx_data == NULL) {
PRINT_ER("Failed to allocate memory for tx_data structure\n");
dev_kfree_skb(skb);
@@ -2181,19 +1412,14 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n");
nic->netstats.tx_packets++;
nic->netstats.tx_bytes += tx_data->size;
- tx_data->pBssid = g_linux_wlan->strInterfaceInfo[nic->u8IfIdx].aBSSID;
- #ifndef WILC_FULLY_HOSTING_AP
- QueueCount = g_linux_wlan->oup.wlan_add_to_tx_que((void *)tx_data,
- tx_data->buff,
- tx_data->size,
- linux_wlan_tx_complete);
- #else
- QueueCount = WILC_Xmit_data((void *)tx_data, HOST_TO_WLAN);
- #endif /* WILC_FULLY_HOSTING_AP */
+ tx_data->pBssid = wilc->vif[nic->u8IfIdx].bssid;
+ QueueCount = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
+ tx_data->buff, tx_data->size,
+ linux_wlan_tx_complete);
if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) {
- netif_stop_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev);
- netif_stop_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev);
+ netif_stop_queue(wilc->vif[0].ndev);
+ netif_stop_queue(wilc->vif[1].ndev);
}
return 0;
@@ -2201,9 +1427,10 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
int mac_close(struct net_device *ndev)
{
- struct WILC_WFI_priv *priv;
+ struct wilc_priv *priv;
perInterface_wlan_t *nic;
- tstrWILC_WFIDrv *pstrWFIDrv;
+ struct host_if_drv *pstrWFIDrv;
+ struct wilc *wl;
nic = netdev_priv(ndev);
@@ -2213,18 +1440,19 @@ int mac_close(struct net_device *ndev)
}
priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
+ wl = nic->wilc;
if (priv == NULL) {
PRINT_ER("priv = NULL\n");
return 0;
}
- pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
PRINT_D(GENERIC_DBG, "Mac close\n");
- if (g_linux_wlan == NULL) {
- PRINT_ER("g_linux_wlan = NULL\n");
+ if (!wl) {
+ PRINT_ER("wl = NULL\n");
return 0;
}
@@ -2233,8 +1461,8 @@ int mac_close(struct net_device *ndev)
return 0;
}
- if ((g_linux_wlan->open_ifcs) > 0) {
- g_linux_wlan->open_ifcs--;
+ if ((wl->open_ifcs) > 0) {
+ wl->open_ifcs--;
} else {
PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n");
return 0;
@@ -2244,23 +1472,17 @@ int mac_close(struct net_device *ndev)
/* Stop the network interface queue */
netif_stop_queue(nic->wilc_netdev);
- #ifdef USE_WIRELESS
- WILC_WFI_DeInitHostInt(nic->wilc_netdev);
- #endif
+ wilc_deinit_host_int(nic->wilc_netdev);
}
- if (g_linux_wlan->open_ifcs == 0) {
+ if (wl->open_ifcs == 0) {
PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n");
- g_linux_wlan->close = 1;
- wilc1000_wlan_deinit(g_linux_wlan);
- #ifdef USE_WIRELESS
- #ifdef WILC_AP_EXTERNAL_MLME
+ wl->close = 1;
+ wilc1000_wlan_deinit(ndev);
WILC_WFI_deinit_mon_interface();
- #endif
- #endif
}
- linux_wlan_unlock(&close_exit_sync);
+ up(&close_exit_sync);
nic->mac_opened = 0;
return 0;
@@ -2273,18 +1495,17 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
s8 rssi;
u32 size = 0, length = 0;
perInterface_wlan_t *nic;
- struct WILC_WFI_priv *priv;
- s32 s32Error = WILC_SUCCESS;
+ struct wilc_priv *priv;
+ s32 s32Error = 0;
+ struct wilc *wilc;
/* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */
- #ifdef USE_WIRELESS
nic = netdev_priv(ndev);
+ wilc = nic->wilc;
- if (!g_linux_wlan->wilc1000_initialized)
+ if (!wilc->initialized)
return 0;
- #endif
-
switch (cmd) {
/* ]] 2013-06-24 */
@@ -2297,19 +1518,14 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
if (size && wrq->u.data.pointer) {
buff = memdup_user(wrq->u.data.pointer, wrq->u.data.length);
- if (IS_ERR(buff)) {
- s32Error = PTR_ERR(buff);
- goto done;
- }
+ if (IS_ERR(buff))
+ return PTR_ERR(buff);
if (strncasecmp(buff, "RSSI", length) == 0) {
-
- #ifdef USE_WIRELESS
priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
s32Error = host_int_get_rssi(priv->hWILCWFIDrv, &(rssi));
if (s32Error)
PRINT_ER("Failed to send get rssi param's message queue ");
- #endif
PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi);
/*Rounding up the rssi negative value*/
@@ -2342,21 +1558,17 @@ done:
return s32Error;
}
-void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
+void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
{
unsigned int frame_len = 0;
int stats;
unsigned char *buff_to_send = NULL;
struct sk_buff *skb;
-#ifndef TCP_ENHANCEMENTS
- char *pu8UdpBuffer;
- struct iphdr *ih;
-#endif
struct net_device *wilc_netdev;
perInterface_wlan_t *nic;
- wilc_netdev = GetIfHandler(buff);
+ wilc_netdev = GetIfHandler(wilc, buff);
if (wilc_netdev == NULL)
return;
@@ -2375,10 +1587,8 @@ void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
return;
}
- skb_reserve(skb, (unsigned int)skb->data & 0x3);
-
- if (g_linux_wlan == NULL || wilc_netdev == NULL)
- PRINT_ER("wilc_netdev in g_linux_wlan is NULL");
+ if (wilc == NULL || wilc_netdev == NULL)
+ PRINT_ER("wilc_netdev in wilc is NULL");
skb->dev = wilc_netdev;
if (skb->dev == NULL)
@@ -2399,24 +1609,7 @@ void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
/* nic = netdev_priv(wilc_netdev); */
-#ifdef USE_WIRELESS
- /* if(nic->monitor_flag)
- * {
- * WILC_WFI_monitor_rx(nic->wilc_netdev,skb);
- * return;
- * }*/
-#endif
skb->protocol = eth_type_trans(skb, wilc_netdev);
- #ifndef TCP_ENHANCEMENTS
- /*get source and dest ip addresses*/
- ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr));
-
- pu8UdpBuffer = (char *)ih + sizeof(struct iphdr);
- if (buff_to_send[35] == 67 && buff_to_send[37] == 68)
- PRINT_D(RX_DBG, "DHCP Message received\n");
- if (buff_to_send[12] == 0x88 && buff_to_send[13] == 0x8e)
- PRINT_D(GENERIC_DBG, "eapol received\n");
- #endif
/* Send the packet to the stack by giving it to the bridge */
nic->netstats.rx_packets++;
nic->netstats.rx_bytes += frame_len;
@@ -2424,56 +1617,86 @@ void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
stats = netif_rx(skb);
PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats);
}
- #ifndef TCP_ENHANCEMENTS
- else
- PRINT_ER("Discard sending packet with len = %d\n", size);
- #endif
}
-void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size)
+void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
{
int i = 0;
perInterface_wlan_t *nic;
- /*BugID_5450*/
/*Pass the frame on the monitor interface, if any.*/
/*Otherwise, pass it on p2p0 netdev, if registered on it*/
- for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
- nic = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ for (i = 0; i < wilc->vif_num; i++) {
+ nic = netdev_priv(wilc->vif[i].ndev);
if (nic->monitor_flag) {
WILC_WFI_monitor_rx(buff, size);
return;
}
}
- #ifdef WILC_P2P
- nic = netdev_priv(g_linux_wlan->strInterfaceInfo[1].wilc_netdev); /* p2p0 */
+ nic = netdev_priv(wilc->vif[1].ndev); /* p2p0 */
if ((buff[0] == nic->g_struct_frame_reg[0].frame_type && nic->g_struct_frame_reg[0].reg) ||
(buff[0] == nic->g_struct_frame_reg[1].frame_type && nic->g_struct_frame_reg[1].reg))
- WILC_WFI_p2p_rx(g_linux_wlan->strInterfaceInfo[1].wilc_netdev, buff, size);
- #endif
+ WILC_WFI_p2p_rx(wilc->vif[1].ndev, buff, size);
}
-int wilc_netdev_init(void)
+void wl_wlan_cleanup(void)
{
+ int i = 0;
+ perInterface_wlan_t *nic[NUM_CONCURRENT_IFC];
+ if (g_linux_wlan &&
+ (g_linux_wlan->vif[0].ndev || g_linux_wlan->vif[1].ndev)) {
+ unregister_inetaddr_notifier(&g_dev_notifier);
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++)
+ nic[i] = netdev_priv(g_linux_wlan->vif[i].ndev);
+ }
+
+ if (g_linux_wlan && g_linux_wlan->firmware)
+ release_firmware(g_linux_wlan->firmware);
+
+ if (g_linux_wlan &&
+ (g_linux_wlan->vif[0].ndev || g_linux_wlan->vif[1].ndev)) {
+ linux_wlan_lock_timeout(&close_exit_sync, 12 * 1000);
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++)
+ if (g_linux_wlan->vif[i].ndev)
+ if (nic[i]->mac_opened)
+ mac_close(g_linux_wlan->vif[i].ndev);
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ unregister_netdev(g_linux_wlan->vif[i].ndev);
+ wilc_free_wiphy(g_linux_wlan->vif[i].ndev);
+ free_netdev(g_linux_wlan->vif[i].ndev);
+ }
+ }
+
+ kfree(g_linux_wlan);
+
+#if defined(WILC_DEBUGFS)
+ wilc_debugfs_remove();
+#endif
+ linux_wlan_device_detection(0);
+ linux_wlan_device_power(0);
+}
+
+int wilc_netdev_init(struct wilc **wilc)
+{
int i;
perInterface_wlan_t *nic;
struct net_device *ndev;
- linux_wlan_init_lock("close_exit_sync", &close_exit_sync, 0);
+ sema_init(&close_exit_sync, 0);
/*create the common structure*/
- g_linux_wlan = WILC_MALLOC(sizeof(linux_wlan_t));
- memset(g_linux_wlan, 0, sizeof(linux_wlan_t));
-
- /*Reset interrupt count debug*/
- int_rcvdU = 0;
- int_rcvdB = 0;
- int_clrd = 0;
- #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ g_linux_wlan = kzalloc(sizeof(*g_linux_wlan), GFP_KERNEL);
+ if (!g_linux_wlan)
+ return -ENOMEM;
+
+ *wilc = g_linux_wlan;
+
register_inetaddr_notifier(&g_dev_notifier);
- #endif
for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
/*allocate first ethernet device with perinterface_wlan_t as its private data*/
@@ -2498,17 +1721,17 @@ int wilc_netdev_init(void)
} else
strcpy(ndev->name, "p2p%d");
- nic->u8IfIdx = g_linux_wlan->u8NoIfcs;
+ nic->u8IfIdx = g_linux_wlan->vif_num;
nic->wilc_netdev = ndev;
- g_linux_wlan->strInterfaceInfo[g_linux_wlan->u8NoIfcs].wilc_netdev = ndev;
- g_linux_wlan->u8NoIfcs++;
+ nic->wilc = *wilc;
+ g_linux_wlan->vif[g_linux_wlan->vif_num].ndev = ndev;
+ g_linux_wlan->vif_num++;
ndev->netdev_ops = &wilc_netdev_ops;
- #ifdef USE_WIRELESS
{
struct wireless_dev *wdev;
/*Register WiFi*/
- wdev = WILC_WFI_WiphyRegister(ndev);
+ wdev = wilc_create_wiphy(ndev);
#ifdef WILC_SDIO
/* set netdev, tony */
@@ -2530,7 +1753,6 @@ int wilc_netdev_init(void)
nic->netstats.tx_bytes = 0;
}
- #endif
if (register_netdev(ndev)) {
PRINT_ER("Device couldn't be registered - %s\n", ndev->name);
@@ -2558,6 +1780,10 @@ int wilc_netdev_init(void)
/*The 1st function called after module inserted*/
static int __init init_wilc_driver(void)
{
+#ifdef WILC_SPI
+ struct wilc *wilc;
+#endif
+
#if defined(WILC_DEBUGFS)
if (wilc_debugfs_init() < 0) {
PRINT_D(GENERIC_DBG, "fail to create debugfs for wilc driver\n");
@@ -2584,7 +1810,7 @@ static int __init init_wilc_driver(void)
}
#else
PRINT_D(INIT_DBG, "Initializing netdev\n");
- if (wilc_netdev_init())
+ if (wilc_netdev_init(&wilc))
PRINT_ER("Couldn't initialize netdev\n");
return 0;
#endif
@@ -2593,84 +1819,13 @@ late_initcall(init_wilc_driver);
static void __exit exit_wilc_driver(void)
{
- int i = 0;
- perInterface_wlan_t *nic[NUM_CONCURRENT_IFC] = {NULL,};
- #define CLOSE_TIMEOUT (12 * 1000)
-
- if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL)
- || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) {
- #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
- unregister_inetaddr_notifier(&g_dev_notifier);
- #endif
-
- for (i = 0; i < NUM_CONCURRENT_IFC; i++)
- nic[i] = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- }
-
- if ((g_linux_wlan != NULL) && g_linux_wlan->wilc_firmware != NULL) {
- release_firmware(g_linux_wlan->wilc_firmware);
- g_linux_wlan->wilc_firmware = NULL;
- }
-
- if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL)
- || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) {
- PRINT_D(INIT_DBG, "Waiting for mac_close ....\n");
-
- if (linux_wlan_lock_timeout(&close_exit_sync, CLOSE_TIMEOUT) < 0)
- PRINT_D(INIT_DBG, "Closed TimedOUT\n");
- else
- PRINT_D(INIT_DBG, "mac_closed\n");
-
- for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
- /* close all opened interfaces */
- if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev != NULL) {
- if (nic[i]->mac_opened)
- mac_close(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- }
- }
- for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
- PRINT_D(INIT_DBG, "Unregistering netdev %p\n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- unregister_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- #ifdef USE_WIRELESS
- PRINT_D(INIT_DBG, "Freeing Wiphy...\n");
- WILC_WFI_WiphyFree(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- #endif
- PRINT_D(INIT_DBG, "Freeing netdev...\n");
- free_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
- }
- }
-
-#ifdef USE_WIRELESS
-#ifdef WILC_AP_EXTERNAL_MLME
- /* Bug 4600 : WILC_WFI_deinit_mon_interface was already called at mac_close */
- /* WILC_WFI_deinit_mon_interface(); */
-#endif
-#endif
-
- /* if(g_linux_wlan->open_ifcs==0) */
- {
- #ifndef WILC_SDIO
- PRINT_D(INIT_DBG, "SPI unregsiter...\n");
- spi_unregister_driver(&wilc_bus);
- #else
- PRINT_D(INIT_DBG, "SDIO unregsiter...\n");
- sdio_unregister_driver(&wilc_bus);
- #endif
-
- linux_wlan_deinit_lock(&close_exit_sync);
- if (g_linux_wlan != NULL) {
- kfree(g_linux_wlan);
- g_linux_wlan = NULL;
- }
- printk("Module_exit Done.\n");
-
-#if defined(WILC_DEBUGFS)
- wilc_debugfs_remove();
+#ifndef WILC_SDIO
+ PRINT_D(INIT_DBG, "SPI unregister...\n");
+ spi_unregister_driver(&wilc_bus);
+#else
+ PRINT_D(INIT_DBG, "SDIO unregister...\n");
+ sdio_unregister_driver(&wilc_bus);
#endif
-
- linux_wlan_device_detection(0);
- linux_wlan_device_power(0);
- }
}
module_exit(exit_wilc_driver);