aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2011-03-31 04:07:00 -0400
committerLuciano Coelho <coelho@ti.com>2011-04-19 09:49:20 -0400
commitd2f4d47d84f8c665ab9babb2cc84d2e7872a96e1 (patch)
tree34a2d0fe6f399c7c3c7bf1e2e85fb0adf5aa378f
parent990f5de7384f9e5922e4c7c7572cbf4f29a9441e (diff)
wl12xx: Simplify TX blocks accounting
The total number of TX memory blocks may change when the dynamic memory option is enabled. The current implementation only tracks the available memory blocks, which over-complicates TX blocks accounting. By tracking the number of allocated blocks, calculation of the number of available blocks becomes simpler and cleaner. It simply equals the total number of TX memory blocks minus the allocated ones. Also, remove some unnecessary castings and use union member accesses instead. Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Arik Nemtsov <arik@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r--drivers/net/wireless/wl12xx/acx.c2
-rw-r--r--drivers/net/wireless/wl12xx/main.c48
-rw-r--r--drivers/net/wireless/wl12xx/tx.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h4
4 files changed, 24 insertions, 31 deletions
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
index e005aa40ef84..b277947400b5 100644
--- a/drivers/net/wireless/wl12xx/acx.c
+++ b/drivers/net/wireless/wl12xx/acx.c
@@ -1081,8 +1081,6 @@ int wl1271_acx_init_mem_config(struct wl1271 *wl)
1081 wl1271_debug(DEBUG_TX, "available tx blocks: %d", 1081 wl1271_debug(DEBUG_TX, "available tx blocks: %d",
1082 wl->tx_blocks_available); 1082 wl->tx_blocks_available);
1083 1083
1084 wl->tx_new_total = wl->tx_blocks_available;
1085
1086 return 0; 1084 return 0;
1087} 1085}
1088 1086
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 7dce24c0b331..1feb9551ef8f 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -622,7 +622,7 @@ static void wl1271_fw_status(struct wl1271 *wl,
622 struct wl1271_fw_common_status *status = &full_status->common; 622 struct wl1271_fw_common_status *status = &full_status->common;
623 struct timespec ts; 623 struct timespec ts;
624 u32 old_tx_blk_count = wl->tx_blocks_available; 624 u32 old_tx_blk_count = wl->tx_blocks_available;
625 u32 total = 0; 625 u32 freed_blocks = 0;
626 int i; 626 int i;
627 627
628 if (wl->bss_type == BSS_TYPE_AP_BSS) { 628 if (wl->bss_type == BSS_TYPE_AP_BSS) {
@@ -631,15 +631,6 @@ static void wl1271_fw_status(struct wl1271 *wl,
631 } else { 631 } else {
632 wl1271_raw_read(wl, FW_STATUS_ADDR, status, 632 wl1271_raw_read(wl, FW_STATUS_ADDR, status,
633 sizeof(struct wl1271_fw_sta_status), false); 633 sizeof(struct wl1271_fw_sta_status), false);
634
635 /* Update tx total blocks change */
636 wl->tx_total_diff +=
637 ((struct wl1271_fw_sta_status *)status)->tx_total -
638 wl->tx_new_total;
639
640 /* Update total tx blocks */
641 wl->tx_new_total =
642 ((struct wl1271_fw_sta_status *)status)->tx_total;
643 } 634 }
644 635
645 wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " 636 wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, "
@@ -651,34 +642,38 @@ static void wl1271_fw_status(struct wl1271 *wl,
651 642
652 /* update number of available TX blocks */ 643 /* update number of available TX blocks */
653 for (i = 0; i < NUM_TX_QUEUES; i++) { 644 for (i = 0; i < NUM_TX_QUEUES; i++) {
654 total += le32_to_cpu(status->tx_released_blks[i]) - 645 freed_blocks += le32_to_cpu(status->tx_released_blks[i]) -
655 wl->tx_blocks_freed[i]; 646 wl->tx_blocks_freed[i];
656 647
657 wl->tx_blocks_freed[i] = 648 wl->tx_blocks_freed[i] =
658 le32_to_cpu(status->tx_released_blks[i]); 649 le32_to_cpu(status->tx_released_blks[i]);
659
660 } 650 }
661 651
662 /* 652 wl->tx_allocated_blocks -= freed_blocks;
663 * By adding the freed blocks to tx_total_diff we are actually 653
664 * moving them to the RX pool. 654 if (wl->bss_type == BSS_TYPE_AP_BSS) {
665 */ 655 /* Update num of allocated TX blocks per link and ps status */
666 wl->tx_total_diff += total; 656 wl1271_irq_update_links_status(wl, &full_status->ap);
657 wl->tx_blocks_available += freed_blocks;
658 } else {
659 int avail = full_status->sta.tx_total - wl->tx_allocated_blocks;
667 660
668 /* if we have positive difference, add the blocks to the TX pool */ 661 /*
669 if (wl->tx_total_diff >= 0) { 662 * The FW might change the total number of TX memblocks before
670 wl->tx_blocks_available += wl->tx_total_diff; 663 * we get a notification about blocks being released. Thus, the
671 wl->tx_total_diff = 0; 664 * available blocks calculation might yield a temporary result
665 * which is lower than the actual available blocks. Keeping in
666 * mind that only blocks that were allocated can be moved from
667 * TX to RX, tx_blocks_available should never decrease here.
668 */
669 wl->tx_blocks_available = max((int)wl->tx_blocks_available,
670 avail);
672 } 671 }
673 672
674 /* if more blocks are available now, tx work can be scheduled */ 673 /* if more blocks are available now, tx work can be scheduled */
675 if (wl->tx_blocks_available > old_tx_blk_count) 674 if (wl->tx_blocks_available > old_tx_blk_count)
676 clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); 675 clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags);
677 676
678 /* for AP update num of allocated TX blocks per link and ps status */
679 if (wl->bss_type == BSS_TYPE_AP_BSS)
680 wl1271_irq_update_links_status(wl, &full_status->ap);
681
682 /* update the host-chipset time offset */ 677 /* update the host-chipset time offset */
683 getnstimeofday(&ts); 678 getnstimeofday(&ts);
684 wl->time_offset = (timespec_to_ns(&ts) >> 10) - 679 wl->time_offset = (timespec_to_ns(&ts) >> 10) -
@@ -1495,6 +1490,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
1495 wl->psm_entry_retry = 0; 1490 wl->psm_entry_retry = 0;
1496 wl->power_level = WL1271_DEFAULT_POWER_LEVEL; 1491 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
1497 wl->tx_blocks_available = 0; 1492 wl->tx_blocks_available = 0;
1493 wl->tx_allocated_blocks = 0;
1498 wl->tx_results_count = 0; 1494 wl->tx_results_count = 0;
1499 wl->tx_packets_count = 0; 1495 wl->tx_packets_count = 0;
1500 wl->tx_security_last_seq = 0; 1496 wl->tx_security_last_seq = 0;
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c
index 67245ad396ea..7a3339fd3415 100644
--- a/drivers/net/wireless/wl12xx/tx.c
+++ b/drivers/net/wireless/wl12xx/tx.c
@@ -203,6 +203,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra,
203 desc->id = id; 203 desc->id = id;
204 204
205 wl->tx_blocks_available -= total_blocks; 205 wl->tx_blocks_available -= total_blocks;
206 wl->tx_allocated_blocks += total_blocks;
206 207
207 if (wl->bss_type == BSS_TYPE_AP_BSS) 208 if (wl->bss_type == BSS_TYPE_AP_BSS)
208 wl->links[hlid].allocated_blks += total_blocks; 209 wl->links[hlid].allocated_blks += total_blocks;
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index 1b430d2aec4e..9ccbcfdd0802 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -418,10 +418,8 @@ struct wl1271 {
418 /* Accounting for allocated / available TX blocks on HW */ 418 /* Accounting for allocated / available TX blocks on HW */
419 u32 tx_blocks_freed[NUM_TX_QUEUES]; 419 u32 tx_blocks_freed[NUM_TX_QUEUES];
420 u32 tx_blocks_available; 420 u32 tx_blocks_available;
421 u32 tx_allocated_blocks;
421 u32 tx_results_count; 422 u32 tx_results_count;
422 /* Indicates how many memory blocks should be moved to the RX pool */
423 int tx_total_diff;
424 u32 tx_new_total;
425 423
426 /* Transmitted TX packets counter for chipset interface */ 424 /* Transmitted TX packets counter for chipset interface */
427 u32 tx_packets_count; 425 u32 tx_packets_count;