mwifiex: add usb multi endpoints resync support
authorZhaoyang Liu <liuzy@marvell.com>
Fri, 18 Sep 2015 13:32:17 +0000 (06:32 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 29 Sep 2015 07:47:48 +0000 (10:47 +0300)
This patch add support for usb multi endpoints resync.
Once multi channel event is received from firmware,
update usb_mc_setp flag to block TX data until setup is over.
And available data endpoint will be attached to BSS interface.

Signed-off-by: Zhaoyang Liu <liuzy@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mwifiex/main.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/sta_cmdresp.c
drivers/net/wireless/mwifiex/sta_event.c
drivers/net/wireless/mwifiex/usb.c
drivers/net/wireless/mwifiex/usb.h

index 4b2110d711bf6e01a7bc469a6217f2ae358be6f1..6e3faa74389c56283980779611955a16bb21cd45 100644 (file)
@@ -294,9 +294,15 @@ process_start:
                        /* We have tried to wakeup the card already */
                        if (adapter->pm_wakeup_fw_try)
                                break;
-                       if (adapter->ps_state != PS_STATE_AWAKE ||
-                           adapter->tx_lock_flag)
+                       if (adapter->ps_state != PS_STATE_AWAKE)
                                break;
+                       if (adapter->tx_lock_flag) {
+                               if (adapter->iface_type == MWIFIEX_USB) {
+                                       if (!adapter->usb_mc_setup)
+                                               break;
+                               } else
+                                       break;
+                       }
 
                        if ((!adapter->scan_chan_gap_enabled &&
                             adapter->scan_processing) || adapter->data_sent ||
@@ -345,11 +351,18 @@ process_start:
                 */
                if ((adapter->ps_state == PS_STATE_SLEEP) ||
                    (adapter->ps_state == PS_STATE_PRE_SLEEP) ||
-                   (adapter->ps_state == PS_STATE_SLEEP_CFM) ||
-                   adapter->tx_lock_flag){
+                   (adapter->ps_state == PS_STATE_SLEEP_CFM)) {
                        continue;
                }
 
+               if (adapter->tx_lock_flag) {
+                       if (adapter->iface_type == MWIFIEX_USB) {
+                               if (!adapter->usb_mc_setup)
+                                       continue;
+                       } else
+                               continue;
+               }
+
                if (!adapter->cmd_sent && !adapter->curr_cmd &&
                    mwifiex_is_send_cmd_allowed
                    (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
@@ -359,6 +372,13 @@ process_start:
                        }
                }
 
+               /** If USB Multi channel setup ongoing,
+                *  wait for ready to tx data.
+                */
+               if (adapter->iface_type == MWIFIEX_USB &&
+                   adapter->usb_mc_setup)
+                       continue;
+
                if ((adapter->scan_chan_gap_enabled ||
                     !adapter->scan_processing) &&
                    !adapter->data_sent &&
@@ -928,6 +948,32 @@ mwifiex_tx_timeout(struct net_device *dev)
        }
 }
 
+void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter)
+{
+       struct usb_card_rec *card = adapter->card;
+       struct mwifiex_private *priv;
+       u16 tx_buf_size;
+       int i, ret;
+
+       card->mc_resync_flag = true;
+       for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
+               if (atomic_read(&card->port[i].tx_data_urb_pending)) {
+                       mwifiex_dbg(adapter, WARN, "pending data urb in sys\n");
+                       return;
+               }
+       }
+
+       card->mc_resync_flag = false;
+       tx_buf_size = 0xffff;
+       priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
+       ret = mwifiex_send_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF,
+                              HostCmd_ACT_GEN_SET, 0, &tx_buf_size, false);
+       if (ret)
+               mwifiex_dbg(adapter, ERROR,
+                           "send reconfig tx buf size cmd err\n");
+}
+EXPORT_SYMBOL_GPL(mwifiex_multi_chan_resync);
+
 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter)
 {
        void *p;
index 9772a186f480d19955610032a201cb40d11a28d0..88130028cd890a011ee0815ff6a625f156eb5537 100644 (file)
@@ -816,6 +816,7 @@ struct mwifiex_if_ops {
        void (*iface_work)(struct work_struct *work);
        void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
        void (*deaggr_pkt)(struct mwifiex_adapter *, struct sk_buff *);
+       void (*multi_port_resync)(struct mwifiex_adapter *);
 };
 
 struct mwifiex_adapter {
@@ -991,6 +992,7 @@ struct mwifiex_adapter {
        bool drcs_enabled;
        u8 active_scan_triggered;
        bool usb_mc_status;
+       bool usb_mc_setup;
 };
 
 void mwifiex_process_tx_queue(struct mwifiex_adapter *adapter);
@@ -1564,6 +1566,7 @@ void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
                                    struct sk_buff *event);
 void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
                                      struct sk_buff *event_skb);
+void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter);
 
 #ifdef CONFIG_DEBUG_FS
 void mwifiex_debugfs_init(void);
index 87b69d8ad120e0e3f51ffb7edfbf39ff6f1d6dbf..d0961635c7b36c72a7952de11fd1b751c2b66ac2 100644 (file)
@@ -1128,6 +1128,17 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
                ret = mwifiex_ret_11n_addba_resp(priv, resp);
                break;
        case HostCmd_CMD_RECONFIGURE_TX_BUFF:
