Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wfi_cfgoperations.c
index a5617de4c3b75a0d71f31fd61cc445e063c0d2f7..3e9501727812c589ba986304cb4689eb87bb4146 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #include "wilc_wfi_cfgoperations.h"
-#include "wilc_wlan.c"
 #ifdef WILC_SDIO
 #include "linux_wlan_sdio.h"
 #endif
@@ -23,7 +22,6 @@
 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
 
 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
-extern u16 Set_machw_change_vir_if(bool bValue);
 
 extern int mac_open(struct net_device *ndev);
 extern int mac_close(struct net_device *ndev);
@@ -36,7 +34,6 @@ static u8 op_ifcs;
 extern u8 u8ConnectedSSID[6];
 
 u8 g_wilc_initialized = 1;
-extern linux_wlan_t *g_linux_wlan;
 extern bool g_obtainingIP;
 
 #define CHAN2G(_channel, _freq, _flags) {       \
@@ -234,10 +231,8 @@ static void remove_network_from_shadow(unsigned long arg)
                if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
                        PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", astrLastScannedNtwrksShadow[i].au8ssid);
 
-                       if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
-                               kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
-                               astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
-                       }
+                       kfree(astrLastScannedNtwrksShadow[i].pu8IEs);
+                       astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
 
                        host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
 
@@ -357,7 +352,7 @@ void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, vo
  *  @date
  *  @version   1.0
  */
-static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
+static void CfgScanResult(enum scan_event enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
 {
        struct wilc_priv *priv;
        struct wiphy *wiphy;
@@ -366,7 +361,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo
        struct cfg80211_bss *bss = NULL;
 
        priv = (struct wilc_priv *)pUserVoid;
-       if (priv->bCfgScanning == true) {
+       if (priv->bCfgScanning) {
                if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
                        wiphy = priv->dev->ieee80211_ptr->wiphy;
 
@@ -394,7 +389,7 @@ static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetwo
                                           "BeaconPeriod: %d\n", channel->center_freq, (((s32)pstrNetworkInfo->s8rssi) * 100),
                                           pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
 
-                               if (pstrNetworkInfo->bNewNetwork == true) {
+                               if (pstrNetworkInfo->bNewNetwork) {
                                        if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
                                                /*               max_scan_ssids */
                                                PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
@@ -531,7 +526,7 @@ int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID);
  */
 int connecting;
 
-static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
+static void CfgConnectResult(enum conn_event enuConnDisconnEvent,
                             tstrConnectInfo *pstrConnectInfo,
                             u8 u8MacStatus,
                             tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
@@ -541,16 +536,20 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
        struct net_device *dev;
        struct host_if_drv *pstrWFIDrv;
        u8 NullBssid[ETH_ALEN] = {0};
+       struct wilc *wl;
+       perInterface_wlan_t *nic;
 
        connecting = 0;
 
        priv = (struct wilc_priv *)pUserVoid;
        dev = priv->dev;
+       nic = netdev_priv(dev);
+       wl = nic->wilc;
        pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv;
 
        if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
                /*Initialization*/
-               u16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
+               u16 u16ConnectStatus;
 
                u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
 
@@ -628,12 +627,12 @@ static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
                        u8WLANChannel = INVALID_CHANNEL;
                /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
                 *      virtual interface to station*/
-               if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
+               if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
                        pstrDisconnectNotifInfo->u16reason = 3;
                }
                /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
                 *      to scan again and retry the connection*/
-               else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
+               else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) {
                        pstrDisconnectNotifInfo->u16reason = 1;
                }
                cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
@@ -892,7 +891,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
                        g_key_wep_params.key_idx = sme->key_idx;
                        g_wep_keys_saved = true;
 
-                       host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
+                       host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
                        host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
                } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104)   {
                        u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
@@ -909,7 +908,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev,
                        g_key_wep_params.key_idx = sme->key_idx;
                        g_wep_keys_saved = true;
 
-                       host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
+                       host_int_set_wep_default_key(priv->hWILCWFIDrv, sme->key_idx);
                        host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
                } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)   {
                        if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
@@ -1086,8 +1085,12 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
        u8 u8gmode = NO_ENCRYPT;
        u8 u8pmode = NO_ENCRYPT;
        enum AUTHTYPE tenuAuth_type = ANY;
+       struct wilc *wl;
+       perInterface_wlan_t *nic;
 
        priv = wiphy_priv(wiphy);
+       nic = netdev_priv(netdev);
+       wl = nic->wilc;
 
        PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
 
@@ -1172,15 +1175,13 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
                                        KeyLen = params->key_len - 16;
                                }
                                /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
-                               if (priv->wilc_gtk[key_index]->key)
-                                       kfree(priv->wilc_gtk[key_index]->key);
+                               kfree(priv->wilc_gtk[key_index]->key);
 
                                priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
                                memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
 
                                /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
-                               if (priv->wilc_gtk[key_index]->seq)
-                                       kfree(priv->wilc_gtk[key_index]->seq);
+                               kfree(priv->wilc_gtk[key_index]->seq);
 
                                if ((params->seq_len) > 0) {
                                        priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
@@ -1218,13 +1219,11 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
                                        KeyLen = params->key_len - 16;
                                }
 
-                               if (priv->wilc_ptk[key_index]->key)
-                                       kfree(priv->wilc_ptk[key_index]->key);
+                               kfree(priv->wilc_ptk[key_index]->key);
 
                                priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
 
-                               if (priv->wilc_ptk[key_index]->seq)
-                                       kfree(priv->wilc_ptk[key_index]->seq);
+                               kfree(priv->wilc_ptk[key_index]->seq);
 
                                if ((params->seq_len) > 0)
                                        priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
@@ -1263,7 +1262,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
                                }
 
                                /*save keys only on interface 0 (wifi interface)*/
