mwifiex: wakeup and stop multiple tx queues in net_device
authorAvinash Patil <patila@marvell.com>
Fri, 9 Dec 2011 04:41:05 +0000 (20:41 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 13 Dec 2011 20:33:26 +0000 (15:33 -0500)
replace single queue function calls with equivalent multiple queue
functions. Wakeup queue and stop queue calls are guarded by spin lock.

Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Kiran Divekar <dkiran@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/init.c
drivers/net/wireless/mwifiex/main.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/sta_event.c
drivers/net/wireless/mwifiex/sta_ioctl.c
drivers/net/wireless/mwifiex/txrx.c

index 26940455255ba4637fdd31ec19a3407640f71e87..244c728ef9dcc63f968617e7e557874d8f4f4977 100644 (file)
@@ -282,6 +282,45 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
        adapter->arp_filter_size = 0;
 }
 
+/*
+ * This function sets trans_start per tx_queue
+ */
+void mwifiex_set_trans_start(struct net_device *dev)
+{
+       int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++)
+               netdev_get_tx_queue(dev, i)->trans_start = jiffies;
+
+       dev->trans_start = jiffies;
+}
+
+/*
+ * This function wakes up all queues in net_device
+ */
+void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
+                                       struct mwifiex_adapter *adapter)
+{
+       unsigned long dev_queue_flags;
+
+       spin_lock_irqsave(&adapter->queue_lock, dev_queue_flags);
+       netif_tx_wake_all_queues(netdev);
+       spin_unlock_irqrestore(&adapter->queue_lock, dev_queue_flags);
+}
+
+/*
+ * This function stops all queues in net_device
+ */
+void mwifiex_stop_net_dev_queue(struct net_device *netdev,
+                                       struct mwifiex_adapter *adapter)
+{
+       unsigned long dev_queue_flags;
+
+       spin_lock_irqsave(&adapter->queue_lock, dev_queue_flags);
+       netif_tx_stop_all_queues(netdev);
+       spin_unlock_irqrestore(&adapter->queue_lock, dev_queue_flags);
+}
+
 /*
  *  This function releases the lock variables and frees the locks and
  *  associated locks.
@@ -359,6 +398,7 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
        spin_lock_init(&adapter->int_lock);
        spin_lock_init(&adapter->main_proc_lock);
        spin_lock_init(&adapter->mwifiex_cmd_lock);
+       spin_lock_init(&adapter->queue_lock);
        for (i = 0; i < adapter->priv_num; i++) {
                if (adapter->priv[i]) {
                        priv = adapter->priv[i];
index 67e6db7d672ddf5fbeb614395bdda7c76b2dab56..d21cd4707f01691a09336cee055daed610f4b2c2 100644 (file)
@@ -401,7 +401,7 @@ mwifiex_fill_buffer(struct sk_buff *skb)
 static int
 mwifiex_open(struct net_device *dev)
 {
-       netif_start_queue(dev);
+       netif_tx_start_all_queues(dev);
        return 0;
 }
 
@@ -465,8 +465,8 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        atomic_inc(&priv->adapter->tx_pending);
 
        if (atomic_read(&priv->adapter->tx_pending) >= MAX_TX_PENDING) {
-               netif_stop_queue(priv->netdev);
-               dev->trans_start = jiffies;
+               mwifiex_set_trans_start(dev);
+               mwifiex_stop_net_dev_queue(priv->netdev, priv->adapter);
        }
 
        queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
@@ -533,7 +533,7 @@ mwifiex_tx_timeout(struct net_device *dev)
 
        dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_index=%d\n",
                                jiffies, priv->bss_index);
-       dev->trans_start = jiffies;
+       mwifiex_set_trans_start(dev);
        priv->num_tx_timeout++;
 }
 
@@ -793,7 +793,8 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
                priv = adapter->priv[i];
                if (priv && priv->netdev) {
                        if (!netif_queue_stopped(priv->netdev))
-                               netif_stop_queue(priv->netdev);
+                               mwifiex_stop_net_dev_queue(priv->netdev,
+                                                               adapter);
                        if (netif_carrier_ok(priv->netdev))
                                netif_carrier_off(priv->netdev);
                }
index 3861a617c0e13e3b5b61a768924e20bfb2784715..41f88631763cc0e2c354f5e2ed1708b41f3f0144 100644 (file)
@@ -655,10 +655,19 @@ struct mwifiex_adapter {
        struct mwifiex_wait_queue cmd_wait_q;
        u8 scan_wait_q_woken;
        struct cmd_ctrl_node *cmd_queued;
+       spinlock_t queue_lock;          /* lock for tx queues */
 };
 
 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
 
