diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
commit | d635711daa98be86d4c7fd01499c34f566b54ccb (patch) | |
tree | aa5cc3760a27c3d57146498cb82fa549547de06c /drivers/staging/wilc1000/linux_wlan.c | |
parent | c91265cd0efb83778f015b4d4b1129bd2cfd075e (diff) |
Linux-libre 4.6.2-gnu
Diffstat (limited to 'drivers/staging/wilc1000/linux_wlan.c')
-rw-r--r-- | drivers/staging/wilc1000/linux_wlan.c | 514 |
1 files changed, 196 insertions, 318 deletions
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 68233ef1f..ce095b020 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1,5 +1,4 @@ #include "wilc_wfi_cfgoperations.h" -#include "linux_wlan_common.h" #include "wilc_wlan_if.h" #include "wilc_wlan.h" @@ -13,7 +12,6 @@ #include <linux/kthread.h> #include <linux/firmware.h> -#include <linux/delay.h> #include <linux/init.h> #include <linux/netdevice.h> @@ -25,7 +23,8 @@ #include <linux/semaphore.h> -static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr); +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 @@ -57,9 +56,10 @@ static const struct net_device_ops wilc_netdev_ops = { }; -static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr) +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 in_ifaddr *dev_iface = ptr; struct wilc_priv *priv; struct host_if_drv *hif_drv; struct net_device *dev; @@ -68,66 +68,48 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event u8 null_ip[4] = {0}; char wlan_dev_name[5] = "wlan0"; - if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev) { - PRINT_D(GENERIC_DBG, "dev_iface = NULL\n"); + if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev) return NOTIFY_DONE; - } if (memcmp(dev_iface->ifa_label, "wlan0", 5) && - memcmp(dev_iface->ifa_label, "p2p0", 4)) { - PRINT_D(GENERIC_DBG, "Interface is neither WLAN0 nor P2P0\n"); + memcmp(dev_iface->ifa_label, "p2p0", 4)) return NOTIFY_DONE; - } dev = (struct net_device *)dev_iface->ifa_dev->dev; - if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) { - PRINT_D(GENERIC_DBG, "No Wireless registerd\n"); + if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) return NOTIFY_DONE; - } + priv = wiphy_priv(dev->ieee80211_ptr->wiphy); - if (!priv) { - PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); + if (!priv) return NOTIFY_DONE; - } - hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv; + + hif_drv = (struct host_if_drv *)priv->hif_drv; vif = netdev_priv(dev); - if (!vif || !hif_drv) { - PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); + if (!vif || !hif_drv) return NOTIFY_DONE; - } - - PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler +++\n"); switch (event) { case NETDEV_UP: - PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_UP %p\n", dev); - - PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Obtained ===============\n\n"); - if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { hif_drv->IFC_UP = 1; wilc_optaining_ip = false; del_timer(&wilc_during_ip_timer); - PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n"); } if (wilc_enable_ps) wilc_set_power_mgmt(vif, 1, 0); - PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label); + netdev_dbg(dev, "[%s] Up IP\n", dev_iface->ifa_label); ip_addr_buf = (char *)&dev_iface->ifa_address; - PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n", - ip_addr_buf[0], ip_addr_buf[1], - ip_addr_buf[2], ip_addr_buf[3]); - wilc_setup_ipaddress(vif, ip_addr_buf, vif->u8IfIdx); + netdev_dbg(dev, "IP add=%d:%d:%d:%d\n", + ip_addr_buf[0], ip_addr_buf[1], + ip_addr_buf[2], ip_addr_buf[3]); + wilc_setup_ipaddress(vif, ip_addr_buf, vif->idx); break; case NETDEV_DOWN: - PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN %p\n", dev); - - PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n"); if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { hif_drv->IFC_UP = 0; wilc_optaining_ip = false; @@ -138,21 +120,18 @@ static int dev_state_ev_handler(struct notifier_block *this, unsigned long event wilc_resolve_disconnect_aberration(vif); - PRINT_D(GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label); + netdev_dbg(dev, "[%s] Down IP\n", dev_iface->ifa_label); ip_addr_buf = null_ip; - PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n", - ip_addr_buf[0], ip_addr_buf[1], - ip_addr_buf[2], ip_addr_buf[3]); + netdev_dbg(dev, "IP add=%d:%d:%d:%d\n", + ip_addr_buf[0], ip_addr_buf[1], + ip_addr_buf[2], ip_addr_buf[3]); - wilc_setup_ipaddress(vif, ip_addr_buf, vif->u8IfIdx); + wilc_setup_ipaddress(vif, ip_addr_buf, vif->idx); break; default: - PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler event=default\n"); - PRINT_INFO(GENERIC_DBG, "[%s] unknown dev event: %lu\n", dev_iface->ifa_label, event); - break; } @@ -163,14 +142,13 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data) { struct wilc_vif *vif; struct wilc *wilc; - struct net_device *dev = (struct net_device *)user_data; + struct net_device *dev = user_data; vif = netdev_priv(dev); wilc = vif->wilc; - PRINT_D(INT_DBG, "Interrupt received UH\n"); if (wilc->close) { - PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n"); + netdev_err(dev, "Can't handle UH interrupt\n"); return IRQ_HANDLED; } return IRQ_WAKE_THREAD; @@ -180,16 +158,16 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata) { struct wilc_vif *vif; struct wilc *wilc; + struct net_device *dev = userdata; vif = netdev_priv(userdata); wilc = vif->wilc; if (wilc->close) { - PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n"); + netdev_err(dev, "Can't handle BH interrupt\n"); return IRQ_HANDLED; } - PRINT_D(INT_DBG, "Interrupt received BH\n"); wilc_handle_isr(wilc); return IRQ_HANDLED; @@ -209,7 +187,7 @@ static int init_irq(struct net_device *dev) wl->dev_irq_num = gpio_to_irq(wl->gpio); } else { ret = -1; - PRINT_ER("could not obtain gpio for WILC_INTR\n"); + netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); } if (ret != -1 && request_threaded_irq(wl->dev_irq_num, @@ -217,12 +195,13 @@ static int init_irq(struct net_device *dev) isr_bh_routine, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "WILC_IRQ", dev) < 0) { - PRINT_ER("Failed to request IRQ for GPIO: %d\n", wl->gpio); + netdev_err(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio); gpio_free(wl->gpio); ret = -1; } else { - PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", - wl->dev_irq_num, wl->gpio); + netdev_dbg(dev, + "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", + wl->dev_irq_num, wl->gpio); } return ret; @@ -243,22 +222,14 @@ static void deinit_irq(struct net_device *dev) } } -void wilc_dbg(u8 *buff) -{ - PRINT_D(INIT_DBG, "%d\n", *buff); -} - int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout) { /* FIXME: replace with mutex_lock or wait_for_completion */ int error = -1; - PRINT_D(LOCK_DBG, "Locking %p\n", vp); if (vp) - error = down_timeout((struct semaphore *)vp, + error = down_timeout(vp, msecs_to_jiffies(timeout)); - else - PRINT_ER("Failed, mutex is NULL\n"); return error; } @@ -275,8 +246,6 @@ void wilc_mac_indicate(struct wilc *wilc, int flag) } else { wilc->mac_status = status; } - } else if (flag == WILC_MAC_INDICATE_SCAN) { - PRINT_D(GENERIC_DBG, "Scanning ...\n"); } } @@ -288,26 +257,19 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) bssid = mac_header + 10; bssid1 = mac_header + 4; - 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 ", mac_header[i]); - bssid = mac_header + 18; - bssid1 = mac_header + 12; - 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; + for (i = 0; i < wilc->vif_num; i++) { + if (wilc->vif[i]->mode == STATION_MODE) + if (!memcmp(bssid, wilc->vif[i]->bssid, ETH_ALEN)) + return wilc->vif[i]->ndev; + if (wilc->vif[i]->mode == AP_MODE) + if (!memcmp(bssid1, wilc->vif[i]->bssid, ETH_ALEN)) + return wilc->vif[i]->ndev; + } - PRINT_INFO(INIT_DBG, "\n"); return NULL; } -int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid) +int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) { int i = 0; int ret = -1; @@ -320,6 +282,7 @@ int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid) for (i = 0; i < wilc->vif_num; i++) if (wilc->vif[i]->ndev == wilc_netdev) { memcpy(wilc->vif[i]->bssid, bssid, 6); + wilc->vif[i]->mode = mode; ret = 0; break; } @@ -362,28 +325,21 @@ static int linux_wlan_txq_task(void *vp) up(&wl->txq_thread_started); while (1) { - PRINT_D(TX_DBG, "txq_task Taking a nap :)\n"); down(&wl->txq_event); - PRINT_D(TX_DBG, "txq_task Who waked me up :$\n"); if (wl->close) { up(&wl->txq_thread_started); while (!kthread_should_stop()) schedule(); - - PRINT_D(TX_DBG, "TX thread stopped\n"); break; } - 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 ret = wilc_wlan_handle_txq(dev, &txq_count); #else do { ret = wilc_wlan_handle_txq(dev, &txq_count); if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { - PRINT_D(TX_DBG, "Waking up queue\n"); - if (netif_queue_stopped(wl->vif[0]->ndev)) netif_wake_queue(wl->vif[0]->ndev); if (netif_queue_stopped(wl->vif[1]->ndev)) @@ -391,9 +347,6 @@ static int linux_wlan_txq_task(void *vp) } if (ret == WILC_TX_ERR_NO_BUF) { - do { - msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight); - } while (0); backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP; if (backoff_weight > TX_BACKOFF_WEIGHT_MAX) backoff_weight = TX_BACKOFF_WEIGHT_MAX; @@ -410,43 +363,31 @@ static int linux_wlan_txq_task(void *vp) return 0; } -void wilc_rx_complete(struct wilc *nic) -{ - PRINT_D(RX_DBG, "RX completed\n"); -} - int wilc_wlan_get_firmware(struct net_device *dev) { struct wilc_vif *vif; struct wilc *wilc; - int ret = 0; + int chip_id, ret = 0; const struct firmware *wilc_firmware; char *firmware; vif = netdev_priv(dev); wilc = vif->wilc; - if (vif->iftype == AP_MODE) { - firmware = AP_FIRMWARE; - } else if (vif->iftype == STATION_MODE) { - firmware = STA_FIRMWARE; - } else { - PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n"); - firmware = P2P_CONCURRENCY_FIRMWARE; - } + chip_id = wilc_get_chipid(wilc, false); - if (!vif) { - PRINT_ER("vif is NULL\n"); - goto _fail_; - } + if (chip_id < 0x1003a0) + firmware = FIRMWARE_1002; + else + firmware = FIRMWARE_1003; - if (!(&vif->ndev->dev)) { - PRINT_ER("&vif->ndev->dev is NULL\n"); + netdev_info(dev, "loading firmware %s\n", firmware); + + if (!(&vif->ndev->dev)) goto _fail_; - } if (reject_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { - PRINT_ER("%s - firmare not available\n", firmware); + netdev_err(dev, "%s - firmare not available\n", firmware); ret = -1; goto _fail_; } @@ -466,20 +407,13 @@ static int linux_wlan_start_firmware(struct net_device *dev) vif = netdev_priv(dev); wilc = vif->wilc; - PRINT_D(INIT_DBG, "Starting Firmware ...\n"); ret = wilc_wlan_start(wilc); - if (ret < 0) { - PRINT_ER("Failed to start Firmware\n"); + if (ret < 0) return ret; - } - PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n"); ret = wilc_lock_timeout(wilc, &wilc->sync_event, 5000); - if (ret) { - PRINT_D(INIT_DBG, "Firmware start timed out"); + if (ret) return ret; - } - PRINT_D(INIT_DBG, "Firmware successfully started\n"); return 0; } @@ -494,128 +428,123 @@ static int wilc1000_firmware_download(struct net_device *dev) wilc = vif->wilc; if (!wilc->firmware) { - PRINT_ER("Firmware buffer is NULL\n"); + netdev_err(dev, "Firmware buffer is NULL\n"); return -ENOBUFS; } - PRINT_D(INIT_DBG, "Downloading Firmware ...\n"); + ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data, wilc->firmware->size); if (ret < 0) return ret; - PRINT_D(INIT_DBG, "Freeing FW buffer ...\n"); - PRINT_D(INIT_DBG, "Releasing firmware\n"); release_firmware(wilc->firmware); wilc->firmware = NULL; - PRINT_D(INIT_DBG, "Download Succeeded\n"); + netdev_dbg(dev, "Download Succeeded\n"); return 0; } static int linux_wlan_init_test_config(struct net_device *dev, - struct wilc *wilc) + struct wilc_vif *vif) { unsigned char c_val[64]; unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff}; - + struct wilc *wilc = vif->wilc; struct wilc_priv *priv; struct host_if_drv *hif_drv; - PRINT_D(TX_DBG, "Start configuring Firmware\n"); - get_random_bytes(&mac_add[5], 1); - get_random_bytes(&mac_add[4], 1); + netdev_dbg(dev, "Start configuring Firmware\n"); priv = wiphy_priv(dev->ieee80211_ptr->wiphy); - hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv; - PRINT_D(INIT_DBG, "Host = %p\n", hif_drv); + hif_drv = (struct host_if_drv *)priv->hif_drv; + netdev_dbg(dev, "Host = %p\n", hif_drv); + wilc_get_mac_address(vif, mac_add); - 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(wilc, 0); + netdev_dbg(dev, "MAC address is : %pM\n", mac_add); + wilc_get_chipid(wilc, false); *(int *)c_val = 1; - if (!wilc_wlan_cfg_set(wilc, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) goto _fail_; c_val[0] = 0; - if (!wilc_wlan_cfg_set(wilc, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = INFRASTRUCTURE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = RATE_AUTO; - if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = G_MIXED_11B_2_MODE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11G_OPERATING_MODE, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) goto _fail_; c_val[0] = G_SHORT_PREAMBLE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_PREAMBLE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = AUTO_PROT; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) goto _fail_; c_val[0] = ACTIVE_SCAN; - if (!wilc_wlan_cfg_set(wilc, 0, WID_SCAN_TYPE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = SITE_SURVEY_OFF; - if (!wilc_wlan_cfg_set(wilc, 0, WID_SITE_SURVEY, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0)) goto _fail_; *((int *)c_val) = 0xffff; - if (!wilc_wlan_cfg_set(wilc, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0)) goto _fail_; *((int *)c_val) = 2346; - if (!wilc_wlan_cfg_set(wilc, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0)) goto _fail_; c_val[0] = 0; - if (!wilc_wlan_cfg_set(wilc, 0, WID_BCAST_SSID, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_QOS_ENABLE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = NO_POWERSAVE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) goto _fail_; c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */ - if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_MODE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = OPEN_SYSTEM; - if (!wilc_wlan_cfg_set(wilc, 0, WID_AUTH_TYPE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0)) goto _fail_; strcpy(c_val, "123456790abcdef1234567890"); - if (!wilc_wlan_cfg_set(wilc, 0, WID_WEP_KEY_VALUE, c_val, + if (!wilc_wlan_cfg_set(vif, 0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0)) goto _fail_; strcpy(c_val, "12345678"); - if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0)) goto _fail_; strcpy(c_val, "password"); - if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1), + if (!wilc_wlan_cfg_set(vif, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0)) goto _fail_; @@ -623,106 +552,106 @@ static int linux_wlan_init_test_config(struct net_device *dev, c_val[1] = 168; c_val[2] = 1; c_val[3] = 112; - if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0)) goto _fail_; c_val[0] = 3; - if (!wilc_wlan_cfg_set(wilc, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 3; - if (!wilc_wlan_cfg_set(wilc, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) goto _fail_; c_val[0] = NORMAL_ACK; - if (!wilc_wlan_cfg_set(wilc, 0, WID_ACK_POLICY, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 0; - if (!wilc_wlan_cfg_set(wilc, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, + if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 48; - if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 28; - if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0)) goto _fail_; *((int *)c_val) = 100; - if (!wilc_wlan_cfg_set(wilc, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) goto _fail_; c_val[0] = REKEY_DISABLE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_POLICY, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, c_val, 1, 0, 0)) goto _fail_; *((int *)c_val) = 84600; - if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0)) goto _fail_; *((int *)c_val) = 500; - if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0)) goto _fail_; c_val[0] = G_SELF_CTS_PROT; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ENABLE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = HT_MIXED_MODE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OPERATING_MODE, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0)) goto _fail_; memcpy(c_val, mac_add, 6); - if (!wilc_wlan_cfg_set(wilc, 0, WID_MAC_ADDR, c_val, 6, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_MAC_ADDR, c_val, 6, 0, 0)) goto _fail_; c_val[0] = DETECT_PROTECT_REPORT; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0)) goto _fail_; c_val[0] = RTS_CTS_NONHT_PROT; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 0; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = MIMO_MODE; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 7; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0)) goto _fail_; c_val[0] = 1; - if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, 1)) goto _fail_; @@ -748,7 +677,6 @@ void wilc1000_wlan_deinit(struct net_device *dev) if (wl->initialized) { netdev_info(dev, "Deinitializing wilc1000...\n"); - PRINT_D(INIT_DBG, "Disabling IRQ\n"); if (!wl->dev_irq_num && wl->hif_func->disable_interrupt) { mutex_lock(&wl->hif_cs); @@ -758,37 +686,26 @@ void wilc1000_wlan_deinit(struct net_device *dev) if (&wl->txq_event) up(&wl->txq_event); - PRINT_D(INIT_DBG, "Deinitializing Threads\n"); wlan_deinitialize_threads(dev); - - PRINT_D(INIT_DBG, "Deinitializing IRQ\n"); deinit_irq(dev); wilc_wlan_stop(wl); - - PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n"); wilc_wlan_cleanup(dev); #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) if (!wl->dev_irq_num && wl->hif_func->disable_interrupt) { - - PRINT_D(INIT_DBG, "Disabling IRQ 2\n"); - mutex_lock(&wl->hif_cs); wl->hif_func->disable_interrupt(wl); mutex_unlock(&wl->hif_cs); } #endif - - PRINT_D(INIT_DBG, "Deinitializing Locks\n"); wlan_deinit_locks(dev); wl->initialized = false; - PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n"); - + netdev_dbg(dev, "wilc1000 deinitialization Done\n"); } else { - PRINT_D(INIT_DBG, "wilc1000 is not initialized\n"); + netdev_dbg(dev, "wilc1000 is not initialized\n"); } } @@ -800,8 +717,6 @@ static int wlan_init_locks(struct net_device *dev) vif = netdev_priv(dev); wl = vif->wilc; - PRINT_D(INIT_DBG, "Initializing Locks ...\n"); - mutex_init(&wl->hif_cs); mutex_init(&wl->rxq_cs); @@ -826,8 +741,6 @@ static int wlan_deinit_locks(struct net_device *dev) vif = netdev_priv(dev); wilc = vif->wilc; - PRINT_D(INIT_DBG, "De-Initializing Locks\n"); - if (&wilc->hif_cs) mutex_destroy(&wilc->hif_cs); @@ -845,12 +758,10 @@ static int wlan_initialize_threads(struct net_device *dev) vif = netdev_priv(dev); wilc = vif->wilc; - PRINT_D(INIT_DBG, "Initializing Threads ...\n"); - PRINT_D(INIT_DBG, "Creating kthread for transmission\n"); 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"); + netdev_err(dev, "couldn't create TXQ thread\n"); wilc->close = 0; return -ENOBUFS; } @@ -863,11 +774,11 @@ static void wlan_deinitialize_threads(struct net_device *dev) { struct wilc_vif *vif; struct wilc *wl; + vif = netdev_priv(dev); wl = vif->wilc; wl->close = 1; - PRINT_D(INIT_DBG, "Deinitializing Threads\n"); if (&wl->txq_event) up(&wl->txq_event); @@ -891,20 +802,17 @@ int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif) ret = wilc_wlan_init(dev); if (ret < 0) { - PRINT_ER("Initializing WILC_Wlan FAILED\n"); ret = -EIO; goto _fail_locks_; } if (wl->gpio >= 0 && init_irq(dev)) { - PRINT_ER("couldn't initialize IRQ\n"); ret = -EIO; goto _fail_locks_; } ret = wlan_initialize_threads(dev); if (ret < 0) { - PRINT_ER("Initializing Threads FAILED\n"); ret = -EIO; goto _fail_wilc_wlan_; } @@ -912,45 +820,41 @@ int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif) if (!wl->dev_irq_num && wl->hif_func->enable_interrupt && wl->hif_func->enable_interrupt(wl)) { - PRINT_ER("couldn't initialize IRQ\n"); ret = -EIO; goto _fail_irq_init_; } if (wilc_wlan_get_firmware(dev)) { - PRINT_ER("Can't get firmware\n"); ret = -EIO; goto _fail_irq_enable_; } ret = wilc1000_firmware_download(dev); if (ret < 0) { - PRINT_ER("Failed to download firmware\n"); ret = -EIO; goto _fail_irq_enable_; } ret = linux_wlan_start_firmware(dev); if (ret < 0) { - PRINT_ER("Failed to start firmware\n"); ret = -EIO; goto _fail_irq_enable_; } - if (wilc_wlan_cfg_get(wl, 1, WID_FIRMWARE_VERSION, 1, 0)) { + if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) { int size; - char Firmware_ver[20]; + char firmware_ver[20]; - 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); + size = wilc_wlan_cfg_get_val(WID_FIRMWARE_VERSION, + firmware_ver, + sizeof(firmware_ver)); + firmware_ver[size] = '\0'; + netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver); } - ret = linux_wlan_init_test_config(dev, wl); + ret = linux_wlan_init_test_config(dev, vif); if (ret < 0) { - PRINT_ER("Failed to configure firmware\n"); + netdev_err(dev, "Failed to configure firmware\n"); ret = -EIO; goto _fail_fw_start_; } @@ -974,9 +878,9 @@ _fail_wilc_wlan_: wilc_wlan_cleanup(dev); _fail_locks_: wlan_deinit_locks(dev); - PRINT_ER("WLAN Iinitialization FAILED\n"); + netdev_err(dev, "WLAN Iinitialization FAILED\n"); } else { - PRINT_D(INIT_DBG, "wilc1000 already initialized\n"); + netdev_dbg(dev, "wilc1000 already initialized\n"); } return ret; } @@ -1003,7 +907,7 @@ int wilc_mac_open(struct net_device *ndev) vif = netdev_priv(ndev); wl = vif->wilc; - if (!wl|| !wl->dev) { + if (!wl || !wl->dev) { netdev_err(ndev, "wilc1000: SPI device not ready\n"); return -ENODEV; } @@ -1011,31 +915,45 @@ int wilc_mac_open(struct net_device *ndev) vif = netdev_priv(ndev); wilc = vif->wilc; priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy); - PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev); + netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev); ret = wilc_init_host_int(ndev); - if (ret < 0) { - PRINT_ER("Failed to initialize host interface\n"); - + if (ret < 0) return ret; - } - PRINT_D(INIT_DBG, "*** re-init ***\n"); ret = wilc1000_wlan_init(ndev, vif); if (ret < 0) { - PRINT_ER("Failed to initialize wilc1000\n"); wilc_deinit_host_int(ndev); return ret; } - wilc_set_machw_change_vir_if(ndev, false); - - wilc_get_mac_address(vif, mac_add); - PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add); - for (i = 0; i < wl->vif_num; i++) { if (ndev == wl->vif[i]->ndev) { + if (vif->iftype == AP_MODE) { + wilc_set_wfi_drv_handler(vif, + wilc_get_vif_idx(vif), + 0); + } else if (!wilc_wlan_get_num_conn_ifcs(wilc)) { + wilc_set_wfi_drv_handler(vif, + wilc_get_vif_idx(vif), + wilc->open_ifcs); + } else { + if (memcmp(wilc->vif[i ^ 1]->bssid, + wilc->vif[i ^ 1]->src_addr, 6)) + wilc_set_wfi_drv_handler(vif, + wilc_get_vif_idx(vif), + 0); + else + wilc_set_wfi_drv_handler(vif, + wilc_get_vif_idx(vif), + 1); + } + wilc_set_operation_mode(vif, vif->iftype); + + wilc_get_mac_address(vif, mac_add); + netdev_dbg(ndev, "Mac address: %pM\n", mac_add); memcpy(wl->vif[i]->src_addr, mac_add, ETH_ALEN); + break; } } @@ -1043,7 +961,7 @@ int wilc_mac_open(struct net_device *ndev) 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"); + netdev_err(ndev, "Wrong MAC address\n"); wilc_deinit_host_int(ndev); wilc1000_wlan_deinit(ndev); return -EINVAL; @@ -1065,7 +983,7 @@ int wilc_mac_open(struct net_device *ndev) static struct net_device_stats *mac_stats(struct net_device *dev) { - struct wilc_vif *vif= netdev_priv(dev); + struct wilc_vif *vif = netdev_priv(dev); return &vif->netstats; } @@ -1080,57 +998,41 @@ static void wilc_set_multicast_list(struct net_device *dev) priv = wiphy_priv(dev->ieee80211_ptr->wiphy); vif = netdev_priv(dev); - hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv; - - if (!dev) - return; + hif_drv = (struct host_if_drv *)priv->hif_drv; - PRINT_D(INIT_DBG, "Setting Multicast List with count = %d.\n", - dev->mc.count); - - if (dev->flags & IFF_PROMISC) { - PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets\n"); + if (dev->flags & IFF_PROMISC) return; - } if ((dev->flags & IFF_ALLMULTI) || (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) { - PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); wilc_setup_multicast_filter(vif, false, 0); return; } if ((dev->mc.count) == 0) { - PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); wilc_setup_multicast_filter(vif, true, 0); return; } netdev_for_each_mc_addr(ha, dev) { memcpy(wilc_multicast_mac_addr_list[i], ha->addr, ETH_ALEN); - PRINT_D(INIT_DBG, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i, - wilc_multicast_mac_addr_list[i][0], - wilc_multicast_mac_addr_list[i][1], - wilc_multicast_mac_addr_list[i][2], - wilc_multicast_mac_addr_list[i][3], - wilc_multicast_mac_addr_list[i][4], - wilc_multicast_mac_addr_list[i][5]); + netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i, + wilc_multicast_mac_addr_list[i][0], + wilc_multicast_mac_addr_list[i][1], + wilc_multicast_mac_addr_list[i][2], + wilc_multicast_mac_addr_list[i][3], + wilc_multicast_mac_addr_list[i][4], + wilc_multicast_mac_addr_list[i][5]); i++; } wilc_setup_multicast_filter(vif, true, (dev->mc.count)); - - return; } static void linux_wlan_tx_complete(void *priv, int status) { - struct tx_complete_data *pv_data = (struct tx_complete_data *)priv; + struct tx_complete_data *pv_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); dev_kfree_skb(pv_data->skb); kfree(pv_data); } @@ -1148,16 +1050,13 @@ int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) vif = netdev_priv(ndev); wilc = vif->wilc; - PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n"); - if (skb->dev != ndev) { - PRINT_ER("Packet not destined to this device\n"); + netdev_err(ndev, "Packet not destined to this device\n"); return 0; } tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); if (!tx_data) { - PRINT_ER("Failed to allocate memory for tx_data structure\n"); dev_kfree_skb(skb); netif_wake_queue(ndev); return 0; @@ -1169,21 +1068,19 @@ int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) eth_h = (struct ethhdr *)(skb->data); if (eth_h->h_proto == 0x8e88) - PRINT_D(INIT_DBG, "EAPOL transmitted\n"); + netdev_dbg(ndev, "EAPOL transmitted\n"); ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr)); udp_buf = (char *)ih + sizeof(struct iphdr); if ((udp_buf[1] == 68 && udp_buf[3] == 67) || (udp_buf[1] == 67 && udp_buf[3] == 68)) - PRINT_D(GENERIC_DBG, "DHCP Message transmitted, type:%x %x %x\n", - udp_buf[248], udp_buf[249], udp_buf[250]); + netdev_dbg(ndev, "DHCP Message transmitted, type:%x %x %x\n", + udp_buf[248], udp_buf[249], udp_buf[250]); - PRINT_D(TX_DBG, "Sending packet - Size = %d - Address = %p - SKB = %p\n", tx_data->size, tx_data->buff, tx_data->skb); - PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n"); vif->netstats.tx_packets++; vif->netstats.tx_bytes += tx_data->size; - tx_data->pBssid = wilc->vif[vif->u8IfIdx]->bssid; + tx_data->bssid = wilc->vif[vif->idx]->bssid; queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data, tx_data->buff, tx_data->size, linux_wlan_tx_complete); @@ -1206,39 +1103,29 @@ int wilc_mac_close(struct net_device *ndev) vif = netdev_priv(ndev); if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr || - !vif->ndev->ieee80211_ptr->wiphy) { - PRINT_ER("vif = NULL\n"); + !vif->ndev->ieee80211_ptr->wiphy) return 0; - } priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy); wl = vif->wilc; - if (!priv) { - PRINT_ER("priv = NULL\n"); + if (!priv) return 0; - } - hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv; + hif_drv = (struct host_if_drv *)priv->hif_drv; - PRINT_D(GENERIC_DBG, "Mac close\n"); + netdev_dbg(ndev, "Mac close\n"); - if (!wl) { - PRINT_ER("wl = NULL\n"); + if (!wl) return 0; - } - if (!hif_drv) { - PRINT_ER("hif_drv = NULL\n"); + if (!hif_drv) return 0; - } - if ((wl->open_ifcs) > 0) { + if ((wl->open_ifcs) > 0) wl->open_ifcs--; - } else { - PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n"); + else return 0; - } if (vif->ndev) { netif_stop_queue(vif->ndev); @@ -1247,7 +1134,7 @@ int wilc_mac_close(struct net_device *ndev) } if (wl->open_ifcs == 0) { - PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n"); + netdev_dbg(ndev, "Deinitializing wilc1000\n"); wl->close = 1; wilc1000_wlan_deinit(ndev); WILC_WFI_deinit_mon_interface(); @@ -1278,7 +1165,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) switch (cmd) { case SIOCSIWPRIV: { - struct iwreq *wrq = (struct iwreq *) req; + struct iwreq *wrq = (struct iwreq *)req; size = wrq->u.data.length; @@ -1291,16 +1178,14 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) if (strncasecmp(buff, "RSSI", length) == 0) { priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy); ret = wilc_get_rssi(vif, &rssi); - if (ret) - PRINT_ER("Failed to send get rssi param's message queue "); - PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi); + netdev_info(ndev, "RSSI :%d\n", rssi); rssi += 5; snprintf(buff, size, "rssi %d", rssi); if (copy_to_user(wrq->u.data.pointer, buff, size)) { - PRINT_ER("%s: failed to copy data to user buffer\n", __func__); + netdev_err(ndev, "failed to copy\n"); ret = -EFAULT; goto done; } @@ -1311,7 +1196,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) default: { - PRINT_INFO(GENERIC_DBG, "Command - %d - has been received\n", cmd); + netdev_info(ndev, "Command - %d - has been received\n", cmd); ret = -EOPNOTSUPP; goto done; } @@ -1333,6 +1218,9 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset) struct net_device *wilc_netdev; struct wilc_vif *vif; + if (!wilc) + return; + wilc_netdev = get_if_handler(wilc, buff); if (!wilc_netdev) return; @@ -1345,18 +1233,11 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset) buff_to_send = buff; skb = dev_alloc_skb(frame_len); - if (!skb) { - PRINT_ER("Low memory - packet droped\n"); + if (!skb) return; - } - if (!wilc || !wilc_netdev) - PRINT_ER("wilc_netdev in wilc is NULL"); skb->dev = wilc_netdev; - if (!skb->dev) - PRINT_ER("skb->dev is NULL\n"); - memcpy(skb_put(skb, frame_len), buff_to_send, frame_len); skb->protocol = eth_type_trans(skb, wilc_netdev); @@ -1364,7 +1245,7 @@ void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset) vif->netstats.rx_bytes += frame_len; skb->ip_summed = CHECKSUM_UNNECESSARY; stats = netif_rx(skb); - PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats); + netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats); } } @@ -1403,7 +1284,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) release_firmware(wilc->firmware); if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { - wilc_lock_timeout(wilc, &close_exit_sync, 12 * 1000); + wilc_lock_timeout(wilc, &close_exit_sync, 5 * 1000); for (i = 0; i < NUM_CONCURRENT_IFC; i++) if (wilc->vif[i]->ndev) @@ -1424,7 +1305,7 @@ EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, int gpio, const struct wilc_hif_func *ops) { - int i; + int i, ret; struct wilc_vif *vif; struct net_device *ndev; struct wilc *wl; @@ -1444,10 +1325,8 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, for (i = 0; i < NUM_CONCURRENT_IFC; i++) { ndev = alloc_etherdev(sizeof(struct wilc_vif)); - if (!ndev) { - PRINT_ER("Failed to allocate ethernet dev\n"); - return -1; - } + if (!ndev) + return -ENOMEM; vif = netdev_priv(ndev); memset(vif, 0, sizeof(struct wilc_vif)); @@ -1457,7 +1336,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, else strcpy(ndev->name, "p2p%d"); - vif->u8IfIdx = wl->vif_num; + vif->idx = wl->vif_num; vif->wilc = *wilc; wl->vif[i] = vif; wl->vif[wl->vif_num]->ndev = ndev; @@ -1466,13 +1345,14 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, { struct wireless_dev *wdev; + wdev = wilc_create_wiphy(ndev, dev); if (dev) SET_NETDEV_DEV(ndev, dev); if (!wdev) { - PRINT_ER("Can't register WILC Wiphy\n"); + netdev_err(ndev, "Can't register WILC Wiphy\n"); return -1; } @@ -1485,11 +1365,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, vif->netstats.tx_bytes = 0; } - if (register_netdev(ndev)) { - PRINT_ER("Device couldn't be registered - %s\n", - ndev->name); - return -1; - } + ret = register_netdev(ndev); + if (ret) + return ret; vif->iftype = STATION_MODE; vif->mac_opened = 0; |