-                               if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+                               if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) {
                                        g_add_gtk_key_params.key_idx = key_index;
                                        g_add_gtk_key_params.pairwise = pairwise;
                                        if (!mac_addr) {
@@ -1299,7 +1298,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
                                }
 
                                /*save keys only on interface 0 (wifi interface)*/
-                               if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+                               if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) {
                                        g_add_ptk_key_params.key_idx = key_index;
                                        g_add_ptk_key_params.pairwise = pairwise;
                                        if (!mac_addr) {
@@ -1360,35 +1359,31 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
                   const u8 *mac_addr)
 {
        struct wilc_priv *priv;
+       struct wilc *wl;
+       perInterface_wlan_t *nic;
 
        priv = wiphy_priv(wiphy);
+       nic = netdev_priv(netdev);
+       wl = nic->wilc;
 
        /*delete saved keys, if any*/
-       if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+       if (netdev == wl->vif[0].ndev) {
                g_ptk_keys_saved = false;
                g_gtk_keys_saved = false;
                g_wep_keys_saved = false;
 
                /*Delete saved WEP keys params, if any*/
-               if (g_key_wep_params.key != NULL) {
-                       kfree(g_key_wep_params.key);
-                       g_key_wep_params.key = NULL;
-               }
+               kfree(g_key_wep_params.key);
+               g_key_wep_params.key = NULL;
 
                /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
 
                if ((priv->wilc_gtk[key_index]) != NULL) {
 
-                       if (priv->wilc_gtk[key_index]->key != NULL) {
-
-                               kfree(priv->wilc_gtk[key_index]->key);
-                               priv->wilc_gtk[key_index]->key = NULL;
-                       }
-                       if (priv->wilc_gtk[key_index]->seq) {
-
-                               kfree(priv->wilc_gtk[key_index]->seq);
-                               priv->wilc_gtk[key_index]->seq = NULL;
-                       }
+                       kfree(priv->wilc_gtk[key_index]->key);
+                       priv->wilc_gtk[key_index]->key = NULL;
+                       kfree(priv->wilc_gtk[key_index]->seq);
+                       priv->wilc_gtk[key_index]->seq = NULL;
 
                        kfree(priv->wilc_gtk[key_index]);
                        priv->wilc_gtk[key_index] = NULL;
@@ -1397,41 +1392,27 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev,
 
                if ((priv->wilc_ptk[key_index]) != NULL) {
 
-                       if (priv->wilc_ptk[key_index]->key) {
-
-                               kfree(priv->wilc_ptk[key_index]->key);
-                               priv->wilc_ptk[key_index]->key = NULL;
-                       }
-                       if (priv->wilc_ptk[key_index]->seq) {
-
-                               kfree(priv->wilc_ptk[key_index]->seq);
-                               priv->wilc_ptk[key_index]->seq = NULL;
-                       }
+                       kfree(priv->wilc_ptk[key_index]->key);
+                       priv->wilc_ptk[key_index]->key = NULL;
+                       kfree(priv->wilc_ptk[key_index]->seq);
+                       priv->wilc_ptk[key_index]->seq = NULL;
                        kfree(priv->wilc_ptk[key_index]);
                        priv->wilc_ptk[key_index] = NULL;
                }
 
                /*Delete saved PTK and GTK keys params, if any*/
-               if (g_key_ptk_params.key != NULL) {
-                       kfree(g_key_ptk_params.key);
-                       g_key_ptk_params.key = NULL;
-               }
-               if (g_key_ptk_params.seq != NULL) {
-                       kfree(g_key_ptk_params.seq);
-                       g_key_ptk_params.seq = NULL;
-               }
+               kfree(g_key_ptk_params.key);
+               g_key_ptk_params.key = NULL;
+               kfree(g_key_ptk_params.seq);
+               g_key_ptk_params.seq = NULL;
 
-               if (g_key_gtk_params.key != NULL) {
-                       kfree(g_key_gtk_params.key);
-                       g_key_gtk_params.key = NULL;
-               }
-               if (g_key_gtk_params.seq != NULL) {
-                       kfree(g_key_gtk_params.seq);
-                       g_key_gtk_params.seq = NULL;
-               }
+               kfree(g_key_gtk_params.key);
+               g_key_gtk_params.key = NULL;
+               kfree(g_key_gtk_params.seq);
+               g_key_gtk_params.seq = NULL;
 
                /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
-               Set_machw_change_vir_if(false);
+               Set_machw_change_vir_if(netdev, false);
        }
 
        if (key_index >= 0 && key_index <= 3) {
@@ -1472,8 +1453,7 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
        priv = wiphy_priv(wiphy);
 
 
-       if (!pairwise)
-       {
+       if (!pairwise) {
                PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
 
                key_params.key = priv->wilc_gtk[key_index]->key;
@@ -1521,7 +1501,7 @@ static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 ke
 
        if (key_index != priv->WILC_WFI_wep_default) {
 
-               host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
+               host_int_set_wep_default_key(priv->hWILCWFIDrv, key_index);
        }
 
        return 0;
@@ -1576,7 +1556,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
        }
 
        if (nic->iftype == STATION_MODE) {
-               tstrStatistics strStatistics;
+               struct rf_info strStatistics;
 
                host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
 
@@ -1650,25 +1630,25 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
 
        priv = wiphy_priv(wiphy);
 
-       pstrCfgParamVal.u32SetCfgFlag = 0;
+       pstrCfgParamVal.flag = 0;
        PRINT_D(CFG80211_DBG, "Setting Wiphy params\n");
 
        if (changed & WIPHY_PARAM_RETRY_SHORT) {
                PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
                        priv->dev->ieee80211_ptr->wiphy->retry_short);
-               pstrCfgParamVal.u32SetCfgFlag  |= RETRY_SHORT;
+               pstrCfgParamVal.flag  |= RETRY_SHORT;
                pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
        }
        if (changed & WIPHY_PARAM_RETRY_LONG) {
 
                PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
-               pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
+               pstrCfgParamVal.flag |= RETRY_LONG;
                pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
 
        }
        if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
                PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
-               pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
+               pstrCfgParamVal.flag |= FRAG_THRESHOLD;
                pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
 
        }
@@ -1676,7 +1656,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
        if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
                PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
 
-               pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
+               pstrCfgParamVal.flag |= RTS_THRESHOLD;
                pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
 
        }
@@ -1756,7 +1736,6 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
 {
 
        u32 i;
-       u8 flag = 0;
        s32 s32Error = 0;
 
        struct wilc_priv *priv = wiphy_priv(wiphy);
@@ -1769,7 +1748,6 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
                        /*If bssid is found, reset the values*/
                        PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
                        memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid));
-                       flag = PMKID_FOUND;
                        break;
                }
        }
