staging: wilc1000: wilc_wlan_rxq_add: add argument wilc and use it
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wlan.c
index 9475ec7569cf2ede1198d4da118b5e8008c83b7a..a6b966f2865e66d2372dc8e76624b1a50a279a63 100644 (file)
@@ -8,7 +8,8 @@
 /* //////////////////////////////////////////////////////////////////////////// */
 
 #include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
+#include "wilc_wfi_netdevice.h"
+#include "wilc_wlan_cfg.h"
 
 /********************************************
  *
  ********************************************/
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
-extern wilc_cfg_func_t mac_cfg;
-extern void WILC_WFI_mgmt_rx(u8 *buff, u32 size);
 u32 wilc_get_chipid(u8 update);
-u16 Set_machw_change_vir_if(bool bValue);
 
 
 
@@ -141,8 +139,7 @@ static inline void release_bus(BUS_RELEASE_T release)
 static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
-       /* unsigned long flags; */
+       wilc_wlan_dev_t *p = &g_wlan;
        if (tqe == p->txq_head) {
 
                p->txq_head = tqe->next;
@@ -165,16 +162,16 @@ static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
 static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void)
 {
        struct txq_entry_t *tqe;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
        if (p->txq_head) {
                tqe = p->txq_head;
                p->txq_head = tqe->next;
-               if (p->txq_head) {
+               if (p->txq_head)
                        p->txq_head->prev = NULL;
-               }
+
                p->txq_entries -= 1;
 
 
@@ -189,7 +186,7 @@ static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void)
 
 static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
 
@@ -219,7 +216,7 @@ static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
 
 static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
        if (linux_wlan_lock_timeout(&g_linux_wlan->txq_add_to_head_cs,
                                    CFG_PKTS_TIMEOUT))
@@ -313,9 +310,8 @@ static inline int add_TCP_track_session(u32 src_prt, u32 dst_prt, u32 seq)
 static inline int Update_TCP_track_session(u32 index, u32 Ack)
 {
 
-       if (Ack > Acks_keep_track_info[index].Bigger_Ack_num) {
+       if (Ack > Acks_keep_track_info[index].Bigger_Ack_num)
                Acks_keep_track_info[index].Bigger_Ack_num = Ack;
-       }
        return 0;
 
 }
@@ -336,7 +332,7 @@ static inline int add_TCP_Pending_Ack(u32 Ack, u32 Session_index, struct txq_ent
 }
 static inline int remove_TCP_related(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
@@ -352,7 +348,7 @@ static inline int tcp_process(struct txq_entry_t *tqe)
        u8 *buffer = tqe->buffer;
        unsigned short h_proto;
        int i;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
@@ -389,9 +385,9 @@ static inline int tcp_process(struct txq_entry_t *tqe)
                                                break;
                                        }
                                }
-                               if (i == Opened_TCP_session) {
+                               if (i == Opened_TCP_session)
                                        add_TCP_track_session(0, 0, seq_no);
-                               }
+
                                add_TCP_Pending_Ack(Ack_no, i, tqe);
 
 
@@ -408,14 +404,18 @@ static inline int tcp_process(struct txq_entry_t *tqe)
 }
 
 
-static int wilc_wlan_txq_filter_dup_tcp_ack(void)
+static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
 {
-
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
        u32 i = 0;
        u32 Dropped = 0;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, p->txq_spinlock_flags);
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
+
+       spin_lock_irqsave(&wilc->txq_spinlock, p->txq_spinlock_flags);
        for (i = PendingAcks_arrBase; i < (PendingAcks_arrBase + Pending_Acks); i++) {
                if (Pending_Acks_info[i].ack_num < Acks_keep_track_info[Pending_Acks_info[i].Session_index].Bigger_Ack_num) {
                        struct txq_entry_t *tqe;
@@ -442,12 +442,11 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(void)
                PendingAcks_arrBase = 0;
 
 
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock,
-                              p->txq_spinlock_flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, p->txq_spinlock_flags);
 
        while (Dropped > 0) {
                /*consume the semaphore count of the removed packet*/
-               linux_wlan_lock_timeout(&g_linux_wlan->txq_event, 1);
+               linux_wlan_lock_timeout(&wilc->txq_event, 1);
                Dropped--;
        }
 
@@ -469,7 +468,7 @@ bool is_TCP_ACK_Filter_Enabled(void)
 
 static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        PRINT_D(TX_DBG, "Adding config packet ...\n");
@@ -506,7 +505,7 @@ static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
 int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
                              wilc_tx_complete_func_t func)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        if (p->quit)
