Staging: wilc1000: coreconfigurator: Remove trailing whitespace
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wlan.c
index c731641653238935a1e7b8616f58e5d94a2e1d0e..c0266574770521860aff9db94f70b882a66feb49 100644 (file)
@@ -18,9 +18,7 @@
  ********************************************/
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
-extern void WILC_WFI_mgmt_rx(u8 *buff, u32 size);
 u32 wilc_get_chipid(u8 update);
-u16 Set_machw_change_vir_if(bool bValue);
 
 
 
@@ -343,7 +341,7 @@ static inline int remove_TCP_related(void)
        return 0;
 }
 
-static inline int tcp_process(struct txq_entry_t *tqe)
+static inline int tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
 {
        int ret;
        u8 *eth_hdr_ptr;
@@ -352,8 +350,13 @@ static inline int tcp_process(struct txq_entry_t *tqe)
        int i;
        wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
 
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
+
+       spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
        eth_hdr_ptr = &buffer[0];
        h_proto = ntohs(*((unsigned short *)&eth_hdr_ptr[12]));
@@ -401,19 +404,23 @@ static inline int tcp_process(struct txq_entry_t *tqe)
        } else {
                ret = 0;
        }
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
        return ret;
 }
 
 
-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 = &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;
@@ -440,12 +447,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--;
        }
 
@@ -501,8 +507,8 @@ static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
        return 1;
 }
 
-int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
-                             wilc_tx_complete_func_t func)
+int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
+                             u32 buffer_size, wilc_tx_complete_func_t func)
 {
        wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
@@ -524,7 +530,7 @@ int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
 #ifdef TCP_ACK_FILTER
        tqe->tcp_PendingAck_index = NOT_TCP_ACK;
        if (is_TCP_ACK_Filter_Enabled())
-               tcp_process(tqe);
+               tcp_process(dev, tqe);
 #endif
        wilc_wlan_txq_add_to_tail(tqe);
        /*return number of itemes in the queue*/
@@ -573,26 +579,27 @@ static struct txq_entry_t *wilc_wlan_txq_get_first(void)
        return tqe;
 }
 
-static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe)
+static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
+                                                 struct txq_entry_t *tqe)
 {
        unsigned long flags;
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+       spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
        tqe = tqe->next;
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
 
 
        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 = &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;
@@ -606,11 +613,11 @@ 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 = &g_wlan;
 
@@ -618,12 +625,12 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
        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");
@@ -814,7 +821,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;
@@ -828,16 +835,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
@@ -881,7 +893,7 @@ int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                i++;
                                sum += vmm_sz;
                                PRINT_D(TX_DBG, "sum = %d\n", sum);
-                               tqe = wilc_wlan_txq_get_next(tqe);
+                               tqe = wilc_wlan_txq_get_next(wilc, tqe);
                        } else {
                                break;
                        }
@@ -1098,7 +1110,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");
@@ -1107,7 +1119,7 @@ _end_:
        return ret;
 }
 
-static void wilc_wlan_handle_rxq(void)
+static void wilc_wlan_handle_rxq(struct wilc *wilc)
 {
        wilc_wlan_dev_t *p = &g_wlan;
        int offset = 0, size, has_packet = 0;
@@ -1122,10 +1134,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;
@@ -1170,14 +1182,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);
                        }
                        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;
@@ -1194,15 +1207,15 @@ static void wilc_wlan_handle_rxq(void)
                                                 **/
                                                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);
+                                                       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);
                                        }
                                }
                        }
@@ -1260,7 +1273,7 @@ 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 = &g_wlan;
 #ifdef MEMORY_STATIC
@@ -1342,7 +1355,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
@@ -1350,10 +1363,10 @@ _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;
 
@@ -1364,7 +1377,7 @@ void wilc_handle_isr(void)
                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;
@@ -1640,13 +1653,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 = &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 {
@@ -1659,7 +1677,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
@@ -1919,24 +1937,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)
 {
 
@@ -2038,13 +2038,18 @@ _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)
                PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
@@ -2059,7 +2064,7 @@ u16 Set_machw_change_vir_if(bool bValue)
        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;
 }