@@ -1846,9 +1824,8 @@ void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len)
                        op_channel_attr_index = index;
                index += buf[index + 1] + 3; /* ID,Length byte */
        }
+       if (u8WLANChannel != INVALID_CHANNEL) {
 
-       if (u8WLANChannel != INVALID_CHANNEL)
-       {
                /*Modify channel list attribute*/
                if (channel_list_attr_index) {
                        PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
@@ -1901,9 +1878,8 @@ void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype)
                        op_channel_attr_index = index;
                index += buf[index + 1] + 3; /* ID,Length byte */
        }
+       if (u8WLANChannel != INVALID_CHANNEL && bOperChan) {
 
-       if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
-       {
                /*Modify channel list attribute*/
                if (channel_list_attr_index) {
                        PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
@@ -1981,7 +1957,7 @@ void WILC_WFI_p2p_rx (struct net_device *dev, u8 *buff, u32 size)
                if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
                        PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
 
-                       if (priv->bCfgScanning == true && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
+                       if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->u64P2p_MgmtTimeout)) {
                                PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
                                return;
                        }
@@ -2202,20 +2178,6 @@ static int cancel_remain_on_channel(struct wiphy *wiphy,
        s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
        return s32Error;
 }
-/**
- *  @brief       WILC_WFI_add_wilcvendorspec
- *  @details    Adding WILC information elemet to allow two WILC devices to
- *                              identify each other and connect
- *  @param[in]   u8 * buf
- *  @return     void
- *  @author    mdaftedar
- *  @date      01 JAN 2014
- *  @version   1.0
- */
-void WILC_WFI_add_wilcvendorspec(u8 *buff)
-{
-       memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
-}
 /**
  *  @brief      WILC_WFI_mgmt_tx_frame
  *  @details
@@ -2226,7 +2188,6 @@ void WILC_WFI_add_wilcvendorspec(u8 *buff)
  *  @date      01 JUL 2012
  *  @version
  */
-extern linux_wlan_t *g_linux_wlan;
 extern bool bEnablePS;
 static int mgmt_tx(struct wiphy *wiphy,
                   struct wireless_dev *wdev,
@@ -2340,7 +2301,11 @@ static int mgmt_tx(struct wiphy *wiphy,
                                                                }
 
                                                                if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
-                                                                       WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
+                                                                       /*
+                                                                        * Adding WILC information element to allow two WILC devices to
+                                                                        * identify each other and connect
+                                                                        */
+                                                                       memcpy(&mgmt_tx->buff[len], u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
                                                                        mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
                                                                        mgmt_tx->size = buf_len;
                                                                }
@@ -2394,7 +2359,7 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy,
        PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
        pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
 
-       if (priv->bInP2PlistenState == false) {
+       if (!priv->bInP2PlistenState) {
                cfg80211_remain_on_channel_expired(priv->wdev,
                                                   priv->strRemainOnChanParams.u64ListenCookie,
                                                   priv->strRemainOnChanParams.pstrListenChan,
@@ -2421,12 +2386,11 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
 
        struct wilc_priv *priv;
        perInterface_wlan_t *nic;
-
+       struct wilc *wl;
 
        priv = wiphy_priv(wiphy);
        nic = netdev_priv(priv->wdev->netdev);
-
-
+       wl = nic->wilc;
 
        if (!frame_type)
                return;
@@ -2454,7 +2418,7 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
 
        }
        /*If mac is closed, then return*/
-       if (!g_linux_wlan->wilc1000_initialized) {
+       if (!wl->initialized) {
                PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
                return;
        }
@@ -2559,7 +2523,6 @@ static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
  *  @date      01 MAR 2012
  *  @version   1.0
  */
-void wilc1000_wlan_deinit(linux_wlan_t *nic);
 int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
 
 static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
@@ -2570,9 +2533,11 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
        u8 interface_type;
        u16 TID = 0;
        u8 i;
+       struct wilc *wl;
 
        nic = netdev_priv(dev);
        priv = wiphy_priv(wiphy);
+       wl = nic->wilc;
 
        PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
        PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
@@ -2586,7 +2551,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
        PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
        /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
        if (g_ptk_keys_saved && g_gtk_keys_saved) {
-               Set_machw_change_vir_if(true);
+               Set_machw_change_vir_if(dev, true);
        }
 
        switch (type) {
@@ -2607,30 +2572,31 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                interface_type = nic->iftype;
                nic->iftype = STATION_MODE;
 
-               if (g_linux_wlan->wilc1000_initialized) {
-                       host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+               if (wl->initialized) {
+                       host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
+                                                     wl->vif[0].bssid, TID);
                        /* ensure that the message Q is empty */
                        host_int_wait_msg_queue_idle();
 
                        /*Eliminate host interface blocking state*/
-                       up(&g_linux_wlan->cfg_event);
+                       up(&wl->cfg_event);
 
-                       wilc1000_wlan_deinit(g_linux_wlan);
+                       wilc1000_wlan_deinit(dev);
                        wilc1000_wlan_init(dev, nic);
                        g_wilc_initialized = 1;
                        nic->iftype = interface_type;
 
                        /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
-                       host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
-                       host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
-                                               g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+                       host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
+                       host_int_set_MacAddress(wl->vif[0].hif_drv,
+                                               wl->vif[0].src_addr);
                        host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
 
                        /*Add saved WEP keys, if any*/
                        if (g_wep_keys_saved) {
-                               host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                               host_int_set_wep_default_key(wl->vif[0].hif_drv,
                                                             g_key_wep_params.key_idx);
-                               host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                               host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
                                                             g_key_wep_params.key,
                                                             g_key_wep_params.key_len,
                                                             g_key_wep_params.key_idx);
@@ -2648,22 +2614,22 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                                PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
                                        g_key_gtk_params.key[1],
                                        g_key_gtk_params.key[2]);
-                               add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                                       g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                               add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                                       wl->vif[0].ndev,
                                        g_add_ptk_key_params.key_idx,
                                        g_add_ptk_key_params.pairwise,
                                        g_add_ptk_key_params.mac_addr,
                                        (struct key_params *)(&g_key_ptk_params));
 
-                               add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                                       g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                               add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                                       wl->vif[0].ndev,
                                        g_add_gtk_key_params.key_idx,
                                        g_add_gtk_key_params.pairwise,
                                        g_add_gtk_key_params.mac_addr,
                                        (struct key_params *)(&g_key_gtk_params));
                        }
 
-                       if (g_linux_wlan->wilc1000_initialized) {
+                       if (wl->initialized)    {
                                for (i = 0; i < num_reg_frame; i++) {
                                        PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
                                                nic->g_struct_frame_reg[i].reg);
@@ -2684,7 +2650,8 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                connecting = 0;
                PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
 
-               host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+               host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
+                                             wl->vif[0].bssid, TID);
 
                dev->ieee80211_ptr->iftype = type;
                priv->wdev->iftype = type;
@@ -2694,24 +2661,24 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                nic->iftype = CLIENT_MODE;
 
 
-               if (g_linux_wlan->wilc1000_initialized) {
+               if (wl->initialized)    {
                        /* ensure that the message Q is empty */
                        host_int_wait_msg_queue_idle();
 
-                       wilc1000_wlan_deinit(g_linux_wlan);
+                       wilc1000_wlan_deinit(dev);
                        wilc1000_wlan_init(dev, nic);
                        g_wilc_initialized = 1;
 
-                       host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
-                       host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
-                                               g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+                       host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
+                       host_int_set_MacAddress(wl->vif[0].hif_drv,
+                                               wl->vif[0].src_addr);
                        host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
 
                        /*Add saved WEP keys, if any*/
                        if (g_wep_keys_saved) {
-                               host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                               host_int_set_wep_default_key(wl->vif[0].hif_drv,
                                                             g_key_wep_params.key_idx);
-                               host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                               host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
                                                             g_key_wep_params.key,
                                                             g_key_wep_params.key_len,
                                                             g_key_wep_params.key_idx);
@@ -2729,15 +2696,15 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                                PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
                                        g_key_gtk_params.key[1],
                                        g_key_gtk_params.key[2]);
-                               add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                                       g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                               add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                                       wl->vif[0].ndev,
                                        g_add_ptk_key_params.key_idx,
                                        g_add_ptk_key_params.pairwise,
                                        g_add_ptk_key_params.mac_addr,
                                        (struct key_params *)(&g_key_ptk_params));
 
-                               add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                                       g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                               add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                                       wl->vif[0].ndev,
                                        g_add_gtk_key_params.key_idx,
                                        g_add_gtk_key_params.pairwise,
                                        g_add_gtk_key_params.mac_addr,
@@ -2746,9 +2713,9 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
 
                        /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
                        refresh_scan(priv, 1, true);
-                       Set_machw_change_vir_if(false);
+                       Set_machw_change_vir_if(dev, false);
 
-                       if (g_linux_wlan->wilc1000_initialized) {
+                       if (wl->initialized)    {
                                for (i = 0; i < num_reg_frame; i++) {
                                        PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
                                                nic->g_struct_frame_reg[i].reg);
@@ -2771,9 +2738,8 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
                linux_wlan_get_firmware(nic);
                /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
-               if (g_linux_wlan->wilc1000_initialized) {
+               if (wl->initialized)    {
                        nic->iftype = AP_MODE;
-                       g_linux_wlan->wilc1000_initialized = 1;
                        mac_close(dev);
                        mac_open(dev);
 
@@ -2797,7 +2763,8 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                /*sent before downloading new FW. This is because it blocks on*/
                /*hWaitResponse semaphore, which allows previous config*/
                /*packets to actually take action on old FW*/
-               host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+               host_int_del_All_Rx_BASession(priv->hWILCWFIDrv,
+                                             wl->vif[0].bssid, TID);
                bEnablePS = false;
                PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
                dev->ieee80211_ptr->iftype = type;
@@ -2812,22 +2779,22 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
 
                /* ensure that the message Q is empty */
                host_int_wait_msg_queue_idle();
-               wilc1000_wlan_deinit(g_linux_wlan);
+               wilc1000_wlan_deinit(dev);
                wilc1000_wlan_init(dev, nic);
                g_wilc_initialized = 1;
 
 
                /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
-               host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
-               host_int_set_MacAddress(g_linux_wlan->strInterfaceInfo[0].drvHandler,
-                                       g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+               host_int_set_wfi_drv_handler(wl->vif[0].hif_drv);
+               host_int_set_MacAddress(wl->vif[0].hif_drv,
+                                       wl->vif[0].src_addr);
                host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
 
                /*Add saved WEP keys, if any*/
                if (g_wep_keys_saved) {
-                       host_int_set_WEPDefaultKeyID(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                       host_int_set_wep_default_key(wl->vif[0].hif_drv,
                                                     g_key_wep_params.key_idx);
-                       host_int_add_wep_key_bss_sta(g_linux_wlan->strInterfaceInfo[0].drvHandler,
+                       host_int_add_wep_key_bss_sta(wl->vif[0].hif_drv,
                                                     g_key_wep_params.key,
                                                     g_key_wep_params.key_len,
                                                     g_key_wep_params.key_idx);
@@ -2847,22 +2814,22 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev,
                                g_key_gtk_params.key[1],
                                g_key_gtk_params.key[2],
                                g_key_gtk_params.cipher);
-                       add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                               g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                       add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                               wl->vif[0].ndev,
                                g_add_ptk_key_params.key_idx,
                                g_add_ptk_key_params.pairwise,
                                g_add_ptk_key_params.mac_addr,
                                (struct key_params *)(&g_key_ptk_params));
 
-                       add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
-                               g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+                       add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy,
+                               wl->vif[0].ndev,
                                g_add_gtk_key_params.key_idx,
                                g_add_gtk_key_params.pairwise,
                                g_add_gtk_key_params.mac_addr,
                                (struct key_params *)(&g_key_gtk_params));
                }
 
-               if (g_linux_wlan->wilc1000_initialized) {
+               if (wl->initialized)    {
                        for (i = 0; i < num_reg_frame; i++) {
                                PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
                                        nic->g_struct_frame_reg[i].reg);
@@ -2913,8 +2880,12 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev,
        struct cfg80211_beacon_data *beacon = &(settings->beacon);
        struct wilc_priv *priv;
        s32 s32Error = 0;
+       struct wilc *wl;
+       perInterface_wlan_t *nic;
 
        priv = wiphy_priv(wiphy);
+       nic = netdev_priv(dev);
+       wl = nic->wilc;
        PRINT_D(HOSTAPD_DBG, "Starting ap\n");
 
        PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n",
@@ -2925,7 +2896,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev,
        if (s32Error != 0)
                PRINT_ER("Error in setting channel\n");
 
-       linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+       linux_wlan_set_bssid(dev, wl->vif[0].src_addr);
 
        s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
                                        settings->beacon_interval,
@@ -3482,7 +3453,7 @@ int wilc_init_host_int(struct net_device *net)
        priv->bInP2PlistenState = false;
 
        sema_init(&(priv->hSemScanReq), 1);
-       s32Error = host_int_init(&priv->hWILCWFIDrv);
+       s32Error = host_int_init(net, &priv->hWILCWFIDrv);
        if (s32Error)
                PRINT_ER("Error while initializing hostinterface\n");