@@ -536,7 +535,7 @@ int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
 int wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_complete_func_t func)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        if (p->quit)
@@ -561,7 +560,7 @@ int wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_
 
 static struct txq_entry_t *wilc_wlan_txq_get_first(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
        unsigned long flags;
 
@@ -587,14 +586,14 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe)
        return tqe;
 }
 
-static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
+static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        if (p->quit)
                return 0;
 
-       mutex_lock(&g_linux_wlan->rxq_cs);
+       mutex_lock(&wilc->rxq_cs);
        if (p->rxq_head == NULL) {
                PRINT_D(RX_DBG, "Add to Queue head\n");
                rqe->next = NULL;
@@ -608,24 +607,24 @@ static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
        }
        p->rxq_entries += 1;
        PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries);
-       mutex_unlock(&g_linux_wlan->rxq_cs);
+       mutex_unlock(&wilc->rxq_cs);
        return p->rxq_entries;
 }
 
-static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
+static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        PRINT_D(RX_DBG, "Getting rxQ element\n");
        if (p->rxq_head) {
                struct rxq_entry_t *rqe;
 
-               mutex_lock(&g_linux_wlan->rxq_cs);
+               mutex_lock(&wilc->rxq_cs);
                rqe = p->rxq_head;
                p->rxq_head = p->rxq_head->next;
                p->rxq_entries -= 1;
                PRINT_D(RX_DBG, "RXQ entries decreased\n");
-               mutex_unlock(&g_linux_wlan->rxq_cs);
+               mutex_unlock(&wilc->rxq_cs);
                return rqe;
        }
        PRINT_D(RX_DBG, "Nothing to get from Q\n");
@@ -672,9 +671,9 @@ static inline void chip_wakeup(void)
                                usleep_range(2 * 1000, 2 * 1000);
                                /* Make sure chip is awake. This is an extra step that can be removed */
                                /* later to avoid the bus access overhead */
-                               if ((wilc_get_chipid(true) == 0)) {
+                               if ((wilc_get_chipid(true) == 0))
                                        wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
-                               }
+
                        } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
 
                } while (wilc_get_chipid(true) == 0);
@@ -698,9 +697,9 @@ static inline void chip_wakeup(void)
                                /* later to avoid the bus access overhead */
                                g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
 
-                               if ((clk_status_reg & 0x1) == 0) {
+                               if ((clk_status_reg & 0x1) == 0)
                                        wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n");
-                               }
+
                        }
                        /* in case of failure, Reset the wakeup bit to introduce a new edge on the next loop */
                        if ((clk_status_reg & 0x1) == 0) {
@@ -762,9 +761,9 @@ static inline void chip_wakeup(void)
 
                        /* Make sure chip is awake. This is an extra step that can be removed */
                        /* later to avoid the bus access overhead */
-                       if ((wilc_get_chipid(true) == 0)) {
+                       if ((wilc_get_chipid(true) == 0))
                                wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
-                       }
+
                } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
 
        } while (wilc_get_chipid(true) == 0);
@@ -816,7 +815,7 @@ void chip_sleep_manually(u32 u32SleepTime)
  *      Tx, Rx queue handle functions
  *
  ********************************************/