+               if (0xffff == (u16)le16_to_cpu(resp->params.tx_buf.buff_size)) {
+                       if (adapter->iface_type == MWIFIEX_USB &&
+                           adapter->usb_mc_setup) {
+                               if (adapter->if_ops.multi_port_resync)
+                                       adapter->if_ops.
+                                               multi_port_resync(adapter);
+                               adapter->usb_mc_setup = false;
+                               adapter->tx_lock_flag = false;
+                       }
+                       break;
+               }
                adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
                                                             tx_buf.buff_size);
                adapter->tx_buf_size = (adapter->tx_buf_size
index 67920899afebc584e83320f168429538fed02118..c333b249245197a8471efbd78af58d6741fcf000 100644 (file)
@@ -381,6 +381,11 @@ void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
                               sizeof(struct mwifiex_ie_types_header));
        }
 
+       if (adapter->iface_type == MWIFIEX_USB) {
+               adapter->tx_lock_flag = true;
+               adapter->usb_mc_setup = true;
+               mwifiex_multi_chan_resync(adapter);
+       }
 }
 
 void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
index df7e7df54a12991be33afbc52d3ece6c3c65b118..78ad857f20ea03f79e9e071685e8a8b6a4a6ae15 100644 (file)
@@ -290,6 +290,9 @@ static void mwifiex_usb_tx_complete(struct urb *urb)
                                            urb->status ? -1 : 0);
        }
 
+       if (card->mc_resync_flag)
+               mwifiex_multi_chan_resync(adapter);
+
        mwifiex_queue_main_work(adapter);
 
        return;
@@ -671,6 +674,10 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
                if (!port->tx_data_ep)
                        continue;
                port->tx_data_ix = 0;
+               if (port->tx_data_ep == MWIFIEX_USB_EP_DATA)
+                       port->block_status = false;
+               else
+                       port->block_status = true;
                for (j = 0; j < MWIFIEX_TX_DATA_URB; j++) {
                        port->tx_data_list[j].adapter = adapter;
                        port->tx_data_list[j].ep = port->tx_data_ep;
@@ -769,6 +776,53 @@ static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf,
        return ret;
 }
 
+static void mwifiex_usb_port_resync(struct mwifiex_adapter *adapter)
+{
+       struct usb_card_rec *card = adapter->card;
+       u8 active_port = MWIFIEX_USB_EP_DATA;
+       struct mwifiex_private *priv = NULL;
+       int i;
+
+       if (adapter->usb_mc_status) {
+               for (i = 0; i < adapter->priv_num; i++) {
+                       priv = adapter->priv[i];
+                       if (!priv)
+                               continue;
+                       if ((priv->bss_role == MWIFIEX_BSS_ROLE_UAP &&
+                            !priv->bss_started) ||
+                           (priv->bss_role == MWIFIEX_BSS_ROLE_STA &&
+                            !priv->media_connected))
+                               priv->usb_port = MWIFIEX_USB_EP_DATA;
+               }
+               for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++)
+                       card->port[i].block_status = false;
+       } else {
+               for (i = 0; i < adapter->priv_num; i++) {
+                       priv = adapter->priv[i];
+                       if (!priv)
+                               continue;
+                       if ((priv->bss_role == MWIFIEX_BSS_ROLE_UAP &&
+                            priv->bss_started) ||
+                           (priv->bss_role == MWIFIEX_BSS_ROLE_STA &&
+                            priv->media_connected)) {
+                               active_port = priv->usb_port;
+                               break;
+                       }
+               }
+               for (i = 0; i < adapter->priv_num; i++) {
+                       priv = adapter->priv[i];
+                       if (priv)
+                               priv->usb_port = active_port;
+               }
+               for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
+                       if (active_port == card->port[i].tx_data_ep)
+                               card->port[i].block_status = false;
+                       else
+                               card->port[i].block_status = true;
+               }
+       }
+}
+
 /* This function write a command/data packet to card. */
 static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
                                    struct sk_buff *skb,
@@ -903,6 +957,7 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
        }
 
        adapter->usb_mc_status = false;
+       adapter->usb_mc_setup = false;
 
        return 0;
 }
@@ -1133,6 +1188,7 @@ static struct mwifiex_if_ops usb_ops = {
        .event_complete =       mwifiex_usb_cmd_event_complete,
        .host_to_card =         mwifiex_usb_host_to_card,
        .submit_rem_rx_urbs =   mwifiex_usb_submit_rem_rx_urbs,
+       .multi_port_resync =    mwifiex_usb_port_resync,
 };
 
 /* This function initializes the USB driver module.
index 0a756f2de717e02f1b7de18468cdb758f3199cc6..bab10ee41923a4286d6854767bb73a3f59f03e87 100644 (file)
@@ -67,6 +67,7 @@ struct urb_context {
 
 struct usb_tx_data_port {
        u8 tx_data_ep;
+       u8 block_status;
        atomic_t tx_data_urb_pending;
        int tx_data_ix;
        struct urb_context tx_data_list[MWIFIEX_TX_DATA_URB];
@@ -87,6 +88,7 @@ struct usb_card_rec {
        atomic_t tx_cmd_urb_pending;
        int bulk_out_maxpktsize;
        struct urb_context tx_cmd;
+       u8 mc_resync_flag;
        struct usb_tx_data_port port[MWIFIEX_TX_DATA_PORT];
 };