Skip to content

Commit

Permalink
mwifiex: wakeup and stop multiple tx queues in net_device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Avinash Patil authored and John W. Linville committed Dec 13, 2011
1 parent 17a60b4 commit bbea3bc
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 12 deletions.
40 changes: 40 additions & 0 deletions drivers/net/wireless/mwifiex/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/wireless/mwifiex/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/mwifiex/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/mwifiex/sta_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/mwifiex/sta_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/mwifiex/txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down

0 comments on commit bbea3bc

Please sign in to comment.