-int wilc_wlan_handle_txq(u32 *pu32TxqCount)
+int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount)
 {
        wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
        int i, entries = 0;
@@ -830,16 +829,21 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
        int counter;
        int timeout;
        u32 vmm_table[WILC_VMM_TBL_SIZE];
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        p->txq_exit = 0;
        do {
                if (p->quit)
                        break;
 
-               linux_wlan_lock_timeout(&g_linux_wlan->txq_add_to_head_cs,
+               linux_wlan_lock_timeout(&wilc->txq_add_to_head_cs,
                                        CFG_PKTS_TIMEOUT);
 #ifdef TCP_ACK_FILTER
-               wilc_wlan_txq_filter_dup_tcp_ack();
+               wilc_wlan_txq_filter_dup_tcp_ack(dev);
 #endif
                /**
                 *      build the vmm list
@@ -849,27 +853,25 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                i = 0;
                sum = 0;
                do {
-                       /* if ((tqe != NULL) && (i < (8)) && */
-                       /* if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE-1)) && */
                        if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE - 1)) /* reserve last entry to 0 */) {
 
-                               if (tqe->type == WILC_CFG_PKT) {
+                               if (tqe->type == WILC_CFG_PKT)
                                        vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET;
-                               }
-                               else if (tqe->type == WILC_NET_PKT) {
+
+                               else if (tqe->type == WILC_NET_PKT)
                                        vmm_sz = ETH_ETHERNET_HDR_OFFSET;
-                               }
-                               else {
+
+                               else
                                        vmm_sz = HOST_HDR_OFFSET;
-                               }
+
                                vmm_sz += tqe->buffer_size;
                                PRINT_D(TX_DBG, "VMM Size before alignment = %d\n", vmm_sz);
                                if (vmm_sz & 0x3) {                                                                                                     /* has to be word aligned */
                                        vmm_sz = (vmm_sz + 4) & ~0x3;
                                }
-                               if ((sum + vmm_sz) > LINUX_TX_SIZE) {
+                               if ((sum + vmm_sz) > LINUX_TX_SIZE)
                                        break;
-                               }
+
                                PRINT_D(TX_DBG, "VMM Size AFTER alignment = %d\n", vmm_sz);
                                vmm_table[i] = vmm_sz / 4;                                                                                /* table take the word size */
                                PRINT_D(TX_DBG, "VMMTable entry size = %d\n", vmm_table[i]);
@@ -932,9 +934,8 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                        }
                } while (!p->quit);
 
-               if (!ret) {
+               if (!ret)
                        goto _end_;
-               }
 
                timeout = 200;
                do {
@@ -973,7 +974,6 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                         *      Get the entries
                                         **/
                                        entries = ((reg >> 3) & 0x3f);
-                                       /* entries = ((reg>>3)&0x2f); */
                                        break;
                                } else {
                                        release_bus(RELEASE_ALLOW_SLEEP);
@@ -987,9 +987,8 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                break;
                        }
 
-                       if (!ret) {
+                       if (!ret)
                                break;
-                       }
 
                        if (entries == 0) {
                                PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]]\n", reg, i, vmm_table[i - 1]);
@@ -1012,9 +1011,9 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                        }
                } while (1);
 
-               if (!ret) {
+               if (!ret)
                        goto _end_;
-               }
+
                if (entries == 0) {
                        ret = WILC_TX_ERR_NO_BUF;
                        goto _end_;
@@ -1070,9 +1069,8 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                if (tqe->tx_complete_func)
                                        tqe->tx_complete_func(tqe->priv, tqe->status);
                                #ifdef TCP_ACK_FILTER
-                               if (tqe->tcp_PendingAck_index != NOT_TCP_ACK) {
+                               if (tqe->tcp_PendingAck_index != NOT_TCP_ACK)
                                        Pending_Acks_info[tqe->tcp_PendingAck_index].txqe = NULL;
-                               }
                                #endif
                                kfree(tqe);
                        } else {
@@ -1106,7 +1104,7 @@ _end_:
                if (ret != 1)
                        break;
        } while (0);