+void mwifiex_set_trans_start(struct net_device *dev);
+
+void mwifiex_stop_net_dev_queue(struct net_device *netdev,
+               struct mwifiex_adapter *adapter);
+
+void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
+               struct mwifiex_adapter *adapter);
+
 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
 
 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
index f204810e83389bfa4085c6dd5dbc39daa26ee70f..40205f60be4d148aa8486c3a8839b7441e76179d 100644 (file)
@@ -126,7 +126,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
                queue_work(priv->workqueue, &priv->cfg_workqueue);
        }
        if (!netif_queue_stopped(priv->netdev))
-               netif_stop_queue(priv->netdev);
+               mwifiex_stop_net_dev_queue(priv->netdev, adapter);
        if (netif_carrier_ok(priv->netdev))
                netif_carrier_off(priv->netdev);
        /* Reset wireless stats signal info */
@@ -201,7 +201,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
                if (!netif_carrier_ok(priv->netdev))
                        netif_carrier_on(priv->netdev);
                if (netif_queue_stopped(priv->netdev))
-                       netif_wake_queue(priv->netdev);
+                       mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
                break;
 
        case EVENT_DEAUTHENTICATED:
@@ -292,7 +292,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
                priv->adhoc_is_link_sensed = false;
                mwifiex_clean_txrx(priv);
                if (!netif_queue_stopped(priv->netdev))
-                       netif_stop_queue(priv->netdev);
+                       mwifiex_stop_net_dev_queue(priv->netdev, adapter);
                if (netif_carrier_ok(priv->netdev))
                        netif_carrier_off(priv->netdev);
                break;
index 4b6f5539657d6cd250c07939cda005c02e66fba0..6d990c798a20f83b7be40334b3305b9cd7f57efa 100644 (file)
@@ -234,7 +234,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
                                      "associating...\n");
 
                if (!netif_queue_stopped(priv->netdev))
-                       netif_stop_queue(priv->netdev);
+                       mwifiex_stop_net_dev_queue(priv->netdev, adapter);
 
                /* Clear any past association response stored for
                 * application retrieval */
@@ -265,7 +265,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
                ret = mwifiex_check_network_compatibility(priv, bss_desc);
 
                if (!netif_queue_stopped(priv->netdev))
-                       netif_stop_queue(priv->netdev);
+                       mwifiex_stop_net_dev_queue(priv->netdev, adapter);
 
                if (!ret) {
                        dev_dbg(adapter->dev, "info: network found in scan"
index a206f412875f74647d8b7362fc17bb7c674bc047..d9274a1b77acabce253e6400af854d71c29b814b 100644 (file)
@@ -134,7 +134,7 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
        if (!priv)
                goto done;
 
-       priv->netdev->trans_start = jiffies;
+       mwifiex_set_trans_start(priv->netdev);
        if (!status) {
                priv->stats.tx_packets++;
                priv->stats.tx_bytes += skb->len;
@@ -152,7 +152,8 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
                if ((GET_BSS_ROLE(tpriv) == MWIFIEX_BSS_ROLE_STA)
                                && (tpriv->media_connected)) {
                        if (netif_queue_stopped(tpriv->netdev))
-                               netif_wake_queue(tpriv->netdev);
+                               mwifiex_wake_up_net_dev_queue(tpriv->netdev,
+                                                               adapter);
                }
        }
 done: