aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/init.c
diff options
context:
space:
mode:
authorAndreas Fenkart <[andreas.fenkart@streamunlimited.com]>2013-04-18 19:34:12 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-23 15:18:40 -0400
commitb006ed545cbadf1ebd4683719554742d20dbcede (patch)
tree4469dfebe8b2ed700175ecba692a03ab581cf548 /drivers/net/wireless/mwifiex/init.c
parent2e23731954d3641a418455e8e0c37c9b8aa7f567 (diff)
mwifiex: rework round robin scheduling of bss nodes.
Rotate bss prio list, so the bss next to the one served, will come first in the list of bss' with equal priority. This way we pick bss nodes in a round robin fashion. Using list rotation instead of a cur ptr simplifies iteration to calling list_for_each_entry. List rotation is done via list_move, where the head itself is temporarily removed and then re-inserted after the bss just served. Signed-off-by: Andreas Fenkart <andreas.fenkart@streamunlimited.com> Acked-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/init.c')
-rw-r--r--drivers/net/wireless/mwifiex/init.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c
index 42d7f0adf9bd..9f44fda19db9 100644
--- a/drivers/net/wireless/mwifiex/init.c
+++ b/drivers/net/wireless/mwifiex/init.c
@@ -44,8 +44,6 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv)
44 44
45 bss_prio->priv = priv; 45 bss_prio->priv = priv;
46 INIT_LIST_HEAD(&bss_prio->list); 46 INIT_LIST_HEAD(&bss_prio->list);
47 if (!tbl[priv->bss_priority].bss_prio_cur)
48 tbl[priv->bss_priority].bss_prio_cur = bss_prio;
49 47
50 spin_lock_irqsave(&tbl[priv->bss_priority].bss_prio_lock, flags); 48 spin_lock_irqsave(&tbl[priv->bss_priority].bss_prio_lock, flags);
51 list_add_tail(&bss_prio->list, &tbl[priv->bss_priority].bss_prio_head); 49 list_add_tail(&bss_prio->list, &tbl[priv->bss_priority].bss_prio_head);
@@ -525,7 +523,6 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
525 523
526 for (i = 0; i < adapter->priv_num; ++i) { 524 for (i = 0; i < adapter->priv_num; ++i) {
527 INIT_LIST_HEAD(&adapter->bss_prio_tbl[i].bss_prio_head); 525 INIT_LIST_HEAD(&adapter->bss_prio_tbl[i].bss_prio_head);
528 adapter->bss_prio_tbl[i].bss_prio_cur = NULL;
529 spin_lock_init(&adapter->bss_prio_tbl[i].bss_prio_lock); 526 spin_lock_init(&adapter->bss_prio_tbl[i].bss_prio_lock);
530 } 527 }
531 528
@@ -625,42 +622,36 @@ static void mwifiex_delete_bss_prio_tbl(struct mwifiex_private *priv)
625{ 622{
626 int i; 623 int i;
627 struct mwifiex_adapter *adapter = priv->adapter; 624 struct mwifiex_adapter *adapter = priv->adapter;
628 struct mwifiex_bss_prio_node *bssprio_node, *tmp_node, **cur; 625 struct mwifiex_bss_prio_node *bssprio_node, *tmp_node;
629 struct list_head *head; 626 struct list_head *head;
630 spinlock_t *lock; /* bss priority lock */ 627 spinlock_t *lock; /* bss priority lock */
631 unsigned long flags; 628 unsigned long flags;
632 629
633 for (i = 0; i < adapter->priv_num; ++i) { 630 for (i = 0; i < adapter->priv_num; ++i) {
634 head = &adapter->bss_prio_tbl[i].bss_prio_head; 631 head = &adapter->bss_prio_tbl[i].bss_prio_head;
635 cur = &adapter->bss_prio_tbl[i].bss_prio_cur;
636 lock = &adapter->bss_prio_tbl[i].bss_prio_lock; 632 lock = &adapter->bss_prio_tbl[i].bss_prio_lock;
637 dev_dbg(adapter->dev, "info: delete BSS priority table," 633 dev_dbg(adapter->dev, "info: delete BSS priority table,"
638 " bss_type = %d, bss_num = %d, i = %d," 634 " bss_type = %d, bss_num = %d, i = %d,"
639 " head = %p, cur = %p\n", 635 " head = %p\n",
640 priv->bss_type, priv->bss_num, i, head, *cur); 636 priv->bss_type, priv->bss_num, i, head);
641 if (*cur) { 637
638 {
642 spin_lock_irqsave(lock, flags); 639 spin_lock_irqsave(lock, flags);
643 if (list_empty(head)) { 640 if (list_empty(head)) {
644 spin_unlock_irqrestore(lock, flags); 641 spin_unlock_irqrestore(lock, flags);
645 continue; 642 continue;
646 } 643 }
647 bssprio_node = list_first_entry(head,
648 struct mwifiex_bss_prio_node, list);
649 spin_unlock_irqrestore(lock, flags);
650
651 list_for_each_entry_safe(bssprio_node, tmp_node, head, 644 list_for_each_entry_safe(bssprio_node, tmp_node, head,
652 list) { 645 list) {
653 if (bssprio_node->priv == priv) { 646 if (bssprio_node->priv == priv) {
654 dev_dbg(adapter->dev, "info: Delete " 647 dev_dbg(adapter->dev, "info: Delete "
655 "node %p, next = %p\n", 648 "node %p, next = %p\n",
656 bssprio_node, tmp_node); 649 bssprio_node, tmp_node);
657 spin_lock_irqsave(lock, flags);
658 list_del(&bssprio_node->list); 650 list_del(&bssprio_node->list);
659 spin_unlock_irqrestore(lock, flags);
660 kfree(bssprio_node); 651 kfree(bssprio_node);
661 } 652 }
662 } 653 }
663 *cur = (struct mwifiex_bss_prio_node *)head; 654 spin_unlock_irqrestore(lock, flags);
664 } 655 }
665 } 656 }
666} 657}