-       up(&g_linux_wlan->txq_add_to_head_cs);
+       up(&wilc->txq_add_to_head_cs);
 
        p->txq_exit = 1;
        PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
@@ -1115,9 +1113,9 @@ _end_:
        return ret;
 }
 
-static void wilc_wlan_handle_rxq(void)
+static void wilc_wlan_handle_rxq(struct wilc *wilc)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        int offset = 0, size, has_packet = 0;
        u8 *buffer;
        struct rxq_entry_t *rqe;
@@ -1130,10 +1128,10 @@ static void wilc_wlan_handle_rxq(void)
        do {
                if (p->quit) {
                        PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function\n");
-                       up(&g_linux_wlan->cfg_event);
+                       up(&wilc->cfg_event);
                        break;
                }
-               rqe = wilc_wlan_rxq_remove();
+               rqe = wilc_wlan_rxq_remove(wilc);
                if (rqe == NULL) {
                        PRINT_D(RX_DBG, "nothing in the queue - exit 1st do-while\n");
                        break;
@@ -1169,7 +1167,6 @@ static void wilc_wlan_handle_rxq(void)
                                break;
                        }
 
-/*bug 3887: [AP] Allow Management frames to be passed to the host*/
                        #define IS_MANAGMEMENT                          0x100
                        #define IS_MANAGMEMENT_CALLBACK                 0x080
                        #define IS_MGMT_STATUS_SUCCES                   0x040
@@ -1179,15 +1176,15 @@ static void wilc_wlan_handle_rxq(void)
                                /* reset mgmt indicator bit, to use pkt_offeset in furthur calculations */
                                pkt_offset &= ~(IS_MANAGMEMENT | IS_MANAGMEMENT_CALLBACK | IS_MGMT_STATUS_SUCCES);
 
-                               WILC_WFI_mgmt_rx(&buffer[offset + HOST_HDR_OFFSET], pkt_len);
+                               WILC_WFI_mgmt_rx(wilc, &buffer[offset + HOST_HDR_OFFSET], pkt_len);
                        }
-                       /* BUG4530 fix */
                        else
                        {
 
                                if (!is_cfg_packet) {
                                        if (pkt_len > 0) {
-                                               frmw_to_linux(&buffer[offset],
+                                               frmw_to_linux(wilc,
+                                                             &buffer[offset],
                                                              pkt_len,
                                                              pkt_offset);
                                                has_packet = 1;
@@ -1197,23 +1194,22 @@ static void wilc_wlan_handle_rxq(void)
 
 
 
-                                       mac_cfg.rx_indicate(&buffer[pkt_offset + offset], pkt_len, &rsp);
+                                       wilc_wlan_cfg_indicate_rx(&buffer[pkt_offset + offset], pkt_len, &rsp);
                                        if (rsp.type == WILC_CFG_RSP) {
                                                /**
                                                 *      wake up the waiting task...
                                                 **/
                                                PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
-                                               if (p->cfg_seq_no == rsp.seq_no) {
-                                                       up(&g_linux_wlan->cfg_event);
-                                               }
+                                               if (p->cfg_seq_no == rsp.seq_no)
+                                                       up(&wilc->cfg_event);
                                        } else if (rsp.type == WILC_CFG_RSP_STATUS) {
                                                /**
                                                 *      Call back to indicate status...
                                                 **/
-                                               linux_wlan_mac_indicate(WILC_MAC_INDICATE_STATUS);
+                                               linux_wlan_mac_indicate(wilc, WILC_MAC_INDICATE_STATUS);
 
                                        } else if (rsp.type == WILC_CFG_RSP_SCAN) {
-                                               linux_wlan_mac_indicate(WILC_MAC_INDICATE_SCAN);
+                                               linux_wlan_mac_indicate(wilc, WILC_MAC_INDICATE_SCAN);
                                        }
                                }
                        }
@@ -1228,9 +1224,9 @@ static void wilc_wlan_handle_rxq(void)
 #endif
                kfree(rqe);
 
-               if (has_packet) {
+               if (has_packet)
                        linux_wlan_rx_complete();
-               }
+
        } while (1);
 
        p->rxq_exit = 1;
@@ -1271,9 +1267,9 @@ static void wilc_sleeptimer_isr_ext(u32 int_stats1)
 #endif
 }
 
-static void wilc_wlan_handle_isr_ext(u32 int_status)
+static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 #ifdef MEMORY_STATIC
        u32 offset = p->rx_buffer_offset;
 #endif
@@ -1353,7 +1349,7 @@ _end_:
                                rqe->buffer = buffer;
                                rqe->buffer_size = size;
                                PRINT_D(RX_DBG, "rxq entery Size= %d - Address = %p\n", rqe->buffer_size, rqe->buffer);
-                               wilc_wlan_rxq_add(rqe);
+                               wilc_wlan_rxq_add(wilc, rqe);
                        }
                } else {
 #ifndef MEMORY_STATIC
@@ -1361,29 +1357,28 @@ _end_:
 #endif
                }
        }
-       wilc_wlan_handle_rxq();
+       wilc_wlan_handle_rxq(wilc);
 }
 
-void wilc_handle_isr(void)
+void wilc_handle_isr(void *wilc)
 {
        u32 int_status;
 
        acquire_bus(ACQUIRE_AND_WAKEUP);
        g_wlan.hif_func.hif_read_int(&int_status);
 
-       if (int_status & PLL_INT_EXT) {
+       if (int_status & PLL_INT_EXT)
                wilc_pllupdate_isr_ext(int_status);
-       }
+
        if (int_status & DATA_INT_EXT) {
-               wilc_wlan_handle_isr_ext(int_status);
+               wilc_wlan_handle_isr_ext(wilc, int_status);
        #ifndef WILC_OPTIMIZE_SLEEP_INT
                /* Chip is up and talking*/
                genuChipPSstate = CHIP_WAKEDUP;
        #endif
        }
-       if (int_status & SLEEP_INT_EXT) {
+       if (int_status & SLEEP_INT_EXT)
                wilc_sleeptimer_isr_ext(int_status);
-       }
 
        if (!(int_status & (ALL_INT_EXT))) {
 #ifdef WILC_SDIO
@@ -1401,7 +1396,7 @@ void wilc_handle_isr(void)
  ********************************************/
 int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        u32 addr, size, size2, blksz;
        u8 *dma_buffer;
@@ -1474,7 +1469,7 @@ _fail_1:
  ********************************************/
 int wilc_wlan_start(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 reg = 0;
        int ret;
        u32 chipid;
@@ -1576,7 +1571,7 @@ int wilc_wlan_start(void)
 void wilc_wlan_global_reset(void)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        acquire_bus(ACQUIRE_AND_WAKEUP);
        p->hif_func.hif_write_reg(WILC_GLB_RESET_0, 0x0);
@@ -1584,7 +1579,7 @@ void wilc_wlan_global_reset(void)
 }
 int wilc_wlan_stop(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 reg = 0;
        int ret;
        u8 timeout = 10;
@@ -1652,13 +1647,18 @@ int wilc_wlan_stop(void)
        return ret;
 }
 
-void wilc_wlan_cleanup(void)
+void wilc_wlan_cleanup(struct net_device *dev)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
        struct rxq_entry_t *rqe;
        u32 reg = 0;
        int ret;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        p->quit = 1;
        do {
@@ -1671,7 +1671,7 @@ void wilc_wlan_cleanup(void)
        } while (1);
 
        do {
-               rqe = wilc_wlan_rxq_remove();
+               rqe = wilc_wlan_rxq_remove(wilc);
                if (rqe == NULL)
                        break;
 #ifndef MEMORY_STATIC
@@ -1714,7 +1714,7 @@ void wilc_wlan_cleanup(void)
 
 static int wilc_wlan_cfg_commit(int type, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        wilc_cfg_frame_t *cfg = &p->cfg_frame;
        int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
        int seq_no = p->cfg_seq_no % 256;
@@ -1751,7 +1751,7 @@ static int wilc_wlan_cfg_commit(int type, u32 drvHandler)
 int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
                      int commit, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        int ret_size;
 
@@ -1763,8 +1763,8 @@ int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
                p->cfg_frame_offset = 0;
 
        offset = p->cfg_frame_offset;
-       ret_size = mac_cfg.cfg_wid_set(p->cfg_frame.frame, offset, (u16)wid,
-                                      buffer, buffer_size);
+       ret_size = wilc_wlan_cfg_set_wid(p->cfg_frame.frame, offset, (u16)wid,
+                                        buffer, buffer_size);
        offset += ret_size;
        p->cfg_frame_offset = offset;
 
@@ -1791,7 +1791,7 @@ int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
 }
 int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        int ret_size;
 
@@ -1803,7 +1803,7 @@ int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
                p->cfg_frame_offset = 0;
 
        offset = p->cfg_frame_offset;
-       ret_size = mac_cfg.cfg_wid_get(p->cfg_frame.frame, offset, (u16)wid);
+       ret_size = wilc_wlan_cfg_get_wid(p->cfg_frame.frame, offset, (u16)wid);
        offset += ret_size;
        p->cfg_frame_offset = offset;
 
@@ -1832,7 +1832,7 @@ int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)
 {
        int ret;
 
-       ret = mac_cfg.cfg_wid_get_val((u16)wid, buffer, buffer_size);
+       ret = wilc_wlan_cfg_get_wid_value((u16)wid, buffer, buffer_size);
 
        return ret;
 }
@@ -1931,24 +1931,6 @@ _fail_:
        return chipid;
 }
 
-#ifdef COMPLEMENT_BOOT
-u8 core_11b_ready(void)
-{
-       u32 reg_val;
-
-       acquire_bus(ACQUIRE_ONLY);
-       g_wlan.hif_func.hif_write_reg(0x16082c, 1);
-       g_wlan.hif_func.hif_write_reg(0x161600, 0x90);
-       g_wlan.hif_func.hif_read_reg(0x161600, &reg_val);
-       release_bus(RELEASE_ONLY);
-
-       if (reg_val == 0x90)
-               return 0;
-       else
-               return 1;
-}
-#endif
-
 int wilc_wlan_init(wilc_wlan_inp_t *inp)
 {
 
@@ -1993,7 +1975,7 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp)
        /***
         *      mac interface init
         **/
-       if (!mac_cfg.cfg_init(wilc_debug)) {
+       if (!wilc_wlan_cfg_init(wilc_debug)) {
                /* ENOBUFS      105 */
                ret = -105;
                goto _fail_;
@@ -2050,17 +2032,21 @@ _fail_:
 
 }
 
-u16 Set_machw_change_vir_if(bool bValue)
+u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue)
 {
        u16 ret;
        u32 reg;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
-       mutex_lock(&g_linux_wlan->hif_cs);
+       mutex_lock(&wilc->hif_cs);
        ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, &reg);
-       if (!ret) {
+       if (!ret)
                PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
-       }
 
        if (bValue)
                reg |= BIT(31);
@@ -2069,10 +2055,10 @@ u16 Set_machw_change_vir_if(bool bValue)
 
        ret = (&g_wlan)->hif_func.hif_write_reg(WILC_CHANGING_VIR_IF, reg);
 
-       if (!ret) {
+       if (!ret)
                PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n");
-       }
-       mutex_unlock(&g_linux_wlan->hif_cs);
+
+       mutex_unlock(&wilc->hif_cs);
 
        return ret;
 }